@alyle/ui
Version:
Minimal Design, a set of components for Angular
71 lines • 2.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AUI_VERSION = void 0;
const tslib_1 = require("tslib");
const fs_1 = require("fs");
const path = require("path");
require("./check");
const yargs = require("yargs");
const c = require("ansi-colors");
const compiler_1 = require("./compiler");
exports.AUI_VERSION = '19.0.0';
const note = `Note: It is recommended to use git and have saved the changes.\n`
+ `Compile the files for production only, this will modify your\nlyl styles to another format.\n`;
const argv = yargs
.alias('h', 'help')
.alias('v', 'version')
.version()
.help(false).argv;
if (argv.help) {
console.log(`Version ${exports.AUI_VERSION}\n`);
console.log(c.bold.yellowBright(note));
console.log(`Usage: lyl src`);
process.exit(0);
}
function walk(dir_1) {
return tslib_1.__awaiter(this, arguments, void 0, function* (dir, fileList = []) {
const files = yield fs_1.promises.readdir(dir);
for (const file of files) {
const stat = yield fs_1.promises.stat(path.join(dir, file));
if (stat.isDirectory()) {
fileList = yield walk(path.join(dir, file), fileList);
}
else {
fileList.push(path.join(dir, file));
}
}
return fileList;
});
}
const directory = argv._[0];
if (directory) {
console.log(c.bold.blueBright(`Directory: ${directory}`));
}
else {
console.log(c.bold.redBright(`Require directory`));
console.log(`Examples: lyl dist/lib`);
process.exit(1);
}
walk(directory).then((res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
res = res
.filter(file => file.endsWith('.ts'));
res.forEach((file) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const content = (yield fs_1.promises.readFile(file)).toString('utf8');
const hasLyl = (0, compiler_1.hasLylStyle)(content);
if (hasLyl) {
let compiled = null;
try {
compiled = (0, compiler_1.styleCompiler)(content);
console.log(`${c.bold.greenBright('Updated: ')}${file}`);
}
catch (error) {
console.log(c.yellow(`error in ${file}`), error);
}
if (compiled) {
yield fs_1.promises.writeFile(file, compiled, 'utf8');
}
}
}));
}));
//# sourceMappingURL=main.js.map