@contrail/cli 3.5.4-alpha.103cd15 → 3.5.4-alpha.2a94b1c

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 CHANGED
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
17
17
  $ contrail COMMAND
18
18
  running command...
19
19
  $ contrail (--version)
20
- @contrail/cli/3.5.4-alpha.103cd15 linux-x64 node-v24.16.0
20
+ @contrail/cli/3.5.4-alpha.2a94b1c linux-x64 node-v24.18.0
21
21
  $ contrail --help [COMMAND]
22
22
  USAGE
23
23
  $ contrail COMMAND
@@ -97,7 +97,7 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
97
97
  * [`contrail workflow-templates delete`](#contrail-workflow-templates-delete)
98
98
  * [`contrail workflow-templates export`](#contrail-workflow-templates-export)
99
99
  * [`contrail workflow-templates list`](#contrail-workflow-templates-list)
100
- * [`contrail workflow-templates load FILELOCATION`](#contrail-workflow-templates-load-filelocation)
100
+ * [`contrail workflow-templates load [FILELOCATION]`](#contrail-workflow-templates-load-filelocation)
101
101
 
102
102
  ## `contrail app create`
103
103
 
@@ -1659,27 +1659,32 @@ EXAMPLES
1659
1659
  $ contrail workflow-templates list
1660
1660
  ```
1661
1661
 
1662
- ## `contrail workflow-templates load FILELOCATION`
1662
+ ## `contrail workflow-templates load [FILELOCATION]`
1663
1663
 
1664
- Loads your workflow from a local file
1664
+ Load workflow templates from a file or scan a directory for per-app workflow files
1665
1665
 
1666
1666
  ```
1667
1667
  USAGE
1668
- $ contrail workflow-templates load FILELOCATION [-l error|warn|info|debug] [-e true|false]
1668
+ $ contrail workflow-templates load [FILELOCATION] [-l error|warn|info|debug] [-e true|false] [-d <value>]
1669
1669
 
1670
1670
  ARGUMENTS
1671
- FILELOCATION The workflow template file to load
1671
+ FILELOCATION A specific workflow template file to load
1672
1672
 
1673
1673
  FLAGS
1674
+ -d, --dir=<value> [default: .] Directory to scan for workflow files when no file argument is given
1674
1675
  -e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
1675
1676
  <options: true|false>
1676
1677
  -l, --logLevel=<option> The Log Level
1677
1678
  <options: error|warn|info|debug>
1678
1679
 
1679
1680
  DESCRIPTION
1680
- Loads your workflow from a local file
1681
+ Load workflow templates from a file or scan a directory for per-app workflow files
1681
1682
 
1682
1683
  EXAMPLES
1683
1684
  $ contrail workflow-templates load <FILE_LOCATION>
1685
+
1686
+ $ contrail workflow-templates load
1687
+
1688
+ $ contrail workflow-templates load --dir ./workflows
1684
1689
  ```
1685
1690
  <!-- commandsstop -->
@@ -102,7 +102,7 @@ async function exportWorkflowsByApp(outputDir, overwrite) {
102
102
  for (const [appIdentifier, workflows] of workflowsByApp.entries()) {
103
103
  const exportObj = { appIdentifier, workflows: [] };
104
104
  for (const workflow of workflows) {
105
- exportObj.workflows.push(await buildExportWorkflow(workflow, allSchedules));
105
+ exportObj.workflows.push(await buildExportWorkflow(workflow, allSchedules, appIdentifier));
106
106
  }
107
107
  const safeAppIdentifier = appIdentifier.replace(/[\\/]/g, '-');
108
108
  const filePath = path.join(resolvedDir, `workflows-${safeAppIdentifier}.yml`);
@@ -133,7 +133,7 @@ async function exportWorkflowsToFile(fileLocation, overwrite) {
133
133
  await writeYamlFile(workflowsObj, pathToWrite, overwrite);
134
134
  }
135
135
  exports.exportWorkflowsToFile = exportWorkflowsToFile;
136
- async function buildExportWorkflow(workflow, allSchedules) {
136
+ async function buildExportWorkflow(workflow, allSchedules, appIdentifier) {
137
137
  const exportWorkflow = lodash_1.default.pick(workflow, [
138
138
  'identifier',
139
139
  'name',
@@ -149,7 +149,12 @@ async function buildExportWorkflow(workflow, allSchedules) {
149
149
  exportWorkflow.crons = schedules.map((s) => ({ name: s.name, cron: s.cron }));
150
150
  }
151
151
  await (0, helper_1.populateActionIdentifiers)(exportWorkflow);
152
- (0, helper_1.extractShortActionKeys)(exportWorkflow);
152
+ // Shortened keys can only be resolved back to a full action identifier on
153
+ // import if an appIdentifier is known. Without one (e.g. unassigned
154
+ // workflows), keep the full identifier so the workflow stays re-importable.
155
+ if (appIdentifier) {
156
+ (0, helper_1.extractShortActionKeys)(exportWorkflow);
157
+ }
153
158
  return exportWorkflow;
154
159
  }
155
160
  async function writeYamlFile(data, absolutePath, overwrite) {
@@ -3,6 +3,7 @@ export default class LoadWorkflowTemplates extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
+ dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
7
  alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
8
  logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
9
  };
@@ -11,3 +12,4 @@ export default class LoadWorkflowTemplates extends BaseCommand {
11
12
  };
12
13
  run(): Promise<void>;
13
14
  }
15
+ export declare function importWorkflowsBySelection(dir: string): Promise<void>;
@@ -1,27 +1,84 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.importWorkflowsBySelection = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path = tslib_1.__importStar(require("path"));
6
+ const fs_1 = tslib_1.__importDefault(require("fs"));
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
3
9
  const core_1 = require("@oclif/core");
4
10
  const login_1 = require("../../auth/login");
5
11
  const helper_1 = require("../../helpers/workflow-templates/helper");
6
12
  const basecommand_1 = require("../../basecommand");
7
13
  class LoadWorkflowTemplates extends basecommand_1.BaseCommand {
8
- static description = 'Loads your workflow from a local file';
14
+ static description = 'Load workflow templates from a file or scan a directory for per-app workflow files';
9
15
  static examples = [
10
- `$ contrail workflow-templates load <FILE_LOCATION>
11
- `,
16
+ '$ contrail workflow-templates load <FILE_LOCATION>',
17
+ '$ contrail workflow-templates load',
18
+ '$ contrail workflow-templates load --dir ./workflows',
12
19
  ];
13
20
  static flags = {
14
21
  ...basecommand_1.BaseCommand.baseFlags,
22
+ dir: core_1.Flags.string({
23
+ char: 'd',
24
+ description: 'Directory to scan for workflow files when no file argument is given',
25
+ required: false,
26
+ default: '.',
27
+ }),
15
28
  };
16
29
  static args = {
17
30
  fileLocation: core_1.Args.string({
18
- description: 'The workflow template file to load',
19
- required: true,
31
+ description: 'A specific workflow template file to load',
32
+ required: false,
20
33
  }),
21
34
  };
22
35
  async run() {
23
36
  await (0, login_1.authUser)();
24
- await (0, helper_1.localDeployWorkflowTemplate)(this.args.fileLocation);
37
+ if (this.args.fileLocation) {
38
+ await (0, helper_1.localDeployWorkflowTemplate)(this.args.fileLocation);
39
+ }
40
+ else {
41
+ await importWorkflowsBySelection(this.flags.dir ?? '.');
42
+ }
25
43
  }
26
44
  }
27
45
  exports.default = LoadWorkflowTemplates;
46
+ async function importWorkflowsBySelection(dir) {
47
+ const resolvedDir = path.resolve(process.cwd(), dir);
48
+ const files = fs_1.default
49
+ .readdirSync(resolvedDir)
50
+ .filter((f) => f.startsWith('workflows-') && f.endsWith('.yml') && f !== 'workflows-unassigned.yml')
51
+ .sort();
52
+ if (files.length === 0) {
53
+ console.log(chalk_1.default.yellow(`No workflow files found in ${resolvedDir}`));
54
+ return;
55
+ }
56
+ const choices = files.map((f) => ({
57
+ name: f,
58
+ value: f,
59
+ checked: true,
60
+ }));
61
+ const { selectedFiles } = await inquirer_1.default.prompt([
62
+ {
63
+ type: 'checkbox',
64
+ name: 'selectedFiles',
65
+ message: 'Select workflow files to import (space to toggle, enter to confirm):',
66
+ choices,
67
+ },
68
+ ]);
69
+ if (selectedFiles.length === 0) {
70
+ console.log(chalk_1.default.yellow('No files selected — nothing imported.'));
71
+ return;
72
+ }
73
+ //log selected file
74
+ console.log(chalk_1.default.blue.bold('SELECTED WORKFLOW FILES:'));
75
+ selectedFiles.forEach((file) => {
76
+ console.log(` - ${file}`);
77
+ });
78
+ for (const file of selectedFiles) {
79
+ console.log(`\n${chalk_1.default.blue.bold('IMPORTING')} ${file}`);
80
+ await (0, helper_1.localDeployWorkflowTemplate)(path.join(dir, file));
81
+ console.log(`${chalk_1.default.green.bold('DONE')} ${file}`);
82
+ }
83
+ }
84
+ exports.importWorkflowsBySelection = importWorkflowsBySelection;
@@ -98,7 +98,7 @@ export interface WorkflowDefinition {
98
98
  dynamicMessageGroupId?: string;
99
99
  }
100
100
  export interface WorkflowTemplateDeclaration {
101
- appIdentifier: string;
101
+ appIdentifier?: string;
102
102
  workflows?: WorkflowTemplate[];
103
103
  }
104
104
  export interface WorkflowTemplate {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.5.4-alpha.103cd15",
2
+ "version": "3.5.4-alpha.2a94b1c",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -3066,14 +3066,16 @@
3066
3066
  },
3067
3067
  "workflow-templates:load": {
3068
3068
  "id": "workflow-templates:load",
3069
- "description": "Loads your workflow from a local file",
3069
+ "description": "Load workflow templates from a file or scan a directory for per-app workflow files",
3070
3070
  "strict": true,
3071
3071
  "pluginName": "@contrail/cli",
3072
3072
  "pluginAlias": "@contrail/cli",
3073
3073
  "pluginType": "core",
3074
3074
  "aliases": [],
3075
3075
  "examples": [
3076
- "$ contrail workflow-templates load <FILE_LOCATION>\n"
3076
+ "$ contrail workflow-templates load <FILE_LOCATION>",
3077
+ "$ contrail workflow-templates load",
3078
+ "$ contrail workflow-templates load --dir ./workflows"
3077
3079
  ],
3078
3080
  "flags": {
3079
3081
  "logLevel": {
@@ -3102,13 +3104,22 @@
3102
3104
  "false"
3103
3105
  ],
3104
3106
  "default": "true"
3107
+ },
3108
+ "dir": {
3109
+ "name": "dir",
3110
+ "type": "option",
3111
+ "char": "d",
3112
+ "description": "Directory to scan for workflow files when no file argument is given",
3113
+ "required": false,
3114
+ "multiple": false,
3115
+ "default": "."
3105
3116
  }
3106
3117
  },
3107
3118
  "args": {
3108
3119
  "fileLocation": {
3109
3120
  "name": "fileLocation",
3110
- "description": "The workflow template file to load",
3111
- "required": true
3121
+ "description": "A specific workflow template file to load",
3122
+ "required": false
3112
3123
  }
3113
3124
  }
3114
3125
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "3.5.4-alpha.103cd15",
3
+ "version": "3.5.4-alpha.2a94b1c",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",