@contrail/cli 3.5.3-alpha.776a5c5 → 3.5.3-alpha.818a5c0

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.3-alpha.776a5c5 linux-x64 node-v24.16.0
20
+ @contrail/cli/3.5.3-alpha.818a5c0 linux-x64 node-v24.19.0
21
21
  $ contrail --help [COMMAND]
22
22
  USAGE
23
23
  $ contrail COMMAND
@@ -61,6 +61,8 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
61
61
  * [`contrail load custom-entity DATAFILE CONFIGFILE`](#contrail-load-custom-entity-datafile-configfile)
62
62
  * [`contrail load line-sheet DATAFILE CONFIGFILE`](#contrail-load-line-sheet-datafile-configfile)
63
63
  * [`contrail load upload-and-load INCOMINGFILE CONFIGFILENAME`](#contrail-load-upload-and-load-incomingfile-configfilename)
64
+ * [`contrail org-config export`](#contrail-org-config-export)
65
+ * [`contrail org-config import ORGCONFIGFILE`](#contrail-org-config-import-orgconfigfile)
64
66
  * [`contrail projects export PROJECTNAME`](#contrail-projects-export-projectname)
65
67
  * [`contrail projects list`](#contrail-projects-list)
66
68
  * [`contrail projects load TEMPLATEFILELOCATION`](#contrail-projects-load-templatefilelocation)
@@ -777,6 +779,53 @@ EXAMPLES
777
779
  $ contrail load-processor upload-and-load <File Path> <Config Path>
778
780
  ```
779
781
 
782
+ ## `contrail org-config export`
783
+
784
+ Export the org config (branding, sorting, and other org-level settings).
785
+
786
+ ```
787
+ USAGE
788
+ $ contrail org-config export [-l error|warn|info|debug] [-e true|false] [-f <value>] [--overwrite]
789
+
790
+ FLAGS
791
+ -e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
792
+ <options: true|false>
793
+ -f, --outFile=<value> [default: org-config.yml] The location for the file to be saved
794
+ -l, --logLevel=<option> The Log Level
795
+ <options: error|warn|info|debug>
796
+ --overwrite Replaces existing files if they exist
797
+
798
+ DESCRIPTION
799
+ Export the org config (branding, sorting, and other org-level settings).
800
+
801
+ EXAMPLES
802
+ $ contrail org-config export
803
+ ```
804
+
805
+ ## `contrail org-config import ORGCONFIGFILE`
806
+
807
+ Import the org config from an org-config.yml file
808
+
809
+ ```
810
+ USAGE
811
+ $ contrail org-config import ORGCONFIGFILE [-l error|warn|info|debug] [-e true|false]
812
+
813
+ ARGUMENTS
814
+ ORGCONFIGFILE The .yml file containing the org config
815
+
816
+ FLAGS
817
+ -e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
818
+ <options: true|false>
819
+ -l, --logLevel=<option> The Log Level
820
+ <options: error|warn|info|debug>
821
+
822
+ DESCRIPTION
823
+ Import the org config from an org-config.yml file
824
+
825
+ EXAMPLES
826
+ $ contrail org-config import <ORG_CONFIG_FILE>
827
+ ```
828
+
780
829
  ## `contrail projects export PROJECTNAME`
781
830
 
782
831
  Export a project.
@@ -1611,31 +1660,25 @@ EXAMPLES
1611
1660
 
1612
1661
  ## `contrail workflow-templates export`
1613
1662
 
1614
- Export all workflows in the org. By default exports one file per app to the current directory.
1663
+ Export all workflows in the org.
1615
1664
 
1616
1665
  ```
1617
1666
  USAGE
1618
- $ contrail workflow-templates export [-l error|warn|info|debug] [-e true|false] [-f <value>] [-d <value>]
1619
- [--overwrite]
1667
+ $ contrail workflow-templates export [-l error|warn|info|debug] [-e true|false] [-f <value>] [--overwrite]
1620
1668
 
1621
1669
  FLAGS
1622
- -d, --dir=<value> [default: .] Directory to write per-app workflow files
1623
1670
  -e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
1624
1671
  <options: true|false>
1625
- -f, --outFile=<value> Export all workflows to a single file at this path (overrides per-app export)
1672
+ -f, --outFile=<value> [default: workflows.yml] The location for the file to be saved
1626
1673
  -l, --logLevel=<option> The Log Level
1627
1674
  <options: error|warn|info|debug>
1628
1675
  --overwrite Replaces existing files if they exist
1629
1676
 
1630
1677
  DESCRIPTION
1631
- Export all workflows in the org. By default exports one file per app to the current directory.
1678
+ Export all workflows in the org.
1632
1679
 
1633
1680
  EXAMPLES
1634
1681
  $ contrail workflow-templates export
1635
-
1636
- $ contrail workflow-templates export --dir ./workflows
1637
-
1638
- $ contrail workflow-templates export --outFile workflows.yml
1639
1682
  ```
1640
1683
 
1641
1684
  ## `contrail workflow-templates list`
@@ -0,0 +1,3 @@
1
+ export declare function getOrgConfigs(options?: any): Promise<any[]>;
2
+ export declare function updateOrgConfig(id: string, changes: any): Promise<any>;
3
+ export declare function createOrgConfig(orgConfig: any): Promise<any>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOrgConfig = exports.updateOrgConfig = exports.getOrgConfigs = void 0;
4
+ const sdk_1 = require("@contrail/sdk");
5
+ async function getOrgConfigs(options) {
6
+ return new sdk_1.Entities().get({
7
+ entityName: 'org-config',
8
+ ...options,
9
+ });
10
+ }
11
+ exports.getOrgConfigs = getOrgConfigs;
12
+ async function updateOrgConfig(id, changes) {
13
+ return new sdk_1.Entities().update({
14
+ entityName: 'org-config',
15
+ id,
16
+ object: changes,
17
+ });
18
+ }
19
+ exports.updateOrgConfig = updateOrgConfig;
20
+ async function createOrgConfig(orgConfig) {
21
+ return new sdk_1.Entities().create({
22
+ entityName: 'org-config',
23
+ object: orgConfig,
24
+ });
25
+ }
26
+ exports.createOrgConfig = createOrgConfig;
@@ -6,6 +6,7 @@ const core_1 = require("@oclif/core");
6
6
  const getAll_1 = require("../types/getAll");
7
7
  const export_1 = require("../users/export");
8
8
  const export_2 = require("../groups/export");
9
+ const export_3 = require("../org-config/export");
9
10
  const basecommand_1 = require("../../basecommand");
10
11
  class ExportInstance extends basecommand_1.BaseCommand {
11
12
  static description = 'Exports an data of an instance including types and users';
@@ -32,6 +33,7 @@ class ExportInstance extends basecommand_1.BaseCommand {
32
33
  await (0, getAll_1.getAll)(this.flags.outDir, this.flags.overwrite);
33
34
  await (0, export_1.exportUsers)(path.join(this.flags.outDir, 'users.yml'), this.flags.overwrite);
34
35
  await (0, export_2.exportGroups)(path.join(this.flags.outDir, 'groups.yml'), this.flags.overwrite);
36
+ await (0, export_3.exportOrgConfig)(path.join(this.flags.outDir, 'org-config.yml'), this.flags.overwrite);
35
37
  }
36
38
  }
37
39
  exports.default = ExportInstance;
@@ -8,6 +8,7 @@ const import_1 = require("../users/import");
8
8
  const import_2 = require("../groups/import");
9
9
  const uploadTypePropertyPolicies_1 = require("../types/uploadTypePropertyPolicies");
10
10
  const uploadTypePolicies_1 = require("../types/uploadTypePolicies");
11
+ const import_3 = require("../org-config/import");
11
12
  const basecommand_1 = require("../../basecommand");
12
13
  class ImportInstance extends basecommand_1.BaseCommand {
13
14
  static description = 'Import the data to an instance, including types and users';
@@ -30,6 +31,7 @@ class ImportInstance extends basecommand_1.BaseCommand {
30
31
  await (0, import_2.uploadGroups)(path.join(this.flags.dir, 'groups.yml'));
31
32
  await (0, uploadTypePropertyPolicies_1.uploadTypePropertyPolicies)(this.flags.dir);
32
33
  await (0, uploadTypePolicies_1.uploadTypePolicies)(this.flags.dir);
34
+ await (0, import_3.uploadOrgConfig)(path.join(this.flags.dir, 'org-config.yml'));
33
35
  }
34
36
  }
35
37
  exports.default = ImportInstance;
@@ -0,0 +1,14 @@
1
+ import { BaseCommand } from '../../basecommand';
2
+ export declare const DEFAULT_FILE_LOCATION = "org-config.yml";
3
+ export default class ExportOrgConfig extends BaseCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ outFile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
14
+ export declare function exportOrgConfig(fileLocation: string, overwrite: boolean): Promise<void>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exportOrgConfig = exports.DEFAULT_FILE_LOCATION = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path = tslib_1.__importStar(require("path"));
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const fs_1 = tslib_1.__importDefault(require("fs"));
8
+ const login_1 = require("../../auth/login");
9
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
10
+ const core_1 = require("@oclif/core");
11
+ const file_helpers_1 = require("../../helpers/file-helpers");
12
+ const org_config_1 = require("../../api/org-config");
13
+ const basecommand_1 = require("../../basecommand");
14
+ exports.DEFAULT_FILE_LOCATION = 'org-config.yml';
15
+ const ORG_SPECIFIC_FIELDS = [
16
+ 'id',
17
+ 'orgId',
18
+ 'createdOn',
19
+ 'updatedOn',
20
+ 'createdById',
21
+ 'updatedById',
22
+ 'createdBy',
23
+ 'updatedBy',
24
+ ];
25
+ class ExportOrgConfig extends basecommand_1.BaseCommand {
26
+ static description = 'Export the org config (branding, sorting, and other org-level settings).';
27
+ static examples = [
28
+ `$ contrail org-config export
29
+ `,
30
+ ];
31
+ static flags = {
32
+ ...basecommand_1.BaseCommand.baseFlags,
33
+ outFile: core_1.Flags.string({
34
+ char: 'f',
35
+ description: 'The location for the file to be saved',
36
+ required: false,
37
+ default: exports.DEFAULT_FILE_LOCATION,
38
+ }),
39
+ overwrite: core_1.Flags.boolean({
40
+ description: 'Replaces existing files if they exist',
41
+ required: false,
42
+ default: false,
43
+ }),
44
+ };
45
+ async run() {
46
+ try {
47
+ await (0, login_1.authUser)();
48
+ this.log(`${chalk_1.default.blue.bold('START')} Getting Org Config.`);
49
+ await exportOrgConfig(this.flags.outFile ?? exports.DEFAULT_FILE_LOCATION, this.flags.overwrite);
50
+ this.log(`${chalk_1.default.yellow.bold('ORG CONFIG')} Done`);
51
+ }
52
+ catch (e) {
53
+ this.log(`${chalk_1.default.red.bold('FAIL')} Org Config download Failed. ${e}`);
54
+ return;
55
+ }
56
+ this.log(`${chalk_1.default.green.bold('COMPLETE')} Org Config download Complete.`);
57
+ }
58
+ }
59
+ exports.default = ExportOrgConfig;
60
+ async function exportOrgConfig(fileLocation, overwrite) {
61
+ const orgConfigs = await (0, org_config_1.getOrgConfigs)();
62
+ if (!Array.isArray(orgConfigs) || orgConfigs.length === 0) {
63
+ return;
64
+ }
65
+ const orgConfig = { ...orgConfigs[0] };
66
+ for (const field of ORG_SPECIFIC_FIELDS) {
67
+ delete orgConfig[field];
68
+ }
69
+ await saveData(orgConfig, fileLocation, overwrite);
70
+ }
71
+ exports.exportOrgConfig = exportOrgConfig;
72
+ async function saveData(data, fileLocation, overwrite) {
73
+ const yamlStr = js_yaml_1.default.dump(data);
74
+ const CURRENT_DIR = process.cwd();
75
+ const pathToWrite = path.resolve(path.join(CURRENT_DIR, fileLocation));
76
+ if (fs_1.default.existsSync(pathToWrite)) {
77
+ await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
78
+ }
79
+ fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
80
+ }
@@ -0,0 +1,14 @@
1
+ import { BaseCommand } from '../../basecommand';
2
+ export default class ImportOrgConfig extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ };
9
+ static args: {
10
+ orgConfigFile: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
14
+ export declare function uploadOrgConfig(fileLocation: string): Promise<void>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadOrgConfig = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path = tslib_1.__importStar(require("path"));
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const fs_1 = tslib_1.__importDefault(require("fs"));
8
+ const login_1 = require("../../auth/login");
9
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
10
+ const core_1 = require("@oclif/core");
11
+ const org_config_1 = require("../../api/org-config");
12
+ const basecommand_1 = require("../../basecommand");
13
+ class ImportOrgConfig extends basecommand_1.BaseCommand {
14
+ static description = 'Import the org config from an org-config.yml file';
15
+ static examples = [
16
+ `$ contrail org-config import <ORG_CONFIG_FILE>
17
+ `,
18
+ ];
19
+ static flags = {
20
+ ...basecommand_1.BaseCommand.baseFlags,
21
+ };
22
+ static args = {
23
+ orgConfigFile: core_1.Args.string({
24
+ description: 'The .yml file containing the org config',
25
+ required: true,
26
+ }),
27
+ };
28
+ async run() {
29
+ try {
30
+ await (0, login_1.authUser)();
31
+ this.log(`${chalk_1.default.blue.bold('START')} Uploading Org Config.`);
32
+ this.log(`${chalk_1.default.yellow.bold('ORG CONFIG')} Uploading`);
33
+ await uploadOrgConfig(this.args.orgConfigFile);
34
+ this.log(`${chalk_1.default.yellow.bold('ORG CONFIG')} Uploaded`);
35
+ }
36
+ catch (e) {
37
+ this.log(`${chalk_1.default.red.bold('FAIL')} Org Config Upload Failed. ${e}`);
38
+ return;
39
+ }
40
+ this.log(`${chalk_1.default.green.bold('COMPLETE')} Org Config Upload Complete.`);
41
+ }
42
+ }
43
+ exports.default = ImportOrgConfig;
44
+ function getOrgConfigFile(fileLocation) {
45
+ const CURRENT_DIR = process.cwd();
46
+ try {
47
+ const fullPath = path.join(CURRENT_DIR, fileLocation);
48
+ const doc = js_yaml_1.default.load(fs_1.default.readFileSync(fullPath, 'utf8'));
49
+ return doc;
50
+ }
51
+ catch (e) {
52
+ throw new Error(`ERROR PARSING YAML: ${e}`);
53
+ }
54
+ }
55
+ async function uploadOrgConfig(fileLocation) {
56
+ const CURRENT_DIR = process.cwd();
57
+ if (!fs_1.default.existsSync(path.join(CURRENT_DIR, fileLocation))) {
58
+ console.log(`No org config file found at ${fileLocation}. Skipping.`);
59
+ return;
60
+ }
61
+ const orgConfig = getOrgConfigFile(fileLocation);
62
+ if (!orgConfig || typeof orgConfig !== 'object') {
63
+ return;
64
+ }
65
+ const existingOrgConfigs = await (0, org_config_1.getOrgConfigs)();
66
+ if (Array.isArray(existingOrgConfigs) && existingOrgConfigs.length > 0) {
67
+ await (0, org_config_1.updateOrgConfig)(existingOrgConfigs[0].id, orgConfig);
68
+ }
69
+ else {
70
+ await (0, org_config_1.createOrgConfig)(orgConfig);
71
+ }
72
+ }
73
+ exports.uploadOrgConfig = uploadOrgConfig;
@@ -5,12 +5,10 @@ export default class ExportWorkflows extends BaseCommand {
5
5
  static examples: string[];
6
6
  static flags: {
7
7
  outFile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
- dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
8
  overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
9
  alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
10
  logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
11
  };
13
12
  run(): Promise<void>;
14
13
  }
15
- export declare function exportWorkflowsByApp(outputDir: string, overwrite: boolean): Promise<void>;
16
- export declare function exportWorkflowsToFile(fileLocation: string, overwrite: boolean): Promise<void>;
14
+ export declare function exportWorkflows(fileLocation: string, overwrite: boolean): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exportWorkflowsToFile = exports.exportWorkflowsByApp = exports.DEFAULT_FILE_LOCATION = void 0;
3
+ exports.exportWorkflows = exports.DEFAULT_FILE_LOCATION = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const path = tslib_1.__importStar(require("path"));
6
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
@@ -11,30 +11,22 @@ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
11
11
  const core_1 = require("@oclif/core");
12
12
  const file_helpers_1 = require("../../helpers/file-helpers");
13
13
  const event_workflow_templates_1 = require("../../api/event-workflow-templates");
14
- const schedules_1 = require("../../api/schedules");
15
- const apps_1 = require("../../api/apps");
16
14
  const helper_1 = require("../../helpers/workflow-templates/helper");
17
15
  const basecommand_1 = require("../../basecommand");
18
16
  exports.DEFAULT_FILE_LOCATION = 'workflows.yml';
19
17
  class ExportWorkflows extends basecommand_1.BaseCommand {
20
- static description = 'Export all workflows in the org. By default exports one file per app to the current directory.';
18
+ static description = 'Export all workflows in the org.';
21
19
  static examples = [
22
- '$ contrail workflow-templates export',
23
- '$ contrail workflow-templates export --dir ./workflows',
24
- '$ contrail workflow-templates export --outFile workflows.yml',
20
+ `$ contrail workflow-templates export
21
+ `,
25
22
  ];
26
23
  static flags = {
27
24
  ...basecommand_1.BaseCommand.baseFlags,
28
25
  outFile: core_1.Flags.string({
29
26
  char: 'f',
30
- description: 'Export all workflows to a single file at this path (overrides per-app export)',
27
+ description: 'The location for the file to be saved',
31
28
  required: false,
32
- }),
33
- dir: core_1.Flags.string({
34
- char: 'd',
35
- description: 'Directory to write per-app workflow files',
36
- required: false,
37
- default: '.',
29
+ default: exports.DEFAULT_FILE_LOCATION,
38
30
  }),
39
31
  overwrite: core_1.Flags.boolean({
40
32
  description: 'Replaces existing files if they exist',
@@ -46,12 +38,7 @@ class ExportWorkflows extends basecommand_1.BaseCommand {
46
38
  try {
47
39
  await (0, login_1.authUser)();
48
40
  this.log(`${chalk_1.default.blue.bold('START')} Getting Workflows.`);
49
- if (this.flags.outFile) {
50
- await exportWorkflowsToFile(this.flags.outFile, this.flags.overwrite);
51
- }
52
- else {
53
- await exportWorkflowsByApp(this.flags.dir ?? '.', this.flags.overwrite);
54
- }
41
+ await exportWorkflows(this.flags.outFile ?? exports.DEFAULT_FILE_LOCATION, this.flags.overwrite);
55
42
  this.log(`${chalk_1.default.yellow.bold('WORKFLOWS')} Done`);
56
43
  }
57
44
  catch (e) {
@@ -62,95 +49,31 @@ class ExportWorkflows extends basecommand_1.BaseCommand {
62
49
  }
63
50
  }
64
51
  exports.default = ExportWorkflows;
65
- async function exportWorkflowsByApp(outputDir, overwrite) {
52
+ async function exportWorkflows(fileLocation, overwrite) {
66
53
  const allWorkflowsInOrg = await (0, event_workflow_templates_1.getExistingWorkflowTemplates)();
67
- const allSchedules = await (0, schedules_1.getExistingSchedules)();
68
- const installedApps = await (0, apps_1.getInstalledApps)();
69
- const appIdToIdentifier = new Map(installedApps.map((a) => [a.appId, a.app.identifier]));
70
- const workflowsByApp = new Map();
71
- const unassigned = [];
72
- for (const workflow of allWorkflowsInOrg) {
73
- let appIdentifier = workflow.supportingAppId
74
- ? appIdToIdentifier.get(workflow.supportingAppId)
75
- : undefined;
76
- // If no supportingAppId, try to extract app identifier from workflow identifier
77
- // Format: @{appIdentifier}@{randomId}:{workflowName}
78
- if (!appIdentifier && workflow.identifier) {
79
- const match = workflow.identifier.match(/^@([^@]+)@/);
80
- if (match) {
81
- // Keep the @ prefix in the appIdentifier
82
- appIdentifier = `@${match[1]}`;
83
- }
84
- }
85
- if (appIdentifier) {
86
- if (!workflowsByApp.has(appIdentifier)) {
87
- workflowsByApp.set(appIdentifier, []);
88
- }
89
- const workflows = workflowsByApp.get(appIdentifier);
90
- if (workflows) {
91
- workflows.push(workflow);
92
- }
93
- }
94
- else {
95
- unassigned.push(workflow);
96
- }
97
- }
98
- const resolvedDir = path.resolve(process.cwd(), outputDir);
99
- for (const [appIdentifier, workflows] of workflowsByApp.entries()) {
100
- const exportObj = { appIdentifier, workflows: [] };
101
- for (const workflow of workflows) {
102
- exportObj.workflows.push(await buildExportWorkflow(workflow, allSchedules));
103
- }
104
- const safeAppIdentifier = appIdentifier.replace(/[\\/]/g, '-');
105
- const filePath = path.join(resolvedDir, `workflows-${safeAppIdentifier}.yml`);
106
- await writeYamlFile(exportObj, filePath, overwrite);
107
- console.log(`${chalk_1.default.green('EXPORTED')} ${filePath}`);
108
- }
109
- if (unassigned.length > 0) {
110
- const unassignedObj = { workflows: [] };
111
- for (const workflow of unassigned) {
112
- unassignedObj.workflows.push(await buildExportWorkflow(workflow, allSchedules));
113
- }
114
- const unassignedFilePath = path.join(resolvedDir, 'workflows-unassigned.yml');
115
- await writeYamlFile(unassignedObj, unassignedFilePath, overwrite);
116
- console.log(`${chalk_1.default.yellow('EXPORTED')} ${unassignedFilePath} (unassigned workflows)`);
117
- }
118
- }
119
- exports.exportWorkflowsByApp = exportWorkflowsByApp;
120
- async function exportWorkflowsToFile(fileLocation, overwrite) {
121
- const allWorkflowsInOrg = await (0, event_workflow_templates_1.getExistingWorkflowTemplates)();
122
- const allSchedules = await (0, schedules_1.getExistingSchedules)();
123
54
  const workflowsObj = { workflows: [] };
124
55
  for (const workflow of allWorkflowsInOrg) {
125
- workflowsObj.workflows.push(await buildExportWorkflow(workflow, allSchedules));
126
- }
127
- const pathToWrite = path.resolve(process.cwd(), fileLocation);
128
- await writeYamlFile(workflowsObj, pathToWrite, overwrite);
129
- }
130
- exports.exportWorkflowsToFile = exportWorkflowsToFile;
131
- async function buildExportWorkflow(workflow, allSchedules) {
132
- const exportWorkflow = lodash_1.default.pick(workflow, [
133
- 'identifier',
134
- 'name',
135
- 'triggerKey',
136
- 'isActive',
137
- 'messageGroup',
138
- 'dynamicMessageGroupId',
139
- 'parallelWorkerCount',
140
- 'workflowDefinition',
141
- ]);
142
- const schedules = allSchedules.filter((s) => s.ownerReference === `event-workflow-template:${workflow.id}`);
143
- if (schedules.length > 0) {
144
- exportWorkflow.crons = schedules.map((s) => ({ name: s.name, cron: s.cron }));
56
+ const exportWorkflow = lodash_1.default.pick(workflow, [
57
+ 'triggerKey',
58
+ 'workflowDefinition',
59
+ 'name',
60
+ 'isActive',
61
+ 'identifier',
62
+ 'messageGroup',
63
+ 'dynamicMessageGroupId',
64
+ ]);
65
+ await (0, helper_1.populateActionIdentifiers)(exportWorkflow);
66
+ workflowsObj.workflows.push(exportWorkflow);
145
67
  }
146
- await (0, helper_1.populateActionIdentifiers)(exportWorkflow);
147
- (0, helper_1.extractShortActionKeys)(exportWorkflow);
148
- return exportWorkflow;
68
+ await saveData(workflowsObj, fileLocation, overwrite);
149
69
  }
150
- async function writeYamlFile(data, absolutePath, overwrite) {
151
- if (fs_1.default.existsSync(absolutePath)) {
152
- await (0, file_helpers_1.safeFileOverwrite)(absolutePath, overwrite);
70
+ exports.exportWorkflows = exportWorkflows;
71
+ async function saveData(data, fileLocation, overwrite) {
72
+ const yamlStr = js_yaml_1.default.dump(data);
73
+ const CURRENT_DIR = process.cwd();
74
+ const pathToWrite = path.resolve(path.join(CURRENT_DIR, fileLocation));
75
+ if (fs_1.default.existsSync(pathToWrite)) {
76
+ await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
153
77
  }
154
- fs_1.default.mkdirSync(path.dirname(absolutePath), { recursive: true });
155
- fs_1.default.writeFileSync(absolutePath, js_yaml_1.default.dump(data), 'utf8');
78
+ fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
156
79
  }
@@ -18,4 +18,3 @@ export declare class WorkflowTemplateDeployer {
18
18
  export declare function deleteWorkflowTemplates(): Promise<void>;
19
19
  export declare function localDeployWorkflowTemplate(saveFileLocation: string): Promise<void>;
20
20
  export declare function populateActionIdentifiers(workflowTemplate: WorkflowTemplate): Promise<void>;
21
- export declare function extractShortActionKeys(workflowTemplate: WorkflowTemplate): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractShortActionKeys = exports.populateActionIdentifiers = exports.localDeployWorkflowTemplate = exports.deleteWorkflowTemplates = exports.WorkflowTemplateDeployer = exports.getActionByIdentifier = exports.getWorkflowTemplateIdentifier = exports.LocalWorkflowTemplateDeployer = void 0;
3
+ exports.populateActionIdentifiers = exports.localDeployWorkflowTemplate = exports.deleteWorkflowTemplates = exports.WorkflowTemplateDeployer = exports.getActionByIdentifier = exports.getWorkflowTemplateIdentifier = exports.LocalWorkflowTemplateDeployer = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const util_1 = require("@contrail/util");
6
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
@@ -44,8 +44,6 @@ class LocalWorkflowTemplateDeployer {
44
44
  isActive: workflowTemplate.isActive,
45
45
  supportingAppId: workflowTemplate.supportingAppId,
46
46
  messageGroupId: workflowTemplate.messageGroupId,
47
- messageGroup: workflowTemplate.messageGroup,
48
- dynamicMessageGroupId: workflowTemplate.dynamicMessageGroupId,
49
47
  parallelWorkerCount: workflowTemplate.parallelWorkerCount,
50
48
  };
51
49
  const newWorkflowTemplate = await (0, event_workflow_templates_1.createWorkflowTemplate)(newObject);
@@ -57,11 +55,8 @@ class LocalWorkflowTemplateDeployer {
57
55
  }
58
56
  async populateActionIds(workflowTemplate, workflowKey, appIdentifier) {
59
57
  const installedApps = await (0, apps_1.getInstalledApps)();
60
- const appOrg = installedApps.find((x) => x.app?.identifier === appIdentifier);
58
+ const appOrg = installedApps.find((x) => x.app.identifier === appIdentifier);
61
59
  logger_1.default.info('workflow template:', JSON.stringify(workflowTemplate, null, 2));
62
- if (!appOrg) {
63
- throw new Error(`Could not find installed app with identifier "${appIdentifier}". Make sure the app is installed in this org before importing workflows.`);
64
- }
65
60
  if (!workflowTemplate?.workflowDefinition?.paths) {
66
61
  return;
67
62
  }
@@ -91,7 +86,7 @@ class LocalWorkflowTemplateDeployer {
91
86
  }
92
87
  }
93
88
  async createWorkflowSchedule(workflowTemplate, workflowId) {
94
- if (!workflowTemplate?.crons?.length) {
89
+ if (!workflowTemplate?.crons?.length || !workflowTemplate.id) {
95
90
  return;
96
91
  }
97
92
  const crons = [];
@@ -288,21 +283,3 @@ async function populateActionIdentifiers(workflowTemplate) {
288
283
  }
289
284
  }
290
285
  exports.populateActionIdentifiers = populateActionIdentifiers;
291
- function extractShortActionKeys(workflowTemplate) {
292
- if (!workflowTemplate?.workflowDefinition?.paths) {
293
- return;
294
- }
295
- for (const wfPath of workflowTemplate.workflowDefinition.paths) {
296
- if (!wfPath?.actionDefinitionConfigs) {
297
- continue;
298
- }
299
- for (const actionConfig of wfPath.actionDefinitionConfigs) {
300
- if (actionConfig.action?.includes(':')) {
301
- // Full identifier format: "app-id@version:action-name" -> "action-name"
302
- actionConfig.action = actionConfig.action.split(':').pop();
303
- }
304
- delete actionConfig.identifier;
305
- }
306
- }
307
- }
308
- exports.extractShortActionKeys = extractShortActionKeys;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.5.3-alpha.776a5c5",
2
+ "version": "3.5.3-alpha.818a5c0",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -1239,6 +1239,112 @@
1239
1239
  }
1240
1240
  }
1241
1241
  },
1242
+ "org-config:export": {
1243
+ "id": "org-config:export",
1244
+ "description": "Export the org config (branding, sorting, and other org-level settings).",
1245
+ "strict": true,
1246
+ "pluginName": "@contrail/cli",
1247
+ "pluginAlias": "@contrail/cli",
1248
+ "pluginType": "core",
1249
+ "aliases": [],
1250
+ "examples": [
1251
+ "$ contrail org-config export\n"
1252
+ ],
1253
+ "flags": {
1254
+ "logLevel": {
1255
+ "name": "logLevel",
1256
+ "type": "option",
1257
+ "char": "l",
1258
+ "description": "The Log Level",
1259
+ "required": false,
1260
+ "multiple": false,
1261
+ "options": [
1262
+ "error",
1263
+ "warn",
1264
+ "info",
1265
+ "debug"
1266
+ ]
1267
+ },
1268
+ "alwaysConfirmEnv": {
1269
+ "name": "alwaysConfirmEnv",
1270
+ "type": "option",
1271
+ "char": "e",
1272
+ "description": "The Environment variables",
1273
+ "required": false,
1274
+ "multiple": false,
1275
+ "options": [
1276
+ "true",
1277
+ "false"
1278
+ ],
1279
+ "default": "true"
1280
+ },
1281
+ "outFile": {
1282
+ "name": "outFile",
1283
+ "type": "option",
1284
+ "char": "f",
1285
+ "description": "The location for the file to be saved",
1286
+ "required": false,
1287
+ "multiple": false,
1288
+ "default": "org-config.yml"
1289
+ },
1290
+ "overwrite": {
1291
+ "name": "overwrite",
1292
+ "type": "boolean",
1293
+ "description": "Replaces existing files if they exist",
1294
+ "required": false,
1295
+ "allowNo": false
1296
+ }
1297
+ },
1298
+ "args": {}
1299
+ },
1300
+ "org-config:import": {
1301
+ "id": "org-config:import",
1302
+ "description": "Import the org config from an org-config.yml file",
1303
+ "strict": true,
1304
+ "pluginName": "@contrail/cli",
1305
+ "pluginAlias": "@contrail/cli",
1306
+ "pluginType": "core",
1307
+ "aliases": [],
1308
+ "examples": [
1309
+ "$ contrail org-config import <ORG_CONFIG_FILE>\n"
1310
+ ],
1311
+ "flags": {
1312
+ "logLevel": {
1313
+ "name": "logLevel",
1314
+ "type": "option",
1315
+ "char": "l",
1316
+ "description": "The Log Level",
1317
+ "required": false,
1318
+ "multiple": false,
1319
+ "options": [
1320
+ "error",
1321
+ "warn",
1322
+ "info",
1323
+ "debug"
1324
+ ]
1325
+ },
1326
+ "alwaysConfirmEnv": {
1327
+ "name": "alwaysConfirmEnv",
1328
+ "type": "option",
1329
+ "char": "e",
1330
+ "description": "The Environment variables",
1331
+ "required": false,
1332
+ "multiple": false,
1333
+ "options": [
1334
+ "true",
1335
+ "false"
1336
+ ],
1337
+ "default": "true"
1338
+ }
1339
+ },
1340
+ "args": {
1341
+ "orgConfigFile": {
1342
+ "name": "orgConfigFile",
1343
+ "description": "The .yml file containing the org config",
1344
+ "required": true
1345
+ }
1346
+ }
1347
+ },
1242
1348
  "projects:export": {
1243
1349
  "id": "projects:export",
1244
1350
  "description": "Export a project.",
@@ -2956,16 +3062,14 @@
2956
3062
  },
2957
3063
  "workflow-templates:export": {
2958
3064
  "id": "workflow-templates:export",
2959
- "description": "Export all workflows in the org. By default exports one file per app to the current directory.",
3065
+ "description": "Export all workflows in the org.",
2960
3066
  "strict": true,
2961
3067
  "pluginName": "@contrail/cli",
2962
3068
  "pluginAlias": "@contrail/cli",
2963
3069
  "pluginType": "core",
2964
3070
  "aliases": [],
2965
3071
  "examples": [
2966
- "$ contrail workflow-templates export",
2967
- "$ contrail workflow-templates export --dir ./workflows",
2968
- "$ contrail workflow-templates export --outFile workflows.yml"
3072
+ "$ contrail workflow-templates export\n"
2969
3073
  ],
2970
3074
  "flags": {
2971
3075
  "logLevel": {
@@ -2999,18 +3103,10 @@
2999
3103
  "name": "outFile",
3000
3104
  "type": "option",
3001
3105
  "char": "f",
3002
- "description": "Export all workflows to a single file at this path (overrides per-app export)",
3003
- "required": false,
3004
- "multiple": false
3005
- },
3006
- "dir": {
3007
- "name": "dir",
3008
- "type": "option",
3009
- "char": "d",
3010
- "description": "Directory to write per-app workflow files",
3106
+ "description": "The location for the file to be saved",
3011
3107
  "required": false,
3012
3108
  "multiple": false,
3013
- "default": "."
3109
+ "default": "workflows.yml"
3014
3110
  },
3015
3111
  "overwrite": {
3016
3112
  "name": "overwrite",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "3.5.3-alpha.776a5c5",
3
+ "version": "3.5.3-alpha.818a5c0",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",