@contrail/cli 3.5.3-alpha.8e9fe43 → 3.5.3-alpha.b5668f4
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.
|
|
20
|
+
@contrail/cli/3.5.3-alpha.b5668f4 linux-x64 node-v24.16.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -78,7 +78,8 @@ async function exportWorkflowsByApp(outputDir, overwrite) {
|
|
|
78
78
|
if (!appIdentifier && workflow.identifier) {
|
|
79
79
|
const match = workflow.identifier.match(/^@([^@]+)@/);
|
|
80
80
|
if (match) {
|
|
81
|
-
|
|
81
|
+
// Keep the @ prefix in the appIdentifier
|
|
82
|
+
appIdentifier = `@${match[1]}`;
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
if (appIdentifier) {
|
|
@@ -100,18 +101,13 @@ async function exportWorkflowsByApp(outputDir, overwrite) {
|
|
|
100
101
|
for (const workflow of workflows) {
|
|
101
102
|
exportObj.workflows.push(await buildExportWorkflow(workflow, allSchedules));
|
|
102
103
|
}
|
|
103
|
-
const
|
|
104
|
+
const safeAppIdentifier = appIdentifier.replace(/[\\/]/g, '-');
|
|
105
|
+
const filePath = path.join(resolvedDir, `workflows-${safeAppIdentifier}.yml`);
|
|
104
106
|
await writeYamlFile(exportObj, filePath, overwrite);
|
|
105
107
|
console.log(`${chalk_1.default.green('EXPORTED')} ${filePath}`);
|
|
106
108
|
}
|
|
107
109
|
if (unassigned.length > 0) {
|
|
108
|
-
|
|
109
|
-
for (const workflow of unassigned) {
|
|
110
|
-
exportObj.workflows.push(await buildExportWorkflow(workflow, allSchedules));
|
|
111
|
-
}
|
|
112
|
-
const filePath = path.join(resolvedDir, exports.DEFAULT_FILE_LOCATION);
|
|
113
|
-
await writeYamlFile(exportObj, filePath, overwrite);
|
|
114
|
-
console.log(`${chalk_1.default.green('EXPORTED')} ${filePath}`);
|
|
110
|
+
console.log(`${chalk_1.default.yellow('SKIPPED')} ${unassigned.length} workflows could not be associated with an app. Re-run with --outFile to export them to a single file.`);
|
|
115
111
|
}
|
|
116
112
|
}
|
|
117
113
|
exports.exportWorkflowsByApp = exportWorkflowsByApp;
|
|
@@ -149,5 +145,6 @@ async function writeYamlFile(data, absolutePath, overwrite) {
|
|
|
149
145
|
if (fs_1.default.existsSync(absolutePath)) {
|
|
150
146
|
await (0, file_helpers_1.safeFileOverwrite)(absolutePath, overwrite);
|
|
151
147
|
}
|
|
148
|
+
fs_1.default.mkdirSync(path.dirname(absolutePath), { recursive: true });
|
|
152
149
|
fs_1.default.writeFileSync(absolutePath, js_yaml_1.default.dump(data), 'utf8');
|
|
153
150
|
}
|
|
@@ -20,7 +20,6 @@ class LocalWorkflowTemplateDeployer {
|
|
|
20
20
|
const existingWorkflows = await (0, event_workflow_templates_1.getExistingWorkflowTemplates)();
|
|
21
21
|
// UPSERT / DELETE BASED ON WORKFLOW TEMPLATES IDENTIFIER
|
|
22
22
|
logger_1.default.info(`${chalk_1.default.yellow.bold('WORKFLOW TEMPLATES')} Deploying workflow templates.`);
|
|
23
|
-
logger_1.default.info(wtDeclaration);
|
|
24
23
|
for (const workflowKey of Object.keys(wtDeclaration.workflows)) {
|
|
25
24
|
await this.deployWorkflowTemplate(wtDeclaration.workflows[workflowKey], existingWorkflows, wtDeclaration.appIdentifier);
|
|
26
25
|
}
|
|
@@ -35,14 +34,14 @@ class LocalWorkflowTemplateDeployer {
|
|
|
35
34
|
return await this.createNewWorkflowTemplate(identifier, workflow, appIdentifier);
|
|
36
35
|
}
|
|
37
36
|
async createNewWorkflowTemplate(workflowKey, workflowTemplate, appIdentifier) {
|
|
38
|
-
await this.populateActionIds(workflowTemplate, workflowKey, appIdentifier);
|
|
37
|
+
const resolvedAppId = await this.populateActionIds(workflowTemplate, workflowKey, appIdentifier);
|
|
39
38
|
const newObject = {
|
|
40
39
|
identifier: getWorkflowTemplateIdentifier(workflowTemplate),
|
|
41
40
|
name: workflowTemplate.name,
|
|
42
41
|
triggerKey: workflowTemplate.triggerKey,
|
|
43
42
|
workflowDefinition: workflowTemplate.workflowDefinition,
|
|
44
43
|
isActive: workflowTemplate.isActive,
|
|
45
|
-
supportingAppId: workflowTemplate.supportingAppId,
|
|
44
|
+
supportingAppId: resolvedAppId ?? workflowTemplate.supportingAppId,
|
|
46
45
|
messageGroupId: workflowTemplate.messageGroupId,
|
|
47
46
|
messageGroup: workflowTemplate.messageGroup,
|
|
48
47
|
dynamicMessageGroupId: workflowTemplate.dynamicMessageGroupId,
|
|
@@ -57,10 +56,12 @@ class LocalWorkflowTemplateDeployer {
|
|
|
57
56
|
}
|
|
58
57
|
async populateActionIds(workflowTemplate, workflowKey, appIdentifier) {
|
|
59
58
|
const installedApps = await (0, apps_1.getInstalledApps)();
|
|
60
|
-
const appOrg = installedApps.find((x) => x.app
|
|
61
|
-
|
|
59
|
+
const appOrg = installedApps.find((x) => x.app?.identifier === appIdentifier);
|
|
60
|
+
if (!appOrg) {
|
|
61
|
+
throw new Error(`Could not find installed app with identifier "${appIdentifier}". Make sure the app is installed in this org before importing workflows.`);
|
|
62
|
+
}
|
|
62
63
|
if (!workflowTemplate?.workflowDefinition?.paths) {
|
|
63
|
-
return;
|
|
64
|
+
return appOrg.appId;
|
|
64
65
|
}
|
|
65
66
|
for (const path of workflowTemplate.workflowDefinition.paths) {
|
|
66
67
|
if (!path?.actionDefinitionConfigs) {
|
|
@@ -86,6 +87,7 @@ class LocalWorkflowTemplateDeployer {
|
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
}
|
|
90
|
+
return appOrg.appId;
|
|
89
91
|
}
|
|
90
92
|
async createWorkflowSchedule(workflowTemplate, workflowId) {
|
|
91
93
|
if (!workflowTemplate?.crons?.length) {
|
|
@@ -154,12 +156,13 @@ class LocalWorkflowTemplateDeployer {
|
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
158
|
async updateWorkflowTemplate(workflowKey, existingWorkflowTemplate, workflowTemplate, appIdentifier) {
|
|
157
|
-
await this.populateActionIds(workflowTemplate, workflowKey, appIdentifier);
|
|
159
|
+
const resolvedAppId = await this.populateActionIds(workflowTemplate, workflowKey, appIdentifier);
|
|
158
160
|
const updates = Object.assign(new Object(), {
|
|
159
161
|
name: workflowTemplate.name,
|
|
160
162
|
triggerKey: workflowTemplate.triggerKey,
|
|
161
163
|
builtIn: workflowTemplate.builtIn,
|
|
162
164
|
workflowDefinition: workflowTemplate.workflowDefinition,
|
|
165
|
+
supportingAppId: resolvedAppId ?? existingWorkflowTemplate.supportingAppId,
|
|
163
166
|
dynamicMessageGroupId: workflowTemplate.dynamicMessageGroupId ?? existingWorkflowTemplate.dynamicMessageGroupId,
|
|
164
167
|
parallelWorkerCount: workflowTemplate.parallelWorkerCount ?? existingWorkflowTemplate.parallelWorkerCount,
|
|
165
168
|
});
|
package/oclif.manifest.json
CHANGED