@camunda8/cli 2.8.0-alpha.3 → 2.8.0-alpha.5
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/dist/commands/run.d.ts +8 -8
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +60 -60
- package/dist/commands/run.js.map +1 -1
- package/package.json +3 -3
package/dist/commands/run.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Run command
|
|
2
|
+
* Run command — deploy a BPMN file and start a process instance in one step.
|
|
3
|
+
*
|
|
4
|
+
* Per #288, the body lives directly in the `defineCommand` handler:
|
|
5
|
+
* dry-run preview via the framework's `dryRun()` helper, validation
|
|
6
|
+
* up-front, and `throw` on every error path so the framework's
|
|
7
|
+
* `handleCommandError` wrapper owns process termination.
|
|
3
8
|
*/
|
|
4
9
|
/**
|
|
5
|
-
*
|
|
10
|
+
* Side-effectful: deploys a BPMN file and creates a process instance,
|
|
11
|
+
* logging progress inline. Self-rendering, so returns `{ kind: "none" }`.
|
|
6
12
|
*/
|
|
7
|
-
export declare function run(path: string, options: {
|
|
8
|
-
profile?: string;
|
|
9
|
-
variables?: string;
|
|
10
|
-
force?: boolean;
|
|
11
|
-
}): Promise<void>;
|
|
12
|
-
/** Side-effectful: deploys a file and creates a process instance, logging progress inline. */
|
|
13
13
|
export declare const runCommand: import("../command-framework.ts").CommandHandler<"run", "">;
|
|
14
14
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsBH;;;GAGG;AACH,eAAO,MAAM,UAAU,6DA2ErB,CAAC"}
|
package/dist/commands/run.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Run command
|
|
2
|
+
* Run command — deploy a BPMN file and start a process instance in one step.
|
|
3
|
+
*
|
|
4
|
+
* Per #288, the body lives directly in the `defineCommand` handler:
|
|
5
|
+
* dry-run preview via the framework's `dryRun()` helper, validation
|
|
6
|
+
* up-front, and `throw` on every error path so the framework's
|
|
7
|
+
* `handleCommandError` wrapper owns process termination.
|
|
3
8
|
*/
|
|
4
9
|
import { readFileSync } from "node:fs";
|
|
5
10
|
import { basename, extname } from "node:path";
|
|
6
11
|
import { ProcessDefinitionId, TenantId, } from "@camunda8/orchestration-cluster-api";
|
|
7
|
-
import {
|
|
8
|
-
import { defineCommand } from "../command-framework.js";
|
|
12
|
+
import { defineCommand, dryRun } from "../command-framework.js";
|
|
9
13
|
import { resolveTenantId } from "../config.js";
|
|
10
|
-
import { handleCommandError } from "../errors.js";
|
|
11
|
-
import { getLogger } from "../logger.js";
|
|
12
14
|
import { DEPLOYABLE_EXTENSIONS } from "./resource-extensions.js";
|
|
13
15
|
/**
|
|
14
|
-
* Extract process ID from BPMN file
|
|
16
|
+
* Extract process ID from BPMN file content.
|
|
15
17
|
*/
|
|
16
18
|
function extractProcessId(bpmnContent) {
|
|
17
19
|
const match = bpmnContent.match(/process[^>]+id="([^"]+)"/);
|
|
18
20
|
return match ? match[1] : null;
|
|
19
21
|
}
|
|
22
|
+
// ─── defineCommand ───────────────────────────────────────────────────────────
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
24
|
+
* Side-effectful: deploys a BPMN file and creates a process instance,
|
|
25
|
+
* logging progress inline. Self-rendering, so returns `{ kind: "none" }`.
|
|
22
26
|
*/
|
|
23
|
-
export
|
|
24
|
-
|
|
27
|
+
export const runCommand = defineCommand("run", "", async (ctx, flags) => {
|
|
28
|
+
const path = ctx.resource;
|
|
29
|
+
// Dry-run preview comes first, mirroring the pre-#288 order pinned by
|
|
30
|
+
// `tests/unit/form-topology-run-behaviour.test.ts`. The body shape
|
|
31
|
+
// `{ path, variables }` is part of that contract.
|
|
32
|
+
const dr = dryRun({
|
|
25
33
|
command: "run",
|
|
26
34
|
method: "POST",
|
|
27
35
|
endpoint: "/deployments + /process-instances",
|
|
28
|
-
profile:
|
|
29
|
-
body: { path, variables:
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Validate file extension unless --force is set
|
|
36
|
+
profile: ctx.profile,
|
|
37
|
+
body: { path, variables: flags.variables },
|
|
38
|
+
});
|
|
39
|
+
if (dr)
|
|
40
|
+
return dr;
|
|
41
|
+
// Validate file extension unless --force is set.
|
|
34
42
|
const ext = extname(path);
|
|
35
|
-
if (!
|
|
43
|
+
if (!flags.force && ext && !DEPLOYABLE_EXTENSIONS.includes(ext)) {
|
|
36
44
|
throw new Error(`Unsupported file extension "${ext}". Use --force to deploy any file type.`);
|
|
37
45
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
// Parse --variables up-front, before any I/O. Pre-#288 this happened
|
|
47
|
+
// after the deploy network call, which made the bad-JSON path
|
|
48
|
+
// untestable in unit tests and wasted a deploy round-trip on a
|
|
49
|
+
// user-fixable input error. Validate at the boundary, where it
|
|
50
|
+
// belongs.
|
|
51
|
+
let variables;
|
|
52
|
+
if (flags.variables !== undefined) {
|
|
53
|
+
try {
|
|
54
|
+
variables = JSON.parse(flags.variables);
|
|
46
55
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const fileName = basename(path) || "process.bpmn";
|
|
50
|
-
const deployResult = await client.createDeployment({
|
|
51
|
-
tenantId: TenantId.assumeExists(tenantId),
|
|
52
|
-
resources: [
|
|
53
|
-
new File([Buffer.from(content)], fileName, { type: "application/xml" }),
|
|
54
|
-
],
|
|
55
|
-
});
|
|
56
|
-
logger.success("Deployment successful", deployResult.deploymentKey.toString());
|
|
57
|
-
// Create process instance
|
|
58
|
-
logger.info(`Creating process instance for ${processId}...`);
|
|
59
|
-
let variables;
|
|
60
|
-
if (options.variables) {
|
|
61
|
-
try {
|
|
62
|
-
variables = JSON.parse(options.variables);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
handleCommandError(logger, "Invalid JSON for variables", error);
|
|
66
|
-
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new Error(`Invalid JSON for variables: ${error instanceof Error ? error.message : String(error)}`);
|
|
67
58
|
}
|
|
68
|
-
const createResult = await client.createProcessInstance({
|
|
69
|
-
processDefinitionId: ProcessDefinitionId.assumeExists(processId),
|
|
70
|
-
tenantId: TenantId.assumeExists(tenantId),
|
|
71
|
-
...(variables !== undefined && { variables }),
|
|
72
|
-
});
|
|
73
|
-
logger.success("Process instance created", createResult.processInstanceKey);
|
|
74
59
|
}
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
// Read BPMN file and extract process ID.
|
|
61
|
+
const content = readFileSync(path, "utf-8");
|
|
62
|
+
const processId = extractProcessId(content);
|
|
63
|
+
if (!processId) {
|
|
64
|
+
throw new Error("Could not extract process ID from BPMN file");
|
|
77
65
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
const { client, logger } = ctx;
|
|
67
|
+
const tenantId = resolveTenantId(ctx.profile);
|
|
68
|
+
logger.info(`Deploying ${path}...`);
|
|
69
|
+
// Deploy the BPMN file. Convert to a File object with the correct
|
|
70
|
+
// MIME type so the multipart boundary the SDK builds is well-formed.
|
|
71
|
+
const fileName = basename(path) || "process.bpmn";
|
|
72
|
+
const deployResult = await client.createDeployment({
|
|
73
|
+
tenantId: TenantId.assumeExists(tenantId),
|
|
74
|
+
resources: [
|
|
75
|
+
new File([Buffer.from(content)], fileName, { type: "application/xml" }),
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
logger.success("Deployment successful", deployResult.deploymentKey.toString());
|
|
79
|
+
// Create process instance.
|
|
80
|
+
logger.info(`Creating process instance for ${processId}...`);
|
|
81
|
+
const createResult = await client.createProcessInstance({
|
|
82
|
+
processDefinitionId: ProcessDefinitionId.assumeExists(processId),
|
|
83
|
+
tenantId: TenantId.assumeExists(tenantId),
|
|
84
|
+
...(variables !== undefined && { variables }),
|
|
86
85
|
});
|
|
86
|
+
logger.success("Process instance created", createResult.processInstanceKey);
|
|
87
87
|
return { kind: "none" };
|
|
88
88
|
});
|
|
89
89
|
//# sourceMappingURL=run.js.map
|
package/dist/commands/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACN,mBAAmB,EACnB,QAAQ,GACR,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;GAEG;AACH,SAAS,gBAAgB,CAAC,WAAmB;IAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC5D,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChC,CAAC;AAED,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,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AE,MAAM,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camunda8/cli",
|
|
3
|
-
"version": "2.8.0-alpha.
|
|
3
|
+
"version": "2.8.0-alpha.5",
|
|
4
4
|
"description": "Camunda 8 CLI - minimal-dependency CLI for Camunda 8 operations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"copy-plugins": "node -e \"const fs=require('fs');const path=require('path');const src='default-plugins';const dest='dist/default-plugins';if(fs.existsSync(src)){fs.cpSync(src,dest,{recursive:true})}\"",
|
|
35
35
|
"copy-templates": "node -e \"const fs=require('fs');const src='src/templates';const dest='dist/templates';if(fs.existsSync(src)){fs.cpSync(src,dest,{recursive:true})}\"",
|
|
36
36
|
"prepublishOnly": "npm run build",
|
|
37
|
-
"test": "
|
|
37
|
+
"test": "npm run test:unit && npm run test:integration",
|
|
38
38
|
"test:unit": "node --experimental-strip-types --test tests/unit/*.test.ts",
|
|
39
|
-
"test:integration": "node --experimental-strip-types --test tests/integration/*.test.ts",
|
|
39
|
+
"test:integration": "node --experimental-strip-types --experimental-test-isolation=none --test tests/integration/*.test.ts",
|
|
40
40
|
"dev": "node src/index.ts",
|
|
41
41
|
"cli": "node src/index.ts"
|
|
42
42
|
},
|