-
Notifications
You must be signed in to change notification settings - Fork 4
/
.zuix.js
64 lines (56 loc) · 1.82 KB
/
.zuix.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright 2020-2022 G-Labs. All Rights Reserved.
* https://zuixjs.github.io/zuix
*
* Licensed under the MIT license. See LICENSE file.
*
*/
/*
*
* This file is part of
* zUIx, Javascript library for component-based development.
* https://zuixjs.github.io/zuix
*
* @author Generoso Martello - https://github.com/genemars
* @version 1.0
*
*/
const path = require('path');
const config = require('config');
const child_process = require('child_process');
const zuixConfig = config.get('zuix');
const sourceFolder = zuixConfig.get('build.input');
const buildFolder = zuixConfig.get('build.output');
const contentFolder = zuixConfig.get('build.contentFolder', 'content');
const contentSourceFolder = path.join(sourceFolder, contentFolder);
const contentBuildFolder = path.join(buildFolder, contentFolder)
const {addPage, wipeContent} = require('./.eleventy-zuix');
function collect(value, previous) {
return previous.concat([value]);
}
module.exports = (program) => {
program
.command('build')
.alias('b')
.description('Build web application')
.action(() => {
// todo: should check if it's a zuix.js project
child_process.execSync('npm run build',{
stdio:[0, 1, 2]
});
});
program
.command('add')
.alias('a')
.description('Add new page')
.requiredOption('-s, --section <section_name>', 'Page section')
.requiredOption('-n, --name <page_name>', 'Page name')
.option('-l, --layout <layout_template>', 'Layout template name', 'article')
.option('-fm, --front-matter "<field>: <value>"', 'Set a front matter field value', collect, [])
.action(addPage);
program
.command('wipe-content')
.alias('wc')
.description(`Delete all content in "${contentSourceFolder}" and "${contentBuildFolder}" folders.`)
.action(wipeContent);
};