@travetto/cli 3.4.0-rc.3 → 3.4.0-rc.5
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/util.ts +30 -12
- package/support/transformer.cli.ts +2 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/cli",
|
|
3
|
-
"version": "3.4.0-rc.
|
|
3
|
+
"version": "3.4.0-rc.5",
|
|
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.0-rc.
|
|
32
|
+
"@travetto/schema": "^3.4.0-rc.4",
|
|
33
33
|
"@travetto/terminal": "^3.4.0-rc.0"
|
|
34
34
|
},
|
|
35
35
|
"travetto": {
|
package/src/util.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { Env, ExecUtil } from '@travetto/base';
|
|
4
|
-
import { path, RootIndex } from '@travetto/manifest';
|
|
1
|
+
import { CompilerClient, Env, ExecUtil } from '@travetto/base';
|
|
2
|
+
import { RootIndex } from '@travetto/manifest';
|
|
5
3
|
|
|
6
4
|
import { CliCommandShape } from './types';
|
|
7
5
|
import { CliCommandRegistry } from './registry';
|
|
@@ -40,23 +38,43 @@ export class CliUtil {
|
|
|
40
38
|
* Dispatch IPC payload
|
|
41
39
|
*/
|
|
42
40
|
static async triggerIpc<T extends CliCommandShape>(action: 'run', cmd: T): Promise<boolean> {
|
|
43
|
-
|
|
41
|
+
if (!process.env.TRV_CLI_IPC) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const client = new CompilerClient({});
|
|
46
|
+
|
|
47
|
+
const info = await client.getInfo(true);
|
|
44
48
|
|
|
45
|
-
if (!
|
|
49
|
+
if (!info) { // Server not running
|
|
46
50
|
return false;
|
|
47
51
|
}
|
|
48
52
|
|
|
53
|
+
const defaultEnvKeys = new Set(Object.keys(info.env ?? {}));
|
|
54
|
+
defaultEnvKeys.add('PS1').add('INIT_CWD').add('COLOR').add('LANGUAGE').add('PROFILEHOME').add('_');
|
|
55
|
+
|
|
56
|
+
const env = Object.fromEntries(
|
|
57
|
+
Object.entries(process.env).filter(([k]) =>
|
|
58
|
+
!defaultEnvKeys.has(k) && !/^(npm_|GTK|GDK|TRV|NODE|GIT|TERM_)/.test(k) && !/VSCODE/.test(k)
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
|
|
49
62
|
const cfg = CliCommandRegistry.getConfig(cmd);
|
|
50
|
-
const
|
|
51
|
-
type: `@travetto/cli:${action}`,
|
|
63
|
+
const req = {
|
|
64
|
+
type: `@travetto/cli:${action}`,
|
|
65
|
+
ipc: process.env.TRV_CLI_IPC,
|
|
66
|
+
data: {
|
|
52
67
|
name: cfg.name,
|
|
53
68
|
commandModule: cfg.module,
|
|
54
69
|
module: RootIndex.manifest.mainModule,
|
|
55
|
-
args: process.argv.slice(3)
|
|
70
|
+
args: process.argv.slice(3),
|
|
71
|
+
env
|
|
56
72
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
console.log('Triggering IPC request', req);
|
|
76
|
+
|
|
77
|
+
await client.sendEvent('custom', req);
|
|
60
78
|
return true;
|
|
61
79
|
}
|
|
62
80
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
|
|
3
|
-
import { TransformerState, DecoratorMeta,
|
|
3
|
+
import { TransformerState, DecoratorMeta, AfterClass } from '@travetto/transformer';
|
|
4
4
|
import { SchemaTransformUtil } from '@travetto/schema/support/transform-util';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -29,22 +29,6 @@ export class CliCommandTransformer {
|
|
|
29
29
|
return node;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const declArgs = [...dec.expression.arguments];
|
|
33
|
-
|
|
34
|
-
// Name only, need a config object
|
|
35
|
-
if (declArgs.length === 0) {
|
|
36
|
-
declArgs.push(state.fromLiteral({}));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Compute new declaration
|
|
40
|
-
const newDec = state.factory.createDecorator(
|
|
41
|
-
state.factory.createCallExpression(
|
|
42
|
-
dec.expression.expression,
|
|
43
|
-
dec.expression.typeArguments,
|
|
44
|
-
[...declArgs]
|
|
45
|
-
)
|
|
46
|
-
);
|
|
47
|
-
|
|
48
32
|
const members = node.members.map(x => ts.isMethodDeclaration(x) && x === runMethod ?
|
|
49
33
|
state.factory.updateMethodDeclaration(
|
|
50
34
|
x,
|
|
@@ -59,7 +43,7 @@ export class CliCommandTransformer {
|
|
|
59
43
|
) : x);
|
|
60
44
|
|
|
61
45
|
return state.factory.updateClassDeclaration(node,
|
|
62
|
-
|
|
46
|
+
node.modifiers,
|
|
63
47
|
node.name,
|
|
64
48
|
node.typeParameters,
|
|
65
49
|
node.heritageClauses,
|