@travetto/cli 7.0.5 → 7.0.6
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 +3 -3
- package/bin/trv.js +3 -2
- package/package.json +3 -3
- package/src/color.ts +13 -11
- package/src/error.ts +1 -1
- package/src/execute.ts +1 -1
- package/src/help.ts +2 -2
- package/src/module.ts +17 -17
- package/src/parse.ts +17 -17
- package/src/registry/decorator.ts +5 -5
- package/src/registry/registry-adapter.ts +3 -3
- package/src/registry/registry-index.ts +5 -5
- package/src/schema-export.ts +2 -2
- package/src/schema.ts +1 -1
- package/src/scm.ts +3 -3
- package/src/types.ts +1 -1
- package/src/util.ts +1 -1
- package/support/cli.cli_schema.ts +1 -1
- package/support/cli.main.ts +3 -3
- package/support/cli.service.ts +3 -3
package/README.md
CHANGED
|
@@ -378,8 +378,8 @@ npx trv call:db +=base --password <custom>
|
|
|
378
378
|
```
|
|
379
379
|
|
|
380
380
|
The flag files can be included in one of a few ways:
|
|
381
|
-
* `+=<name>` - This translates into `<
|
|
382
|
-
* `+=<
|
|
381
|
+
* `+=<name>` - This translates into `<module>/support/<name>.flags`, which is a convenient shorthand.
|
|
382
|
+
* `+=<module>/path/file.flags` - This is a path-related file that will be resolved from the module's location.
|
|
383
383
|
* `+=/path/file.flags` - This is an absolute path that will be read from the root of the file system.
|
|
384
384
|
|
|
385
385
|
Ultimately, after resolution, the content of these files will be injected inline within the location.
|
|
@@ -463,7 +463,7 @@ If the goal is to run a more complex application, which may include depending on
|
|
|
463
463
|
```typescript
|
|
464
464
|
import { Runtime, toConcrete } from '@travetto/runtime';
|
|
465
465
|
import { DependencyRegistryIndex } from '@travetto/di';
|
|
466
|
-
import { CliCommand, CliCommandShape } from '@travetto/cli';
|
|
466
|
+
import { CliCommand, type CliCommandShape } from '@travetto/cli';
|
|
467
467
|
import { NetUtil } from '@travetto/web';
|
|
468
468
|
import { Registry } from '@travetto/registry';
|
|
469
469
|
|
package/bin/trv.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// @ts-check
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import '@travetto/compiler/bin/hook.js';
|
|
4
|
+
const { invoke } = await import('@travetto/compiler/support/invoke.ts');
|
|
5
|
+
invoke('exec', ['@travetto/cli/support/entry.trv.js', ...process.argv.slice(2)]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/cli",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI infrastructure for Travetto framework",
|
|
6
6
|
"keywords": [
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"directory": "module/cli"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@travetto/schema": "^7.0.
|
|
33
|
-
"@travetto/terminal": "^7.0.
|
|
32
|
+
"@travetto/schema": "^7.0.5",
|
|
33
|
+
"@travetto/terminal": "^7.0.4"
|
|
34
34
|
},
|
|
35
35
|
"travetto": {
|
|
36
36
|
"displayName": "Command Line Interface",
|
package/src/color.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { StyleUtil } from '@travetto/terminal';
|
|
1
|
+
import { StyleUtil, type TermStyledTemplate } from '@travetto/terminal';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
input: '#6b8e23', // Olive drab
|
|
5
|
-
output: '#ffc0cb', // Pink
|
|
6
|
-
path: '#008080', // Teal
|
|
7
|
-
success: '#00ff00', // Green
|
|
8
|
-
failure: '#ff0000', // Red
|
|
3
|
+
const input = {
|
|
4
|
+
input: ['#6b8e23'], // Olive drab
|
|
5
|
+
output: ['#ffc0cb'], // Pink
|
|
6
|
+
path: ['#008080'], // Teal
|
|
7
|
+
success: ['#00ff00'], // Green
|
|
8
|
+
failure: ['#ff0000'], // Red
|
|
9
9
|
param: ['#ffff00', '#daa520'], // Yellow / Goldenrod
|
|
10
|
-
type: '#00ffff', // Teal
|
|
10
|
+
type: ['#00ffff'], // Teal
|
|
11
11
|
description: ['#e5e5e5', '#808080'], // White / Gray
|
|
12
12
|
title: ['#ffffff', '#000000'], // Bright white / black
|
|
13
|
-
identifier: '#1e90ff', // Dodger blue
|
|
13
|
+
identifier: ['#1e90ff'], // Dodger blue
|
|
14
14
|
subtitle: ['#d3d3d3', '#a9a9a9'], // Light gray / Dark Gray
|
|
15
|
-
subsubtitle: '#a9a9a9' // Dark gray
|
|
16
|
-
}
|
|
15
|
+
subsubtitle: ['#a9a9a9'] // Dark gray
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
export const cliTpl: TermStyledTemplate<keyof typeof input> = StyleUtil.getTemplate(input);
|
package/src/error.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AppError, Runtime } from '@travetto/runtime';
|
|
|
2
2
|
import { PackageUtil } from '@travetto/manifest';
|
|
3
3
|
|
|
4
4
|
import { cliTpl } from './color.ts';
|
|
5
|
-
import { CliValidationError, CliCommandShape } from './types.ts';
|
|
5
|
+
import type { CliValidationError, CliCommandShape } from './types.ts';
|
|
6
6
|
|
|
7
7
|
const COMMAND_PACKAGE = [
|
|
8
8
|
[/^test(:watch)?$/, 'test', false],
|
package/src/execute.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { CliCommandRegistryIndex } from './registry/registry-index.ts';
|
|
|
5
5
|
import { CliCommandSchemaUtil } from './schema.ts';
|
|
6
6
|
import { CliUnknownCommandError, CliValidationResultError } from './error.ts';
|
|
7
7
|
import { CliParseUtil } from './parse.ts';
|
|
8
|
-
import { CliCommandShape } from './types.ts';
|
|
8
|
+
import type { CliCommandShape } from './types.ts';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Execution manager
|
package/src/help.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { castKey, getClass } from '@travetto/runtime';
|
|
|
4
4
|
import { SchemaRegistryIndex } from '@travetto/schema';
|
|
5
5
|
|
|
6
6
|
import { cliTpl } from './color.ts';
|
|
7
|
-
import { CliCommandShape } from './types.ts';
|
|
7
|
+
import type { CliCommandShape } from './types.ts';
|
|
8
8
|
import { CliCommandRegistryIndex } from './registry/registry-index.ts';
|
|
9
|
-
import { CliValidationResultError } from './error.ts';
|
|
9
|
+
import type { CliValidationResultError } from './error.ts';
|
|
10
10
|
import { CliSchemaExportUtil } from './schema-export.ts';
|
|
11
11
|
|
|
12
12
|
const validationSourceMap: Record<string, string> = {
|
package/src/module.ts
CHANGED
|
@@ -25,10 +25,10 @@ export class CliModuleUtil {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const out = new Map<string, IndexedModule>();
|
|
28
|
-
for (const
|
|
29
|
-
out.set(
|
|
28
|
+
for (const module of await CliScmUtil.findChangedModules(fromHash, toHash)) {
|
|
29
|
+
out.set(module.name, module);
|
|
30
30
|
if (transitive) {
|
|
31
|
-
for (const sub of await RuntimeIndex.getDependentModules(
|
|
31
|
+
for (const sub of await RuntimeIndex.getDependentModules(module, 'parents')) {
|
|
32
32
|
out.set(sub.name, sub);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -48,7 +48,7 @@ export class CliModuleUtil {
|
|
|
48
48
|
return (mode === 'changed' ?
|
|
49
49
|
await this.findChangedModulesRecursive(fromHash, toHash, true) :
|
|
50
50
|
[...RuntimeIndex.getModuleList(mode)].map(name => RuntimeIndex.getModule(name)!)
|
|
51
|
-
).filter(
|
|
51
|
+
).filter(module => module.sourcePath !== Runtime.workspace.path);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -59,13 +59,13 @@ export class CliModuleUtil {
|
|
|
59
59
|
const get = (name: string): ModuleGraphEntry =>
|
|
60
60
|
childMap.has(name) ? childMap.get(name)! : childMap.set(name, { children: new Set(), name, active: new Set() }).get(name)!;
|
|
61
61
|
|
|
62
|
-
for (const
|
|
63
|
-
get(
|
|
64
|
-
get(
|
|
65
|
-
for (const parentModule of
|
|
62
|
+
for (const module of modules) {
|
|
63
|
+
get(module.name).parents = [...module.parents];
|
|
64
|
+
get(module.name).children = new Set(module.children);
|
|
65
|
+
for (const parentModule of module.parents) {
|
|
66
66
|
const parent = get(parentModule);
|
|
67
|
-
parent.children.add(
|
|
68
|
-
parent.active.add(
|
|
67
|
+
parent.children.add(module.name); // Store child into parent
|
|
68
|
+
parent.active.add(module.name);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -91,13 +91,13 @@ export class CliModuleUtil {
|
|
|
91
91
|
/**
|
|
92
92
|
* Determine if module has a given dependency
|
|
93
93
|
*/
|
|
94
|
-
static async moduleHasDependency(
|
|
95
|
-
if (
|
|
94
|
+
static async moduleHasDependency(moduleName: string, dependencyModuleName: string): Promise<boolean> {
|
|
95
|
+
if (moduleName === dependencyModuleName) {
|
|
96
96
|
return true;
|
|
97
97
|
}
|
|
98
|
-
const
|
|
99
|
-
const graph = this.getDependencyGraph(
|
|
100
|
-
return graph[
|
|
98
|
+
const modules = await this.findModules('all');
|
|
99
|
+
const graph = this.getDependencyGraph(modules);
|
|
100
|
+
return graph[moduleName].includes(dependencyModuleName);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
@@ -115,8 +115,8 @@ export class CliModuleUtil {
|
|
|
115
115
|
return [];
|
|
116
116
|
}
|
|
117
117
|
} else {
|
|
118
|
-
const
|
|
119
|
-
return
|
|
118
|
+
const modules = await this.findModules(config.changed ? 'changed' : 'workspace', undefined, 'HEAD');
|
|
119
|
+
return modules.map(module => module.sourcePath);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
package/src/parse.ts
CHANGED
|
@@ -2,17 +2,17 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
import { Runtime } from '@travetto/runtime';
|
|
5
|
-
import { SchemaClassConfig, SchemaFieldConfig, SchemaInputConfig } from '@travetto/schema';
|
|
5
|
+
import type { SchemaClassConfig, SchemaFieldConfig, SchemaInputConfig } from '@travetto/schema';
|
|
6
6
|
|
|
7
|
-
import { ParsedState } from './types.ts';
|
|
7
|
+
import type { ParsedState } from './types.ts';
|
|
8
8
|
|
|
9
9
|
type ParsedInput = ParsedState['all'][number];
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const RAW_SEPARATOR = '--';
|
|
12
12
|
const VALID_FLAG = /^-{1,2}[a-z]/i;
|
|
13
13
|
const HELP_FLAG = /^-h|--help$/;
|
|
14
14
|
const LONG_FLAG_WITH_EQ = /^--[a-z][^= ]+=\S+/i;
|
|
15
|
-
const
|
|
15
|
+
const CONFIG_PREFIX = '+=';
|
|
16
16
|
const SPACE = new Set([32, 7, 13, 10]);
|
|
17
17
|
|
|
18
18
|
export const ENV_PREFIX = 'env.';
|
|
@@ -68,24 +68,24 @@ export class CliParseUtil {
|
|
|
68
68
|
* Get a user-specified module if present
|
|
69
69
|
*/
|
|
70
70
|
static getSpecifiedModule(schema: SchemaClassConfig, args: string[]): string | undefined {
|
|
71
|
-
const
|
|
71
|
+
const separatorIndex = args.includes(RAW_SEPARATOR) ? args.indexOf(RAW_SEPARATOR) : args.length;
|
|
72
72
|
const input = Object.values(schema.fields).find(config => config.specifiers?.includes('module'));
|
|
73
|
-
const
|
|
73
|
+
const envKey = input?.aliases?.filter(alias => alias.startsWith(ENV_PREFIX)).map(alias => alias.replace(ENV_PREFIX, ''))[0] ?? '';
|
|
74
74
|
const flags = new Set(input?.aliases ?? []);
|
|
75
75
|
const check = (key?: string, value?: string): string | undefined => flags.has(key!) ? value : undefined;
|
|
76
76
|
return args.reduce(
|
|
77
77
|
(name, value, i, values) =>
|
|
78
|
-
(i <
|
|
79
|
-
process.env[
|
|
78
|
+
(i < separatorIndex ? check(values[i - 1], value) ?? check(...value.split('=')) : undefined) ?? name,
|
|
79
|
+
process.env[envKey]
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Read configuration file given flag
|
|
85
85
|
*/
|
|
86
|
-
static async readFlagFile(flag: string,
|
|
87
|
-
const key = flag.replace(
|
|
88
|
-
const overrides = { '@':
|
|
86
|
+
static async readFlagFile(flag: string, module?: string): Promise<string[]> {
|
|
87
|
+
const key = flag.replace(CONFIG_PREFIX, '');
|
|
88
|
+
const overrides = { '@': module ?? Runtime.main.name };
|
|
89
89
|
|
|
90
90
|
// We have a file
|
|
91
91
|
const relativePath = (key.includes('/') ? key : `@#support/pack.${key}.flags`)
|
|
@@ -119,7 +119,7 @@ export class CliParseUtil {
|
|
|
119
119
|
offset = 2;
|
|
120
120
|
}
|
|
121
121
|
const out = argv.slice(offset);
|
|
122
|
-
const max = out.includes(
|
|
122
|
+
const max = out.includes(RAW_SEPARATOR) ? out.indexOf(RAW_SEPARATOR) : out.length;
|
|
123
123
|
const valid = out.slice(0, max);
|
|
124
124
|
const cmd = valid.length > 0 && !valid[0].startsWith('-') ? valid[0] : undefined;
|
|
125
125
|
const helpIdx = valid.findIndex(flag => HELP_FLAG.test(flag));
|
|
@@ -132,10 +132,10 @@ export class CliParseUtil {
|
|
|
132
132
|
* Expand flag arguments into full argument list
|
|
133
133
|
*/
|
|
134
134
|
static async expandArgs(schema: SchemaClassConfig, args: string[]): Promise<string[]> {
|
|
135
|
-
const
|
|
136
|
-
const
|
|
135
|
+
const separatorIndex = args.includes(RAW_SEPARATOR) ? args.indexOf(RAW_SEPARATOR) : args.length;
|
|
136
|
+
const module = this.getSpecifiedModule(schema, args);
|
|
137
137
|
return (await Promise.all(args.map((arg, i) =>
|
|
138
|
-
arg.startsWith(
|
|
138
|
+
arg.startsWith(CONFIG_PREFIX) && (i < separatorIndex || separatorIndex < 0) ? this.readFlagFile(arg, module) : arg))).flat();
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
/**
|
|
@@ -168,7 +168,7 @@ export class CliParseUtil {
|
|
|
168
168
|
for (let i = 0; i < inputs.length; i += 1) {
|
|
169
169
|
const input = inputs[i];
|
|
170
170
|
|
|
171
|
-
if (input ===
|
|
171
|
+
if (input === RAW_SEPARATOR) { // Raw separator
|
|
172
172
|
out.push(...inputs.slice(i + 1).map((arg, idx) => ({ type: 'unknown', input: arg, index: argIdx + idx }) as const));
|
|
173
173
|
break;
|
|
174
174
|
} else if (LONG_FLAG_WITH_EQ.test(input)) {
|
|
@@ -186,7 +186,7 @@ export class CliParseUtil {
|
|
|
186
186
|
} else {
|
|
187
187
|
const next = inputs[i + 1];
|
|
188
188
|
const base = { type: 'flag', fieldName: field.name, input, array: field.array } as const;
|
|
189
|
-
if ((next && (VALID_FLAG.test(next) || next ===
|
|
189
|
+
if ((next && (VALID_FLAG.test(next) || next === RAW_SEPARATOR)) || isBoolFlag(field)) {
|
|
190
190
|
if (isBoolFlag(field)) {
|
|
191
191
|
out.push({ ...base, value: !input.startsWith('--no-') });
|
|
192
192
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Class, ClassInstance, Env, Runtime, RuntimeIndex, TypedObject, castTo, describeFunction, getClass } from '@travetto/runtime';
|
|
2
|
-
import { SchemaFieldConfig, SchemaRegistryIndex, ValidationError } from '@travetto/schema';
|
|
1
|
+
import { type Class, type ClassInstance, Env, Runtime, RuntimeIndex, TypedObject, castTo, describeFunction, getClass } from '@travetto/runtime';
|
|
2
|
+
import { type SchemaFieldConfig, SchemaRegistryIndex, type ValidationError } from '@travetto/schema';
|
|
3
3
|
|
|
4
|
-
import { CliCommandShape } from '../types.ts';
|
|
4
|
+
import type { CliCommandShape } from '../types.ts';
|
|
5
5
|
import { CliCommandRegistryIndex } from './registry-index.ts';
|
|
6
6
|
import { CliModuleUtil } from '../module.ts';
|
|
7
7
|
import { CliParseUtil } from '../parse.ts';
|
|
@@ -126,8 +126,8 @@ export function CliCommand(config: CliCommandConfigOptions = {}) {
|
|
|
126
126
|
|
|
127
127
|
if (runtimeModule) { // Validate module
|
|
128
128
|
adapter.register({
|
|
129
|
-
validators: [async ({ module
|
|
130
|
-
const runModule = (runtimeModule === 'command' ? commandModule :
|
|
129
|
+
validators: [async ({ module }): Promise<ValidationError | undefined> => {
|
|
130
|
+
const runModule = (runtimeModule === 'command' ? commandModule : module) || Runtime.main.name;
|
|
131
131
|
|
|
132
132
|
// If we need to run as a specific module
|
|
133
133
|
if (runModule !== Runtime.main.name) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Class, classConstruct, describeFunction } from '@travetto/runtime';
|
|
2
|
-
import { RegistryAdapter } from '@travetto/registry';
|
|
1
|
+
import { type Class, classConstruct, describeFunction } from '@travetto/runtime';
|
|
2
|
+
import type { RegistryAdapter } from '@travetto/registry';
|
|
3
3
|
import { SchemaRegistryIndex } from '@travetto/schema';
|
|
4
4
|
|
|
5
|
-
import { CliCommandConfig, CliCommandShape } from '../types.ts';
|
|
5
|
+
import type { CliCommandConfig, CliCommandShape } from '../types.ts';
|
|
6
6
|
import { CliParseUtil, ENV_PREFIX } from '../parse.ts';
|
|
7
7
|
|
|
8
8
|
const CLI_FILE_REGEX = /\/cli[.](?<name>.{0,100}?)([.]tsx?)?$/;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Class, getClass, getParentClass, isClass, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
2
|
-
import { RegistryAdapter, RegistryIndex, RegistryIndexStore, Registry } from '@travetto/registry';
|
|
3
|
-
import { SchemaClassConfig, SchemaRegistryIndex } from '@travetto/schema';
|
|
1
|
+
import { type Class, getClass, getParentClass, isClass, Runtime, RuntimeIndex } from '@travetto/runtime';
|
|
2
|
+
import { type RegistryAdapter, type RegistryIndex, RegistryIndexStore, Registry } from '@travetto/registry';
|
|
3
|
+
import { type SchemaClassConfig, SchemaRegistryIndex } from '@travetto/schema';
|
|
4
4
|
|
|
5
|
-
import { CliCommandConfig, CliCommandShape } from '../types.ts';
|
|
5
|
+
import type { CliCommandConfig, CliCommandShape } from '../types.ts';
|
|
6
6
|
import { CliUnknownCommandError } from '../error.ts';
|
|
7
7
|
import { CliCommandRegistryAdapter } from './registry-adapter.ts';
|
|
8
8
|
|
|
@@ -41,7 +41,7 @@ export class CliCommandRegistryIndex implements RegistryIndex {
|
|
|
41
41
|
if (!this.#fileMapping) {
|
|
42
42
|
const all = new Map<string, string>();
|
|
43
43
|
for (const entry of RuntimeIndex.find({
|
|
44
|
-
module:
|
|
44
|
+
module: module => !Runtime.production || module.prod,
|
|
45
45
|
folder: folder => folder === 'support',
|
|
46
46
|
file: file => file.role === 'std' && CLI_FILE_REGEX.test(file.sourceFile)
|
|
47
47
|
})) {
|
package/src/schema-export.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Class, describeFunction } from '@travetto/runtime';
|
|
2
|
-
import { SchemaInputConfig, SchemaRegistryIndex } from '@travetto/schema';
|
|
1
|
+
import { type Class, describeFunction } from '@travetto/runtime';
|
|
2
|
+
import { type SchemaInputConfig, SchemaRegistryIndex } from '@travetto/schema';
|
|
3
3
|
|
|
4
4
|
import { CliCommandRegistryIndex } from '../src/registry/registry-index.ts';
|
|
5
5
|
|
package/src/schema.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { castKey, castTo, getClass } from '@travetto/runtime';
|
|
2
2
|
import { BindUtil, SchemaRegistryIndex, SchemaValidator, ValidationResultError } from '@travetto/schema';
|
|
3
3
|
|
|
4
|
-
import { ParsedState, CliCommandShape, CliValidationError } from './types.ts';
|
|
4
|
+
import type { ParsedState, CliCommandShape, CliValidationError } from './types.ts';
|
|
5
5
|
import { CliValidationResultError } from './error.ts';
|
|
6
6
|
|
|
7
7
|
const getSource = (source: string | undefined, def: CliValidationError['source']): CliValidationError['source'] => {
|
package/src/scm.ts
CHANGED
|
@@ -71,13 +71,13 @@ export class CliScmUtil {
|
|
|
71
71
|
*/
|
|
72
72
|
static async findChangedModules(fromHash: string, toHash?: string): Promise<IndexedModule[]> {
|
|
73
73
|
const files = await this.findChangedFiles(fromHash, toHash);
|
|
74
|
-
const
|
|
74
|
+
const modules = files
|
|
75
75
|
.map(file => RuntimeIndex.getFromSource(file))
|
|
76
76
|
.filter(file => !!file)
|
|
77
77
|
.map(file => RuntimeIndex.getModule(file.module))
|
|
78
|
-
.filter(
|
|
78
|
+
.filter(module => !!module);
|
|
79
79
|
|
|
80
|
-
return [...new Set(
|
|
80
|
+
return [...new Set(modules)]
|
|
81
81
|
.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
82
82
|
}
|
|
83
83
|
|
package/src/types.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { spawn, type ChildProcess } from 'node:child_process';
|
|
|
2
2
|
|
|
3
3
|
import { Env, ExecUtil, Runtime, ShutdownManager, Util, WatchUtil } from '@travetto/runtime';
|
|
4
4
|
|
|
5
|
-
import { CliCommandShape, CliCommandShapeFields } from './types.ts';
|
|
5
|
+
import type { CliCommandShape, CliCommandShapeFields } from './types.ts';
|
|
6
6
|
|
|
7
7
|
const IPC_ALLOWED_ENV = new Set(['NODE_OPTIONS']);
|
|
8
8
|
const IPC_INVALID_ENV = new Set(['PS1', 'INIT_CWD', 'COLOR', 'LANGUAGE', 'PROFILEHOME', '_']);
|
|
@@ -2,7 +2,7 @@ import { Env } from '@travetto/runtime';
|
|
|
2
2
|
import { IsPrivate } from '@travetto/schema';
|
|
3
3
|
|
|
4
4
|
import { CliCommand } from '../src/registry/decorator.ts';
|
|
5
|
-
import { CliCommandShape, CliValidationError } from '../src/types.ts';
|
|
5
|
+
import type { CliCommandShape, CliValidationError } from '../src/types.ts';
|
|
6
6
|
import { CliCommandRegistryIndex } from '../src/registry/registry-index.ts';
|
|
7
7
|
import { CliUtil } from '../src/util.ts';
|
|
8
8
|
import { CliSchemaExportUtil } from '../src/schema-export.ts';
|
package/support/cli.main.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Runtime } from '@travetto/runtime';
|
|
2
|
-
import { CliCommandShape, CliCommand, CliValidationError, ParsedState } from '@travetto/cli';
|
|
2
|
+
import { type CliCommandShape, CliCommand, type CliValidationError, type ParsedState } from '@travetto/cli';
|
|
3
3
|
import { Ignore, IsPrivate } from '@travetto/schema';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -23,8 +23,8 @@ export class MainCommand implements CliCommandShape {
|
|
|
23
23
|
async main(fileOrImport: string, args: string[] = []): Promise<void> {
|
|
24
24
|
let result: unknown;
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
result = await
|
|
26
|
+
const module = await Runtime.importFrom<{ main(..._: unknown[]): Promise<unknown> }>(fileOrImport);
|
|
27
|
+
result = await module.main(...args, ...this._parsed.unknown);
|
|
28
28
|
} catch (error) {
|
|
29
29
|
result = error;
|
|
30
30
|
process.exitCode = Math.max(process.exitCode ? +process.exitCode : 1, 1);
|
package/support/cli.service.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CliCommandShape, CliCommand, cliTpl, CliValidationError } from '@travetto/cli';
|
|
1
|
+
import { type CliCommandShape, CliCommand, cliTpl, type CliValidationError } from '@travetto/cli';
|
|
2
2
|
import { Terminal } from '@travetto/terminal';
|
|
3
3
|
import { AsyncQueue, Runtime, RuntimeIndex, Util } from '@travetto/runtime';
|
|
4
4
|
|
|
5
|
-
import { ServiceRunner, ServiceDescriptor, ServiceAction } from '../src/service.ts';
|
|
5
|
+
import { ServiceRunner, type ServiceDescriptor, type ServiceAction } from '../src/service.ts';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Allows for running services
|
|
@@ -13,7 +13,7 @@ export class CliServiceCommand implements CliCommandShape {
|
|
|
13
13
|
async #getServices(services: string[]): Promise<ServiceDescriptor[]> {
|
|
14
14
|
return (await Promise.all(
|
|
15
15
|
RuntimeIndex.find({
|
|
16
|
-
module:
|
|
16
|
+
module: module => module.roles.includes('std'),
|
|
17
17
|
folder: folder => folder === 'support',
|
|
18
18
|
file: file => /support\/service[.]/.test(file.sourceFile)
|
|
19
19
|
})
|