@travetto/cli 5.0.16 → 5.0.18
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 +17 -17
- package/bin/trv.js +2 -3
- package/package.json +3 -3
- package/src/decorators.ts +0 -1
- package/src/error.ts +0 -1
- package/src/parse.ts +0 -1
- package/src/registry.ts +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ This module also has a tight integration with the [VSCode plugin](https://market
|
|
|
60
60
|
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:
|
|
61
61
|
* The file must be located in the `support/` folder, and have a name that matches `cli.*.ts`
|
|
62
62
|
* The file must be a class that has a main method
|
|
63
|
-
* The class must use the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#
|
|
63
|
+
* The class must use the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#L84) decorator
|
|
64
64
|
|
|
65
65
|
**Code: Basic Command**
|
|
66
66
|
```typescript
|
|
@@ -94,7 +94,7 @@ Examples of mappings:
|
|
|
94
94
|
The pattern is that underscores(_) translate to colons (:), and the `cli.` prefix, and `.ts` suffix are dropped.
|
|
95
95
|
|
|
96
96
|
## Binding Flags
|
|
97
|
-
[@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#
|
|
97
|
+
[@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#L84) is a wrapper for [@Schema](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/schema.ts#L14), and so every class that uses the [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#L84) decorator is now a full [@Schema](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/schema.ts#L14) class. The fields of the class represent the flags that are available to the command.
|
|
98
98
|
|
|
99
99
|
**Code: Basic Command with Flag**
|
|
100
100
|
```typescript
|
|
@@ -131,7 +131,7 @@ $ trv basic:flag --loud
|
|
|
131
131
|
HELLO
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
The [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#
|
|
134
|
+
The [@CliCommand](https://github.com/travetto/travetto/tree/main/module/cli/src/decorators.ts#L84) supports the following data types for flags:
|
|
135
135
|
* Boolean values
|
|
136
136
|
* Number values. The [@Integer](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L166), [@Float](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L172), [@Precision](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L160), [@Min](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L101) and [@Max](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L111) decorators help provide additional validation.
|
|
137
137
|
* String values. [@MinLength](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L101), [@MaxLength](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L111), [@Match](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L93) and [@Enum](https://github.com/travetto/travetto/tree/main/module/schema/src/decorator/field.ts#L72) provide additional constraints
|
|
@@ -389,7 +389,7 @@ npx trv call:db --host localhost --port 3306 --username app --password <custom>
|
|
|
389
389
|
```
|
|
390
390
|
|
|
391
391
|
## VSCode Integration
|
|
392
|
-
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. [RESTful API](https://github.com/travetto/travetto/tree/main/module/rest#readme "Declarative api for RESTful APIs with support for the dependency injection module.") does expose a cli target `run:rest` that will show up, to help run/debug a rest 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/decorators.ts#
|
|
392
|
+
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. [RESTful API](https://github.com/travetto/travetto/tree/main/module/rest#readme "Declarative api for RESTful APIs with support for the dependency injection module.") does expose a cli target `run:rest` that will show up, to help run/debug a rest 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/decorators.ts#L84) decorator. This means the target will be visible within the editor tooling.
|
|
393
393
|
|
|
394
394
|
**Code: Simple Run Target**
|
|
395
395
|
```typescript
|
|
@@ -548,14 +548,14 @@ Options:
|
|
|
548
548
|
|
|
549
549
|
Available Services
|
|
550
550
|
--------------------
|
|
551
|
-
* dynamodb@2.
|
|
552
|
-
* elasticsearch@8.
|
|
551
|
+
* dynamodb@2.5.3
|
|
552
|
+
* elasticsearch@8.17.0
|
|
553
553
|
* firestore@latest
|
|
554
|
-
* mongodb@
|
|
554
|
+
* mongodb@8.0
|
|
555
555
|
* mysql@8.0
|
|
556
|
-
* postgresql@
|
|
557
|
-
* redis@7.
|
|
558
|
-
* s3@3.
|
|
556
|
+
* postgresql@17.2
|
|
557
|
+
* redis@7.4
|
|
558
|
+
* s3@3.12.0
|
|
559
559
|
```
|
|
560
560
|
|
|
561
561
|
A sample of all services available to the entire framework:
|
|
@@ -566,14 +566,14 @@ $ trv service status
|
|
|
566
566
|
|
|
567
567
|
Service Version Status
|
|
568
568
|
-------------------------------------------------
|
|
569
|
-
dynamodb 2.
|
|
570
|
-
elasticsearch
|
|
569
|
+
dynamodb 2.5.3 Running 93af422e793a
|
|
570
|
+
elasticsearch 8.17.0 Running ed76ee063d13
|
|
571
571
|
firestore latest Running feec2e5e95b4
|
|
572
|
-
mongodb
|
|
572
|
+
mongodb 8.0 Running 5513eba6734e
|
|
573
573
|
mysql 8.0 Running 307bc66d442a
|
|
574
|
-
postgresql
|
|
575
|
-
redis 7.
|
|
576
|
-
s3
|
|
574
|
+
postgresql 17.2 Running e78291e71040
|
|
575
|
+
redis 7.4 Running 77ba279b4e30
|
|
576
|
+
s3 3.12.0 Running fdacfc55b9e3
|
|
577
577
|
```
|
|
578
578
|
|
|
579
579
|
### Defining new Services
|
|
@@ -583,7 +583,7 @@ The services are defined as plain typescript files within the framework and can
|
|
|
583
583
|
```typescript
|
|
584
584
|
import type { ServiceDescriptor } from '@travetto/cli';
|
|
585
585
|
|
|
586
|
-
const version = process.env.MONGO_VERSION
|
|
586
|
+
const version = process.env.MONGO_VERSION || '8.0';
|
|
587
587
|
|
|
588
588
|
export const service: ServiceDescriptor = {
|
|
589
589
|
name: 'mongodb',
|
package/bin/trv.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// @ts-check
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
getEntry().then(ops => ops.getLoader()).then(load => load('@travetto/cli/support/entry.trv.js'));
|
|
4
|
+
require('@travetto/compiler/bin/entry.common.js')
|
|
5
|
+
.load(ops => ops.exec('@travetto/cli/support/entry.trv.js'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/cli",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.18",
|
|
4
4
|
"description": "CLI infrastructure for Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"directory": "module/cli"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@travetto/schema": "^5.0.
|
|
32
|
-
"@travetto/terminal": "^5.0.
|
|
31
|
+
"@travetto/schema": "^5.0.15",
|
|
32
|
+
"@travetto/terminal": "^5.0.17"
|
|
33
33
|
},
|
|
34
34
|
"travetto": {
|
|
35
35
|
"displayName": "Command Line Interface",
|
package/src/decorators.ts
CHANGED
package/src/error.ts
CHANGED
package/src/parse.ts
CHANGED
package/src/registry.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { asConstructable, Class, classConstruct, describeFunction, Runtime, Runt
|
|
|
3
3
|
import { CliCommandConfig, CliCommandShape } from './types';
|
|
4
4
|
import { CliUnknownCommandError } from './error';
|
|
5
5
|
|
|
6
|
-
const CLI_FILE_REGEX = /\/cli[.](?<name
|
|
6
|
+
const CLI_FILE_REGEX = /\/cli[.](?<name>.{0,100}?)([.]tsx?)?$/;
|
|
7
7
|
const getName = (s: string): string => (s.match(CLI_FILE_REGEX)?.groups?.name ?? s).replaceAll('_', ':');
|
|
8
8
|
|
|
9
9
|
class $CliCommandRegistry {
|