@travetto/cli 8.0.0-alpha.9 → 8.0.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/README.md +111 -85
- package/__index__.ts +10 -9
- package/bin/trv.js +2 -1
- package/package.json +15 -15
- package/src/color.ts +1 -1
- package/src/execute.ts +3 -3
- package/src/help.ts +127 -74
- package/src/module.ts +9 -10
- package/src/parse.ts +57 -42
- package/src/registry/decorator.ts +37 -27
- package/src/registry/registry-adapter.ts +15 -25
- package/src/registry/registry-index.ts +24 -24
- package/src/schema-export.ts +25 -16
- package/src/schema.ts +15 -10
- package/src/scm.ts +20 -10
- package/src/service.ts +34 -33
- package/src/trv.d.ts +5 -5
- package/src/types.ts +7 -5
- package/src/util.ts +16 -18
- package/support/cli.cli_schema.ts +8 -7
- package/support/cli.main.ts +12 -8
- package/support/cli.service.ts +22 -16
- package/support/entry.trv.ts +2 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @travetto/cli
|
|
|
13
13
|
yarn add @travetto/cli
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
The cli module represents the primary entry point for execution within the framework. One of the main goals for this module is extensibility, as adding new entry points is meant to be trivial. The framework leverages this module for exposing all executable tools and entry points.
|
|
16
|
+
The cli module represents the primary entry point for execution within the framework. One of the main goals for this module is extensibility, as adding new entry points is meant to be trivial. The framework leverages this module for exposing all executable tools and entry points. To see a high level listing of all supported commands, invoke `trv --help`
|
|
17
17
|
|
|
18
18
|
**Terminal: General Usage**
|
|
19
19
|
```bash
|
|
@@ -22,39 +22,47 @@ $ trv --help
|
|
|
22
22
|
Usage: [options] [command]
|
|
23
23
|
|
|
24
24
|
Commands:
|
|
25
|
-
doc
|
|
26
|
-
doc:angular
|
|
27
|
-
doc:mapping
|
|
28
|
-
email:compile
|
|
29
|
-
email:editor
|
|
30
|
-
email:test
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
25
|
+
doc Generate documentation outputs from a module `DOC.tsx` entry file.
|
|
26
|
+
doc:angular Generate documentation into the angular webapp under related/travetto.github.io
|
|
27
|
+
doc:mapping Generate module mapping for
|
|
28
|
+
email:compile Compile all email templates into generated runtime artifacts.
|
|
29
|
+
email:editor Start the email template editor service for interactive preview and testing.
|
|
30
|
+
email:test Render and send a template file to a target recipient for quick validation.
|
|
31
|
+
firestore:indexes Generate the Firestore composite indexes JSON for all registered models.
|
|
32
|
+
lint:check Run oxlint linter for the workspace or changed files.
|
|
33
|
+
lint:format Run oxfmt formatter for the workspace or changed files.
|
|
34
|
+
lint:register Generate the workspace oxlint, oxfmt, and cspell configuration entry files.
|
|
35
|
+
lint:spell Run cspell spell checker for the workspace or changed files.
|
|
36
|
+
llm:support:execute Execute llm-support operations with dry-run by default.
|
|
37
|
+
llm:support:inline Inline and compile reference snippets for llm-support packaging.
|
|
38
|
+
llm:support:mcp Minimal MCP stdio server for llm-support tools.
|
|
39
|
+
llm:support:plan Build plan-first execution details for llm-support operations.
|
|
40
|
+
llm:support:recommend Recommend llm-support bundles, workflows, and operations.
|
|
41
|
+
llm:support:status Show llm-support execution coverage status.
|
|
42
|
+
model:export Export model definitions for a selected provider and model set.
|
|
43
|
+
model:install Install or update model definitions for a selected provider.
|
|
44
|
+
openapi:client Generate API clients from an OpenAPI specification using the generator image.
|
|
45
|
+
openapi:spec Generate the OpenAPI specification for the selected module.
|
|
46
|
+
pack Build a standard module package artifact.
|
|
47
|
+
pack:docker Build container-ready artifacts and optionally publish Docker images.
|
|
48
|
+
pack:lambda Build an AWS Lambda-ready zip package using the pack pipeline.
|
|
49
|
+
pack:zip Build a deployable zip artifact using the standard pack pipeline.
|
|
50
|
+
repo:exec Execute a shell command across workspace modules.
|
|
51
|
+
repo:list List workspace modules and their relationships.
|
|
52
|
+
repo:publish Publish unpublished workspace modules to the package registry.
|
|
53
|
+
repo:version Bump workspace module versions and optionally commit/tag release metadata.
|
|
54
|
+
repo:version-sync Synchronize package versions and dependency ranges across the monorepo.
|
|
55
|
+
run:double Doubles a number
|
|
56
|
+
service Manage development services (start/stop/restart/status) across the workspace.
|
|
57
|
+
test Execute the test framework for targeted files, suites, or methods.
|
|
58
|
+
test:watch Start the test watcher for continuous test execution.
|
|
59
|
+
web:http Start the configured web HTTP server for a module.
|
|
60
|
+
web:rpc-client Generate web-rpc client artifacts from a specified provider or leveraging local config.
|
|
53
61
|
```
|
|
54
62
|
|
|
55
63
|
This listing is from the [Travetto](https://travetto.dev) monorepo, and represents the majority of tools that can be invoked from the command line.
|
|
56
64
|
|
|
57
|
-
This module also has a tight integration with the [VSCode plugin](https://marketplace.visualstudio.com/items?itemName=arcsine.travetto-plugin), allowing the editing experience to benefit from the commands defined. The most commonly used commands will be the ones packaged with the framework, but its also very easy to create new commands.
|
|
65
|
+
This module also has a tight integration with the [VSCode plugin](https://marketplace.visualstudio.com/items?itemName=arcsine.travetto-plugin), allowing the editing experience to benefit from the commands defined. The most commonly used commands will be the ones packaged with the framework, but its also very easy to create new commands. With the correct configuration, these commands will also be exposed within VSCode.
|
|
58
66
|
|
|
59
67
|
At it's heart, a cli command is the contract defined by what flags, and what arguments the command supports. Within the framework this requires three criteria to be met:
|
|
60
68
|
* The file must be located in the `support/` folder, and have a name that matches `cli.*.ts`
|
|
@@ -75,16 +83,16 @@ export class BasicCommand {
|
|
|
75
83
|
|
|
76
84
|
**Terminal: Basic Command Help**
|
|
77
85
|
```bash
|
|
78
|
-
$ trv basic
|
|
86
|
+
$ trv basic --help
|
|
79
87
|
|
|
80
88
|
Usage: basic [options]
|
|
81
89
|
|
|
82
90
|
Options:
|
|
83
|
-
|
|
91
|
+
--help display help for command
|
|
84
92
|
```
|
|
85
93
|
|
|
86
94
|
## Command Naming
|
|
87
|
-
The file name `support/cli.<name>.ts` has a direct mapping to the cli command name.
|
|
95
|
+
The file name `support/cli.<name>.ts` has a direct mapping to the cli command name. This hard mapping allows for the framework to be able to know which file to invoke without needing to load all command-related files.
|
|
88
96
|
|
|
89
97
|
Examples of mappings:
|
|
90
98
|
* `cli.test.ts` maps to `test`
|
|
@@ -102,7 +110,6 @@ import { CliCommand } from '@travetto/cli';
|
|
|
102
110
|
|
|
103
111
|
@CliCommand()
|
|
104
112
|
export class BasicCommand {
|
|
105
|
-
|
|
106
113
|
loud?: boolean;
|
|
107
114
|
|
|
108
115
|
main() {
|
|
@@ -113,16 +120,16 @@ export class BasicCommand {
|
|
|
113
120
|
|
|
114
121
|
**Terminal: Basic Command with Flag Help**
|
|
115
122
|
```bash
|
|
116
|
-
$ trv basic:flag
|
|
123
|
+
$ trv basic:flag --help
|
|
117
124
|
|
|
118
125
|
Usage: basic:flag [options]
|
|
119
126
|
|
|
120
127
|
Options:
|
|
121
128
|
-l, --loud
|
|
122
|
-
|
|
129
|
+
--help display help for command
|
|
123
130
|
```
|
|
124
131
|
|
|
125
|
-
As you can see the command now has the support of a basic boolean flag to determine if the response should be loud or not.
|
|
132
|
+
As you can see the command now has the support of a basic boolean flag to determine if the response should be loud or not. The default value here is undefined/false, and so is an opt-in experience.
|
|
126
133
|
|
|
127
134
|
**Terminal: Basic Command with Loud Flag**
|
|
128
135
|
```bash
|
|
@@ -133,14 +140,14 @@ HELLO
|
|
|
133
140
|
|
|
134
141
|
The [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/registry/decorator.ts#L20) supports the following data types for flags:
|
|
135
142
|
* Boolean values
|
|
136
|
-
* Number values. The [@Integer](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#
|
|
137
|
-
* String values. [@MinLength](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#
|
|
138
|
-
* Date values. The [@Min](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#
|
|
143
|
+
* Number values. The [@Integer](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L202), [@Float](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L211), [@Precision](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L193), [@Min](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L119) and [@Max](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L130) decorators help provide additional validation.
|
|
144
|
+
* String values. [@MinLength](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L119), [@MaxLength](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L130), [@Match](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L108) and [@Enum](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L78) provide additional constraints
|
|
145
|
+
* Date values. The [@Min](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L119) and [@Max](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/input.ts#L130) decorators help provide additional validation.
|
|
139
146
|
* String lists. Same as String, but allowing multiple values.
|
|
140
147
|
* Numeric lists. Same as Number, but allowing multiple values.
|
|
141
148
|
|
|
142
149
|
## Binding Arguments
|
|
143
|
-
The `main()` method is the entrypoint for the command, represents a series of parameters. Some will be required, some may be optional.
|
|
150
|
+
The `main()` method is the entrypoint for the command, represents a series of parameters. Some will be required, some may be optional. The arguments support all types supported by the flags, and decorators can be provided using the decorators inline on parameters. Optional arguments in the method, will be optional at run time, and filled with the provided default values.
|
|
144
151
|
|
|
145
152
|
**Code: Basic Command with Arg**
|
|
146
153
|
```typescript
|
|
@@ -149,7 +156,6 @@ import { Max, Min } from '@travetto/schema';
|
|
|
149
156
|
|
|
150
157
|
@CliCommand()
|
|
151
158
|
export class BasicCommand {
|
|
152
|
-
|
|
153
159
|
main(@Min(1) @Max(10) volume: number = 1) {
|
|
154
160
|
console.log(volume > 7 ? 'HELLO' : 'Hello');
|
|
155
161
|
}
|
|
@@ -158,12 +164,12 @@ export class BasicCommand {
|
|
|
158
164
|
|
|
159
165
|
**Terminal: Basic Command**
|
|
160
166
|
```bash
|
|
161
|
-
$ trv basic:arg
|
|
167
|
+
$ trv basic:arg --help
|
|
162
168
|
|
|
163
169
|
Usage: basic:arg [options] [volume:number]
|
|
164
170
|
|
|
165
171
|
Options:
|
|
166
|
-
|
|
172
|
+
--help display help for command
|
|
167
173
|
```
|
|
168
174
|
|
|
169
175
|
**Terminal: Basic Command with Invalid Loud Arg**
|
|
@@ -176,7 +182,7 @@ Execution failed:
|
|
|
176
182
|
Usage: basic:arg [options] [volume:number]
|
|
177
183
|
|
|
178
184
|
Options:
|
|
179
|
-
|
|
185
|
+
--help display help for command
|
|
180
186
|
```
|
|
181
187
|
|
|
182
188
|
**Terminal: Basic Command with Loud Arg > 7**
|
|
@@ -202,7 +208,6 @@ import { Max, Min } from '@travetto/schema';
|
|
|
202
208
|
|
|
203
209
|
@CliCommand()
|
|
204
210
|
export class BasicCommand {
|
|
205
|
-
|
|
206
211
|
reverse?: boolean;
|
|
207
212
|
|
|
208
213
|
main(@Min(1) @Max(10) volumes: number[]) {
|
|
@@ -213,13 +218,13 @@ export class BasicCommand {
|
|
|
213
218
|
|
|
214
219
|
**Terminal: Basic Command**
|
|
215
220
|
```bash
|
|
216
|
-
$ trv basic:arg-list
|
|
221
|
+
$ trv basic:arg-list --help
|
|
217
222
|
|
|
218
223
|
Usage: basic:arg-list [options] <volumes...:number>
|
|
219
224
|
|
|
220
225
|
Options:
|
|
221
226
|
-r, --reverse
|
|
222
|
-
|
|
227
|
+
--help display help for command
|
|
223
228
|
```
|
|
224
229
|
|
|
225
230
|
**Terminal: Basic Arg List**
|
|
@@ -240,7 +245,7 @@ Usage: basic:arg-list [options] <volumes...:number>
|
|
|
240
245
|
|
|
241
246
|
Options:
|
|
242
247
|
-r, --reverse
|
|
243
|
-
|
|
248
|
+
--help display help for command
|
|
244
249
|
```
|
|
245
250
|
|
|
246
251
|
**Terminal: Basic Arg List with Reverse**
|
|
@@ -251,7 +256,7 @@ $ trv basic:arg-list -r 10 5 3 9 8 1
|
|
|
251
256
|
```
|
|
252
257
|
|
|
253
258
|
## Customization
|
|
254
|
-
By default, all fields are treated as flags and all parameters of `main()` are treated as arguments within the validation process.
|
|
259
|
+
By default, all fields are treated as flags and all parameters of `main()` are treated as arguments within the validation process. Like the standard [@Schema](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/schema.ts#L19) behavior, we can leverage the metadata of the fields/parameters to help provide additional customization/context for the users of the commands.
|
|
255
260
|
|
|
256
261
|
**Code: Custom Command with Metadata**
|
|
257
262
|
```typescript
|
|
@@ -259,11 +264,10 @@ import { CliCommand } from '@travetto/cli';
|
|
|
259
264
|
import { Max, Min } from '@travetto/schema';
|
|
260
265
|
|
|
261
266
|
/**
|
|
262
|
-
*
|
|
267
|
+
* Example command with a custom argument
|
|
263
268
|
*/
|
|
264
269
|
@CliCommand()
|
|
265
270
|
export class CustomCommand {
|
|
266
|
-
|
|
267
271
|
/**
|
|
268
272
|
* The message to send back to the user
|
|
269
273
|
* @alias -m
|
|
@@ -279,13 +283,16 @@ export class CustomCommand {
|
|
|
279
283
|
|
|
280
284
|
**Terminal: Custom Command Help**
|
|
281
285
|
```bash
|
|
282
|
-
$ trv custom:arg
|
|
286
|
+
$ trv custom:arg --help
|
|
283
287
|
|
|
284
288
|
Usage: custom:arg [options] [volume:number]
|
|
285
289
|
|
|
290
|
+
Description:
|
|
291
|
+
Example command with a custom argument
|
|
292
|
+
|
|
286
293
|
Options:
|
|
287
294
|
-m, --message <string> The message to send back to the user (default: "hello")
|
|
288
|
-
|
|
295
|
+
--help display help for command
|
|
289
296
|
```
|
|
290
297
|
|
|
291
298
|
**Terminal: Custom Command Help with overridden Text**
|
|
@@ -311,11 +318,10 @@ import { CliCommand } from '@travetto/cli';
|
|
|
311
318
|
import { Max, Min } from '@travetto/schema';
|
|
312
319
|
|
|
313
320
|
/**
|
|
314
|
-
*
|
|
321
|
+
* Example of a command with a custom environment variable argument
|
|
315
322
|
*/
|
|
316
323
|
@CliCommand()
|
|
317
324
|
export class CustomCommand {
|
|
318
|
-
|
|
319
325
|
/**
|
|
320
326
|
* The message to send back to the user
|
|
321
327
|
* @alias env.MESSAGE
|
|
@@ -330,13 +336,16 @@ export class CustomCommand {
|
|
|
330
336
|
|
|
331
337
|
**Terminal: Custom Command Help**
|
|
332
338
|
```bash
|
|
333
|
-
$ trv custom:env-arg
|
|
339
|
+
$ trv custom:env-arg --help
|
|
334
340
|
|
|
335
341
|
Usage: custom:env-arg [options] [volume:number]
|
|
336
342
|
|
|
343
|
+
Description:
|
|
344
|
+
Example of a command with a custom environment variable argument
|
|
345
|
+
|
|
337
346
|
Options:
|
|
338
347
|
-t, --text <string> The message to send back to the user (default: "hello")
|
|
339
|
-
|
|
348
|
+
--help display help for command
|
|
340
349
|
```
|
|
341
350
|
|
|
342
351
|
**Terminal: Custom Command Help with default Text**
|
|
@@ -361,7 +370,7 @@ CuStOm
|
|
|
361
370
|
```
|
|
362
371
|
|
|
363
372
|
## Flag File Support
|
|
364
|
-
Sometimes its also convenient, especially with commands that support a variety of flags, to provide easy access to pre-defined sets of flags.
|
|
373
|
+
Sometimes its also convenient, especially with commands that support a variety of flags, to provide easy access to pre-defined sets of flags. Flag files represent a snapshot of command line arguments and flags, as defined in a file. When referenced, these inputs are essentially injected into the command line as if the user had typed them manually.
|
|
365
374
|
|
|
366
375
|
**Code: Example Flag File**
|
|
367
376
|
```bash
|
|
@@ -390,7 +399,7 @@ npx trv call:db --host localhost --port 3306 --username app --password <custom>
|
|
|
390
399
|
```
|
|
391
400
|
|
|
392
401
|
## VSCode Integration
|
|
393
|
-
By default, cli commands do not expose themselves to the VSCode extension, as the majority of them are not intended for that sort of operation.
|
|
402
|
+
By default, cli commands do not expose themselves to the VSCode extension, as the majority of them are not intended for that sort of operation. [Web API](https://github.com/travetto/travetto/tree/main/module/web#readme "Declarative support for creating Web Applications") does expose a cli target `web:http` that will show up, to help run/debug a web application. Any command can mark itself as being a run target, and will be eligible for running from within the [VSCode plugin](https://marketplace.visualstudio.com/items?itemName=arcsine.travetto-plugin). This is achieved by setting the `runTarget` field on the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/registry/decorator.ts#L20) decorator. This means the target will be visible within the editor tooling.
|
|
394
403
|
|
|
395
404
|
**Code: Simple Run Target**
|
|
396
405
|
```typescript
|
|
@@ -401,7 +410,6 @@ import { CliCommand } from '@travetto/cli';
|
|
|
401
410
|
*/
|
|
402
411
|
@CliCommand({ runTarget: true })
|
|
403
412
|
export class RunCommand {
|
|
404
|
-
|
|
405
413
|
main(name: string) {
|
|
406
414
|
console.log(name);
|
|
407
415
|
}
|
|
@@ -433,20 +441,26 @@ If the goal is to run a more complex application, which may include depending on
|
|
|
433
441
|
|
|
434
442
|
**Code: Simple Run Target**
|
|
435
443
|
```typescript
|
|
436
|
-
import {
|
|
444
|
+
import { CliCommand, type CliCommandShape, CliDebugIpcFlag, CliModuleFlag, CliProfilesFlag, CliRestartOnChangeFlag } from '@travetto/cli';
|
|
437
445
|
import { DependencyRegistryIndex } from '@travetto/di';
|
|
438
|
-
import { CliCommand, CliDebugIpcFlag, CliModuleFlag, CliProfilesFlag, CliRestartOnChangeFlag, type CliCommandShape } from '@travetto/cli';
|
|
439
|
-
import { NetUtil } from '@travetto/web';
|
|
440
446
|
import { Registry } from '@travetto/registry';
|
|
447
|
+
import { Runtime, toConcrete } from '@travetto/runtime';
|
|
448
|
+
import { NetUtil } from '@travetto/web';
|
|
441
449
|
|
|
442
450
|
import type { WebHttpServer } from '../src/types.ts';
|
|
443
451
|
|
|
444
452
|
/**
|
|
445
|
-
*
|
|
453
|
+
* Start the configured web HTTP server for a module.
|
|
454
|
+
*
|
|
455
|
+
* Initializes registry and server bindings, supports restart-aware development
|
|
456
|
+
* flags, and can attempt to clear conflicting port owners in local workflows.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* Starting a web server on port 8000
|
|
460
|
+
* > trv web:http -m <MODULE> -p 8000
|
|
446
461
|
*/
|
|
447
462
|
@CliCommand()
|
|
448
463
|
export class WebHttpCommand implements CliCommandShape {
|
|
449
|
-
|
|
450
464
|
/** Port to run on */
|
|
451
465
|
port?: number;
|
|
452
466
|
|
|
@@ -493,7 +507,7 @@ export class WebHttpCommand implements CliCommandShape {
|
|
|
493
507
|
|
|
494
508
|
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/runtime/src/context.ts#L13) `name` defined in the [Runtime](https://github.com/travetto/travetto/tree/main/module/runtime#readme "Runtime for travetto applications.") module.
|
|
495
509
|
|
|
496
|
-
The `module` field is slightly more complex, but is geared towards supporting commands within a monorepo context.
|
|
510
|
+
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.
|
|
497
511
|
|
|
498
512
|
### Custom Validation
|
|
499
513
|
In addition to dependency injection, the command contract also allows for a custom validation function, which will have access to bound command (flags, and args) as well as the unknown arguments. When a command implements this method, any [ValidationError](https://github.com/travetto/travetto/tree/main/module/schema/src/validate/types.ts#L10) errors that are returned will be shared with the user, and fail to invoke the `main` method.
|
|
@@ -540,7 +554,7 @@ A simple example of the validation can be found in the `doc` command:
|
|
|
540
554
|
|
|
541
555
|
**Code: Simple Validation Example**
|
|
542
556
|
```typescript
|
|
543
|
-
@Validator(async
|
|
557
|
+
@Validator(async cmd => {
|
|
544
558
|
const docFile = path.resolve(cmd.input);
|
|
545
559
|
if (!(await fs.stat(docFile, { throwIfNoEntry: false }))) {
|
|
546
560
|
return { message: `input: ${cmd.input} does not exist`, path: 'input', source: 'flag', kind: 'invalid' };
|
|
@@ -549,28 +563,34 @@ A simple example of the validation can be found in the `doc` command:
|
|
|
549
563
|
```
|
|
550
564
|
|
|
551
565
|
## CLI - service
|
|
552
|
-
The module provides the ability to start/stop/restart services as [docker](https://www.docker.com/community-edition) containers.
|
|
566
|
+
The module provides the ability to start/stop/restart services as [docker](https://www.docker.com/community-edition) containers. This is meant to be used for development purposes, to minimize the effort of getting an application up and running. Services can be targeted individually or handled as a group.
|
|
553
567
|
|
|
554
|
-
**Terminal:
|
|
568
|
+
**Terminal: Help for service**
|
|
555
569
|
```bash
|
|
556
570
|
$ trv service --help
|
|
557
571
|
|
|
558
572
|
Usage: service [options] <action:restart|start|status|stop> [services...:string]
|
|
559
573
|
|
|
574
|
+
Description:
|
|
575
|
+
Manage development services (start/stop/restart/status) across the workspace.
|
|
576
|
+
|
|
577
|
+
Services are discovered from registered descriptors and executed with streamed
|
|
578
|
+
terminal feedback, including optional quiet mode.
|
|
579
|
+
|
|
560
580
|
Options:
|
|
561
581
|
-q, --quiet (default: false)
|
|
562
|
-
|
|
582
|
+
--help display help for command
|
|
563
583
|
|
|
564
584
|
Available Services
|
|
565
585
|
--------------------
|
|
566
586
|
* dynamodb@3.3.0
|
|
567
|
-
* elasticsearch@9.2
|
|
587
|
+
* elasticsearch@9.5.2
|
|
568
588
|
* firestore@latest
|
|
569
|
-
* mongodb@8.
|
|
570
|
-
* mysql@9.
|
|
571
|
-
* postgresql@18.
|
|
572
|
-
* redis@8.
|
|
573
|
-
* s3@4.
|
|
589
|
+
* mongodb@8.3
|
|
590
|
+
* mysql@9.7
|
|
591
|
+
* postgresql@18.6
|
|
592
|
+
* redis@8.10
|
|
593
|
+
* s3@4.12.4
|
|
574
594
|
```
|
|
575
595
|
|
|
576
596
|
A sample of all services available to the entire framework:
|
|
@@ -582,13 +602,13 @@ $ trv service status
|
|
|
582
602
|
Service Version Status
|
|
583
603
|
-------------------------------------------------
|
|
584
604
|
dynamodb 3.3.0 Running 93af422e793a
|
|
585
|
-
elasticsearch 9.2
|
|
605
|
+
elasticsearch 9.5.2 Running ed76ee063d13
|
|
586
606
|
firestore latest Running feec2e5e95b4
|
|
587
|
-
mongodb 8.
|
|
588
|
-
mysql 9.
|
|
589
|
-
postgresql 18.
|
|
590
|
-
redis
|
|
591
|
-
s3 4.
|
|
607
|
+
mongodb 8.3 Running 5513eba6734e
|
|
608
|
+
mysql 9.7 Running 307bc66d442a
|
|
609
|
+
postgresql 18.6 Running e78291e71040
|
|
610
|
+
redis 8.10 Running 77ba279b4e30
|
|
611
|
+
s3 4.12.4 Running fdacfc55b9e3
|
|
592
612
|
```
|
|
593
613
|
|
|
594
614
|
### Defining new Services
|
|
@@ -598,12 +618,18 @@ The services are defined as plain typescript files within the framework and can
|
|
|
598
618
|
```typescript
|
|
599
619
|
import type { ServiceDescriptor } from '@travetto/cli';
|
|
600
620
|
|
|
601
|
-
const version = process.env.MONGO_VERSION || '8.
|
|
621
|
+
const version = process.env.MONGO_VERSION || '8.3';
|
|
622
|
+
|
|
623
|
+
/* cspell:words orbstack pthread rseq glibc TUNABLES */
|
|
602
624
|
|
|
603
625
|
export const service: ServiceDescriptor = {
|
|
604
626
|
name: 'mongodb',
|
|
605
627
|
version,
|
|
606
628
|
port: 27017,
|
|
607
|
-
image: `mongo:${version}
|
|
629
|
+
image: `mongo:${version}`,
|
|
630
|
+
env: {
|
|
631
|
+
// Temp until mongo image fixes orbstack issue
|
|
632
|
+
GLIBC_TUNABLES: 'glibc.pthread.rseq=1'
|
|
633
|
+
}
|
|
608
634
|
};
|
|
609
635
|
```
|
package/__index__.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {} from './src/trv.d.ts';
|
|
2
|
+
|
|
3
|
+
export * from './src/color.ts';
|
|
3
4
|
export * from './src/execute.ts';
|
|
4
|
-
export * from './src/schema.ts';
|
|
5
|
-
export * from './src/schema-export.ts';
|
|
6
|
-
export * from './src/registry/decorator.ts';
|
|
7
|
-
export * from './src/registry/registry-index.ts';
|
|
8
|
-
export * from './src/registry/registry-adapter.ts';
|
|
9
5
|
export * from './src/help.ts';
|
|
10
|
-
export * from './src/color.ts';
|
|
11
6
|
export * from './src/module.ts';
|
|
12
|
-
export * from './src/scm.ts';
|
|
13
7
|
export * from './src/parse.ts';
|
|
8
|
+
export * from './src/registry/decorator.ts';
|
|
9
|
+
export * from './src/registry/registry-adapter.ts';
|
|
10
|
+
export * from './src/registry/registry-index.ts';
|
|
11
|
+
export * from './src/schema.ts';
|
|
12
|
+
export * from './src/schema-export.ts';
|
|
13
|
+
export * from './src/scm.ts';
|
|
14
14
|
export * from './src/service.ts';
|
|
15
|
+
export * from './src/types.ts';
|
|
15
16
|
export * from './src/util.ts';
|
package/bin/trv.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
// @ts-check
|
|
3
3
|
import '@travetto/runtime/support/patch.js';
|
|
4
4
|
import '@travetto/compiler/bin/hook.js';
|
|
5
|
+
|
|
5
6
|
const { invoke } = await import('@travetto/compiler/support/invoke.ts');
|
|
6
|
-
await invoke('exec',
|
|
7
|
+
await invoke('exec', '@travetto/cli/support/entry.trv.ts', ...process.argv.slice(2));
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/cli",
|
|
3
|
-
"version": "8.0.0
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "8.0.0",
|
|
5
4
|
"description": "CLI infrastructure for Travetto framework",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"cli",
|
|
@@ -11,8 +10,15 @@
|
|
|
11
10
|
"homepage": "https://travetto.io",
|
|
12
11
|
"license": "MIT",
|
|
13
12
|
"author": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
13
|
+
"name": "Travetto Framework",
|
|
14
|
+
"email": "travetto.framework@gmail.com"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"url": "git+https://github.com/travetto/travetto.git",
|
|
18
|
+
"directory": "module/cli"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"trv": "bin/trv.js"
|
|
16
22
|
},
|
|
17
23
|
"files": [
|
|
18
24
|
"__index__.ts",
|
|
@@ -20,23 +26,17 @@
|
|
|
20
26
|
"src",
|
|
21
27
|
"support"
|
|
22
28
|
],
|
|
29
|
+
"type": "module",
|
|
23
30
|
"main": "__index__.ts",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
},
|
|
27
|
-
"repository": {
|
|
28
|
-
"url": "git+https://github.com/travetto/travetto.git",
|
|
29
|
-
"directory": "module/cli"
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
30
33
|
},
|
|
31
34
|
"dependencies": {
|
|
32
|
-
"@travetto/schema": "^8.0.0
|
|
33
|
-
"@travetto/terminal": "^8.0.0
|
|
35
|
+
"@travetto/schema": "^8.0.0",
|
|
36
|
+
"@travetto/terminal": "^8.0.0"
|
|
34
37
|
},
|
|
35
38
|
"travetto": {
|
|
36
39
|
"displayName": "Command Line Interface",
|
|
37
40
|
"workspaceInclude": true
|
|
38
|
-
},
|
|
39
|
-
"publishConfig": {
|
|
40
|
-
"access": "public"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/color.ts
CHANGED
package/src/execute.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { ConsoleManager, getClass, Runtime, ShutdownManager, Util } from '@travetto/runtime';
|
|
2
2
|
|
|
3
3
|
import { HelpUtil } from './help.ts';
|
|
4
|
+
import { CliParseUtil } from './parse.ts';
|
|
4
5
|
import { CliCommandRegistryIndex } from './registry/registry-index.ts';
|
|
5
6
|
import { CliCommandSchemaUtil } from './schema.ts';
|
|
6
|
-
import { CliParseUtil } from './parse.ts';
|
|
7
7
|
import type { CliCommandShape } from './types.ts';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Execution manager
|
|
11
11
|
*/
|
|
12
12
|
export class ExecutionManager {
|
|
13
|
-
|
|
14
13
|
/** Command Execution */
|
|
15
14
|
static async execute(instance: CliCommandShape, args: unknown[]): Promise<void> {
|
|
16
15
|
const config = CliCommandRegistryIndex.get(getClass(instance));
|
|
@@ -69,8 +68,9 @@ export class ExecutionManager {
|
|
|
69
68
|
await execute?.();
|
|
70
69
|
} catch (error) {
|
|
71
70
|
console.error!(error);
|
|
71
|
+
process.exitCode ??= 1;
|
|
72
72
|
} finally {
|
|
73
73
|
await ShutdownManager.shutdown();
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
}
|
|
76
|
+
}
|