@travetto/cli 7.0.0-rc.1 → 7.0.0-rc.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/README.md +5 -5
- package/bin/trv.js +3 -1
- package/package.json +3 -3
- package/src/error.ts +3 -3
- package/src/execute.ts +11 -11
- package/src/help.ts +21 -21
- package/src/module.ts +21 -21
- package/src/parse.ts +35 -35
- package/src/registry/decorator.ts +17 -18
- package/src/registry/registry-adapter.ts +11 -11
- package/src/registry/registry-index.ts +25 -28
- package/src/schema-export.ts +20 -20
- package/src/schema.ts +9 -9
- package/src/scm.ts +10 -10
- package/src/service.ts +42 -42
- package/src/types.ts +2 -2
- package/src/util.ts +88 -23
- package/support/cli.cli_schema.ts +2 -2
- package/support/cli.main.ts +2 -2
- package/support/cli.service.ts +18 -18
package/support/cli.service.ts
CHANGED
|
@@ -13,14 +13,14 @@ 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:
|
|
17
|
-
folder:
|
|
18
|
-
file:
|
|
16
|
+
module: mod => mod.roles.includes('std'),
|
|
17
|
+
folder: folder => folder === 'support',
|
|
18
|
+
file: file => /support\/service[.]/.test(file.sourceFile)
|
|
19
19
|
})
|
|
20
|
-
.map(
|
|
20
|
+
.map(file => Runtime.importFrom<{ service: ServiceDescriptor }>(file.import).then(value => value.service))
|
|
21
21
|
))
|
|
22
|
-
.filter(
|
|
23
|
-
.filter(
|
|
22
|
+
.filter(file => !!file)
|
|
23
|
+
.filter(file => services?.length ? services.includes(file.name) : true)
|
|
24
24
|
.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -37,29 +37,29 @@ export class CliServiceCommand implements CliCommandShape {
|
|
|
37
37
|
return [
|
|
38
38
|
cliTpl`${{ title: 'Available Services' }}`,
|
|
39
39
|
'-'.repeat(20),
|
|
40
|
-
...all.map(
|
|
40
|
+
...all.map(service => cliTpl` * ${{ identifier: service.name }}@${{ type: service.version }}`)
|
|
41
41
|
];
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async main(action: ServiceAction, services: string[] = []): Promise<void> {
|
|
45
45
|
const all = await this.#getServices(services);
|
|
46
|
-
const maxName = Math.max(...all.map(
|
|
47
|
-
const maxVersion = Math.max(...all.map(
|
|
46
|
+
const maxName = Math.max(...all.map(service => service.name.length), 'Service'.length) + 3;
|
|
47
|
+
const maxVersion = Math.max(...all.map(service => `${service.version}`.length), 'Version'.length) + 3;
|
|
48
48
|
const maxStatus = 20;
|
|
49
|
-
const
|
|
49
|
+
const queue = new AsyncQueue<{ idx: number, text: string, done?: boolean }>();
|
|
50
50
|
|
|
51
|
-
const jobs = all.map(async (
|
|
52
|
-
const identifier =
|
|
53
|
-
const type = `${
|
|
51
|
+
const jobs = all.map(async (descriptor, i) => {
|
|
52
|
+
const identifier = descriptor.name.padEnd(maxName);
|
|
53
|
+
const type = `${descriptor.version}`.padStart(maxVersion - 3).padEnd(maxVersion);
|
|
54
54
|
let msg: string;
|
|
55
|
-
for await (const [valueType, value] of new ServiceRunner(
|
|
55
|
+
for await (const [valueType, value] of new ServiceRunner(descriptor).action(action)) {
|
|
56
56
|
const details = { [valueType === 'message' ? 'subtitle' : valueType]: value };
|
|
57
|
-
|
|
57
|
+
queue.add({ idx: i, text: msg = cliTpl`${{ identifier }} ${{ type }} ${details}` });
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
queue.add({ idx: i, done: true, text: msg! });
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
Promise.all(jobs).then(() => Util.queueMacroTask()).then(() =>
|
|
62
|
+
Promise.all(jobs).then(() => Util.queueMacroTask()).then(() => queue.close());
|
|
63
63
|
|
|
64
64
|
const term = new Terminal();
|
|
65
65
|
await term.writer.writeLines([
|
|
@@ -68,6 +68,6 @@ export class CliServiceCommand implements CliCommandShape {
|
|
|
68
68
|
''.padEnd(maxName + maxVersion + maxStatus + 3, '-'),
|
|
69
69
|
]).commit();
|
|
70
70
|
|
|
71
|
-
await term.streamList(
|
|
71
|
+
await term.streamList(queue);
|
|
72
72
|
}
|
|
73
73
|
}
|