ng-alain-plugin-theme
Version:
NG-ALAIN theme plugin
77 lines (76 loc) • 2.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const meow_1 = __importDefault(require("meow"));
const path_1 = require("path");
const fs_1 = require("fs");
const theme_css_1 = require("./theme-css");
const color_less_1 = require("./color-less");
const utils_1 = require("./utils");
const cli = (0, meow_1.default)({
help: `
Usage
ng-alain-plugin-theme
Example
ng-alain-plugin-theme -t=themeCss -c=ng-alain.json
Options
-t, --type Can be set 'themeCss', 'colorLess'
-n, --name Angular project name
-c, --config A filepath of NG-ALAIN config script
-d, --debug Debug mode
`,
flags: {
type: {
type: 'string',
default: 'themeCss',
alias: 't',
},
name: {
type: 'string',
alias: 'n',
},
config: {
type: 'string',
default: 'ng-alain.json',
alias: 'c',
},
debug: {
type: 'boolean',
default: false,
alias: 'd',
},
},
});
let config;
try {
const configFile = (0, path_1.resolve)(process.cwd(), cli.flags.config);
if ((0, fs_1.existsSync)(configFile)) {
config = (0, utils_1.getJSON)(configFile);
}
else {
console.error(`The config file '${cli.flags.config}' will not found`);
process.exit(1);
}
}
catch (err) {
console.error('Invalid config file', err);
process.exit(1);
}
['theme', 'colorLess'].forEach(key => {
if (config[key] == null)
config[key] = {};
config[key].name = cli.flags.name;
config[key].debug = cli.flags.debug === true;
});
if (cli.flags.type === 'themeCss') {
(0, theme_css_1.buildThemeCSS)(config.theme);
}
else if (cli.flags.type === 'colorLess') {
(0, color_less_1.genColorLess)(config.colorLess);
}
else {
throw new Error(`Invalid type, can be set themeCss or colorLess value`);
}