wishthis/node_modules/fomantic-ui/tasks/docs/build.js

116 lines
3 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*******************************
Build Docs
*******************************/
2023-08-17 09:47:40 +00:00
const
fs = require('fs'),
2023-08-17 09:47:40 +00:00
extend = require('extend'),
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// node dependencies
console = require('better-console'),
gulp = require('gulp'),
2023-08-17 09:47:40 +00:00
map = require('map-stream'),
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// gulp dependencies
print = require('gulp-print').default,
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// user config
configDocs = require('../config/docs'),
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// install config
tasks = require('../config/tasks'),
configSetup = require('../config/project/config'),
install = require('../config/project/install'),
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// metadata parsing
metadata = require('./metadata'),
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// build methods
buildJS = require('../build/javascript').buildJS,
buildCSS = require('../build/css').buildCSS,
buildAssets = require('../build/assets').buildAssets,
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// shorthand
log = tasks.log
2022-01-13 13:00:31 +00:00
;
module.exports = function (callback) {
2023-08-17 09:47:40 +00:00
// use a different config
const config = extend(true, {}, configDocs);
configSetup.addDerivedValues(config);
// shorthand
const globs = config.globs;
const output = config.paths.output;
/* --------------
Parse metadata
--------------- */
function buildMetaData() {
// parse all *.html.eco in docs repo, data will end up in
// metadata.result object. Note this assumes that the docs
// repository is present and in proper directory location as
// specified by docs.json.
console.info('Building Metadata');
return gulp.src(config.paths.template.eco + globs.eco)
.pipe(map(metadata.parser))
.on('end', function () {
fs.mkdirSync(output.metadata, { recursive: true });
fs.writeFileSync(output.metadata + '/metadata.json', JSON.stringify(metadata.result, null, 2));
})
;
}
/* --------------
Copy Examples
--------------- */
function copyExample() {
// copy src/ to server
console.info('Copying examples');
return gulp.src('examples/**/*.*')
.pipe(gulp.dest(output.examples))
.pipe(print(log.created))
;
}
/* --------------
Copy Source
--------------- */
function copyLess() {
// copy src/ to server
console.info('Copying LESS source');
return gulp.src('src/**/*.*')
.pipe(gulp.dest(output.less))
.pipe(print(log.created))
;
}
/* --------------
Build
--------------- */
console.info('Building Fomantic for docs');
if (!install.isSetup()) {
console.error('Cannot build files. Run "gulp install" to set-up Fomantic');
callback();
return;
}
gulp.series(
buildMetaData,
copyExample,
copyLess,
(callback) => buildJS('docs', config, callback),
(callback) => buildCSS('docs', config, {}, callback),
(callback) => buildAssets(config, callback)
)(callback);
2022-01-13 13:00:31 +00:00
};