@camunda8/cli 4.7.0-alpha.22 → 4.7.0-alpha.24
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 +1 -2
- package/dist/command-dispatch.d.ts.map +1 -1
- package/dist/command-dispatch.js +0 -3
- package/dist/command-dispatch.js.map +1 -1
- package/dist/default-plugins/mcp/README.md +33 -0
- package/dist/default-plugins/mcp/c8ctl-plugin.js +2604 -0
- package/dist/default-plugins/mcp/package.json +8 -0
- package/dist/default-plugins/modeler/README.md +10 -1
- package/dist/default-plugins/modeler/c8ctl-plugin.js +1030 -56
- package/dist/default-plugins/modeler/package.json +1 -1
- package/dist/default-plugins/setup/README.md +12 -6
- package/dist/default-plugins/setup/c8ctl-plugin.js +173 -119
- package/dist/default-plugins/skills/README.md +9 -2
- package/dist/default-plugins/skills/c8ctl-plugin.js +116 -20
- package/dist/framework/command-registry.d.ts +0 -30
- package/dist/framework/command-registry.d.ts.map +1 -1
- package/dist/framework/command-registry.js +0 -54
- package/dist/framework/command-registry.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/mcp.d.ts +0 -9
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js +0 -109
- package/dist/commands/mcp.js.map +0 -1
|
@@ -722,8 +722,8 @@ var require_gt = __commonJS({
|
|
|
722
722
|
"node_modules/semver/functions/gt.js"(exports, module) {
|
|
723
723
|
"use strict";
|
|
724
724
|
var compare = require_compare();
|
|
725
|
-
var
|
|
726
|
-
module.exports =
|
|
725
|
+
var gt2 = (a, b, loose) => compare(a, b, loose) > 0;
|
|
726
|
+
module.exports = gt2;
|
|
727
727
|
}
|
|
728
728
|
});
|
|
729
729
|
|
|
@@ -783,7 +783,7 @@ var require_cmp = __commonJS({
|
|
|
783
783
|
"use strict";
|
|
784
784
|
var eq = require_eq();
|
|
785
785
|
var neq = require_neq();
|
|
786
|
-
var
|
|
786
|
+
var gt2 = require_gt();
|
|
787
787
|
var gte = require_gte();
|
|
788
788
|
var lt = require_lt();
|
|
789
789
|
var lte = require_lte();
|
|
@@ -812,7 +812,7 @@ var require_cmp = __commonJS({
|
|
|
812
812
|
case "!=":
|
|
813
813
|
return neq(a, b, loose);
|
|
814
814
|
case ">":
|
|
815
|
-
return
|
|
815
|
+
return gt2(a, b, loose);
|
|
816
816
|
case ">=":
|
|
817
817
|
return gte(a, b, loose);
|
|
818
818
|
case "<":
|
|
@@ -1541,7 +1541,7 @@ var require_min_version = __commonJS({
|
|
|
1541
1541
|
"use strict";
|
|
1542
1542
|
var SemVer = require_semver();
|
|
1543
1543
|
var Range = require_range();
|
|
1544
|
-
var
|
|
1544
|
+
var gt2 = require_gt();
|
|
1545
1545
|
var minVersion = (range, loose) => {
|
|
1546
1546
|
range = new Range(range, loose);
|
|
1547
1547
|
let minver = new SemVer("0.0.0");
|
|
@@ -1569,7 +1569,7 @@ var require_min_version = __commonJS({
|
|
|
1569
1569
|
/* fallthrough */
|
|
1570
1570
|
case "":
|
|
1571
1571
|
case ">=":
|
|
1572
|
-
if (!setMin ||
|
|
1572
|
+
if (!setMin || gt2(compver, setMin)) {
|
|
1573
1573
|
setMin = compver;
|
|
1574
1574
|
}
|
|
1575
1575
|
break;
|
|
@@ -1581,7 +1581,7 @@ var require_min_version = __commonJS({
|
|
|
1581
1581
|
throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
1582
1582
|
}
|
|
1583
1583
|
});
|
|
1584
|
-
if (setMin && (!minver ||
|
|
1584
|
+
if (setMin && (!minver || gt2(minver, setMin))) {
|
|
1585
1585
|
minver = setMin;
|
|
1586
1586
|
}
|
|
1587
1587
|
}
|
|
@@ -1619,7 +1619,7 @@ var require_outside = __commonJS({
|
|
|
1619
1619
|
var { ANY } = Comparator;
|
|
1620
1620
|
var Range = require_range();
|
|
1621
1621
|
var satisfies = require_satisfies();
|
|
1622
|
-
var
|
|
1622
|
+
var gt2 = require_gt();
|
|
1623
1623
|
var lt = require_lt();
|
|
1624
1624
|
var lte = require_lte();
|
|
1625
1625
|
var gte = require_gte();
|
|
@@ -1629,7 +1629,7 @@ var require_outside = __commonJS({
|
|
|
1629
1629
|
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
1630
1630
|
switch (hilo) {
|
|
1631
1631
|
case ">":
|
|
1632
|
-
gtfn =
|
|
1632
|
+
gtfn = gt2;
|
|
1633
1633
|
ltefn = lte;
|
|
1634
1634
|
ltfn = lt;
|
|
1635
1635
|
comp = ">";
|
|
@@ -1638,7 +1638,7 @@ var require_outside = __commonJS({
|
|
|
1638
1638
|
case "<":
|
|
1639
1639
|
gtfn = lt;
|
|
1640
1640
|
ltefn = gte;
|
|
1641
|
-
ltfn =
|
|
1641
|
+
ltfn = gt2;
|
|
1642
1642
|
comp = "<";
|
|
1643
1643
|
ecomp = "<=";
|
|
1644
1644
|
break;
|
|
@@ -1816,10 +1816,10 @@ var require_subset = __commonJS({
|
|
|
1816
1816
|
}
|
|
1817
1817
|
}
|
|
1818
1818
|
const eqSet = /* @__PURE__ */ new Set();
|
|
1819
|
-
let
|
|
1819
|
+
let gt2, lt;
|
|
1820
1820
|
for (const c of sub) {
|
|
1821
1821
|
if (c.operator === ">" || c.operator === ">=") {
|
|
1822
|
-
|
|
1822
|
+
gt2 = higherGT(gt2, c, options);
|
|
1823
1823
|
} else if (c.operator === "<" || c.operator === "<=") {
|
|
1824
1824
|
lt = lowerLT(lt, c, options);
|
|
1825
1825
|
} else {
|
|
@@ -1830,16 +1830,16 @@ var require_subset = __commonJS({
|
|
|
1830
1830
|
return null;
|
|
1831
1831
|
}
|
|
1832
1832
|
let gtltComp;
|
|
1833
|
-
if (
|
|
1834
|
-
gtltComp = compare(
|
|
1833
|
+
if (gt2 && lt) {
|
|
1834
|
+
gtltComp = compare(gt2.semver, lt.semver, options);
|
|
1835
1835
|
if (gtltComp > 0) {
|
|
1836
1836
|
return null;
|
|
1837
|
-
} else if (gtltComp === 0 && (
|
|
1837
|
+
} else if (gtltComp === 0 && (gt2.operator !== ">=" || lt.operator !== "<=")) {
|
|
1838
1838
|
return null;
|
|
1839
1839
|
}
|
|
1840
1840
|
}
|
|
1841
1841
|
for (const eq of eqSet) {
|
|
1842
|
-
if (
|
|
1842
|
+
if (gt2 && !satisfies(eq, String(gt2), options)) {
|
|
1843
1843
|
return null;
|
|
1844
1844
|
}
|
|
1845
1845
|
if (lt && !satisfies(eq, String(lt), options)) {
|
|
@@ -1855,25 +1855,25 @@ var require_subset = __commonJS({
|
|
|
1855
1855
|
let higher, lower;
|
|
1856
1856
|
let hasDomLT, hasDomGT;
|
|
1857
1857
|
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
1858
|
-
let needDomGTPre =
|
|
1858
|
+
let needDomGTPre = gt2 && !options.includePrerelease && gt2.semver.prerelease.length ? gt2.semver : false;
|
|
1859
1859
|
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
|
|
1860
1860
|
needDomLTPre = false;
|
|
1861
1861
|
}
|
|
1862
1862
|
for (const c of dom) {
|
|
1863
1863
|
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
1864
1864
|
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
1865
|
-
if (
|
|
1865
|
+
if (gt2) {
|
|
1866
1866
|
if (needDomGTPre) {
|
|
1867
1867
|
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
|
|
1868
1868
|
needDomGTPre = false;
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
1871
|
if (c.operator === ">" || c.operator === ">=") {
|
|
1872
|
-
higher = higherGT(
|
|
1873
|
-
if (higher === c && higher !==
|
|
1872
|
+
higher = higherGT(gt2, c, options);
|
|
1873
|
+
if (higher === c && higher !== gt2) {
|
|
1874
1874
|
return false;
|
|
1875
1875
|
}
|
|
1876
|
-
} else if (
|
|
1876
|
+
} else if (gt2.operator === ">=" && !c.test(gt2.semver)) {
|
|
1877
1877
|
return false;
|
|
1878
1878
|
}
|
|
1879
1879
|
}
|
|
@@ -1892,14 +1892,14 @@ var require_subset = __commonJS({
|
|
|
1892
1892
|
return false;
|
|
1893
1893
|
}
|
|
1894
1894
|
}
|
|
1895
|
-
if (!c.operator && (lt ||
|
|
1895
|
+
if (!c.operator && (lt || gt2) && gtltComp !== 0) {
|
|
1896
1896
|
return false;
|
|
1897
1897
|
}
|
|
1898
1898
|
}
|
|
1899
|
-
if (
|
|
1899
|
+
if (gt2 && hasDomLT && !lt && gtltComp !== 0) {
|
|
1900
1900
|
return false;
|
|
1901
1901
|
}
|
|
1902
|
-
if (lt && hasDomGT && !
|
|
1902
|
+
if (lt && hasDomGT && !gt2 && gtltComp !== 0) {
|
|
1903
1903
|
return false;
|
|
1904
1904
|
}
|
|
1905
1905
|
if (needDomGTPre || needDomLTPre) {
|
|
@@ -1948,7 +1948,7 @@ var require_semver2 = __commonJS({
|
|
|
1948
1948
|
var compareBuild = require_compare_build();
|
|
1949
1949
|
var sort = require_sort();
|
|
1950
1950
|
var rsort = require_rsort();
|
|
1951
|
-
var
|
|
1951
|
+
var gt2 = require_gt();
|
|
1952
1952
|
var lt = require_lt();
|
|
1953
1953
|
var eq = require_eq();
|
|
1954
1954
|
var neq = require_neq();
|
|
@@ -1987,7 +1987,7 @@ var require_semver2 = __commonJS({
|
|
|
1987
1987
|
compareBuild,
|
|
1988
1988
|
sort,
|
|
1989
1989
|
rsort,
|
|
1990
|
-
gt,
|
|
1990
|
+
gt: gt2,
|
|
1991
1991
|
lt,
|
|
1992
1992
|
eq,
|
|
1993
1993
|
neq,
|
|
@@ -2228,20 +2228,27 @@ var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
|
|
|
2228
2228
|
|
|
2229
2229
|
// default-plugins/modeler/install.ts
|
|
2230
2230
|
import { spawnSync } from "node:child_process";
|
|
2231
|
+
import { randomUUID } from "node:crypto";
|
|
2231
2232
|
import {
|
|
2232
2233
|
accessSync,
|
|
2233
2234
|
constants,
|
|
2234
2235
|
createWriteStream,
|
|
2235
2236
|
existsSync,
|
|
2237
|
+
linkSync,
|
|
2238
|
+
lstatSync,
|
|
2236
2239
|
mkdirSync,
|
|
2237
2240
|
mkdtempSync,
|
|
2241
|
+
readFileSync as readFileSync2,
|
|
2242
|
+
readlinkSync,
|
|
2238
2243
|
realpathSync,
|
|
2239
2244
|
renameSync,
|
|
2240
2245
|
rmSync,
|
|
2241
|
-
statSync
|
|
2246
|
+
statSync,
|
|
2247
|
+
unlinkSync,
|
|
2248
|
+
writeFileSync
|
|
2242
2249
|
} from "node:fs";
|
|
2243
2250
|
import { homedir as homedir2, tmpdir } from "node:os";
|
|
2244
|
-
import { delimiter, join as join2 } from "node:path";
|
|
2251
|
+
import { delimiter, dirname as dirname2, join as join2 } from "node:path";
|
|
2245
2252
|
import { Readable, Transform } from "node:stream";
|
|
2246
2253
|
import { pipeline } from "node:stream/promises";
|
|
2247
2254
|
|
|
@@ -2264,6 +2271,16 @@ function latestStableModelerVersion(indexHtml) {
|
|
|
2264
2271
|
}
|
|
2265
2272
|
return latest;
|
|
2266
2273
|
}
|
|
2274
|
+
function isNewerModelerVersion(candidate, current) {
|
|
2275
|
+
const candidateVersion = (0, import_semver.parse)(candidate);
|
|
2276
|
+
const currentVersion = (0, import_semver.parse)(current);
|
|
2277
|
+
if (!candidateVersion || !currentVersion) {
|
|
2278
|
+
throw new Error(
|
|
2279
|
+
`Invalid Camunda Modeler version "${candidate}" or "${current}"`
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
return (0, import_semver.gt)(candidateVersion, currentVersion);
|
|
2283
|
+
}
|
|
2267
2284
|
function modelerMacArchiveName(version, architecture) {
|
|
2268
2285
|
if (architecture !== "arm64" && architecture !== "x64") {
|
|
2269
2286
|
throw new Error(
|
|
@@ -2329,12 +2346,124 @@ var WINGET_INSTALL_URL = "https://learn.microsoft.com/windows/package-manager/wi
|
|
|
2329
2346
|
var WINGET_NO_APPLICATIONS_FOUND = 2316632084;
|
|
2330
2347
|
var WINDOWS_EXECUTABLE = "Camunda Modeler.exe";
|
|
2331
2348
|
var MODELER_FILE_TYPES = ["bpmn", "dmn", "form", "rpa"];
|
|
2349
|
+
var UNREGISTER_WINDOWS_SCRIPT = `$ErrorActionPreference='Stop'; $base=[Microsoft.Win32.Registry]::CurrentUser; foreach ($type in @('bpmn','dmn','form','rpa')) { $prog='CamundaModeler.'+$type.ToUpper(); $path='Software\\Classes\\'+$prog+'\\shell\\open\\command'; $key=$base.OpenSubKey($path); if ($key -and $key.GetValue('') -ieq ('"'+$env:C8CTL_TARGET+'" "%1"')) { $key.Close(); $ext=$base.OpenSubKey('Software\\Classes\\.'+$type,$true); if ($ext) { if ($ext.GetValue('') -ieq $prog) { $ext.DeleteValue('', $false) }; $ext.Close() }; Remove-Item -LiteralPath ('Registry::HKEY_CURRENT_USER\\Software\\Classes\\'+$prog) -Recurse -Force } elseif ($key) { $key.Close() } }; $shortcut=(New-Object -ComObject WScript.Shell).CreateShortcut($env:C8CTL_SHORTCUT); if ((Test-Path -LiteralPath $env:C8CTL_SHORTCUT) -and $shortcut.TargetPath -ieq $env:C8CTL_TARGET) { Remove-Item -LiteralPath $env:C8CTL_SHORTCUT -Force }`;
|
|
2332
2350
|
var CREATE_SHORTCUT_SCRIPT = "$ErrorActionPreference = 'Stop'; $shortcut = (New-Object -ComObject WScript.Shell).CreateShortcut($env:C8CTL_SHORTCUT); $shortcut.TargetPath = $env:C8CTL_TARGET; $shortcut.Save()";
|
|
2333
2351
|
var LINUX_INSTALL_ROOT = "/usr/bin";
|
|
2334
2352
|
var LINUX_EXECUTABLE = "camunda-modeler";
|
|
2353
|
+
var LINUX_LIFECYCLE_LOCK = "/tmp/c8ctl-modeler-lifecycle.lock";
|
|
2354
|
+
var LINUX_LIFECYCLE_RECLAIM_LOCK = `${LINUX_LIFECYCLE_LOCK}.reclaim`;
|
|
2335
2355
|
function errorMessage(error) {
|
|
2336
2356
|
return error instanceof Error ? error.message : String(error);
|
|
2337
2357
|
}
|
|
2358
|
+
function errorCode(error) {
|
|
2359
|
+
if (error instanceof Error && "code" in error) {
|
|
2360
|
+
const { code } = error;
|
|
2361
|
+
if (typeof code === "string") return code;
|
|
2362
|
+
}
|
|
2363
|
+
return void 0;
|
|
2364
|
+
}
|
|
2365
|
+
var lifecycleToken = randomUUID();
|
|
2366
|
+
function readLifecycleLock(path) {
|
|
2367
|
+
try {
|
|
2368
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
2369
|
+
return isRecord(parsed) ? parsed : void 0;
|
|
2370
|
+
} catch {
|
|
2371
|
+
return void 0;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
function isProcessAlive(pid) {
|
|
2375
|
+
try {
|
|
2376
|
+
process.kill(pid, 0);
|
|
2377
|
+
return true;
|
|
2378
|
+
} catch (error) {
|
|
2379
|
+
return errorCode(error) === "EPERM";
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
function isStaleLock(path) {
|
|
2383
|
+
const pid = readLifecycleLock(path)?.pid;
|
|
2384
|
+
if (typeof pid !== "number" || !Number.isInteger(pid)) return true;
|
|
2385
|
+
return !isProcessAlive(pid);
|
|
2386
|
+
}
|
|
2387
|
+
function tryCreateLifecycleLock(path) {
|
|
2388
|
+
const payload = {
|
|
2389
|
+
pid: process.pid,
|
|
2390
|
+
token: lifecycleToken
|
|
2391
|
+
};
|
|
2392
|
+
const staging = `${path}.${process.pid}.${lifecycleToken}`;
|
|
2393
|
+
writeFileSync(staging, JSON.stringify(payload), { flag: "wx", mode: 420 });
|
|
2394
|
+
try {
|
|
2395
|
+
linkSync(staging, path);
|
|
2396
|
+
return true;
|
|
2397
|
+
} catch (error) {
|
|
2398
|
+
if (errorCode(error) === "EEXIST") return false;
|
|
2399
|
+
throw error;
|
|
2400
|
+
} finally {
|
|
2401
|
+
try {
|
|
2402
|
+
unlinkSync(staging);
|
|
2403
|
+
} catch {
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
function releaseOwnLifecycleLock(path) {
|
|
2408
|
+
if (readLifecycleLock(path)?.token !== lifecycleToken) return;
|
|
2409
|
+
try {
|
|
2410
|
+
unlinkSync(path);
|
|
2411
|
+
} catch {
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
function lifecycleLockBusy() {
|
|
2415
|
+
return new Error(
|
|
2416
|
+
`Another c8ctl Modeler operation is in progress. Wait for it to finish, or remove ${LINUX_LIFECYCLE_LOCK} if you are sure none is running.`
|
|
2417
|
+
);
|
|
2418
|
+
}
|
|
2419
|
+
function reclaimStaleLifecycleLock(logger) {
|
|
2420
|
+
if (!tryCreateLifecycleLock(LINUX_LIFECYCLE_RECLAIM_LOCK)) {
|
|
2421
|
+
throw new Error(
|
|
2422
|
+
`Another c8ctl Modeler operation is recovering an interrupted run's lock. If no such operation is running, remove ${LINUX_LIFECYCLE_RECLAIM_LOCK} and ${LINUX_LIFECYCLE_LOCK} manually.`
|
|
2423
|
+
);
|
|
2424
|
+
}
|
|
2425
|
+
try {
|
|
2426
|
+
if (!pathExists(LINUX_LIFECYCLE_LOCK) || !isStaleLock(LINUX_LIFECYCLE_LOCK)) {
|
|
2427
|
+
return false;
|
|
2428
|
+
}
|
|
2429
|
+
logger.warn(
|
|
2430
|
+
`Reclaiming a stale Camunda Modeler lifecycle lock at ${LINUX_LIFECYCLE_LOCK} from a previous run.`
|
|
2431
|
+
);
|
|
2432
|
+
try {
|
|
2433
|
+
unlinkSync(LINUX_LIFECYCLE_LOCK);
|
|
2434
|
+
} catch (error) {
|
|
2435
|
+
throw new Error(
|
|
2436
|
+
`Could not reclaim the stale Modeler lifecycle lock at ${LINUX_LIFECYCLE_LOCK} (${errorMessage(error)}). Remove it manually if no other c8ctl modeler command is running.`
|
|
2437
|
+
);
|
|
2438
|
+
}
|
|
2439
|
+
return tryCreateLifecycleLock(LINUX_LIFECYCLE_LOCK);
|
|
2440
|
+
} finally {
|
|
2441
|
+
releaseOwnLifecycleLock(LINUX_LIFECYCLE_RECLAIM_LOCK);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
function acquireLinuxLifecycleLock(logger) {
|
|
2445
|
+
if (tryCreateLifecycleLock(LINUX_LIFECYCLE_LOCK)) return;
|
|
2446
|
+
if (isStaleLock(LINUX_LIFECYCLE_LOCK) && reclaimStaleLifecycleLock(logger)) {
|
|
2447
|
+
return;
|
|
2448
|
+
}
|
|
2449
|
+
throw lifecycleLockBusy();
|
|
2450
|
+
}
|
|
2451
|
+
function releaseLinuxLifecycleLock() {
|
|
2452
|
+
releaseOwnLifecycleLock(LINUX_LIFECYCLE_LOCK);
|
|
2453
|
+
}
|
|
2454
|
+
async function withLinuxLifecycleLock(ctx, body) {
|
|
2455
|
+
acquireLinuxLifecycleLock(ctx.logger);
|
|
2456
|
+
const onSignal = () => releaseLinuxLifecycleLock();
|
|
2457
|
+
process.once("SIGINT", onSignal);
|
|
2458
|
+
process.once("SIGTERM", onSignal);
|
|
2459
|
+
try {
|
|
2460
|
+
return await body();
|
|
2461
|
+
} finally {
|
|
2462
|
+
process.off("SIGINT", onSignal);
|
|
2463
|
+
process.off("SIGTERM", onSignal);
|
|
2464
|
+
releaseLinuxLifecycleLock();
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2338
2467
|
function reportProgress({ logger, quiet }, message) {
|
|
2339
2468
|
if (!quiet) logger.info(message);
|
|
2340
2469
|
}
|
|
@@ -2347,11 +2476,13 @@ function formatExitCode(status) {
|
|
|
2347
2476
|
function runCommand(command, args, {
|
|
2348
2477
|
failureMessage,
|
|
2349
2478
|
quiet,
|
|
2350
|
-
stdin = "inherit"
|
|
2479
|
+
stdin = "inherit",
|
|
2480
|
+
env
|
|
2351
2481
|
}) {
|
|
2352
2482
|
const result = spawnSync(command, args, {
|
|
2353
2483
|
encoding: "utf8",
|
|
2354
|
-
stdio: quiet ? [stdin, "pipe", "pipe"] : [stdin, process.stderr.fd, process.stderr.fd]
|
|
2484
|
+
stdio: quiet ? [stdin, "pipe", "pipe"] : [stdin, process.stderr.fd, process.stderr.fd],
|
|
2485
|
+
env
|
|
2355
2486
|
});
|
|
2356
2487
|
const diagnostics = quiet ? `${result.stdout ?? ""}${result.stderr ?? ""}`.trim() : "";
|
|
2357
2488
|
const details = diagnostics ? `
|
|
@@ -2365,6 +2496,24 @@ ${diagnostics}` : "";
|
|
|
2365
2496
|
);
|
|
2366
2497
|
}
|
|
2367
2498
|
}
|
|
2499
|
+
function runCommandCapture(command, args, failureMessage) {
|
|
2500
|
+
const result = spawnSync(command, args, {
|
|
2501
|
+
encoding: "utf8",
|
|
2502
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2503
|
+
});
|
|
2504
|
+
const diagnostics = `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
|
|
2505
|
+
const details = diagnostics ? `
|
|
2506
|
+
${diagnostics}` : "";
|
|
2507
|
+
if (result.error) {
|
|
2508
|
+
throw new Error(`${failureMessage}: ${result.error.message}${details}`);
|
|
2509
|
+
}
|
|
2510
|
+
if (result.status !== 0) {
|
|
2511
|
+
throw new Error(
|
|
2512
|
+
`${failureMessage} (exit code ${formatExitCode(result.status)}).${details}`
|
|
2513
|
+
);
|
|
2514
|
+
}
|
|
2515
|
+
return result.stdout ?? "";
|
|
2516
|
+
}
|
|
2368
2517
|
function registerWithLaunchServices(appPath, logger) {
|
|
2369
2518
|
const result = spawnSync(LAUNCH_SERVICES_REGISTER, ["-f", appPath], {
|
|
2370
2519
|
stdio: "ignore"
|
|
@@ -2375,6 +2524,16 @@ function registerWithLaunchServices(appPath, logger) {
|
|
|
2375
2524
|
);
|
|
2376
2525
|
}
|
|
2377
2526
|
}
|
|
2527
|
+
function unregisterWithLaunchServices(appPath, logger) {
|
|
2528
|
+
const result = spawnSync(LAUNCH_SERVICES_REGISTER, ["-u", "-f", appPath], {
|
|
2529
|
+
stdio: "ignore"
|
|
2530
|
+
});
|
|
2531
|
+
if (result.error || result.status !== 0) {
|
|
2532
|
+
logger.warn(
|
|
2533
|
+
`Could not unregister ${appPath} from macOS Launch Services. Remove its file associations manually if they remain.`
|
|
2534
|
+
);
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2378
2537
|
function hasPackageManager(command, name) {
|
|
2379
2538
|
const result = spawnSync(command, ["--version"], { stdio: "ignore" });
|
|
2380
2539
|
if (result.error) {
|
|
@@ -2565,6 +2724,50 @@ async function downloadLatestRelease({
|
|
|
2565
2724
|
});
|
|
2566
2725
|
return { version, archivePath };
|
|
2567
2726
|
}
|
|
2727
|
+
async function downloadReleaseVersion({
|
|
2728
|
+
dir,
|
|
2729
|
+
version,
|
|
2730
|
+
platform: platform2,
|
|
2731
|
+
archiveName,
|
|
2732
|
+
logger,
|
|
2733
|
+
quiet,
|
|
2734
|
+
signal
|
|
2735
|
+
}) {
|
|
2736
|
+
const name = archiveName(version);
|
|
2737
|
+
const archivePath = join2(dir, name);
|
|
2738
|
+
reportProgress(
|
|
2739
|
+
{ logger, quiet },
|
|
2740
|
+
`Downloading Camunda Modeler ${version} for ${platform2}...`
|
|
2741
|
+
);
|
|
2742
|
+
await downloadArchive({
|
|
2743
|
+
url: new URL(`${version}/${name}`, MODELER_RELEASE_URL).toString(),
|
|
2744
|
+
destination: archivePath,
|
|
2745
|
+
logger,
|
|
2746
|
+
quiet,
|
|
2747
|
+
signal
|
|
2748
|
+
});
|
|
2749
|
+
return { version, archivePath };
|
|
2750
|
+
}
|
|
2751
|
+
function registerDownloadInterrupts(operation) {
|
|
2752
|
+
const controller = new AbortController();
|
|
2753
|
+
let interruptedSignal;
|
|
2754
|
+
const interrupt = (signal) => {
|
|
2755
|
+
interruptedSignal ??= signal;
|
|
2756
|
+
controller.abort(new Error(`${operation} interrupted by ${signal}`));
|
|
2757
|
+
};
|
|
2758
|
+
const onSigint = () => interrupt("SIGINT");
|
|
2759
|
+
const onSigterm = () => interrupt("SIGTERM");
|
|
2760
|
+
process.on("SIGINT", onSigint);
|
|
2761
|
+
process.on("SIGTERM", onSigterm);
|
|
2762
|
+
return {
|
|
2763
|
+
signal: controller.signal,
|
|
2764
|
+
cleanup: () => {
|
|
2765
|
+
process.off("SIGINT", onSigint);
|
|
2766
|
+
process.off("SIGTERM", onSigterm);
|
|
2767
|
+
if (interruptedSignal) process.kill(process.pid, interruptedSignal);
|
|
2768
|
+
}
|
|
2769
|
+
};
|
|
2770
|
+
}
|
|
2568
2771
|
async function installFromOfficialDownload({
|
|
2569
2772
|
applicationsDir,
|
|
2570
2773
|
logger,
|
|
@@ -2768,12 +2971,13 @@ function findOnPath(command) {
|
|
|
2768
2971
|
}
|
|
2769
2972
|
});
|
|
2770
2973
|
}
|
|
2771
|
-
function runAsRoot(args, failureMessage, quiet) {
|
|
2974
|
+
function runAsRoot(args, failureMessage, quiet, includeManualDownload = true) {
|
|
2772
2975
|
const [command, ...rest] = process.getuid?.() === 0 ? args : ["sudo", ...args];
|
|
2773
2976
|
try {
|
|
2774
2977
|
runCommand(command, rest, { failureMessage, quiet });
|
|
2775
2978
|
} catch (error) {
|
|
2776
|
-
|
|
2979
|
+
const message = errorMessage(error);
|
|
2980
|
+
throw includeManualDownload ? manualDownloadError(message) : new Error(message);
|
|
2777
2981
|
}
|
|
2778
2982
|
}
|
|
2779
2983
|
function registerWithDesktop({
|
|
@@ -2798,6 +3002,39 @@ function registerWithDesktop({
|
|
|
2798
3002
|
logger.warn(errorMessage(error));
|
|
2799
3003
|
}
|
|
2800
3004
|
}
|
|
3005
|
+
function unregisterWithDesktop({
|
|
3006
|
+
installDir,
|
|
3007
|
+
logger,
|
|
3008
|
+
quiet
|
|
3009
|
+
}) {
|
|
3010
|
+
const script = join2(installDir, "support", "xdg_unregister.sh");
|
|
3011
|
+
if (!existsSync(script)) {
|
|
3012
|
+
logger.warn(
|
|
3013
|
+
`Could not unregister Camunda Modeler file types because ${script} is missing.`
|
|
3014
|
+
);
|
|
3015
|
+
return;
|
|
3016
|
+
}
|
|
3017
|
+
const missingTools = [
|
|
3018
|
+
"xdg-mime",
|
|
3019
|
+
"xdg-desktop-menu",
|
|
3020
|
+
"xdg-icon-resource"
|
|
3021
|
+
].filter((tool) => !findOnPath(tool));
|
|
3022
|
+
if (missingTools.length > 0) {
|
|
3023
|
+
logger.warn(
|
|
3024
|
+
`Could not unregister Camunda Modeler file types because these xdg-utils are not installed: ${missingTools.join(", ")}.`
|
|
3025
|
+
);
|
|
3026
|
+
return;
|
|
3027
|
+
}
|
|
3028
|
+
try {
|
|
3029
|
+
runCommand("/bin/bash", [script], {
|
|
3030
|
+
failureMessage: `Could not unregister Camunda Modeler file types using ${script}`,
|
|
3031
|
+
quiet,
|
|
3032
|
+
stdin: "ignore"
|
|
3033
|
+
});
|
|
3034
|
+
} catch (error) {
|
|
3035
|
+
logger.warn(`${errorMessage(error)} File registrations may remain.`);
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
2801
3038
|
async function installOnLinux({
|
|
2802
3039
|
isDryRun,
|
|
2803
3040
|
logger,
|
|
@@ -2893,7 +3130,9 @@ async function installOnLinux({
|
|
|
2893
3130
|
}
|
|
2894
3131
|
async function installDesktopModeler(ctx) {
|
|
2895
3132
|
if (process.platform === "win32") return installOnWindows(ctx);
|
|
2896
|
-
if (process.platform === "linux")
|
|
3133
|
+
if (process.platform === "linux") {
|
|
3134
|
+
return withLinuxLifecycleLock(ctx, () => installOnLinux(ctx));
|
|
3135
|
+
}
|
|
2897
3136
|
if (process.platform !== "darwin") {
|
|
2898
3137
|
throw new Error(
|
|
2899
3138
|
`c8ctl modeler install currently supports macOS, Windows, and Linux only. Download Modeler manually from ${MANUAL_DOWNLOAD_URL}`
|
|
@@ -2971,63 +3210,798 @@ async function installDesktopModeler(ctx) {
|
|
|
2971
3210
|
message: `Installed Camunda Modeler ${version} to ${destination}.`
|
|
2972
3211
|
};
|
|
2973
3212
|
}
|
|
3213
|
+
function noModelerInstalled() {
|
|
3214
|
+
return {
|
|
3215
|
+
kind: "info",
|
|
3216
|
+
message: "Camunda Modeler is not installed; run `c8ctl modeler install` first."
|
|
3217
|
+
};
|
|
3218
|
+
}
|
|
3219
|
+
function verifyExpectedRemovalTarget(ctx, target) {
|
|
3220
|
+
const expected = ctx.expectedRemovalTarget;
|
|
3221
|
+
if (expected !== void 0 && (target === void 0 || target.method !== expected.method || target.path !== expected.path)) {
|
|
3222
|
+
throw new Error(
|
|
3223
|
+
"Camunda Modeler installation changed after the setup preview; refusing to remove a different target. Run `c8ctl setup --remove` again to review the current installation."
|
|
3224
|
+
);
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
function dryRunResult(command, message, removalTarget) {
|
|
3228
|
+
return {
|
|
3229
|
+
kind: "dryRun",
|
|
3230
|
+
// `wouldChange` lets automation (c8ctl setup --remove) tell a real
|
|
3231
|
+
// preview apart from a normalized "nothing to do" info result.
|
|
3232
|
+
info: {
|
|
3233
|
+
dryRun: true,
|
|
3234
|
+
command,
|
|
3235
|
+
message,
|
|
3236
|
+
wouldChange: true,
|
|
3237
|
+
...removalTarget === void 0 ? {} : { removalTarget }
|
|
3238
|
+
}
|
|
3239
|
+
};
|
|
3240
|
+
}
|
|
3241
|
+
function homebrewModelerInstalled() {
|
|
3242
|
+
return isInstalledWith({
|
|
3243
|
+
command: "brew",
|
|
3244
|
+
args: ["list", "--cask", "--versions", "camunda-modeler"],
|
|
3245
|
+
notInstalledStatus: 1,
|
|
3246
|
+
description: "the Homebrew Modeler cask"
|
|
3247
|
+
});
|
|
3248
|
+
}
|
|
3249
|
+
function updateHomebrewModeler(ctx) {
|
|
3250
|
+
const outdated = runCommandCapture(
|
|
3251
|
+
"brew",
|
|
3252
|
+
["outdated", "--cask", "--quiet", "camunda-modeler"],
|
|
3253
|
+
"Could not check Homebrew for Camunda Modeler updates"
|
|
3254
|
+
).trim();
|
|
3255
|
+
if (!outdated) {
|
|
3256
|
+
return {
|
|
3257
|
+
kind: "info",
|
|
3258
|
+
message: "Camunda Modeler is already up to date with Homebrew."
|
|
3259
|
+
};
|
|
3260
|
+
}
|
|
3261
|
+
if (ctx.isDryRun) {
|
|
3262
|
+
return dryRunResult(
|
|
3263
|
+
"modeler update",
|
|
3264
|
+
"Dry run: would update Camunda Modeler with `brew upgrade --cask camunda-modeler`."
|
|
3265
|
+
);
|
|
3266
|
+
}
|
|
3267
|
+
reportProgress(ctx, "Updating Camunda Modeler with Homebrew...");
|
|
3268
|
+
runCommand("brew", ["upgrade", "--cask", "camunda-modeler"], {
|
|
3269
|
+
failureMessage: "Homebrew could not update Camunda Modeler",
|
|
3270
|
+
quiet: ctx.quiet
|
|
3271
|
+
});
|
|
3272
|
+
return {
|
|
3273
|
+
kind: "success",
|
|
3274
|
+
message: "Updated Camunda Modeler with Homebrew."
|
|
3275
|
+
};
|
|
3276
|
+
}
|
|
3277
|
+
function isHomebrewCaskPath(appPath) {
|
|
3278
|
+
return /\/Caskroom\/camunda-modeler\//i.test(realpathSync(appPath));
|
|
3279
|
+
}
|
|
3280
|
+
function verifyMacModelerBundle(appPath, action, quiet) {
|
|
3281
|
+
runCommand(
|
|
3282
|
+
"codesign",
|
|
3283
|
+
[
|
|
3284
|
+
"--verify",
|
|
3285
|
+
"--deep",
|
|
3286
|
+
"--strict",
|
|
3287
|
+
`-R=${MODELER_CODE_REQUIREMENT}`,
|
|
3288
|
+
appPath
|
|
3289
|
+
],
|
|
3290
|
+
{
|
|
3291
|
+
failureMessage: `Camunda Modeler at ${appPath} is not signed by Camunda; refusing to ${action} it`,
|
|
3292
|
+
quiet
|
|
3293
|
+
}
|
|
3294
|
+
);
|
|
3295
|
+
}
|
|
3296
|
+
function readMacModelerVersion(appPath) {
|
|
3297
|
+
const plistPath = join2(appPath, "Contents", "Info.plist");
|
|
3298
|
+
const plist = readFileSync2(plistPath, "utf8");
|
|
3299
|
+
const version = /<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)<\/string>/.exec(plist)?.[1]?.trim();
|
|
3300
|
+
if (!version) {
|
|
3301
|
+
throw new Error(
|
|
3302
|
+
`Could not read the installed Camunda Modeler version from ${plistPath}; reinstall it with c8ctl before updating.`
|
|
3303
|
+
);
|
|
3304
|
+
}
|
|
3305
|
+
return version;
|
|
3306
|
+
}
|
|
3307
|
+
async function updateDirectMacModeler(ctx, appPath) {
|
|
3308
|
+
if (isHomebrewCaskPath(appPath)) {
|
|
3309
|
+
throw new Error(
|
|
3310
|
+
"Camunda Modeler appears to be Homebrew-managed, but its cask was not found; refusing to update the app bundle directly."
|
|
3311
|
+
);
|
|
3312
|
+
}
|
|
3313
|
+
verifyMacModelerBundle(appPath, "update", ctx.quiet);
|
|
3314
|
+
const currentVersion = readMacModelerVersion(appPath);
|
|
3315
|
+
const tempDir = mkdtempSync(join2(tmpdir(), "c8ctl-modeler-"));
|
|
3316
|
+
const interruption = registerDownloadInterrupts("Modeler update");
|
|
3317
|
+
try {
|
|
3318
|
+
reportProgress(
|
|
3319
|
+
ctx,
|
|
3320
|
+
"Checking for the latest stable Camunda Modeler release..."
|
|
3321
|
+
);
|
|
3322
|
+
const latestVersion = latestStableModelerVersion(
|
|
3323
|
+
await fetchReleaseIndex(interruption.signal)
|
|
3324
|
+
);
|
|
3325
|
+
if (!isNewerModelerVersion(latestVersion, currentVersion)) {
|
|
3326
|
+
return {
|
|
3327
|
+
kind: "info",
|
|
3328
|
+
message: `Camunda Modeler is already up to date (installed ${currentVersion}; latest stable ${latestVersion}).`
|
|
3329
|
+
};
|
|
3330
|
+
}
|
|
3331
|
+
if (ctx.isDryRun) {
|
|
3332
|
+
return dryRunResult(
|
|
3333
|
+
"modeler update",
|
|
3334
|
+
`Dry run: would update Camunda Modeler from ${currentVersion} to ${latestVersion} at ${appPath}.`
|
|
3335
|
+
);
|
|
3336
|
+
}
|
|
3337
|
+
const { archivePath } = await downloadReleaseVersion({
|
|
3338
|
+
dir: tempDir,
|
|
3339
|
+
version: latestVersion,
|
|
3340
|
+
platform: "macOS",
|
|
3341
|
+
archiveName: (version) => modelerMacArchiveName(version, process.arch),
|
|
3342
|
+
logger: ctx.logger,
|
|
3343
|
+
quiet: ctx.quiet,
|
|
3344
|
+
signal: interruption.signal
|
|
3345
|
+
});
|
|
3346
|
+
const stagingDir = mkdtempSync(
|
|
3347
|
+
join2(dirname2(appPath), ".c8ctl-modeler-update-")
|
|
3348
|
+
);
|
|
3349
|
+
const stagedApp = join2(stagingDir, APP_BUNDLE_NAME);
|
|
3350
|
+
const backupApp = join2(stagingDir, "previous.app");
|
|
3351
|
+
try {
|
|
3352
|
+
reportProgress(ctx, `Updating Camunda Modeler to ${latestVersion}...`);
|
|
3353
|
+
runCommand("ditto", ["-x", "-k", archivePath, stagingDir], {
|
|
3354
|
+
failureMessage: "Could not extract Camunda Modeler",
|
|
3355
|
+
quiet: ctx.quiet
|
|
3356
|
+
});
|
|
3357
|
+
if (!existsSync(stagedApp)) {
|
|
3358
|
+
throw manualDownloadError(
|
|
3359
|
+
`The Camunda Modeler ${latestVersion} archive did not contain ${APP_BUNDLE_NAME}`
|
|
3360
|
+
);
|
|
3361
|
+
}
|
|
3362
|
+
verifyMacModelerBundle(stagedApp, "update", ctx.quiet);
|
|
3363
|
+
renameSync(appPath, backupApp);
|
|
3364
|
+
try {
|
|
3365
|
+
renameSync(stagedApp, appPath);
|
|
3366
|
+
} catch (error) {
|
|
3367
|
+
try {
|
|
3368
|
+
renameSync(backupApp, appPath);
|
|
3369
|
+
} catch (restoreError) {
|
|
3370
|
+
throw new Error(
|
|
3371
|
+
`Could not install the new Camunda Modeler bundle; the previous bundle remains at ${backupApp}: ${errorMessage(restoreError)}`
|
|
3372
|
+
);
|
|
3373
|
+
}
|
|
3374
|
+
throw new Error(
|
|
3375
|
+
`Could not replace the Camunda Modeler bundle: ${errorMessage(error)}`
|
|
3376
|
+
);
|
|
3377
|
+
}
|
|
3378
|
+
try {
|
|
3379
|
+
rmSync(backupApp, { recursive: true, force: true });
|
|
3380
|
+
} catch (error) {
|
|
3381
|
+
ctx.logger.warn(
|
|
3382
|
+
`Could not remove the previous Camunda Modeler bundle at ${backupApp}: ${errorMessage(error)}`
|
|
3383
|
+
);
|
|
3384
|
+
}
|
|
3385
|
+
} finally {
|
|
3386
|
+
if (!existsSync(backupApp)) {
|
|
3387
|
+
try {
|
|
3388
|
+
rmSync(stagingDir, { recursive: true, force: true });
|
|
3389
|
+
} catch (error) {
|
|
3390
|
+
ctx.logger.warn(
|
|
3391
|
+
`Could not clean up the Modeler update directory ${stagingDir}: ${errorMessage(error)}`
|
|
3392
|
+
);
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
registerWithLaunchServices(appPath, ctx.logger);
|
|
3397
|
+
return {
|
|
3398
|
+
kind: "success",
|
|
3399
|
+
message: `Updated Camunda Modeler to ${latestVersion} at ${appPath}.`
|
|
3400
|
+
};
|
|
3401
|
+
} finally {
|
|
3402
|
+
try {
|
|
3403
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
3404
|
+
} finally {
|
|
3405
|
+
interruption.cleanup();
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
async function updateMacModeler(ctx) {
|
|
3410
|
+
if (hasPackageManager("brew", "Homebrew") && homebrewModelerInstalled()) {
|
|
3411
|
+
return updateHomebrewModeler(ctx);
|
|
3412
|
+
}
|
|
3413
|
+
const appPath = findInstalledModeler();
|
|
3414
|
+
if (!appPath) return noModelerInstalled();
|
|
3415
|
+
return updateDirectMacModeler(ctx, appPath);
|
|
3416
|
+
}
|
|
3417
|
+
function wingetUpgradeAvailable() {
|
|
3418
|
+
const result = spawnSync(
|
|
3419
|
+
"winget",
|
|
3420
|
+
["list", "--upgrade-available", ...WINGET_PACKAGE],
|
|
3421
|
+
{
|
|
3422
|
+
encoding: "utf8",
|
|
3423
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
3424
|
+
}
|
|
3425
|
+
);
|
|
3426
|
+
if (result.error) {
|
|
3427
|
+
throw new Error(
|
|
3428
|
+
`Could not check for Camunda Modeler updates with winget: ${result.error.message}`
|
|
3429
|
+
);
|
|
3430
|
+
}
|
|
3431
|
+
if (result.status === WINGET_NO_APPLICATIONS_FOUND) return false;
|
|
3432
|
+
if (result.status !== 0) {
|
|
3433
|
+
throw new Error(
|
|
3434
|
+
`Could not check for Camunda Modeler updates with winget (exit code ${formatExitCode(result.status)})`
|
|
3435
|
+
);
|
|
3436
|
+
}
|
|
3437
|
+
return `${result.stdout ?? ""}
|
|
3438
|
+
${result.stderr ?? ""}`.split(/\r?\n/).some((line) => line.includes(WINGET_PACKAGE_ID));
|
|
3439
|
+
}
|
|
3440
|
+
function wingetModelerPaths() {
|
|
3441
|
+
const localAppData = process.env.LOCALAPPDATA || join2(homedir2(), "AppData", "Local");
|
|
3442
|
+
const installDir = join2(localAppData, "Programs", "Camunda Modeler");
|
|
3443
|
+
return { installDir, executable: join2(installDir, WINDOWS_EXECUTABLE) };
|
|
3444
|
+
}
|
|
3445
|
+
function updateWindowsModeler(ctx) {
|
|
3446
|
+
const { executable, installDir } = wingetModelerPaths();
|
|
3447
|
+
if (!hasPackageManager("winget", "winget")) {
|
|
3448
|
+
if (existsSync(executable)) {
|
|
3449
|
+
throw new Error(
|
|
3450
|
+
`winget is not available, so c8ctl cannot safely update the Modeler installation at ${installDir}.`
|
|
3451
|
+
);
|
|
3452
|
+
}
|
|
3453
|
+
return noModelerInstalled();
|
|
3454
|
+
}
|
|
3455
|
+
if (!isInstalledWith({
|
|
3456
|
+
command: "winget",
|
|
3457
|
+
args: ["list", ...WINGET_PACKAGE],
|
|
3458
|
+
notInstalledStatus: WINGET_NO_APPLICATIONS_FOUND,
|
|
3459
|
+
description: "the winget Modeler package"
|
|
3460
|
+
})) {
|
|
3461
|
+
if (existsSync(executable)) {
|
|
3462
|
+
throw new Error(
|
|
3463
|
+
`Camunda Modeler at ${installDir} is not installed with winget; refusing to update it.`
|
|
3464
|
+
);
|
|
3465
|
+
}
|
|
3466
|
+
return noModelerInstalled();
|
|
3467
|
+
}
|
|
3468
|
+
if (!wingetUpgradeAvailable()) {
|
|
3469
|
+
return {
|
|
3470
|
+
kind: "info",
|
|
3471
|
+
message: "Camunda Modeler is already up to date with winget."
|
|
3472
|
+
};
|
|
3473
|
+
}
|
|
3474
|
+
if (ctx.isDryRun) {
|
|
3475
|
+
return dryRunResult(
|
|
3476
|
+
"modeler update",
|
|
3477
|
+
"Dry run: would update Camunda Modeler with `winget upgrade --id Camunda.Modeler --exact --source winget`."
|
|
3478
|
+
);
|
|
3479
|
+
}
|
|
3480
|
+
reportProgress(ctx, "Updating Camunda Modeler with winget...");
|
|
3481
|
+
runCommand("winget", ["upgrade", ...WINGET_PACKAGE], {
|
|
3482
|
+
failureMessage: "winget could not update Camunda Modeler",
|
|
3483
|
+
quiet: ctx.quiet
|
|
3484
|
+
});
|
|
3485
|
+
return { kind: "success", message: "Updated Camunda Modeler with winget." };
|
|
3486
|
+
}
|
|
3487
|
+
function unregisterWindowsModeler(ctx, executable) {
|
|
3488
|
+
const appData = process.env.APPDATA || join2(homedir2(), "AppData", "Roaming");
|
|
3489
|
+
const shortcut = join2(
|
|
3490
|
+
appData,
|
|
3491
|
+
"Microsoft",
|
|
3492
|
+
"Windows",
|
|
3493
|
+
"Start Menu",
|
|
3494
|
+
"Programs",
|
|
3495
|
+
"Camunda Modeler.lnk"
|
|
3496
|
+
);
|
|
3497
|
+
try {
|
|
3498
|
+
runCommand(
|
|
3499
|
+
"powershell",
|
|
3500
|
+
["-NoProfile", "-NonInteractive", "-Command", UNREGISTER_WINDOWS_SCRIPT],
|
|
3501
|
+
{
|
|
3502
|
+
failureMessage: "Could not unregister Camunda Modeler file types",
|
|
3503
|
+
quiet: ctx.quiet,
|
|
3504
|
+
stdin: "ignore",
|
|
3505
|
+
env: {
|
|
3506
|
+
...process.env,
|
|
3507
|
+
C8CTL_SHORTCUT: shortcut,
|
|
3508
|
+
C8CTL_TARGET: executable
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
);
|
|
3512
|
+
} catch (error) {
|
|
3513
|
+
ctx.logger.warn(
|
|
3514
|
+
`${errorMessage(error)} File associations or the Start Menu shortcut may remain.`
|
|
3515
|
+
);
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
function removeWindowsModeler(ctx) {
|
|
3519
|
+
const { executable, installDir } = wingetModelerPaths();
|
|
3520
|
+
if (!hasPackageManager("winget", "winget")) {
|
|
3521
|
+
if (existsSync(executable)) {
|
|
3522
|
+
throw new Error(
|
|
3523
|
+
`winget is not available, so c8ctl cannot safely remove the Modeler installation at ${installDir}.`
|
|
3524
|
+
);
|
|
3525
|
+
}
|
|
3526
|
+
verifyExpectedRemovalTarget(ctx, void 0);
|
|
3527
|
+
return noModelerInstalled();
|
|
3528
|
+
}
|
|
3529
|
+
if (!isInstalledWith({
|
|
3530
|
+
command: "winget",
|
|
3531
|
+
args: ["list", ...WINGET_PACKAGE],
|
|
3532
|
+
notInstalledStatus: WINGET_NO_APPLICATIONS_FOUND,
|
|
3533
|
+
description: "the winget Modeler package"
|
|
3534
|
+
})) {
|
|
3535
|
+
if (existsSync(executable)) {
|
|
3536
|
+
throw new Error(
|
|
3537
|
+
`Camunda Modeler at ${installDir} is not installed with winget; refusing to remove it.`
|
|
3538
|
+
);
|
|
3539
|
+
}
|
|
3540
|
+
verifyExpectedRemovalTarget(ctx, void 0);
|
|
3541
|
+
return noModelerInstalled();
|
|
3542
|
+
}
|
|
3543
|
+
const removalTarget = { method: "winget-package", path: installDir };
|
|
3544
|
+
verifyExpectedRemovalTarget(ctx, removalTarget);
|
|
3545
|
+
if (ctx.isDryRun) {
|
|
3546
|
+
return dryRunResult(
|
|
3547
|
+
"modeler remove",
|
|
3548
|
+
"Dry run: would remove Camunda Modeler with `winget uninstall --id Camunda.Modeler --exact --source winget`.",
|
|
3549
|
+
removalTarget
|
|
3550
|
+
);
|
|
3551
|
+
}
|
|
3552
|
+
reportProgress(ctx, "Removing Camunda Modeler with winget...");
|
|
3553
|
+
runCommand("winget", ["uninstall", ...WINGET_PACKAGE], {
|
|
3554
|
+
failureMessage: "winget could not remove Camunda Modeler",
|
|
3555
|
+
quiet: ctx.quiet
|
|
3556
|
+
});
|
|
3557
|
+
unregisterWindowsModeler(ctx, executable);
|
|
3558
|
+
return {
|
|
3559
|
+
kind: "success",
|
|
3560
|
+
message: "Removed Camunda Modeler with winget."
|
|
3561
|
+
};
|
|
3562
|
+
}
|
|
3563
|
+
function pathExists(path) {
|
|
3564
|
+
try {
|
|
3565
|
+
lstatSync(path);
|
|
3566
|
+
return true;
|
|
3567
|
+
} catch {
|
|
3568
|
+
return false;
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
function findManagedLinuxModeler() {
|
|
3572
|
+
const launcher = join2(LINUX_INSTALL_ROOT, LINUX_EXECUTABLE);
|
|
3573
|
+
let target;
|
|
3574
|
+
try {
|
|
3575
|
+
target = readlinkSync(launcher);
|
|
3576
|
+
} catch {
|
|
3577
|
+
return void 0;
|
|
3578
|
+
}
|
|
3579
|
+
const version = /^camunda-modeler-(\d+\.\d+\.\d+)-linux-x64\/camunda-modeler$/.exec(
|
|
3580
|
+
target
|
|
3581
|
+
)?.[1];
|
|
3582
|
+
if (!version) return void 0;
|
|
3583
|
+
const installDir = join2(
|
|
3584
|
+
LINUX_INSTALL_ROOT,
|
|
3585
|
+
`camunda-modeler-${version}-linux-x64`
|
|
3586
|
+
);
|
|
3587
|
+
return { version, target, installDir, launcher };
|
|
3588
|
+
}
|
|
3589
|
+
function linuxModelerForAction(action) {
|
|
3590
|
+
const installation = findManagedLinuxModeler();
|
|
3591
|
+
if (installation) return installation;
|
|
3592
|
+
const launcher = join2(LINUX_INSTALL_ROOT, LINUX_EXECUTABLE);
|
|
3593
|
+
const installedPath = findOnPath(LINUX_EXECUTABLE);
|
|
3594
|
+
if (installedPath || pathExists(launcher)) {
|
|
3595
|
+
throw new Error(
|
|
3596
|
+
`Camunda Modeler at ${installedPath ?? launcher} is not installed by c8ctl; refusing to ${action} it.`
|
|
3597
|
+
);
|
|
3598
|
+
}
|
|
3599
|
+
return void 0;
|
|
3600
|
+
}
|
|
3601
|
+
async function updateLinuxModeler(ctx) {
|
|
3602
|
+
if (process.arch !== "x64") {
|
|
3603
|
+
throw manualDownloadError(
|
|
3604
|
+
`Unsupported Linux architecture "${process.arch}"`
|
|
3605
|
+
);
|
|
3606
|
+
}
|
|
3607
|
+
const installation = linuxModelerForAction("update");
|
|
3608
|
+
if (!installation) return noModelerInstalled();
|
|
3609
|
+
if (!existsSync(join2(installation.installDir, LINUX_EXECUTABLE))) {
|
|
3610
|
+
throw new Error(
|
|
3611
|
+
`Camunda Modeler ${installation.version} is only partially installed: ${join2(installation.installDir, LINUX_EXECUTABLE)} is missing. Run \`c8ctl modeler remove\` to clean up, then \`c8ctl modeler install\` to install it again.`
|
|
3612
|
+
);
|
|
3613
|
+
}
|
|
3614
|
+
const tempDir = mkdtempSync(join2(tmpdir(), "c8ctl-modeler-"));
|
|
3615
|
+
const interruption = registerDownloadInterrupts("Modeler update");
|
|
3616
|
+
try {
|
|
3617
|
+
reportProgress(
|
|
3618
|
+
ctx,
|
|
3619
|
+
"Checking for the latest stable Camunda Modeler release..."
|
|
3620
|
+
);
|
|
3621
|
+
const latestVersion = latestStableModelerVersion(
|
|
3622
|
+
await fetchReleaseIndex(interruption.signal)
|
|
3623
|
+
);
|
|
3624
|
+
if (!isNewerModelerVersion(latestVersion, installation.version)) {
|
|
3625
|
+
return {
|
|
3626
|
+
kind: "info",
|
|
3627
|
+
message: `Camunda Modeler is already up to date (installed ${installation.version}; latest stable ${latestVersion}).`
|
|
3628
|
+
};
|
|
3629
|
+
}
|
|
3630
|
+
const newReleaseName = `camunda-modeler-${latestVersion}-linux-x64`;
|
|
3631
|
+
const newInstallDir = join2(LINUX_INSTALL_ROOT, newReleaseName);
|
|
3632
|
+
if (ctx.isDryRun) {
|
|
3633
|
+
return dryRunResult(
|
|
3634
|
+
"modeler update",
|
|
3635
|
+
`Dry run: would update Camunda Modeler from ${installation.version} to ${latestVersion} in ${newInstallDir}.`
|
|
3636
|
+
);
|
|
3637
|
+
}
|
|
3638
|
+
if (existsSync(newInstallDir)) {
|
|
3639
|
+
throw new Error(
|
|
3640
|
+
`A release directory already exists at ${newInstallDir}; refusing to overwrite it.`
|
|
3641
|
+
);
|
|
3642
|
+
}
|
|
3643
|
+
if (process.getuid?.() !== 0) {
|
|
3644
|
+
reportProgress(
|
|
3645
|
+
ctx,
|
|
3646
|
+
`Updating in ${LINUX_INSTALL_ROOT} needs root privileges; sudo may ask for your password.`
|
|
3647
|
+
);
|
|
3648
|
+
}
|
|
3649
|
+
runAsRoot(["true"], "Could not get root privileges", ctx.quiet);
|
|
3650
|
+
const { archivePath } = await downloadReleaseVersion({
|
|
3651
|
+
dir: tempDir,
|
|
3652
|
+
version: latestVersion,
|
|
3653
|
+
platform: "Linux",
|
|
3654
|
+
archiveName: (version) => `camunda-modeler-${version}-linux-x64.tar.gz`,
|
|
3655
|
+
logger: ctx.logger,
|
|
3656
|
+
quiet: ctx.quiet,
|
|
3657
|
+
signal: interruption.signal
|
|
3658
|
+
});
|
|
3659
|
+
const temporaryLauncher = join2(
|
|
3660
|
+
LINUX_INSTALL_ROOT,
|
|
3661
|
+
".c8ctl-camunda-modeler-update"
|
|
3662
|
+
);
|
|
3663
|
+
let launcherUpdated = false;
|
|
3664
|
+
try {
|
|
3665
|
+
reportProgress(
|
|
3666
|
+
ctx,
|
|
3667
|
+
`Installing Camunda Modeler ${latestVersion} to ${newInstallDir}...`
|
|
3668
|
+
);
|
|
3669
|
+
runAsRoot(
|
|
3670
|
+
[
|
|
3671
|
+
"tar",
|
|
3672
|
+
"--no-same-owner",
|
|
3673
|
+
"-xzf",
|
|
3674
|
+
archivePath,
|
|
3675
|
+
"-C",
|
|
3676
|
+
LINUX_INSTALL_ROOT
|
|
3677
|
+
],
|
|
3678
|
+
"Could not extract Camunda Modeler",
|
|
3679
|
+
ctx.quiet
|
|
3680
|
+
);
|
|
3681
|
+
if (!existsSync(join2(newInstallDir, LINUX_EXECUTABLE))) {
|
|
3682
|
+
throw manualDownloadError(
|
|
3683
|
+
`The Camunda Modeler ${latestVersion} archive did not contain ${newReleaseName}/${LINUX_EXECUTABLE}`
|
|
3684
|
+
);
|
|
3685
|
+
}
|
|
3686
|
+
runAsRoot(
|
|
3687
|
+
["chmod", "4755", join2(newInstallDir, "chrome-sandbox")],
|
|
3688
|
+
"Could not set up the Camunda Modeler sandbox",
|
|
3689
|
+
ctx.quiet
|
|
3690
|
+
);
|
|
3691
|
+
runAsRoot(
|
|
3692
|
+
[
|
|
3693
|
+
"ln",
|
|
3694
|
+
"-sfn",
|
|
3695
|
+
join2(newReleaseName, LINUX_EXECUTABLE),
|
|
3696
|
+
temporaryLauncher
|
|
3697
|
+
],
|
|
3698
|
+
`Could not prepare ${LINUX_EXECUTABLE}`,
|
|
3699
|
+
ctx.quiet
|
|
3700
|
+
);
|
|
3701
|
+
runAsRoot(
|
|
3702
|
+
["mv", "-f", temporaryLauncher, installation.launcher],
|
|
3703
|
+
`Could not switch ${LINUX_EXECUTABLE} to the updated release`,
|
|
3704
|
+
ctx.quiet
|
|
3705
|
+
);
|
|
3706
|
+
launcherUpdated = true;
|
|
3707
|
+
} catch (error) {
|
|
3708
|
+
if (!launcherUpdated) {
|
|
3709
|
+
try {
|
|
3710
|
+
runAsRoot(
|
|
3711
|
+
["rm", "-f", temporaryLauncher],
|
|
3712
|
+
`Could not remove ${temporaryLauncher}`,
|
|
3713
|
+
ctx.quiet,
|
|
3714
|
+
false
|
|
3715
|
+
);
|
|
3716
|
+
} catch (cleanupError) {
|
|
3717
|
+
ctx.logger.warn(errorMessage(cleanupError));
|
|
3718
|
+
}
|
|
3719
|
+
if (existsSync(newInstallDir)) {
|
|
3720
|
+
try {
|
|
3721
|
+
runAsRoot(
|
|
3722
|
+
["rm", "-rf", newInstallDir],
|
|
3723
|
+
`Could not remove incomplete release ${newInstallDir}`,
|
|
3724
|
+
ctx.quiet,
|
|
3725
|
+
false
|
|
3726
|
+
);
|
|
3727
|
+
} catch (cleanupError) {
|
|
3728
|
+
ctx.logger.warn(errorMessage(cleanupError));
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
throw error;
|
|
3733
|
+
}
|
|
3734
|
+
unregisterWithDesktop({
|
|
3735
|
+
installDir: installation.installDir,
|
|
3736
|
+
logger: ctx.logger,
|
|
3737
|
+
quiet: ctx.quiet
|
|
3738
|
+
});
|
|
3739
|
+
registerWithDesktop({
|
|
3740
|
+
installDir: newInstallDir,
|
|
3741
|
+
logger: ctx.logger,
|
|
3742
|
+
quiet: ctx.quiet
|
|
3743
|
+
});
|
|
3744
|
+
try {
|
|
3745
|
+
runAsRoot(
|
|
3746
|
+
["rm", "-rf", installation.installDir],
|
|
3747
|
+
`Could not remove previous Modeler release ${installation.installDir}`,
|
|
3748
|
+
ctx.quiet,
|
|
3749
|
+
false
|
|
3750
|
+
);
|
|
3751
|
+
} catch (error) {
|
|
3752
|
+
ctx.logger.warn(
|
|
3753
|
+
`Updated Camunda Modeler, but could not remove the previous release at ${installation.installDir}: ${errorMessage(error)}`
|
|
3754
|
+
);
|
|
3755
|
+
}
|
|
3756
|
+
return {
|
|
3757
|
+
kind: "success",
|
|
3758
|
+
message: `Updated Camunda Modeler to ${latestVersion} in ${newInstallDir}.`
|
|
3759
|
+
};
|
|
3760
|
+
} finally {
|
|
3761
|
+
try {
|
|
3762
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
3763
|
+
} finally {
|
|
3764
|
+
interruption.cleanup();
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
function removeLinuxModeler(ctx) {
|
|
3769
|
+
const installation = linuxModelerForAction("remove");
|
|
3770
|
+
if (!installation) {
|
|
3771
|
+
verifyExpectedRemovalTarget(ctx, void 0);
|
|
3772
|
+
return noModelerInstalled();
|
|
3773
|
+
}
|
|
3774
|
+
const removalTarget = {
|
|
3775
|
+
method: "linux-managed-install",
|
|
3776
|
+
path: installation.installDir
|
|
3777
|
+
};
|
|
3778
|
+
verifyExpectedRemovalTarget(ctx, removalTarget);
|
|
3779
|
+
if (ctx.isDryRun) {
|
|
3780
|
+
return dryRunResult(
|
|
3781
|
+
"modeler remove",
|
|
3782
|
+
`Dry run: would remove Camunda Modeler ${installation.version} from ${installation.installDir} and unregister its file types.`,
|
|
3783
|
+
removalTarget
|
|
3784
|
+
);
|
|
3785
|
+
}
|
|
3786
|
+
if (process.getuid?.() !== 0) {
|
|
3787
|
+
reportProgress(
|
|
3788
|
+
ctx,
|
|
3789
|
+
`Removing from ${LINUX_INSTALL_ROOT} needs root privileges; sudo may ask for your password.`
|
|
3790
|
+
);
|
|
3791
|
+
}
|
|
3792
|
+
runAsRoot(["true"], "Could not get root privileges", ctx.quiet, false);
|
|
3793
|
+
unregisterWithDesktop({
|
|
3794
|
+
installDir: installation.installDir,
|
|
3795
|
+
logger: ctx.logger,
|
|
3796
|
+
quiet: ctx.quiet
|
|
3797
|
+
});
|
|
3798
|
+
runAsRoot(
|
|
3799
|
+
["rm", "-rf", installation.installDir],
|
|
3800
|
+
`Could not remove ${installation.installDir}`,
|
|
3801
|
+
ctx.quiet,
|
|
3802
|
+
false
|
|
3803
|
+
);
|
|
3804
|
+
runAsRoot(
|
|
3805
|
+
["rm", "-f", installation.launcher],
|
|
3806
|
+
`Could not remove ${installation.launcher}`,
|
|
3807
|
+
ctx.quiet,
|
|
3808
|
+
false
|
|
3809
|
+
);
|
|
3810
|
+
return {
|
|
3811
|
+
kind: "success",
|
|
3812
|
+
message: `Removed Camunda Modeler ${installation.version} from ${installation.installDir}.`
|
|
3813
|
+
};
|
|
3814
|
+
}
|
|
3815
|
+
async function removeMacModeler(ctx) {
|
|
3816
|
+
if (hasPackageManager("brew", "Homebrew") && homebrewModelerInstalled()) {
|
|
3817
|
+
let appPath2;
|
|
3818
|
+
try {
|
|
3819
|
+
appPath2 = resolveHomebrewModelerPath();
|
|
3820
|
+
} catch (error) {
|
|
3821
|
+
if (ctx.isDryRun || ctx.expectedRemovalTarget !== void 0) {
|
|
3822
|
+
throw error;
|
|
3823
|
+
}
|
|
3824
|
+
ctx.logger.warn(
|
|
3825
|
+
`Could not locate the Homebrew Modeler bundle before uninstalling it: ${errorMessage(error)}`
|
|
3826
|
+
);
|
|
3827
|
+
}
|
|
3828
|
+
const removalTarget2 = appPath2 === void 0 ? void 0 : { method: "homebrew-cask", path: appPath2 };
|
|
3829
|
+
verifyExpectedRemovalTarget(ctx, removalTarget2);
|
|
3830
|
+
if (ctx.isDryRun) {
|
|
3831
|
+
if (removalTarget2 === void 0) {
|
|
3832
|
+
throw new Error(
|
|
3833
|
+
"Could not identify the Homebrew Modeler target for the removal preview."
|
|
3834
|
+
);
|
|
3835
|
+
}
|
|
3836
|
+
return dryRunResult(
|
|
3837
|
+
"modeler remove",
|
|
3838
|
+
"Dry run: would remove Camunda Modeler with `brew uninstall --cask camunda-modeler`.",
|
|
3839
|
+
removalTarget2
|
|
3840
|
+
);
|
|
3841
|
+
}
|
|
3842
|
+
reportProgress(ctx, "Removing Camunda Modeler with Homebrew...");
|
|
3843
|
+
runCommand("brew", ["uninstall", "--cask", "camunda-modeler"], {
|
|
3844
|
+
failureMessage: "Homebrew could not remove Camunda Modeler",
|
|
3845
|
+
quiet: ctx.quiet
|
|
3846
|
+
});
|
|
3847
|
+
if (appPath2) unregisterWithLaunchServices(appPath2, ctx.logger);
|
|
3848
|
+
return {
|
|
3849
|
+
kind: "success",
|
|
3850
|
+
message: "Removed Camunda Modeler with Homebrew."
|
|
3851
|
+
};
|
|
3852
|
+
}
|
|
3853
|
+
const appPath = findInstalledModeler();
|
|
3854
|
+
if (!appPath) {
|
|
3855
|
+
verifyExpectedRemovalTarget(ctx, void 0);
|
|
3856
|
+
return noModelerInstalled();
|
|
3857
|
+
}
|
|
3858
|
+
const removalTarget = { method: "macos-app-bundle", path: appPath };
|
|
3859
|
+
verifyExpectedRemovalTarget(ctx, removalTarget);
|
|
3860
|
+
if (isHomebrewCaskPath(appPath)) {
|
|
3861
|
+
throw new Error(
|
|
3862
|
+
"Camunda Modeler appears to be Homebrew-managed, but its cask was not found; refusing to remove the app bundle directly."
|
|
3863
|
+
);
|
|
3864
|
+
}
|
|
3865
|
+
verifyMacModelerBundle(appPath, "remove", ctx.quiet);
|
|
3866
|
+
if (ctx.isDryRun) {
|
|
3867
|
+
return dryRunResult(
|
|
3868
|
+
"modeler remove",
|
|
3869
|
+
`Dry run: would remove the Camunda Modeler app bundle at ${appPath}.`,
|
|
3870
|
+
removalTarget
|
|
3871
|
+
);
|
|
3872
|
+
}
|
|
3873
|
+
reportProgress(ctx, `Removing Camunda Modeler from ${appPath}...`);
|
|
3874
|
+
unregisterWithLaunchServices(appPath, ctx.logger);
|
|
3875
|
+
rmSync(appPath, { recursive: true });
|
|
3876
|
+
return {
|
|
3877
|
+
kind: "success",
|
|
3878
|
+
message: `Removed Camunda Modeler from ${appPath}.`
|
|
3879
|
+
};
|
|
3880
|
+
}
|
|
3881
|
+
async function updateDesktopModeler(ctx) {
|
|
3882
|
+
if (process.platform === "win32") return updateWindowsModeler(ctx);
|
|
3883
|
+
if (process.platform === "linux") {
|
|
3884
|
+
return withLinuxLifecycleLock(ctx, () => updateLinuxModeler(ctx));
|
|
3885
|
+
}
|
|
3886
|
+
if (process.platform === "darwin") return updateMacModeler(ctx);
|
|
3887
|
+
throw new Error(
|
|
3888
|
+
`c8ctl modeler update currently supports macOS, Windows, and Linux only. Download Modeler manually from ${MANUAL_DOWNLOAD_URL}`
|
|
3889
|
+
);
|
|
3890
|
+
}
|
|
3891
|
+
async function removeDesktopModeler(ctx) {
|
|
3892
|
+
if (process.platform === "win32") return removeWindowsModeler(ctx);
|
|
3893
|
+
if (process.platform === "linux") {
|
|
3894
|
+
return withLinuxLifecycleLock(ctx, () => removeLinuxModeler(ctx));
|
|
3895
|
+
}
|
|
3896
|
+
if (process.platform === "darwin") return removeMacModeler(ctx);
|
|
3897
|
+
throw new Error(
|
|
3898
|
+
`c8ctl modeler remove currently supports macOS, Windows, and Linux only. Download Modeler manually from ${MANUAL_DOWNLOAD_URL}`
|
|
3899
|
+
);
|
|
3900
|
+
}
|
|
2974
3901
|
|
|
2975
3902
|
// default-plugins/modeler/c8ctl-plugin.ts
|
|
2976
3903
|
var metadata = {
|
|
2977
3904
|
name: "modeler",
|
|
2978
|
-
description: "
|
|
3905
|
+
description: "Manage Camunda Desktop Modeler",
|
|
2979
3906
|
commands: {
|
|
2980
3907
|
modeler: {
|
|
2981
|
-
description: "
|
|
2982
|
-
helpDescription: "
|
|
3908
|
+
description: "Manage Camunda Desktop Modeler",
|
|
3909
|
+
helpDescription: "Manage Camunda Desktop Modeler on macOS, Windows, or Linux. Install the latest stable release, update it using the same installation method, or remove it. On macOS, uses Homebrew when available and otherwise downloads the Camunda-signed release into /Applications (or ~/Applications when /Applications is not writable). On Windows, uses winget and registers file types and a Start Menu shortcut. On Linux (x64), installs into /usr/bin as root and registers file types with Modeler's bundled support scripts.",
|
|
2983
3910
|
subcommands: [
|
|
2984
3911
|
{
|
|
2985
3912
|
name: "install",
|
|
2986
3913
|
description: "Install the latest stable Camunda Desktop Modeler"
|
|
3914
|
+
},
|
|
3915
|
+
{
|
|
3916
|
+
name: "update",
|
|
3917
|
+
description: "Update Camunda Desktop Modeler to the latest stable release"
|
|
3918
|
+
},
|
|
3919
|
+
{
|
|
3920
|
+
name: "remove",
|
|
3921
|
+
description: "Remove a c8ctl-managed Camunda Desktop Modeler installation"
|
|
2987
3922
|
}
|
|
2988
3923
|
],
|
|
2989
3924
|
examples: [
|
|
2990
3925
|
{
|
|
2991
3926
|
command: "c8ctl modeler install",
|
|
2992
3927
|
description: "Install the latest stable Camunda Desktop Modeler"
|
|
3928
|
+
},
|
|
3929
|
+
{
|
|
3930
|
+
command: "c8ctl modeler update",
|
|
3931
|
+
description: "Update Camunda Desktop Modeler"
|
|
3932
|
+
},
|
|
3933
|
+
{
|
|
3934
|
+
command: "c8ctl modeler remove --dry-run",
|
|
3935
|
+
description: "Preview removal of Camunda Desktop Modeler"
|
|
2993
3936
|
}
|
|
2994
3937
|
]
|
|
2995
3938
|
}
|
|
2996
3939
|
}
|
|
2997
3940
|
};
|
|
3941
|
+
function expectedRemovalTargetFromEnvironment() {
|
|
3942
|
+
const serialized = process.env.C8CTL_SETUP_MODELER_REMOVAL_TARGET;
|
|
3943
|
+
if (serialized === void 0) return void 0;
|
|
3944
|
+
let parsed;
|
|
3945
|
+
try {
|
|
3946
|
+
parsed = JSON.parse(serialized);
|
|
3947
|
+
} catch {
|
|
3948
|
+
throw new Error("Invalid setup-provided Modeler removal target.");
|
|
3949
|
+
}
|
|
3950
|
+
if (!isRecord(parsed) || typeof parsed.method !== "string" || parsed.method.length === 0 || typeof parsed.path !== "string" || parsed.path.length === 0) {
|
|
3951
|
+
throw new Error("Invalid setup-provided Modeler removal target.");
|
|
3952
|
+
}
|
|
3953
|
+
return { method: parsed.method, path: parsed.path };
|
|
3954
|
+
}
|
|
2998
3955
|
async function modelerHandler(args, _flags, ctx) {
|
|
2999
3956
|
if (!ctx) throw new Error("modeler requires the plugin host context");
|
|
3000
3957
|
const { logger } = ctx;
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
}
|
|
3958
|
+
const action = args[0];
|
|
3959
|
+
if (action === void 0) {
|
|
3960
|
+
logger.info(
|
|
3961
|
+
"\nUsage: c8ctl modeler <install|update|remove>\n\nAvailable commands:\n install\n update\n remove",
|
|
3962
|
+
{ essential: true }
|
|
3963
|
+
);
|
|
3964
|
+
process.exitCode = 1;
|
|
3965
|
+
return;
|
|
3966
|
+
}
|
|
3967
|
+
if (action !== "install" && action !== "update" && action !== "remove") {
|
|
3968
|
+
logger.error(`Unknown command: modeler ${args.join(" ")}`);
|
|
3969
|
+
logger.info('Run "c8 help" for usage information', { essential: true });
|
|
3013
3970
|
process.exitCode = 1;
|
|
3014
3971
|
return;
|
|
3015
3972
|
}
|
|
3016
3973
|
try {
|
|
3017
|
-
const
|
|
3974
|
+
const operation = {
|
|
3975
|
+
install: installDesktopModeler,
|
|
3976
|
+
update: updateDesktopModeler,
|
|
3977
|
+
remove: removeDesktopModeler
|
|
3978
|
+
}[action];
|
|
3979
|
+
const result = await operation({
|
|
3018
3980
|
isDryRun: ctx.dryRun,
|
|
3019
3981
|
logger,
|
|
3020
|
-
quiet: ctx.quiet
|
|
3982
|
+
quiet: ctx.quiet,
|
|
3983
|
+
...action === "remove" ? {
|
|
3984
|
+
expectedRemovalTarget: expectedRemovalTargetFromEnvironment()
|
|
3985
|
+
} : {}
|
|
3021
3986
|
});
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3987
|
+
const normalized = result.kind === "info" && ctx.dryRun ? {
|
|
3988
|
+
kind: "dryRun",
|
|
3989
|
+
info: {
|
|
3990
|
+
dryRun: true,
|
|
3991
|
+
command: `modeler ${action}`,
|
|
3992
|
+
message: result.message,
|
|
3993
|
+
wouldChange: false
|
|
3994
|
+
}
|
|
3995
|
+
} : result;
|
|
3996
|
+
if (normalized.kind === "dryRun") {
|
|
3997
|
+
logger.json(normalized.info);
|
|
3998
|
+
} else if (normalized.kind === "info") {
|
|
3999
|
+
logger.info(normalized.message, { essential: true });
|
|
3026
4000
|
} else {
|
|
3027
|
-
logger.success(
|
|
4001
|
+
logger.success(normalized.message);
|
|
3028
4002
|
}
|
|
3029
4003
|
} catch (error) {
|
|
3030
|
-
renderCommandFailure(logger,
|
|
4004
|
+
renderCommandFailure(logger, `Failed to ${action} Camunda Modeler`, error, {
|
|
3031
4005
|
verbose: ctx.verbose
|
|
3032
4006
|
});
|
|
3033
4007
|
process.exitCode = 1;
|