@travetto/cli 3.4.0-rc.9 → 3.4.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 +4 -4
- package/package.json +3 -3
- package/src/decorators.ts +2 -2
- package/src/execute.ts +2 -2
- package/src/schema.ts +3 -1
- package/src/types.ts +2 -2
package/README.md
CHANGED
|
@@ -170,7 +170,7 @@ Options:
|
|
|
170
170
|
$ trv basic:arg 20
|
|
171
171
|
|
|
172
172
|
Execution failed:
|
|
173
|
-
* Argument
|
|
173
|
+
* Argument volume is bigger than (10)
|
|
174
174
|
|
|
175
175
|
Usage: basic:arg [options] [volume:number]
|
|
176
176
|
|
|
@@ -233,7 +233,7 @@ $ trv basic:arglist 10 5 3 9 8 1
|
|
|
233
233
|
$ trv basic:arglist 10 5 3 9 20 1
|
|
234
234
|
|
|
235
235
|
Execution failed:
|
|
236
|
-
* Argument [4] is bigger than (10)
|
|
236
|
+
* Argument volumes[4] is bigger than (10)
|
|
237
237
|
|
|
238
238
|
Usage: basic:arglist [options] <volumes...:number>
|
|
239
239
|
|
|
@@ -390,7 +390,7 @@ export interface CliCommandShape {
|
|
|
390
390
|
/**
|
|
391
391
|
* Setup environment before command runs
|
|
392
392
|
*/
|
|
393
|
-
envInit?(): OrProm<
|
|
393
|
+
envInit?(): OrProm<EnvInit>;
|
|
394
394
|
/**
|
|
395
395
|
* Extra help
|
|
396
396
|
*/
|
|
@@ -454,7 +454,7 @@ export class RunRestCommand {
|
|
|
454
454
|
}
|
|
455
455
|
```
|
|
456
456
|
|
|
457
|
-
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 [GlobalEnv](https://github.com/travetto/travetto/tree/main/module/base/src/global-env.ts#
|
|
457
|
+
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 [GlobalEnv](https://github.com/travetto/travetto/tree/main/module/base/src/global-env.ts#L9) flags defined in the [Base](https://github.com/travetto/travetto/tree/main/module/base#readme "Environment config and common utilities for travetto applications.") module.
|
|
458
458
|
|
|
459
459
|
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.
|
|
460
460
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/cli",
|
|
3
|
-
"version": "3.4.0
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "CLI infrastructure for Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"directory": "module/cli"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@travetto/schema": "^3.4.0
|
|
33
|
-
"@travetto/terminal": "^3.4.0
|
|
32
|
+
"@travetto/schema": "^3.4.0",
|
|
33
|
+
"@travetto/terminal": "^3.4.0"
|
|
34
34
|
},
|
|
35
35
|
"travetto": {
|
|
36
36
|
"displayName": "Command Line Interface"
|
package/src/decorators.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Class, ClassInstance, ConsoleManager, GlobalEnv,
|
|
1
|
+
import { Class, ClassInstance, ConsoleManager, GlobalEnv, defineEnv } from '@travetto/base';
|
|
2
2
|
import { RootIndex } from '@travetto/manifest';
|
|
3
3
|
import { SchemaRegistry } from '@travetto/schema';
|
|
4
4
|
|
|
@@ -26,7 +26,7 @@ export function CliCommand(cfg: CliCommandConfigOptions = {}) {
|
|
|
26
26
|
hidden: cfg.hidden,
|
|
27
27
|
preMain: async (cmd) => {
|
|
28
28
|
if (addEnv && 'env' in cmd && typeof cmd.env === 'string') {
|
|
29
|
-
|
|
29
|
+
defineEnv({ envName: cmd.env });
|
|
30
30
|
ConsoleManager.setDebug(GlobalEnv.debug, GlobalEnv.devMode);
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/execute.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GlobalTerminal } from '@travetto/terminal';
|
|
2
|
-
import { ConsoleManager,
|
|
2
|
+
import { ConsoleManager, defineEnv, ShutdownManager, GlobalEnv } from '@travetto/base';
|
|
3
3
|
|
|
4
4
|
import { HelpUtil } from './help';
|
|
5
5
|
import { CliCommandShape } from './types';
|
|
@@ -14,7 +14,7 @@ export class ExecutionManager {
|
|
|
14
14
|
|
|
15
15
|
static async #envInit(cmd: CliCommandShape): Promise<void> {
|
|
16
16
|
if (cmd.envInit) {
|
|
17
|
-
|
|
17
|
+
defineEnv(await cmd.envInit());
|
|
18
18
|
ConsoleManager.setDebug(GlobalEnv.debug, GlobalEnv.devMode);
|
|
19
19
|
}
|
|
20
20
|
}
|
package/src/schema.ts
CHANGED
|
@@ -237,9 +237,11 @@ export class CliCommandSchemaUtil {
|
|
|
237
237
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
238
238
|
const cls = cmd.constructor as Class<CliCommandShape>;
|
|
239
239
|
|
|
240
|
+
const paramNames = SchemaRegistry.getMethodSchema(cls, 'main').map(x => x.name);
|
|
241
|
+
|
|
240
242
|
const validators = [
|
|
241
243
|
(): Promise<void> => SchemaValidator.validate(cls, cmd).then(() => { }),
|
|
242
|
-
(): Promise<void> => SchemaValidator.validateMethod(cls, 'main', args),
|
|
244
|
+
(): Promise<void> => SchemaValidator.validateMethod(cls, 'main', args, paramNames),
|
|
243
245
|
async (): Promise<void> => {
|
|
244
246
|
const res = await cmd.validate?.(...args);
|
|
245
247
|
if (res) {
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Closeable,
|
|
1
|
+
import { Closeable, EnvInit } from '@travetto/base';
|
|
2
2
|
|
|
3
3
|
type OrProm<T> = T | Promise<T>;
|
|
4
4
|
|
|
@@ -29,7 +29,7 @@ export interface CliCommandShape {
|
|
|
29
29
|
/**
|
|
30
30
|
* Setup environment before command runs
|
|
31
31
|
*/
|
|
32
|
-
envInit?(): OrProm<
|
|
32
|
+
envInit?(): OrProm<EnvInit>;
|
|
33
33
|
/**
|
|
34
34
|
* Extra help
|
|
35
35
|
*/
|