1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 |
|
7 | const process_1 = __importDefault(require("process"));
|
8 |
|
9 | const caterpillar_1 = require("caterpillar");
|
10 |
|
11 | const get_cli_arg_1 = __importDefault(require("get-cli-arg"));
|
12 |
|
13 | const index_js_1 = require("./index.js");
|
14 | async function main() {
|
15 |
|
16 | if (process_1.default.argv.includes('compile')) {
|
17 |
|
18 | const p = get_cli_arg_1.default('path');
|
19 | const d = get_cli_arg_1.default('verbose');
|
20 |
|
21 | if (process_1.default.argv.includes('-p')) {
|
22 | console.log('projecz now requires -p argument to be specifie via --path=value');
|
23 | return process_1.default.exit(1);
|
24 | }
|
25 | if (process_1.default.argv.includes('-d')) {
|
26 | console.log('projecz now requires -d argument to be specifie via --verbose');
|
27 | return process_1.default.exit(1);
|
28 | }
|
29 |
|
30 | const level = d ? 7 : 6;
|
31 |
|
32 | const logger = new caterpillar_1.Logger({ lineLevel: level });
|
33 | const filter = new caterpillar_1.Filter({ filterLevel: level });
|
34 | const human = new caterpillar_1.Human();
|
35 |
|
36 | logger.pipe(filter).pipe(human).pipe(process_1.default.stdout);
|
37 |
|
38 | try {
|
39 | const project = new index_js_1.Projectz({
|
40 | log: logger.log.bind(logger),
|
41 | cwd: p || null,
|
42 | });
|
43 | await project.compile();
|
44 | }
|
45 | catch (err) {
|
46 |
|
47 | logger.log('err', err.stack);
|
48 | return process_1.default.exit(1);
|
49 | }
|
50 |
|
51 | logger.log('info', 'Completed successfully');
|
52 | }
|
53 | else {
|
54 |
|
55 | console.log('projectz compile: merge our data files and compile our meta files');
|
56 | console.log('\t--verbose\tOutputs verbose logging');
|
57 | console.log('\t--path=value\tPath to the project that you wish to work with, defaults to the current working directory');
|
58 | return process_1.default.exit(1);
|
59 | }
|
60 | }
|
61 | main();
|