@travetto/compiler 8.0.0-alpha.9 → 8.0.1
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/__index__.ts +4 -4
- package/bin/hook.js +10 -4
- package/bin/trvc-target.js +2 -1
- package/bin/trvc.js +2 -1
- package/package.json +18 -18
- package/src/common.ts +15 -9
- package/src/compiler.ts +26 -29
- package/src/event.ts +8 -6
- package/src/log.ts +57 -22
- package/src/queue.ts +4 -2
- package/src/server/client.ts +38 -24
- package/src/server/manager.ts +16 -11
- package/src/server/process-handle.ts +14 -10
- package/src/server/server.ts +50 -26
- package/src/state.ts +85 -52
- package/src/ts-proxy.ts +5 -3
- package/src/types.ts +22 -15
- package/src/util.ts +2 -4
- package/src/watch.ts +80 -68
- package/support/invoke.ts +37 -22
- package/tsconfig.trv.json +4 -18
package/support/invoke.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
// @trv-no-transform
|
|
2
2
|
import { getManifestContext, ManifestUtil } from '@travetto/manifest';
|
|
3
3
|
|
|
4
|
-
import { Log } from '../src/log.ts';
|
|
5
|
-
import { CompilerManager } from '../src/server/manager.ts';
|
|
6
|
-
import { CompilerClient } from '../src/server/client.ts';
|
|
7
4
|
import { CommonUtil } from '../src/common.ts';
|
|
8
5
|
import { EventUtil } from '../src/event.ts';
|
|
6
|
+
import { Log } from '../src/log.ts';
|
|
7
|
+
import { CompilerClient } from '../src/server/client.ts';
|
|
8
|
+
import { CompilerManager } from '../src/server/manager.ts';
|
|
9
9
|
|
|
10
10
|
const hasColor = (process.stdout.isTTY && /^(0)*$/.test(process.env.NO_COLOR ?? '')) || /1\d*/.test(process.env.FORCE_COLOR ?? '');
|
|
11
|
-
const color =
|
|
12
|
-
|
|
11
|
+
const color =
|
|
12
|
+
(code: number) =>
|
|
13
|
+
(value: string): string =>
|
|
14
|
+
hasColor ? `\x1b[${code}m${value}\x1b[0m` : `${value}`;
|
|
15
|
+
const STYLE = { error: color(91), title: color(36), main: color(92), command: color(35), arg: color(37), description: color(33) };
|
|
13
16
|
|
|
14
17
|
const COMMANDS = {
|
|
15
18
|
start: { description: 'Run the compiler in watch mode' },
|
|
@@ -31,17 +34,26 @@ function showHelp(errorMessage?: string): void {
|
|
|
31
34
|
|
|
32
35
|
const commandWidth = Math.max(...PREPARED.map(config => config.commandLength));
|
|
33
36
|
|
|
34
|
-
console.log(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
'
|
|
40
|
-
' '
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
console.log(
|
|
38
|
+
[
|
|
39
|
+
...(errorMessage ? ['', STYLE.error(errorMessage)] : []),
|
|
40
|
+
'',
|
|
41
|
+
`${STYLE.main('trvc')} ${STYLE.command('[command]')}`,
|
|
42
|
+
'',
|
|
43
|
+
STYLE.title('Available Commands'),
|
|
44
|
+
...PREPARED.map(({ name, args, description, commandLength }) =>
|
|
45
|
+
[
|
|
46
|
+
'*',
|
|
47
|
+
STYLE.command(name),
|
|
48
|
+
...args.map(arg => STYLE.arg(arg)),
|
|
49
|
+
' '.repeat(commandWidth - commandLength),
|
|
50
|
+
'-',
|
|
51
|
+
STYLE.description(description)
|
|
52
|
+
].join(' ')
|
|
53
|
+
),
|
|
54
|
+
''
|
|
55
|
+
].join('\n')
|
|
56
|
+
);
|
|
45
57
|
}
|
|
46
58
|
|
|
47
59
|
const validateInputs = (value: string[]): value is [keyof typeof COMMANDS, ...string[]] => !!value.length && value[0] in COMMANDS;
|
|
@@ -51,7 +63,7 @@ const validateInputs = (value: string[]): value is [keyof typeof COMMANDS, ...st
|
|
|
51
63
|
*/
|
|
52
64
|
export async function invoke(...input: string[]): Promise<unknown> {
|
|
53
65
|
if (!validateInputs(input)) {
|
|
54
|
-
return showHelp(input[0] ? `Unknown trvc command: ${input[0]}` : undefined)
|
|
66
|
+
return showHelp(input[0] ? `Unknown trvc command: ${input[0]}` : undefined);
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
const [command, ...args] = input;
|
|
@@ -62,15 +74,18 @@ export async function invoke(...input: string[]): Promise<unknown> {
|
|
|
62
74
|
Log.root = ctx.workspace.path;
|
|
63
75
|
|
|
64
76
|
switch (command) {
|
|
65
|
-
case 'start':
|
|
66
|
-
|
|
67
|
-
case '
|
|
77
|
+
case 'start':
|
|
78
|
+
return CompilerManager.compile(ctx, client, { watch: true });
|
|
79
|
+
case 'build':
|
|
80
|
+
return CompilerManager.compile(ctx, client, { watch: false });
|
|
81
|
+
case 'restart':
|
|
82
|
+
return CompilerManager.compile(ctx, client, { watch: true, forceRestart: true });
|
|
68
83
|
case 'info': {
|
|
69
84
|
const info = await client.info();
|
|
70
85
|
return CommonUtil.writeStdout(2, info);
|
|
71
86
|
}
|
|
72
87
|
case 'event': {
|
|
73
|
-
if (!EventUtil.
|
|
88
|
+
if (!EventUtil.isCompilerEventType(args[0])) {
|
|
74
89
|
throw new Error(`Unknown event type: ${args[0]}`);
|
|
75
90
|
}
|
|
76
91
|
for await (const event of client.fetchEvents(args[0])) {
|
|
@@ -115,4 +130,4 @@ export async function invoke(...input: string[]): Promise<unknown> {
|
|
|
115
130
|
return import(importTarget);
|
|
116
131
|
}
|
|
117
132
|
}
|
|
118
|
-
}
|
|
133
|
+
}
|
package/tsconfig.trv.json
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"module": "esnext",
|
|
4
|
-
"target": "esnext",
|
|
5
3
|
"moduleResolution": "bundler",
|
|
6
4
|
"allowImportingTsExtensions": true,
|
|
7
|
-
"lib": [
|
|
8
|
-
|
|
9
|
-
],
|
|
10
|
-
"types": [
|
|
11
|
-
"node"
|
|
12
|
-
],
|
|
5
|
+
"lib": ["ESNext"],
|
|
6
|
+
"types": ["node"],
|
|
13
7
|
"jsx": "react-jsx",
|
|
14
|
-
"stableTypeOrdering": true,
|
|
15
|
-
"strict": true,
|
|
16
8
|
"declaration": true,
|
|
17
9
|
"declarationMap": true,
|
|
18
10
|
"emitDeclarationOnly": false,
|
|
19
|
-
"noUncheckedSideEffectImports": true,
|
|
20
|
-
"libReplacement": false,
|
|
21
11
|
"strictPropertyInitialization": false,
|
|
22
12
|
"erasableSyntaxOnly": true,
|
|
23
13
|
"experimentalDecorators": true,
|
|
@@ -34,10 +24,6 @@
|
|
|
34
24
|
"noEmit": true
|
|
35
25
|
},
|
|
36
26
|
"watchOptions": {
|
|
37
|
-
"excludeDirectories": [
|
|
38
|
-
"**/node_modules",
|
|
39
|
-
"**/.trv",
|
|
40
|
-
"**/.git",
|
|
41
|
-
]
|
|
27
|
+
"excludeDirectories": ["**/node_modules", "**/.trv", "**/.git"]
|
|
42
28
|
}
|
|
43
|
-
}
|
|
29
|
+
}
|