This repository has been archived by the owner on Mar 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.js
75 lines (62 loc) · 2.1 KB
/
build.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
65
66
67
68
69
70
71
72
73
74
75
const Program = require('commander');
const Chalk = require('chalk');
// Joomla Build modules
const installer = require('./build/build-modules-js/installation.js');
const update = require('./build/build-modules-js/update.js');
const css = require('./build/build-modules-js/compilescss.js');
const Js = require('./build/build-modules-js/compilejs.js');
const CEscss = require('./build/build-modules-js/compilecescss.js');
const CEjs = require('./build/build-modules-js/compilecejs.js');
// The settings
const options = require('./package.json');
// Initialize CLI
Program
.version(options.version)
.option('--update', 'Updates the vendor scripts')
.option('--compilejs, --compilejs path', 'Compiles ES6 to ES5 scripts')
.option('--compilecss, --compilecss path', 'Compiles all the scss files to css')
.option('--compilecejs, --compilecejs path', 'Compiles/traspiles all the custom elements files')
.option('--compilecescss, --compilecescss path', 'Compiles/traspiles all the custom elements files')
.option('--installer', 'Creates the language file for installer error page')
.on('--help', () => {
console.log(Chalk.cyan('\n Version %s\n'), options.version);
process.exit(1);
})
.parse(process.argv);
// Show help by default
if (!process.argv.slice(2).length) {
Program.outputHelp();
process.exit(1);
}
// Update the vendor folder
if (Program.update) {
Promise.resolve()
.then(update.update(options))
// Exit with success
.then(() => process.exit(1))
// Handle errors
.catch((err) => {
console.error(Chalk.red(err));
process.exit(-1);
});
}
// Create the languages file for the error page on the installer
if (Program.installer) {
installer.installation()
}
// Convert scss to css
if (Program['compilecss']) {
css.css(options, Program.args[0])
}
// Compress/transpile the javascript files
if (Program['compilejs']) {
Js.js(options, Program.args[0])
}
// Compress/transpile the Custom Elements files
if (Program['compilecescss']) {
CEscss.compileCEscss(options, Program.args[0])
}
// Compress/transpile the Custom Elements files
if (Program['compilecejs']) {
CEjs.compileCEjs(options, Program.args[0])
}