@travetto/cli 5.0.0-rc.1 → 5.0.0-rc.2
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/README.md +7 -7
- package/package.json +3 -3
- package/src/decorators.ts +6 -8
- package/src/error.ts +2 -2
- package/src/execute.ts +2 -2
- package/src/module.ts +5 -5
- package/src/parse.ts +4 -13
- package/src/registry.ts +3 -4
- package/src/schema.ts +1 -1
- package/src/scm.ts +7 -8
- package/src/trv.d.ts +1 -1
- package/src/types.ts +1 -1
- package/src/util.ts +6 -6
- package/support/cli.cli_schema.ts +1 -1
- package/support/cli.main.ts +2 -3
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ This module also has a tight integration with the [VSCode plugin](https://market
|
|
|
59
59
|
At it's heart, a cli command is the contract defined by what flags, and what arguments the command supports. Within the framework this requires three criteria to be met:
|
|
60
60
|
* The file must be located in the `support/` folder, and have a name that matches `cli.*.ts`
|
|
61
61
|
* The file must be a class that has a main method
|
|
62
|
-
* The class must use the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#
|
|
62
|
+
* The class must use the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#L14) decorator
|
|
63
63
|
|
|
64
64
|
**Code: Basic Command**
|
|
65
65
|
```typescript
|
|
@@ -93,7 +93,7 @@ Examples of mappings:
|
|
|
93
93
|
The pattern is that underscores(_) translate to colons (:), and the `cli.` prefix, and `.ts` suffix are dropped.
|
|
94
94
|
|
|
95
95
|
## Binding Flags
|
|
96
|
-
[@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#
|
|
96
|
+
[@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#L14) is a wrapper for [@Schema](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/schema.ts#L14), and so every class that uses the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#L14) decorator is now a full [@Schema](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/schema.ts#L14) class. The fields of the class represent the flags that are available to the command.
|
|
97
97
|
|
|
98
98
|
**Code: Basic Command with Flag**
|
|
99
99
|
```typescript
|
|
@@ -130,7 +130,7 @@ $ trv basic:flag --loud
|
|
|
130
130
|
HELLO
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
-
The [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#
|
|
133
|
+
The [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#L14) supports the following data types for flags:
|
|
134
134
|
* Boolean values
|
|
135
135
|
* Number values. The [@Integer](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L172), [@Float](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L178), [@Precision](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L166), [@Min](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L107) and [@Max](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L117) decorators help provide additional validation.
|
|
136
136
|
* String values. [@MinLength](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L107), [@MaxLength](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L117), [@Match](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L99) and [@Enum](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L78) provide additional constraints
|
|
@@ -388,7 +388,7 @@ npx trv call:db --host localhost --port 3306 --username app --password <custom>
|
|
|
388
388
|
```
|
|
389
389
|
|
|
390
390
|
## VSCode Integration
|
|
391
|
-
By default, cli commands do not expose themselves to the VSCode extension, as the majority of them are not intended for that sort of operation. [RESTful API](https://github.com/travetto/travetto/tree/main/module/rest#readme "Declarative api for RESTful APIs with support for the dependency injection module.") does expose a cli target `run:rest` that will show up, to help run/debug a rest application. Any command can mark itself as being a run target, and will be eligible for running from within the [VSCode plugin](https://marketplace.visualstudio.com/items?itemName=arcsine.travetto-plugin). This is achieved by setting the `runTarget` field on the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#
|
|
391
|
+
By default, cli commands do not expose themselves to the VSCode extension, as the majority of them are not intended for that sort of operation. [RESTful API](https://github.com/travetto/travetto/tree/main/module/rest#readme "Declarative api for RESTful APIs with support for the dependency injection module.") does expose a cli target `run:rest` that will show up, to help run/debug a rest application. Any command can mark itself as being a run target, and will be eligible for running from within the [VSCode plugin](https://marketplace.visualstudio.com/items?itemName=arcsine.travetto-plugin). This is achieved by setting the `runTarget` field on the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#L14) decorator. This means the target will be visible within the editor tooling.
|
|
392
392
|
|
|
393
393
|
**Code: Simple Run Target**
|
|
394
394
|
```typescript
|
|
@@ -459,7 +459,7 @@ If the goal is to run a more complex application, which may include depending on
|
|
|
459
459
|
|
|
460
460
|
**Code: Simple Run Target**
|
|
461
461
|
```typescript
|
|
462
|
-
import {
|
|
462
|
+
import { Runtime } from '@travetto/runtime';
|
|
463
463
|
import { DependencyRegistry } from '@travetto/di';
|
|
464
464
|
import { CliCommand, CliCommandShape, CliUtil } from '@travetto/cli';
|
|
465
465
|
|
|
@@ -498,7 +498,7 @@ export class RunRestCommand implements CliCommandShape {
|
|
|
498
498
|
try {
|
|
499
499
|
return await DependencyRegistry.runInstance(RestApplication);
|
|
500
500
|
} catch (err) {
|
|
501
|
-
if (RestNetUtil.isInuseError(err) && !
|
|
501
|
+
if (RestNetUtil.isInuseError(err) && !Runtime.production && this.killConflict) {
|
|
502
502
|
await RestNetUtil.freePort(err.port);
|
|
503
503
|
return await DependencyRegistry.runInstance(RestApplication);
|
|
504
504
|
}
|
|
@@ -508,7 +508,7 @@ export class RunRestCommand implements CliCommandShape {
|
|
|
508
508
|
}
|
|
509
509
|
```
|
|
510
510
|
|
|
511
|
-
As noted in the example above, `fields` is specified in this execution, with support for `module`, and `env`. These env flag is directly tied to the [Runtime](https://github.com/travetto/travetto/tree/main/module/
|
|
511
|
+
As noted in the example above, `fields` is specified in this execution, with support for `module`, and `env`. These env flag is directly tied to the [Runtime](https://github.com/travetto/travetto/tree/main/module/runtime/src/env.ts#L109) `name` defined in the [Base](https://github.com/travetto/travetto/tree/main/module/runtime#readme "Environment config and common utilities for travetto applications.") module.
|
|
512
512
|
|
|
513
513
|
The `module` field is slightly more complex, but is geared towards supporting commands within a monorepo context. This flag ensures that a module is specified if running from the root of the monorepo, and that the module provided is real, and can run the desired command. When running from an explicit module folder in the monorepo, the module flag is ignored.
|
|
514
514
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/cli",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.2",
|
|
4
4
|
"description": "CLI infrastructure for Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"directory": "module/cli"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@travetto/schema": "^5.0.0-rc.
|
|
33
|
-
"@travetto/terminal": "^5.0.0-rc.
|
|
32
|
+
"@travetto/schema": "^5.0.0-rc.2",
|
|
33
|
+
"@travetto/terminal": "^5.0.0-rc.2"
|
|
34
34
|
},
|
|
35
35
|
"travetto": {
|
|
36
36
|
"displayName": "Command Line Interface",
|
package/src/decorators.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Class, ClassInstance, Env,
|
|
2
|
-
import { RuntimeIndex } from '@travetto/manifest';
|
|
1
|
+
import { Class, ClassInstance, Env, Runtime, RuntimeIndex, describeFunction } from '@travetto/runtime';
|
|
3
2
|
import { SchemaRegistry } from '@travetto/schema';
|
|
4
3
|
|
|
5
4
|
import { CliCommandShape, CliCommandShapeFields } from './types';
|
|
@@ -14,8 +13,7 @@ import { CliParseUtil } from './parse';
|
|
|
14
13
|
*/
|
|
15
14
|
export function CliCommand(cfg: CliCommandConfigOptions = {}) {
|
|
16
15
|
return function <T extends CliCommandShape>(target: Class<T>): void {
|
|
17
|
-
|
|
18
|
-
if (!meta || meta.abstract) {
|
|
16
|
+
if (!target.Ⲑid || describeFunction(target)?.abstract) {
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
19
|
|
|
@@ -27,7 +25,7 @@ export function CliCommand(cfg: CliCommandConfigOptions = {}) {
|
|
|
27
25
|
runTarget: cfg.runTarget,
|
|
28
26
|
preMain: async (cmd: CliCommandShape & { env?: string }) => {
|
|
29
27
|
if (addEnv) {
|
|
30
|
-
Env.TRV_ENV.set(cmd.env ||
|
|
28
|
+
Env.TRV_ENV.set(cmd.env || Runtime.name);
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
});
|
|
@@ -47,7 +45,7 @@ export function CliCommand(cfg: CliCommandConfigOptions = {}) {
|
|
|
47
45
|
aliases: ['m', CliParseUtil.toEnvField(Env.TRV_MODULE.key)],
|
|
48
46
|
description: 'Module to run for',
|
|
49
47
|
specifiers: ['module'],
|
|
50
|
-
required: { active:
|
|
48
|
+
required: { active: Runtime.monoRoot }
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
51
|
|
|
@@ -55,10 +53,10 @@ export function CliCommand(cfg: CliCommandConfigOptions = {}) {
|
|
|
55
53
|
(pendingCls.validators ??= []).push(async item => {
|
|
56
54
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
57
55
|
const { module: mod } = item as CliCommandShapeFields;
|
|
58
|
-
const runModule = (runtimeModule === 'command' ? commandModule : mod) ||
|
|
56
|
+
const runModule = (runtimeModule === 'command' ? commandModule : mod) || Runtime.main.name;
|
|
59
57
|
|
|
60
58
|
// If we need to run as a specific module
|
|
61
|
-
if (runModule !==
|
|
59
|
+
if (runModule !== Runtime.main.name) {
|
|
62
60
|
try {
|
|
63
61
|
RuntimeIndex.reinitForModule(runModule);
|
|
64
62
|
} catch (err) {
|
package/src/error.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppError,
|
|
1
|
+
import { AppError, Runtime } from '@travetto/runtime';
|
|
2
2
|
import { PackageUtil } from '@travetto/manifest';
|
|
3
3
|
import { cliTpl } from './color';
|
|
4
4
|
import { CliValidationError, CliCommandShape } from './types';
|
|
@@ -23,7 +23,7 @@ export class CliUnknownCommandError extends Error {
|
|
|
23
23
|
const matchedCfg = COMMAND_PACKAGE.find(([re]) => re.test(cmd));
|
|
24
24
|
if (matchedCfg) {
|
|
25
25
|
const [, pkg, prod] = matchedCfg;
|
|
26
|
-
const install = PackageUtil.getInstallCommand(
|
|
26
|
+
const install = PackageUtil.getInstallCommand(Runtime, `@travetto/${pkg}`, prod);
|
|
27
27
|
return cliTpl`
|
|
28
28
|
${{ title: 'Missing Package' }}\n${'-'.repeat(20)}\nTo use ${{ input: cmd }} please run:\n
|
|
29
29
|
${{ identifier: install }}
|
package/src/execute.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConsoleManager,
|
|
1
|
+
import { ConsoleManager, Runtime, ShutdownManager } from '@travetto/runtime';
|
|
2
2
|
|
|
3
3
|
import { HelpUtil } from './help';
|
|
4
4
|
import { CliCommandRegistry } from './registry';
|
|
@@ -54,7 +54,7 @@ export class ExecutionManager {
|
|
|
54
54
|
await command._cfg!.preMain?.(command);
|
|
55
55
|
await command.preMain?.();
|
|
56
56
|
|
|
57
|
-
ConsoleManager.debug(
|
|
57
|
+
ConsoleManager.debug(Runtime.debug);
|
|
58
58
|
const result = await command.main(...boundArgs);
|
|
59
59
|
await CliUtil.listenForResponse(result);
|
|
60
60
|
}
|
package/src/module.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
2
|
+
import type { IndexedModule } from '@travetto/manifest';
|
|
3
3
|
|
|
4
4
|
import { CliScmUtil } from './scm';
|
|
5
5
|
|
|
@@ -44,11 +44,11 @@ export class CliModuleUtil {
|
|
|
44
44
|
* @param transitive
|
|
45
45
|
* @returns
|
|
46
46
|
*/
|
|
47
|
-
static async findModules(mode: 'all' | 'changed', fromHash?: string, toHash?: string
|
|
47
|
+
static async findModules(mode: 'all' | 'changed', fromHash?: string, toHash?: string): Promise<IndexedModule[]> {
|
|
48
48
|
return (mode === 'changed' ?
|
|
49
|
-
await this.findChangedModulesRecursive(fromHash, toHash,
|
|
49
|
+
await this.findChangedModulesRecursive(fromHash, toHash, true) :
|
|
50
50
|
[...RuntimeIndex.getModuleList('all')].map(x => RuntimeIndex.getModule(x)!)
|
|
51
|
-
).filter(x => x.sourcePath !==
|
|
51
|
+
).filter(x => x.sourcePath !== Runtime.workspace.path);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
package/src/parse.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { RuntimeIndex } from '@travetto/manifest';
|
|
4
|
+
import { Runtime } from '@travetto/runtime';
|
|
6
5
|
import { CliCommandInput, CliCommandSchema, ParsedState } from './types';
|
|
7
6
|
|
|
8
7
|
type ParsedInput = ParsedState['all'][number];
|
|
@@ -86,16 +85,8 @@ export class CliParseUtil {
|
|
|
86
85
|
const key = flag.replace(CONFIG_PRE, '');
|
|
87
86
|
|
|
88
87
|
// We have a file
|
|
89
|
-
const rel = (key.includes('/') ? key :
|
|
90
|
-
.replace(
|
|
91
|
-
.replace('@/', `${mod}/`)
|
|
92
|
-
.replace(/^(@[^\/]+\/[^\/]+)(\/.*)$/, (_, imp, rest) => {
|
|
93
|
-
const val = RuntimeIndex.getModule(imp);
|
|
94
|
-
if (!val) {
|
|
95
|
-
throw new Error(`Unknown module file: ${_}, unable to proceed`);
|
|
96
|
-
}
|
|
97
|
-
return `${val.sourcePath}${rest}`;
|
|
98
|
-
});
|
|
88
|
+
const rel = (key.includes('/') ? key : `@#support/pack.${key}.flags`)
|
|
89
|
+
.replace(/^(@[^#]*)#(.*)$/, (_, imp, rest) => `${Runtime.modulePath(imp)}/${rest}`);
|
|
99
90
|
|
|
100
91
|
const file = path.resolve(rel);
|
|
101
92
|
|
|
@@ -146,7 +137,7 @@ export class CliParseUtil {
|
|
|
146
137
|
const mod = args.reduce(
|
|
147
138
|
(m, x, i, arr) =>
|
|
148
139
|
(i < SEP ? check(arr[i - 1], x) ?? check(...x.split('=')) : undefined) ?? m,
|
|
149
|
-
process.env[ENV_KEY] ||
|
|
140
|
+
process.env[ENV_KEY] || Runtime.main.name
|
|
150
141
|
);
|
|
151
142
|
return (await Promise.all(args.map((x, i) =>
|
|
152
143
|
x.startsWith(CONFIG_PRE) && (i < SEP || SEP < 0) ? this.readFlagFile(x, mod) : x))).flat();
|
package/src/registry.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Class, ConcreteClass,
|
|
2
|
-
import { RuntimeIndex } from '@travetto/manifest';
|
|
1
|
+
import { Class, ConcreteClass, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
3
2
|
|
|
4
3
|
import { CliCommandConfig, CliCommandShape } from './types';
|
|
5
4
|
import { CliUnknownCommandError } from './error';
|
|
@@ -37,7 +36,7 @@ class $CliCommandRegistry {
|
|
|
37
36
|
if (!this.#fileMapping) {
|
|
38
37
|
const all = new Map<string, string>();
|
|
39
38
|
for (const e of RuntimeIndex.find({
|
|
40
|
-
module: m => !
|
|
39
|
+
module: m => !Runtime.production || m.prod,
|
|
41
40
|
folder: f => f === 'support',
|
|
42
41
|
file: f => f.role === 'std' && CLI_FILE_REGEX.test(f.sourceFile)
|
|
43
42
|
})) {
|
|
@@ -52,7 +51,7 @@ class $CliCommandRegistry {
|
|
|
52
51
|
* Registers a cli command
|
|
53
52
|
*/
|
|
54
53
|
registerClass(cls: Class, cfg: Partial<CliCommandConfig>): CliCommandConfig {
|
|
55
|
-
const source =
|
|
54
|
+
const source = Runtime.getSource(cls);
|
|
56
55
|
this.#commands.set(cls, {
|
|
57
56
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
58
57
|
cls: cls as ConcreteClass,
|
package/src/schema.ts
CHANGED
package/src/scm.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
|
-
import { ExecUtil,
|
|
6
|
-
import {
|
|
5
|
+
import { AppError, ExecUtil, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
6
|
+
import type { IndexedModule } from '@travetto/manifest';
|
|
7
7
|
|
|
8
8
|
export class CliScmUtil {
|
|
9
9
|
/**
|
|
@@ -35,7 +35,7 @@ export class CliScmUtil {
|
|
|
35
35
|
* @returns
|
|
36
36
|
*/
|
|
37
37
|
static async findLastRelease(): Promise<string | undefined> {
|
|
38
|
-
const result = await ExecUtil.getResult(spawn('git', ['log', '--pretty=oneline'], { cwd:
|
|
38
|
+
const result = await ExecUtil.getResult(spawn('git', ['log', '--pretty=oneline'], { cwd: Runtime.workspace.path }));
|
|
39
39
|
return result.stdout
|
|
40
40
|
.split(/\n/)
|
|
41
41
|
.find(x => /Publish /.test(x))?.split(/\s+/)?.[0];
|
|
@@ -46,12 +46,11 @@ export class CliScmUtil {
|
|
|
46
46
|
* @param fromHash
|
|
47
47
|
* @returns
|
|
48
48
|
*/
|
|
49
|
-
static async findChangedFiles(fromHash: string, toHash: string = 'HEAD'
|
|
50
|
-
const ws =
|
|
49
|
+
static async findChangedFiles(fromHash: string, toHash: string = 'HEAD'): Promise<string[]> {
|
|
50
|
+
const ws = Runtime.workspace.path;
|
|
51
51
|
const res = await ExecUtil.getResult(spawn('git', ['diff', '--name-only', `${fromHash}..${toHash}`, ':!**/DOC.*', ':!**/README.*'], { cwd: ws }), { catch: true });
|
|
52
|
-
if (!res.valid
|
|
53
|
-
|
|
54
|
-
return [];
|
|
52
|
+
if (!res.valid) {
|
|
53
|
+
throw new AppError('Unable to detect changes between', 'data', { fromHash, toHash, output: (res.stderr || res.stdout) });
|
|
55
54
|
}
|
|
56
55
|
const out = new Set<string>();
|
|
57
56
|
for (const line of res.stdout.split(/\n/g)) {
|
package/src/trv.d.ts
CHANGED
package/src/types.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
|
|
3
|
-
import { Env, ExecUtil, ShutdownManager,
|
|
3
|
+
import { Env, ExecUtil, ShutdownManager, Runtime } from '@travetto/runtime';
|
|
4
4
|
|
|
5
5
|
import { CliCommandShape, CliCommandShapeFields, RunResponse } from './types';
|
|
6
6
|
|
|
@@ -14,10 +14,10 @@ export class CliUtil {
|
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
16
|
static getSimpleModuleName(placeholder: string, module?: string): string {
|
|
17
|
-
const simple = (module ??
|
|
17
|
+
const simple = (module ?? Runtime.main.name).replace(/[\/]/, '_').replace(/@/, '');
|
|
18
18
|
if (!simple) {
|
|
19
19
|
return placeholder;
|
|
20
|
-
} else if (!module &&
|
|
20
|
+
} else if (!module && Runtime.monoRoot) {
|
|
21
21
|
return placeholder;
|
|
22
22
|
} else {
|
|
23
23
|
return placeholder.replace('<module>', simple);
|
|
@@ -31,7 +31,7 @@ export class CliUtil {
|
|
|
31
31
|
if (ipc && process.connected) {
|
|
32
32
|
process.once('disconnect', () => process.exit());
|
|
33
33
|
}
|
|
34
|
-
if (Env.TRV_CAN_RESTART.isFalse || !(cmd.canRestart ?? !
|
|
34
|
+
if (Env.TRV_CAN_RESTART.isFalse || !(cmd.canRestart ?? !Runtime.production)) {
|
|
35
35
|
Env.TRV_CAN_RESTART.clear();
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
@@ -64,7 +64,7 @@ export class CliUtil {
|
|
|
64
64
|
data: {
|
|
65
65
|
name: cmd._cfg!.name, env,
|
|
66
66
|
commandModule: cmd._cfg!.commandModule,
|
|
67
|
-
module:
|
|
67
|
+
module: Runtime.main.name,
|
|
68
68
|
args: process.argv.slice(3),
|
|
69
69
|
}
|
|
70
70
|
};
|
|
@@ -79,7 +79,7 @@ export class CliUtil {
|
|
|
79
79
|
* Debug if IPC available
|
|
80
80
|
*/
|
|
81
81
|
static async debugIfIpc<T extends CliCommandShapeFields & CliCommandShape>(cmd: T): Promise<boolean> {
|
|
82
|
-
return (cmd.debugIpc ?? !
|
|
82
|
+
return (cmd.debugIpc ?? !Runtime.production) && this.triggerIpc('run', cmd);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
package/support/cli.main.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
5
5
|
import { CliCommandShape, CliCommand, CliValidationError, ParsedState } from '@travetto/cli';
|
|
6
|
-
import { RuntimeIndex } from '@travetto/manifest';
|
|
7
6
|
import { Ignore } from '@travetto/schema';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -19,7 +18,7 @@ export class MainCommand implements CliCommandShape {
|
|
|
19
18
|
// If referenced file exists
|
|
20
19
|
let file = fileOrImport;
|
|
21
20
|
if (await (fs.stat(path.resolve(fileOrImport)).then(() => true, () => false))) {
|
|
22
|
-
file = path.join(
|
|
21
|
+
file = path.join(Runtime.main.name, fileOrImport);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
return RuntimeIndex.getFromImport(file)?.import;
|