-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli
More file actions
50 lines (46 loc) · 1.46 KB
/
cli
File metadata and controls
50 lines (46 loc) · 1.46 KB
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
#!/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;
}
const fileName = "./dist/apps/media-service/src/module";
if (!checkFileExistsSync(`${fileName}.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(fileName); // CHANGE THE IMPORT IF NEEDED
async function bootstrap() {
const app = await core_1.NestFactory.createApplicationContext(
app_1.MediaModule,
{ logger: true }
);
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