@travetto/cli 4.0.2 → 4.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/cli",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
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": "^4.0.2",
33
- "@travetto/terminal": "^4.0.1"
32
+ "@travetto/schema": "^4.0.3",
33
+ "@travetto/terminal": "^4.0.2"
34
34
  },
35
35
  "travetto": {
36
36
  "displayName": "Command Line Interface",
package/src/execute.ts CHANGED
@@ -6,6 +6,7 @@ import { CliCommandSchemaUtil } from './schema';
6
6
  import { CliUnknownCommandError, CliValidationResultError } from './error';
7
7
  import { CliParseUtil } from './parse';
8
8
  import { CliUtil } from './util';
9
+ import { CliCommandShape } from './types';
9
10
 
10
11
  /**
11
12
  * Execution manager
@@ -31,8 +32,8 @@ export class ExecutionManager {
31
32
  console.error!();
32
33
  }
33
34
 
34
- /** Run command */
35
- static async #runCommand(cmd: string, args: string[]): Promise<void> {
35
+ /** Bind command */
36
+ static async #bindCommand(cmd: string, args: string[]): Promise<{ command: CliCommandShape, boundArgs: unknown[] }> {
36
37
  const command = await CliCommandRegistry.getInstance(cmd, true);
37
38
  const schema = await CliCommandSchemaUtil.getSchema(command);
38
39
  const fullArgs = await CliParseUtil.expandArgs(schema, args);
@@ -40,6 +41,12 @@ export class ExecutionManager {
40
41
 
41
42
  await command.preBind?.();
42
43
  const boundArgs = await CliCommandSchemaUtil.bindInput(command, state);
44
+ return { command, boundArgs };
45
+ }
46
+
47
+ /** Run command */
48
+ static async #runCommand(cmd: string, args: string[]): Promise<void> {
49
+ const { command, boundArgs } = await this.#bindCommand(cmd, args);
43
50
 
44
51
  await command.preValidate?.();
45
52
  await CliCommandSchemaUtil.validate(command, boundArgs);
@@ -62,7 +69,8 @@ export class ExecutionManager {
62
69
  if (!cmd) {
63
70
  console.info!(await HelpUtil.renderAllHelp());
64
71
  } else if (help) {
65
- console.log!(await HelpUtil.renderCommandHelp(cmd));
72
+ const { command } = await this.#bindCommand(cmd, args);
73
+ console.log!(await HelpUtil.renderCommandHelp(command));
66
74
  } else {
67
75
  await this.#runCommand(cmd, args);
68
76
  }
package/src/help.ts CHANGED
@@ -64,7 +64,7 @@ export class HelpUtil {
64
64
  params.push(param.join(' '));
65
65
  const desc = [cliTpl`${{ title: flag.description }}`];
66
66
 
67
- if (key !== 'help' && flagVal !== null && flagVal !== undefined) {
67
+ if (key !== 'help' && flagVal !== null && flagVal !== undefined && flagVal !== '') {
68
68
  desc.push(cliTpl`(default: ${{ input: JSON.stringify(flagVal) }})`);
69
69
  }
70
70
  descs.push(desc.join(' '));
package/src/scm.ts CHANGED
@@ -83,6 +83,14 @@ export class CliScmUtil {
83
83
  return ExecUtil.getResult(spawn('git', ['commit', '.', '-m', message])).then(r => r.stdout);
84
84
  }
85
85
 
86
+ /**
87
+ * Create a tag
88
+ */
89
+ static createTag(version: string): Promise<string> {
90
+ version = version.replace(/[^0-9a-z_\-.]/g, '');
91
+ return ExecUtil.getResult(spawn('git', ['tag', '-a', `${version}`, '-m', `Release ${version}`])).then(r => r.stdout);
92
+ }
93
+
86
94
  /**
87
95
  * Verify if workspace is dirty
88
96
  */