-
Notifications
You must be signed in to change notification settings - Fork 101
/
cli
49 lines (45 loc) · 1.42 KB
/
cli
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
#!/usr/bin/env node
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const core_1 = require('@nestjs/core');
const console_1 = require('@squareboat/nest-console');
const yargs = require('yargs');
const fs = require('fs');
function checkFileExistsSync(filepath) {
let flag = true;
try {
fs.accessSync(filepath, fs.constants.F_OK);
} catch (e) {
flag = false;
}
return flag;
}
if (!checkFileExistsSync('./dist/src/app.js')) {
// CHANGE THE FILE TO CHECK IF NEEDED
console_1.Logger.error(' PLEASE BUILD THE CLI PROJECT FIRST ');
console_1.Logger.info('🪄 Run command: `npm run build` '); // CHANGE THE BUILD COMMAND IF NEEDED
return process.exit();
}
const app_1 = require('./dist/src/app'); // CHANGE THE IMPORT IF NEEDED
async function bootstrap() {
const app = await core_1.NestFactory.createApplicationContext(
app_1.AppModule,
{ logger: false },
);
const argv = yargs.argv;
const c = argv._[0];
argv.command = c;
if (typeof argv.command != 'string') {
console_1.Logger.error(' PLEASE ADD A COMMAND ');
return process.exit();
}
const command = console_1.CommandMeta.getCommand(argv.command);
if (!command || !command.target) {
console_1.Logger.error(` ${argv.command} : command not found `);
return process.exit();
}
await console_1.CommandRunner.handle(command, argv);
return process.exit();
}
bootstrap();
//# sourceMappingURL=cli.js.map