@travetto/cli 3.4.1 → 3.4.3
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/package.json +2 -2
- package/src/module.ts +8 -7
- package/src/schema.ts +18 -8
- package/src/scm.ts +9 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/cli",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3",
|
|
4
4
|
"description": "CLI infrastructure for Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"directory": "module/cli"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@travetto/schema": "^3.4.
|
|
32
|
+
"@travetto/schema": "^3.4.1",
|
|
33
33
|
"@travetto/terminal": "^3.4.0"
|
|
34
34
|
},
|
|
35
35
|
"travetto": {
|
package/src/module.ts
CHANGED
|
@@ -11,19 +11,20 @@ export class CliModuleUtil {
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Find modules that changed, and the dependent modules
|
|
14
|
-
* @param
|
|
14
|
+
* @param fromHash
|
|
15
|
+
* @param toHash
|
|
15
16
|
* @param transitive
|
|
16
17
|
* @returns
|
|
17
18
|
*/
|
|
18
|
-
static async findChangedModulesRecursive(
|
|
19
|
-
|
|
19
|
+
static async findChangedModulesRecursive(fromHash?: string, toHash?: string, transitive = true): Promise<IndexedModule[]> {
|
|
20
|
+
fromHash ??= await CliScmUtil.findLastRelease();
|
|
20
21
|
|
|
21
|
-
if (!
|
|
22
|
+
if (!fromHash) {
|
|
22
23
|
return RootIndex.getLocalModules();
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const out = new Map<string, IndexedModule>();
|
|
26
|
-
for (const mod of await CliScmUtil.
|
|
27
|
+
for (const mod of await CliScmUtil.findChangedModules(fromHash, toHash)) {
|
|
27
28
|
out.set(mod.name, mod);
|
|
28
29
|
if (transitive) {
|
|
29
30
|
for (const sub of await RootIndex.getDependentModules(mod)) {
|
|
@@ -42,9 +43,9 @@ export class CliModuleUtil {
|
|
|
42
43
|
* @param transitive
|
|
43
44
|
* @returns
|
|
44
45
|
*/
|
|
45
|
-
static async findModules(mode: 'all' | 'changed',
|
|
46
|
+
static async findModules(mode: 'all' | 'changed', fromHash?: string, toHash?: string): Promise<IndexedModule[]> {
|
|
46
47
|
return (mode === 'changed' ?
|
|
47
|
-
await this.findChangedModulesRecursive(
|
|
48
|
+
await this.findChangedModulesRecursive(fromHash, toHash) :
|
|
48
49
|
[...RootIndex.getModuleList('all')].map(x => RootIndex.getModule(x)!)
|
|
49
50
|
).filter(x => x.sourcePath !== RootIndex.manifest.workspacePath);
|
|
50
51
|
}
|
package/src/schema.ts
CHANGED
|
@@ -12,17 +12,17 @@ const SHORT_FLAG = /^-[a-z]/i;
|
|
|
12
12
|
|
|
13
13
|
type ParsedInput =
|
|
14
14
|
{ type: 'unknown', input: string } |
|
|
15
|
-
{ type: 'arg', input: string, array?: boolean } |
|
|
15
|
+
{ type: 'arg', input: string, array?: boolean, index: number } |
|
|
16
16
|
{ type: 'flag', input: string, array?: boolean, fieldName: string, value?: unknown };
|
|
17
17
|
|
|
18
18
|
const isBoolFlag = (x?: CliCommandInput): boolean => x?.type === 'boolean' && !x.array;
|
|
19
19
|
|
|
20
|
-
const getInput = (cfg: { field?: CliCommandInput, rawText?: string, input: string, value?: string }): ParsedInput => {
|
|
21
|
-
const { field, input, rawText = input, value } = cfg;
|
|
20
|
+
const getInput = (cfg: { field?: CliCommandInput, rawText?: string, input: string, index?: number, value?: string }): ParsedInput => {
|
|
21
|
+
const { field, input, rawText = input, value, index } = cfg;
|
|
22
22
|
if (!field) {
|
|
23
23
|
return { type: 'unknown', input: rawText };
|
|
24
24
|
} else if (!field.flagNames?.length) {
|
|
25
|
-
return { type: 'arg', input: field ? input : rawText ?? input, array: field.array };
|
|
25
|
+
return { type: 'arg', input: field ? input : rawText ?? input, array: field.array, index: index! };
|
|
26
26
|
} else {
|
|
27
27
|
return {
|
|
28
28
|
type: 'flag',
|
|
@@ -183,7 +183,7 @@ export class CliCommandSchemaUtil {
|
|
|
183
183
|
}
|
|
184
184
|
} else {
|
|
185
185
|
const field = schema.args[argIdx];
|
|
186
|
-
out.push(getInput({ field, input }));
|
|
186
|
+
out.push(getInput({ field, input, index: argIdx }));
|
|
187
187
|
// Move argIdx along if not in a vararg situation
|
|
188
188
|
if (!field?.array) {
|
|
189
189
|
argIdx += 1;
|
|
@@ -225,11 +225,21 @@ export class CliCommandSchemaUtil {
|
|
|
225
225
|
/**
|
|
226
226
|
* Produce the arguments into the final argument set
|
|
227
227
|
*/
|
|
228
|
-
static async bindArgs(cmd: CliCommandShape,
|
|
228
|
+
static async bindArgs(cmd: CliCommandShape, inputs: ParsedInput[]): Promise<unknown[]> {
|
|
229
229
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
230
230
|
const cls = cmd.constructor as Class<CliCommandShape>;
|
|
231
|
-
const
|
|
232
|
-
|
|
231
|
+
const bound: unknown[] = [];
|
|
232
|
+
for (const input of inputs) {
|
|
233
|
+
if (input.type === 'arg') {
|
|
234
|
+
if (input.array) {
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
236
|
+
((bound[input.index] ??= []) as unknown[]).push(input.input);
|
|
237
|
+
} else {
|
|
238
|
+
bound[input.index] = input.input;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return BindUtil.coerceMethodParams(cls, 'main', bound, true);
|
|
233
243
|
}
|
|
234
244
|
|
|
235
245
|
/**
|
package/src/scm.ts
CHANGED
|
@@ -41,13 +41,13 @@ export class CliScmUtil {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Find all source files that changed
|
|
45
|
-
* @param
|
|
44
|
+
* Find all source files that changed between from and to hashes
|
|
45
|
+
* @param fromHash
|
|
46
46
|
* @returns
|
|
47
47
|
*/
|
|
48
|
-
static async
|
|
48
|
+
static async findChangedFiles(fromHash: string, toHash: string = 'HEAD'): Promise<string[]> {
|
|
49
49
|
const ws = RootIndex.manifest.workspacePath;
|
|
50
|
-
const res = await ExecUtil.spawn('git', ['diff', '--name-only',
|
|
50
|
+
const res = await ExecUtil.spawn('git', ['diff', '--name-only', `${fromHash}..${toHash}`, ':!**/DOC.*', ':!**/README.*'], { cwd: ws }).result;
|
|
51
51
|
const out = new Set<string>();
|
|
52
52
|
for (const line of res.stdout.split(/\n/g)) {
|
|
53
53
|
const entry = RootIndex.getEntry(path.resolve(ws, line));
|
|
@@ -59,12 +59,13 @@ export class CliScmUtil {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* Find all modules that changed
|
|
63
|
-
* @param
|
|
62
|
+
* Find all modules that changed between from and to hashes
|
|
63
|
+
* @param fromHash
|
|
64
|
+
* @param toHash
|
|
64
65
|
* @returns
|
|
65
66
|
*/
|
|
66
|
-
static async
|
|
67
|
-
const files = await this.
|
|
67
|
+
static async findChangedModules(fromHash: string, toHash?: string): Promise<IndexedModule[]> {
|
|
68
|
+
const files = await this.findChangedFiles(fromHash, toHash);
|
|
68
69
|
const mods = files
|
|
69
70
|
.map(x => RootIndex.getFromSource(x))
|
|
70
71
|
.filter((x): x is IndexedFile => !!x)
|