@rsdk/cli.cmd.start 4.3.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/start-dev.cmd.d.ts +4 -0
- package/dist/start-dev.cmd.js +69 -0
- package/dist/start-dev.cmd.js.map +1 -0
- package/dist/start.cmd.d.ts +4 -0
- package/dist/start.cmd.js +52 -0
- package/dist/start.cmd.js.map +1 -0
- package/dist/tracing/tracing.cfg.d.ts +1 -0
- package/dist/tracing/tracing.cfg.js +5 -0
- package/dist/tracing/tracing.cfg.js.map +1 -0
- package/package.json +32 -0
- package/src/index.ts +17 -0
- package/src/start-dev.cmd.ts +53 -0
- package/src/start.cmd.ts +36 -0
- package/src/tracing/tracing.cfg.ts +1 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +7 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [4.3.0-next.0](https://github.com/R-Vision/rsdk/compare/v4.2.5-next.0...v4.3.0-next.0) (2024-03-19)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* reworked cli system ([745ebf5](https://github.com/R-Vision/rsdk/commit/745ebf53635de135a4a9083f47ce833efe2d4411))
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cmd = void 0;
|
|
4
|
+
const cli_common_1 = require("@rsdk/cli.common");
|
|
5
|
+
const start_cmd_1 = require("./start.cmd");
|
|
6
|
+
const start_dev_cmd_1 = require("./start-dev.cmd");
|
|
7
|
+
class StartRsdkCmd {
|
|
8
|
+
getCommands() {
|
|
9
|
+
return [
|
|
10
|
+
...(0, cli_common_1.getCommanderCommand)(start_cmd_1.StartCmd),
|
|
11
|
+
...(0, cli_common_1.getCommanderCommand)(start_dev_cmd_1.StartDevCmd),
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.Cmd = new StartRsdkCmd();
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,iDAAuD;AAGvD,2CAAuC;AACvC,mDAA8C;AAE9C,MAAM,YAAY;IAChB,WAAW;QACT,OAAO;YACL,GAAG,IAAA,gCAAmB,EAAC,oBAAQ,CAAC;YAChC,GAAG,IAAA,gCAAmB,EAAC,2BAAW,CAAC;SACpC,CAAC;IACJ,CAAC;CACF;AAEY,QAAA,GAAG,GAAG,IAAI,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.StartDevCmd = void 0;
|
|
19
|
+
const cli_common_1 = require("@rsdk/cli.common");
|
|
20
|
+
const logging_1 = require("@rsdk/logging");
|
|
21
|
+
const execa_1 = __importDefault(require("execa"));
|
|
22
|
+
const node_path_1 = require("node:path");
|
|
23
|
+
const tracing_cfg_1 = require("./tracing/tracing.cfg");
|
|
24
|
+
class StartDevCmd {
|
|
25
|
+
static logger = logging_1.LoggerFactory.create(StartDevCmd);
|
|
26
|
+
async handle(tracing, pretty) {
|
|
27
|
+
const tracingPart = [`-e`, `node -r ${tracing_cfg_1.tracingFilePath}`];
|
|
28
|
+
const command = [`nest`, `start`, `--watch`];
|
|
29
|
+
if (tracing) {
|
|
30
|
+
command.push(...tracingPart);
|
|
31
|
+
}
|
|
32
|
+
const bin = 'npx';
|
|
33
|
+
const cmd = [bin, ...command].join(' ');
|
|
34
|
+
StartDevCmd.logger.trace('run command: ' + cmd);
|
|
35
|
+
const appCwd = (0, node_path_1.resolve)();
|
|
36
|
+
const spawn = (0, execa_1.default)(bin, command, {
|
|
37
|
+
cwd: appCwd,
|
|
38
|
+
});
|
|
39
|
+
if (pretty) {
|
|
40
|
+
// TODO make correctly with commonly stream from pino-pretty
|
|
41
|
+
const spawnPinoPretty = (0, execa_1.default)('npx', ['pino-pretty'], {
|
|
42
|
+
stdout: process.stdout,
|
|
43
|
+
stderr: process.stderr,
|
|
44
|
+
cwd: (0, node_path_1.resolve)(),
|
|
45
|
+
});
|
|
46
|
+
spawn.stderr.pipe(spawnPinoPretty.stdin);
|
|
47
|
+
spawn.stdout.pipe(spawnPinoPretty.stdin);
|
|
48
|
+
spawn.on('exit', (code) => {
|
|
49
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
50
|
+
process.exit(code ?? 0);
|
|
51
|
+
});
|
|
52
|
+
await spawnPinoPretty;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
spawn.stderr.pipe(process.stderr);
|
|
56
|
+
spawn.stdout.pipe(process.stdout);
|
|
57
|
+
await spawn;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.StartDevCmd = StartDevCmd;
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, cli_common_1.SubCmd)('start:dev', 'Start app with watch mode'),
|
|
63
|
+
__param(0, (0, cli_common_1.Option)('tracing', 'Enable tracing', Boolean)),
|
|
64
|
+
__param(1, (0, cli_common_1.Option)('pretty', 'Enable PinoPretty output', Boolean)),
|
|
65
|
+
__metadata("design:type", Function),
|
|
66
|
+
__metadata("design:paramtypes", [Boolean, Boolean]),
|
|
67
|
+
__metadata("design:returntype", Promise)
|
|
68
|
+
], StartDevCmd.prototype, "handle", null);
|
|
69
|
+
//# sourceMappingURL=start-dev.cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-dev.cmd.js","sourceRoot":"","sources":["../src/start-dev.cmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iDAAkD;AAClD,2CAA8C;AAC9C,kDAA0B;AAC1B,yCAAoC;AAEpC,uDAAwD;AAExD,MAAa,WAAW;IACtB,MAAM,CAAC,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAG5C,AAAN,KAAK,CAAC,MAAM,CACoC,OAAgB,EACP,MAAe;QAEtE,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,WAAW,6BAAe,EAAE,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAC7C,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;QAC/B,CAAC;QACD,MAAM,GAAG,GAAG,KAAK,CAAC;QAElB,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAExC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,IAAA,mBAAO,GAAE,CAAC;QAEzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,GAAG,EAAE,OAAO,EAAE;YAChC,GAAG,EAAE,MAAM;SACZ,CAAC,CAAC;QAEH,IAAI,MAAM,EAAE,CAAC;YACX,4DAA4D;YAC5D,MAAM,eAAe,GAAG,IAAA,eAAK,EAAC,KAAK,EAAE,CAAC,aAAa,CAAC,EAAE;gBACpD,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,GAAG,EAAE,IAAA,mBAAO,GAAE;aACf,CAAC,CAAC;YAEH,KAAK,CAAC,MAAO,CAAC,IAAI,CAAC,eAAe,CAAC,KAAM,CAAC,CAAC;YAC3C,KAAK,CAAC,MAAO,CAAC,IAAI,CAAC,eAAe,CAAC,KAAM,CAAC,CAAC;YAC3C,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBACxB,mDAAmD;gBACnD,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;YACH,MAAM,eAAe,CAAC;YACtB,OAAO;QACT,CAAC;QACD,KAAK,CAAC,MAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,CAAC,MAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,KAAK,CAAC;IACd,CAAC;;AA5CH,kCA6CC;AAzCO;IADL,IAAA,mBAAM,EAAC,WAAW,EAAE,2BAA2B,CAAC;IAE9C,WAAA,IAAA,mBAAM,EAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAA;IAC5C,WAAA,IAAA,mBAAM,EAAC,QAAQ,EAAE,0BAA0B,EAAE,OAAO,CAAC,CAAA;;;;yCAsCvD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.StartCmd = void 0;
|
|
16
|
+
const cli_common_1 = require("@rsdk/cli.common");
|
|
17
|
+
const logging_1 = require("@rsdk/logging");
|
|
18
|
+
const node_path_1 = require("node:path");
|
|
19
|
+
const tracing_cfg_1 = require("./tracing/tracing.cfg");
|
|
20
|
+
class StartCmd {
|
|
21
|
+
async handle(tracing) {
|
|
22
|
+
StartCmd.logger.trace('execute start command');
|
|
23
|
+
try {
|
|
24
|
+
if (tracing) {
|
|
25
|
+
require(tracing_cfg_1.tracingFilePath);
|
|
26
|
+
}
|
|
27
|
+
const appFile = (0, node_path_1.resolve)(`dist/app.js`);
|
|
28
|
+
StartCmd.logger.trace('resolved appFile', { appFile });
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
30
|
+
const app = require(appFile).app;
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
32
|
+
if (!(app instanceof require('@rsdk/core').PlatformApp)) {
|
|
33
|
+
throw new TypeError('app is not instance PlatformApp');
|
|
34
|
+
}
|
|
35
|
+
await app.run();
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
StartCmd.logger.error(error);
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
static logger = logging_1.LoggerFactory.create(StartCmd);
|
|
43
|
+
}
|
|
44
|
+
exports.StartCmd = StartCmd;
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, cli_common_1.SubCmd)('start', 'Start built app'),
|
|
47
|
+
__param(0, (0, cli_common_1.Option)('tracing', 'Enable tracing', Boolean)),
|
|
48
|
+
__metadata("design:type", Function),
|
|
49
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
50
|
+
__metadata("design:returntype", Promise)
|
|
51
|
+
], StartCmd.prototype, "handle", null);
|
|
52
|
+
//# sourceMappingURL=start.cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.cmd.js","sourceRoot":"","sources":["../src/start.cmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iDAAkD;AAClD,2CAA8C;AAC9C,yCAAoC;AAEpC,uDAAwD;AAExD,MAAa,QAAQ;IAEb,AAAN,KAAK,CAAC,MAAM,CACoC,OAAgB;QAE9D,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAE/C,IAAI,CAAC;YACH,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,6BAAe,CAAC,CAAC;YAC3B,CAAC;YAED,MAAM,OAAO,GAAG,IAAA,mBAAO,EAAC,aAAa,CAAC,CAAC;YAEvC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YACvD,8DAA8D;YAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC;YACjC,8DAA8D;YAC9D,IAAI,CAAC,CAAC,GAAG,YAAY,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;gBACxD,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;YACzD,CAAC;YACD,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,KAAc,CAAC,CAAC;YACtC,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;;AA5BzD,4BA6BC;AA3BO;IADL,IAAA,mBAAM,EAAC,OAAO,EAAE,iBAAiB,CAAC;IAEhC,WAAA,IAAA,mBAAM,EAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAA;;;;sCAuB9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tracingFilePath: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracing.cfg.js","sourceRoot":"","sources":["../../src/tracing/tracing.cfg.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rsdk/cli.cmd.start",
|
|
3
|
+
"version": "4.3.0-next.0",
|
|
4
|
+
"description": "Start command for rsdk cli",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"rsdk": "bin.js"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"rsdk",
|
|
14
|
+
"cli"
|
|
15
|
+
],
|
|
16
|
+
"license": "Apache License 2.0",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@nestjs/cli": "^10.0.0",
|
|
19
|
+
"commander": "^12.0.0",
|
|
20
|
+
"dotenv": "^16.3.1",
|
|
21
|
+
"execa": "^5.1.1",
|
|
22
|
+
"listr2": "^6.6.1",
|
|
23
|
+
"yaml": "^2.3.1"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@rsdk/cli.common": "^4.3.0-next.0",
|
|
27
|
+
"@rsdk/core": "^4.3.0-next.0",
|
|
28
|
+
"@rsdk/exception": "workspace:^",
|
|
29
|
+
"@rsdk/logging": "^4.3.0-next.0"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "68619cc6fc60db01568eede7df182d9882e857dd"
|
|
32
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RsdkCliCommand } from '@rsdk/cli.common';
|
|
2
|
+
import { getCommanderCommand } from '@rsdk/cli.common';
|
|
3
|
+
import type { Command } from 'commander';
|
|
4
|
+
|
|
5
|
+
import { StartCmd } from './start.cmd';
|
|
6
|
+
import { StartDevCmd } from './start-dev.cmd';
|
|
7
|
+
|
|
8
|
+
class StartRsdkCmd implements RsdkCliCommand {
|
|
9
|
+
getCommands(): Command[] {
|
|
10
|
+
return [
|
|
11
|
+
...getCommanderCommand(StartCmd),
|
|
12
|
+
...getCommanderCommand(StartDevCmd),
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const Cmd = new StartRsdkCmd();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Option, SubCmd } from '@rsdk/cli.common';
|
|
2
|
+
import { LoggerFactory } from '@rsdk/logging';
|
|
3
|
+
import execa from 'execa';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { tracingFilePath } from './tracing/tracing.cfg';
|
|
7
|
+
|
|
8
|
+
export class StartDevCmd {
|
|
9
|
+
static logger = LoggerFactory.create(StartDevCmd);
|
|
10
|
+
|
|
11
|
+
@SubCmd('start:dev', 'Start app with watch mode')
|
|
12
|
+
async handle(
|
|
13
|
+
@Option('tracing', 'Enable tracing', Boolean) tracing: boolean,
|
|
14
|
+
@Option('pretty', 'Enable PinoPretty output', Boolean) pretty: boolean,
|
|
15
|
+
): Promise<void> {
|
|
16
|
+
const tracingPart = [`-e`, `node -r ${tracingFilePath}`];
|
|
17
|
+
const command = [`nest`, `start`, `--watch`];
|
|
18
|
+
if (tracing) {
|
|
19
|
+
command.push(...tracingPart);
|
|
20
|
+
}
|
|
21
|
+
const bin = 'npx';
|
|
22
|
+
|
|
23
|
+
const cmd = [bin, ...command].join(' ');
|
|
24
|
+
|
|
25
|
+
StartDevCmd.logger.trace('run command: ' + cmd);
|
|
26
|
+
const appCwd = resolve();
|
|
27
|
+
|
|
28
|
+
const spawn = execa(bin, command, {
|
|
29
|
+
cwd: appCwd,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (pretty) {
|
|
33
|
+
// TODO make correctly with commonly stream from pino-pretty
|
|
34
|
+
const spawnPinoPretty = execa('npx', ['pino-pretty'], {
|
|
35
|
+
stdout: process.stdout,
|
|
36
|
+
stderr: process.stderr,
|
|
37
|
+
cwd: resolve(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
spawn.stderr!.pipe(spawnPinoPretty.stdin!);
|
|
41
|
+
spawn.stdout!.pipe(spawnPinoPretty.stdin!);
|
|
42
|
+
spawn.on('exit', (code) => {
|
|
43
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
44
|
+
process.exit(code ?? 0);
|
|
45
|
+
});
|
|
46
|
+
await spawnPinoPretty;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
spawn.stderr!.pipe(process.stderr);
|
|
50
|
+
spawn.stdout!.pipe(process.stdout);
|
|
51
|
+
await spawn;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/src/start.cmd.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Option, SubCmd } from '@rsdk/cli.common';
|
|
2
|
+
import { LoggerFactory } from '@rsdk/logging';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { tracingFilePath } from './tracing/tracing.cfg';
|
|
6
|
+
|
|
7
|
+
export class StartCmd {
|
|
8
|
+
@SubCmd('start', 'Start built app')
|
|
9
|
+
async handle(
|
|
10
|
+
@Option('tracing', 'Enable tracing', Boolean) tracing: boolean,
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
StartCmd.logger.trace('execute start command');
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
if (tracing) {
|
|
16
|
+
require(tracingFilePath);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const appFile = resolve(`dist/app.js`);
|
|
20
|
+
|
|
21
|
+
StartCmd.logger.trace('resolved appFile', { appFile });
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
23
|
+
const app = require(appFile).app;
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
25
|
+
if (!(app instanceof require('@rsdk/core').PlatformApp)) {
|
|
26
|
+
throw new TypeError('app is not instance PlatformApp');
|
|
27
|
+
}
|
|
28
|
+
await app.run();
|
|
29
|
+
} catch (error) {
|
|
30
|
+
StartCmd.logger.error(error as Error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private static logger = LoggerFactory.create(StartCmd);
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const tracingFilePath = require.resolve('@rsdk/tracing/dist/tracing.js');
|