@travetto/cli 4.1.1 → 5.0.0-rc.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/LICENSE +1 -1
- package/README.md +1 -1
- package/package.json +3 -3
- package/src/help.ts +1 -1
- package/src/module.ts +2 -2
- package/src/parse.ts +3 -2
- package/src/scm.ts +10 -5
- package/src/util.ts +1 -1
- package/support/cli.main.ts +3 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -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/base/src/env.ts#
|
|
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/base/src/env.ts#L116) `name` defined in the [Base](https://github.com/travetto/travetto/tree/main/module/base#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": "
|
|
3
|
+
"version": "5.0.0-rc.0",
|
|
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": "^
|
|
33
|
-
"@travetto/terminal": "^
|
|
32
|
+
"@travetto/schema": "^5.0.0-rc.0",
|
|
33
|
+
"@travetto/terminal": "^5.0.0-rc.0"
|
|
34
34
|
},
|
|
35
35
|
"travetto": {
|
|
36
36
|
"displayName": "Command Line Interface",
|
package/src/help.ts
CHANGED
package/src/module.ts
CHANGED
|
@@ -43,9 +43,9 @@ export class CliModuleUtil {
|
|
|
43
43
|
* @param transitive
|
|
44
44
|
* @returns
|
|
45
45
|
*/
|
|
46
|
-
static async findModules(mode: 'all' | 'changed', fromHash?: string, toHash?: string): Promise<IndexedModule[]> {
|
|
46
|
+
static async findModules(mode: 'all' | 'changed', fromHash?: string, toHash?: string, emptyOnFail = false): Promise<IndexedModule[]> {
|
|
47
47
|
return (mode === 'changed' ?
|
|
48
|
-
await this.findChangedModulesRecursive(fromHash, toHash) :
|
|
48
|
+
await this.findChangedModulesRecursive(fromHash, toHash, emptyOnFail) :
|
|
49
49
|
[...RuntimeIndex.getModuleList('all')].map(x => RuntimeIndex.getModule(x)!)
|
|
50
50
|
).filter(x => x.sourcePath !== RuntimeContext.workspace.path);
|
|
51
51
|
}
|
package/src/parse.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
|
|
3
|
-
import { RuntimeIndex, RuntimeContext
|
|
4
|
+
import { RuntimeIndex, RuntimeContext } from '@travetto/manifest';
|
|
4
5
|
import { CliCommandInput, CliCommandSchema, ParsedState } from './types';
|
|
5
6
|
|
|
6
7
|
type ParsedInput = ParsedState['all'][number];
|
|
@@ -210,7 +211,7 @@ export class CliParseUtil {
|
|
|
210
211
|
inputs,
|
|
211
212
|
all: out,
|
|
212
213
|
unknown: out.filter(x => x.type === 'unknown').map(x => x.input),
|
|
213
|
-
flags: out.filter(
|
|
214
|
+
flags: out.filter(x => x.type === 'flag')
|
|
214
215
|
};
|
|
215
216
|
}
|
|
216
217
|
}
|
package/src/scm.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
3
4
|
|
|
4
5
|
import { ExecUtil } from '@travetto/base';
|
|
5
|
-
import {
|
|
6
|
+
import { IndexedModule, RuntimeIndex, RuntimeContext } from '@travetto/manifest';
|
|
6
7
|
|
|
7
8
|
export class CliScmUtil {
|
|
8
9
|
/**
|
|
@@ -45,9 +46,13 @@ export class CliScmUtil {
|
|
|
45
46
|
* @param fromHash
|
|
46
47
|
* @returns
|
|
47
48
|
*/
|
|
48
|
-
static async findChangedFiles(fromHash: string, toHash: string = 'HEAD'): Promise<string[]> {
|
|
49
|
+
static async findChangedFiles(fromHash: string, toHash: string = 'HEAD', emptyOnFail = false): Promise<string[]> {
|
|
49
50
|
const ws = RuntimeContext.workspace.path;
|
|
50
|
-
const res = await ExecUtil.getResult(spawn('git', ['diff', '--name-only', `${fromHash}..${toHash}`, ':!**/DOC.*', ':!**/README.*'], { cwd: ws }));
|
|
51
|
+
const res = await ExecUtil.getResult(spawn('git', ['diff', '--name-only', `${fromHash}..${toHash}`, ':!**/DOC.*', ':!**/README.*'], { cwd: ws }), { catch: true });
|
|
52
|
+
if (!res.valid && emptyOnFail) {
|
|
53
|
+
console.warn('Unable to detect changes between', fromHash, toHash, 'with', (res.stderr || res.stdout));
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
51
56
|
const out = new Set<string>();
|
|
52
57
|
for (const line of res.stdout.split(/\n/g)) {
|
|
53
58
|
const entry = RuntimeIndex.getEntry(path.resolve(ws, line));
|
|
@@ -68,9 +73,9 @@ export class CliScmUtil {
|
|
|
68
73
|
const files = await this.findChangedFiles(fromHash, toHash);
|
|
69
74
|
const mods = files
|
|
70
75
|
.map(x => RuntimeIndex.getFromSource(x))
|
|
71
|
-
.filter(
|
|
76
|
+
.filter(x => !!x)
|
|
72
77
|
.map(x => RuntimeIndex.getModule(x.module))
|
|
73
|
-
.filter(
|
|
78
|
+
.filter(x => !!x);
|
|
74
79
|
|
|
75
80
|
return [...new Set(mods)]
|
|
76
81
|
.sort((a, b) => a.name.localeCompare(b.name));
|
package/src/util.ts
CHANGED
|
@@ -30,7 +30,7 @@ export class CliUtil {
|
|
|
30
30
|
*/
|
|
31
31
|
static runWithRestart<T extends CliCommandShapeFields & CliCommandShape>(cmd: T, ipc?: boolean): Promise<unknown> | undefined {
|
|
32
32
|
if (ipc && process.connected) {
|
|
33
|
-
|
|
33
|
+
process.once('disconnect', () => process.exit());
|
|
34
34
|
}
|
|
35
35
|
if (Env.TRV_CAN_RESTART.isFalse || !(cmd.canRestart ?? !Env.production)) {
|
|
36
36
|
Env.TRV_CAN_RESTART.clear();
|
package/support/cli.main.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
|
|
3
4
|
import { CliCommandShape, CliCommand, CliValidationError, ParsedState } from '@travetto/cli';
|
|
4
|
-
import {
|
|
5
|
+
import { RuntimeIndex, RuntimeContext } from '@travetto/manifest';
|
|
5
6
|
import { Ignore } from '@travetto/schema';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -38,7 +39,7 @@ export class MainCommand implements CliCommandShape {
|
|
|
38
39
|
res = await mod.main(...args, ...this._parsed.unknown);
|
|
39
40
|
} catch (err) {
|
|
40
41
|
res = err;
|
|
41
|
-
process.exitCode = Math.max(process.exitCode
|
|
42
|
+
process.exitCode = Math.max(process.exitCode ? +process.exitCode : 1, 1);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
if (res !== undefined) {
|