@camunda8/cli 4.7.0-alpha.20 → 4.7.0-alpha.21

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.
Files changed (83) hide show
  1. package/README.md +0 -3
  2. package/dist/command-dispatch.d.ts.map +1 -1
  3. package/dist/command-dispatch.js +0 -8
  4. package/dist/command-dispatch.js.map +1 -1
  5. package/dist/commands/run.d.ts +0 -5
  6. package/dist/commands/run.d.ts.map +1 -1
  7. package/dist/commands/run.js +1 -9
  8. package/dist/commands/run.js.map +1 -1
  9. package/dist/core/errors.d.ts +17 -0
  10. package/dist/core/errors.d.ts.map +1 -1
  11. package/dist/core/errors.js +32 -0
  12. package/dist/core/errors.js.map +1 -1
  13. package/dist/default-plugins/modeler/README.md +12 -0
  14. package/dist/default-plugins/modeler/c8ctl-plugin.js +3042 -0
  15. package/dist/default-plugins/modeler/package.json +8 -0
  16. package/dist/default-plugins/setup/README.md +36 -0
  17. package/dist/default-plugins/setup/c8ctl-plugin.js +6336 -0
  18. package/dist/default-plugins/setup/package.json +8 -0
  19. package/dist/default-plugins/skills/README.md +18 -0
  20. package/dist/default-plugins/skills/c8ctl-plugin.js +572 -0
  21. package/dist/default-plugins/skills/package.json +8 -0
  22. package/dist/framework/command-registry.d.ts +0 -76
  23. package/dist/framework/command-registry.d.ts.map +1 -1
  24. package/dist/framework/command-registry.js +0 -161
  25. package/dist/framework/command-registry.js.map +1 -1
  26. package/dist/framework/plugins/plugin-loader.d.ts +5 -2
  27. package/dist/framework/plugins/plugin-loader.d.ts.map +1 -1
  28. package/dist/framework/plugins/plugin-loader.js.map +1 -1
  29. package/dist/framework/ui/help.d.ts.map +1 -1
  30. package/dist/framework/ui/help.js +26 -13
  31. package/dist/framework/ui/help.js.map +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +7 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/utils/command-local/mcp-install-helpers.d.ts +17 -0
  36. package/dist/utils/command-local/mcp-install-helpers.d.ts.map +1 -1
  37. package/dist/utils/command-local/mcp-install-helpers.js +23 -9
  38. package/dist/utils/command-local/mcp-install-helpers.js.map +1 -1
  39. package/dist/utils/command-local/process-instance-helpers.d.ts +6 -0
  40. package/dist/utils/command-local/process-instance-helpers.d.ts.map +1 -1
  41. package/dist/utils/command-local/process-instance-helpers.js +9 -0
  42. package/dist/utils/command-local/process-instance-helpers.js.map +1 -1
  43. package/dist/utils/index.d.ts +0 -6
  44. package/dist/utils/index.d.ts.map +1 -1
  45. package/dist/utils/index.js +0 -6
  46. package/dist/utils/index.js.map +1 -1
  47. package/package.json +1 -1
  48. package/dist/commands/modeler.d.ts +0 -10
  49. package/dist/commands/modeler.d.ts.map +0 -1
  50. package/dist/commands/modeler.js +0 -604
  51. package/dist/commands/modeler.js.map +0 -1
  52. package/dist/commands/setup.d.ts +0 -39
  53. package/dist/commands/setup.d.ts.map +0 -1
  54. package/dist/commands/setup.js +0 -856
  55. package/dist/commands/setup.js.map +0 -1
  56. package/dist/commands/skills.d.ts +0 -2
  57. package/dist/commands/skills.d.ts.map +0 -1
  58. package/dist/commands/skills.js +0 -38
  59. package/dist/commands/skills.js.map +0 -1
  60. package/dist/utils/command-local/blueprint-scaffold.d.ts +0 -151
  61. package/dist/utils/command-local/blueprint-scaffold.d.ts.map +0 -1
  62. package/dist/utils/command-local/blueprint-scaffold.js +0 -547
  63. package/dist/utils/command-local/blueprint-scaffold.js.map +0 -1
  64. package/dist/utils/command-local/modeler-helpers.d.ts +0 -15
  65. package/dist/utils/command-local/modeler-helpers.d.ts.map +0 -1
  66. package/dist/utils/command-local/modeler-helpers.js +0 -67
  67. package/dist/utils/command-local/modeler-helpers.js.map +0 -1
  68. package/dist/utils/command-local/setup-detectors.d.ts +0 -51
  69. package/dist/utils/command-local/setup-detectors.d.ts.map +0 -1
  70. package/dist/utils/command-local/setup-detectors.js +0 -115
  71. package/dist/utils/command-local/setup-detectors.js.map +0 -1
  72. package/dist/utils/command-local/setup-helpers.d.ts +0 -179
  73. package/dist/utils/command-local/setup-helpers.d.ts.map +0 -1
  74. package/dist/utils/command-local/setup-helpers.js +0 -374
  75. package/dist/utils/command-local/setup-helpers.js.map +0 -1
  76. package/dist/utils/command-local/setup-prerequisites.d.ts +0 -67
  77. package/dist/utils/command-local/setup-prerequisites.d.ts.map +0 -1
  78. package/dist/utils/command-local/setup-prerequisites.js +0 -238
  79. package/dist/utils/command-local/setup-prerequisites.js.map +0 -1
  80. package/dist/utils/command-local/setup-removal.d.ts +0 -37
  81. package/dist/utils/command-local/setup-removal.d.ts.map +0 -1
  82. package/dist/utils/command-local/setup-removal.js +0 -82
  83. package/dist/utils/command-local/setup-removal.js.map +0 -1
@@ -0,0 +1,3042 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ try {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ } catch (e) {
11
+ throw mod = 0, e;
12
+ }
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+
31
+ // node_modules/semver/internal/constants.js
32
+ var require_constants = __commonJS({
33
+ "node_modules/semver/internal/constants.js"(exports, module) {
34
+ "use strict";
35
+ var SEMVER_SPEC_VERSION = "2.0.0";
36
+ var MAX_LENGTH = 256;
37
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
38
+ 9007199254740991;
39
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
40
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
41
+ var RELEASE_TYPES = [
42
+ "major",
43
+ "premajor",
44
+ "minor",
45
+ "preminor",
46
+ "patch",
47
+ "prepatch",
48
+ "prerelease"
49
+ ];
50
+ module.exports = {
51
+ MAX_LENGTH,
52
+ MAX_SAFE_COMPONENT_LENGTH,
53
+ MAX_SAFE_BUILD_LENGTH,
54
+ MAX_SAFE_INTEGER,
55
+ RELEASE_TYPES,
56
+ SEMVER_SPEC_VERSION,
57
+ FLAG_INCLUDE_PRERELEASE: 1,
58
+ FLAG_LOOSE: 2
59
+ };
60
+ }
61
+ });
62
+
63
+ // node_modules/semver/internal/debug.js
64
+ var require_debug = __commonJS({
65
+ "node_modules/semver/internal/debug.js"(exports, module) {
66
+ "use strict";
67
+ var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
68
+ };
69
+ module.exports = debug;
70
+ }
71
+ });
72
+
73
+ // node_modules/semver/internal/re.js
74
+ var require_re = __commonJS({
75
+ "node_modules/semver/internal/re.js"(exports, module) {
76
+ "use strict";
77
+ var {
78
+ MAX_SAFE_COMPONENT_LENGTH,
79
+ MAX_SAFE_BUILD_LENGTH,
80
+ MAX_LENGTH
81
+ } = require_constants();
82
+ var debug = require_debug();
83
+ exports = module.exports = {};
84
+ var re = exports.re = [];
85
+ var safeRe = exports.safeRe = [];
86
+ var src = exports.src = [];
87
+ var safeSrc = exports.safeSrc = [];
88
+ var t = exports.t = {};
89
+ var R = 0;
90
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
91
+ var safeRegexReplacements = [
92
+ ["\\s", 1],
93
+ ["\\d", MAX_LENGTH],
94
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
95
+ ];
96
+ var makeSafeRegex = (value) => {
97
+ for (const [token, max] of safeRegexReplacements) {
98
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
99
+ }
100
+ return value;
101
+ };
102
+ var createToken = (name, value, isGlobal) => {
103
+ const safe = makeSafeRegex(value);
104
+ const index = R++;
105
+ debug(name, index, value);
106
+ t[name] = index;
107
+ src[index] = value;
108
+ safeSrc[index] = safe;
109
+ re[index] = new RegExp(value, isGlobal ? "g" : void 0);
110
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
111
+ };
112
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
113
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
114
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
115
+ createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
116
+ createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
117
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
118
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
119
+ createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
120
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
121
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
122
+ createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
123
+ createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
124
+ createToken("FULL", `^${src[t.FULLPLAIN]}$`);
125
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
126
+ createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
127
+ createToken("GTLT", "((?:<|>)?=?)");
128
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
129
+ createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
130
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
131
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
132
+ createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
133
+ createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
134
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
135
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
136
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
137
+ createToken("COERCERTL", src[t.COERCE], true);
138
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
139
+ createToken("LONETILDE", "(?:~>?)");
140
+ createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
141
+ exports.tildeTrimReplace = "$1~";
142
+ createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
143
+ createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
144
+ createToken("LONECARET", "(?:\\^)");
145
+ createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
146
+ exports.caretTrimReplace = "$1^";
147
+ createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
148
+ createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
149
+ createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
150
+ createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
151
+ createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
152
+ exports.comparatorTrimReplace = "$1$2$3";
153
+ createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
154
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
155
+ createToken("STAR", "(<|>)?=?\\s*\\*");
156
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
157
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
158
+ }
159
+ });
160
+
161
+ // node_modules/semver/internal/parse-options.js
162
+ var require_parse_options = __commonJS({
163
+ "node_modules/semver/internal/parse-options.js"(exports, module) {
164
+ "use strict";
165
+ var looseOption = Object.freeze({ loose: true });
166
+ var emptyOpts = Object.freeze({});
167
+ var parseOptions = (options) => {
168
+ if (!options) {
169
+ return emptyOpts;
170
+ }
171
+ if (typeof options !== "object") {
172
+ return looseOption;
173
+ }
174
+ return options;
175
+ };
176
+ module.exports = parseOptions;
177
+ }
178
+ });
179
+
180
+ // node_modules/semver/internal/identifiers.js
181
+ var require_identifiers = __commonJS({
182
+ "node_modules/semver/internal/identifiers.js"(exports, module) {
183
+ "use strict";
184
+ var numeric = /^[0-9]+$/;
185
+ var compareIdentifiers = (a, b) => {
186
+ if (typeof a === "number" && typeof b === "number") {
187
+ return a === b ? 0 : a < b ? -1 : 1;
188
+ }
189
+ const anum = numeric.test(a);
190
+ const bnum = numeric.test(b);
191
+ if (anum && bnum) {
192
+ a = +a;
193
+ b = +b;
194
+ }
195
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
196
+ };
197
+ var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
198
+ module.exports = {
199
+ compareIdentifiers,
200
+ rcompareIdentifiers
201
+ };
202
+ }
203
+ });
204
+
205
+ // node_modules/semver/classes/semver.js
206
+ var require_semver = __commonJS({
207
+ "node_modules/semver/classes/semver.js"(exports, module) {
208
+ "use strict";
209
+ var debug = require_debug();
210
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
211
+ var { safeRe: re, t } = require_re();
212
+ var parseOptions = require_parse_options();
213
+ var { compareIdentifiers } = require_identifiers();
214
+ var isPrereleaseIdentifier = (prerelease, identifier) => {
215
+ const identifiers = identifier.split(".");
216
+ if (identifiers.length > prerelease.length) {
217
+ return false;
218
+ }
219
+ for (let i = 0; i < identifiers.length; i++) {
220
+ if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
221
+ return false;
222
+ }
223
+ }
224
+ return true;
225
+ };
226
+ var SemVer = class _SemVer {
227
+ constructor(version, options) {
228
+ options = parseOptions(options);
229
+ if (version instanceof _SemVer) {
230
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
231
+ return version;
232
+ } else {
233
+ version = version.version;
234
+ }
235
+ } else if (typeof version !== "string") {
236
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
237
+ }
238
+ if (version.length > MAX_LENGTH) {
239
+ throw new TypeError(
240
+ `version is longer than ${MAX_LENGTH} characters`
241
+ );
242
+ }
243
+ debug("SemVer", version, options);
244
+ this.options = options;
245
+ this.loose = !!options.loose;
246
+ this.includePrerelease = !!options.includePrerelease;
247
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
248
+ if (!m) {
249
+ throw new TypeError(`Invalid Version: ${version}`);
250
+ }
251
+ this.raw = version;
252
+ this.major = +m[1];
253
+ this.minor = +m[2];
254
+ this.patch = +m[3];
255
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
256
+ throw new TypeError("Invalid major version");
257
+ }
258
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
259
+ throw new TypeError("Invalid minor version");
260
+ }
261
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
262
+ throw new TypeError("Invalid patch version");
263
+ }
264
+ if (!m[4]) {
265
+ this.prerelease = [];
266
+ } else {
267
+ this.prerelease = m[4].split(".").map((id) => {
268
+ if (/^[0-9]+$/.test(id)) {
269
+ const num = +id;
270
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
271
+ return num;
272
+ }
273
+ }
274
+ return id;
275
+ });
276
+ }
277
+ this.build = m[5] ? m[5].split(".") : [];
278
+ this.format();
279
+ }
280
+ format() {
281
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
282
+ if (this.prerelease.length) {
283
+ this.version += `-${this.prerelease.join(".")}`;
284
+ }
285
+ return this.version;
286
+ }
287
+ toString() {
288
+ return this.version;
289
+ }
290
+ compare(other) {
291
+ debug("SemVer.compare", this.version, this.options, other);
292
+ if (!(other instanceof _SemVer)) {
293
+ if (typeof other === "string" && other === this.version) {
294
+ return 0;
295
+ }
296
+ other = new _SemVer(other, this.options);
297
+ }
298
+ if (other.version === this.version) {
299
+ return 0;
300
+ }
301
+ return this.compareMain(other) || this.comparePre(other);
302
+ }
303
+ compareMain(other) {
304
+ if (!(other instanceof _SemVer)) {
305
+ other = new _SemVer(other, this.options);
306
+ }
307
+ if (this.major < other.major) {
308
+ return -1;
309
+ }
310
+ if (this.major > other.major) {
311
+ return 1;
312
+ }
313
+ if (this.minor < other.minor) {
314
+ return -1;
315
+ }
316
+ if (this.minor > other.minor) {
317
+ return 1;
318
+ }
319
+ if (this.patch < other.patch) {
320
+ return -1;
321
+ }
322
+ if (this.patch > other.patch) {
323
+ return 1;
324
+ }
325
+ return 0;
326
+ }
327
+ comparePre(other) {
328
+ if (!(other instanceof _SemVer)) {
329
+ other = new _SemVer(other, this.options);
330
+ }
331
+ if (this.prerelease.length && !other.prerelease.length) {
332
+ return -1;
333
+ } else if (!this.prerelease.length && other.prerelease.length) {
334
+ return 1;
335
+ } else if (!this.prerelease.length && !other.prerelease.length) {
336
+ return 0;
337
+ }
338
+ let i = 0;
339
+ do {
340
+ const a = this.prerelease[i];
341
+ const b = other.prerelease[i];
342
+ debug("prerelease compare", i, a, b);
343
+ if (a === void 0 && b === void 0) {
344
+ return 0;
345
+ } else if (b === void 0) {
346
+ return 1;
347
+ } else if (a === void 0) {
348
+ return -1;
349
+ } else if (a === b) {
350
+ continue;
351
+ } else {
352
+ return compareIdentifiers(a, b);
353
+ }
354
+ } while (++i);
355
+ }
356
+ compareBuild(other) {
357
+ if (!(other instanceof _SemVer)) {
358
+ other = new _SemVer(other, this.options);
359
+ }
360
+ let i = 0;
361
+ do {
362
+ const a = this.build[i];
363
+ const b = other.build[i];
364
+ debug("build compare", i, a, b);
365
+ if (a === void 0 && b === void 0) {
366
+ return 0;
367
+ } else if (b === void 0) {
368
+ return 1;
369
+ } else if (a === void 0) {
370
+ return -1;
371
+ } else if (a === b) {
372
+ continue;
373
+ } else {
374
+ return compareIdentifiers(a, b);
375
+ }
376
+ } while (++i);
377
+ }
378
+ // preminor will bump the version up to the next minor release, and immediately
379
+ // down to pre-release. premajor and prepatch work the same way.
380
+ inc(release, identifier, identifierBase) {
381
+ if (release.startsWith("pre")) {
382
+ if (!identifier && identifierBase === false) {
383
+ throw new Error("invalid increment argument: identifier is empty");
384
+ }
385
+ if (identifier) {
386
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
387
+ if (!match || match[1] !== identifier) {
388
+ throw new Error(`invalid identifier: ${identifier}`);
389
+ }
390
+ }
391
+ }
392
+ switch (release) {
393
+ case "premajor":
394
+ this.prerelease.length = 0;
395
+ this.patch = 0;
396
+ this.minor = 0;
397
+ this.major++;
398
+ this.inc("pre", identifier, identifierBase);
399
+ break;
400
+ case "preminor":
401
+ this.prerelease.length = 0;
402
+ this.patch = 0;
403
+ this.minor++;
404
+ this.inc("pre", identifier, identifierBase);
405
+ break;
406
+ case "prepatch":
407
+ this.prerelease.length = 0;
408
+ this.inc("patch", identifier, identifierBase);
409
+ this.inc("pre", identifier, identifierBase);
410
+ break;
411
+ // If the input is a non-prerelease version, this acts the same as
412
+ // prepatch.
413
+ case "prerelease":
414
+ if (this.prerelease.length === 0) {
415
+ this.inc("patch", identifier, identifierBase);
416
+ }
417
+ this.inc("pre", identifier, identifierBase);
418
+ break;
419
+ case "release":
420
+ if (this.prerelease.length === 0) {
421
+ throw new Error(`version ${this.raw} is not a prerelease`);
422
+ }
423
+ this.prerelease.length = 0;
424
+ break;
425
+ case "major":
426
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
427
+ this.major++;
428
+ }
429
+ this.minor = 0;
430
+ this.patch = 0;
431
+ this.prerelease = [];
432
+ break;
433
+ case "minor":
434
+ if (this.patch !== 0 || this.prerelease.length === 0) {
435
+ this.minor++;
436
+ }
437
+ this.patch = 0;
438
+ this.prerelease = [];
439
+ break;
440
+ case "patch":
441
+ if (this.prerelease.length === 0) {
442
+ this.patch++;
443
+ }
444
+ this.prerelease = [];
445
+ break;
446
+ // This probably shouldn't be used publicly.
447
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
448
+ case "pre": {
449
+ const base = Number(identifierBase) ? 1 : 0;
450
+ if (this.prerelease.length === 0) {
451
+ this.prerelease = [base];
452
+ } else {
453
+ let i = this.prerelease.length;
454
+ while (--i >= 0) {
455
+ if (typeof this.prerelease[i] === "number") {
456
+ this.prerelease[i]++;
457
+ i = -2;
458
+ }
459
+ }
460
+ if (i === -1) {
461
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
462
+ throw new Error("invalid increment argument: identifier already exists");
463
+ }
464
+ this.prerelease.push(base);
465
+ }
466
+ }
467
+ if (identifier) {
468
+ let prerelease = [identifier, base];
469
+ if (identifierBase === false) {
470
+ prerelease = [identifier];
471
+ }
472
+ if (isPrereleaseIdentifier(this.prerelease, identifier)) {
473
+ const prereleaseBase = this.prerelease[identifier.split(".").length];
474
+ if (isNaN(prereleaseBase)) {
475
+ this.prerelease = prerelease;
476
+ }
477
+ } else {
478
+ this.prerelease = prerelease;
479
+ }
480
+ }
481
+ break;
482
+ }
483
+ default:
484
+ throw new Error(`invalid increment argument: ${release}`);
485
+ }
486
+ this.raw = this.format();
487
+ if (this.build.length) {
488
+ this.raw += `+${this.build.join(".")}`;
489
+ }
490
+ return this;
491
+ }
492
+ };
493
+ module.exports = SemVer;
494
+ }
495
+ });
496
+
497
+ // node_modules/semver/functions/parse.js
498
+ var require_parse = __commonJS({
499
+ "node_modules/semver/functions/parse.js"(exports, module) {
500
+ "use strict";
501
+ var SemVer = require_semver();
502
+ var parse2 = (version, options, throwErrors = false) => {
503
+ if (version instanceof SemVer) {
504
+ return version;
505
+ }
506
+ try {
507
+ return new SemVer(version, options);
508
+ } catch (er) {
509
+ if (!throwErrors) {
510
+ return null;
511
+ }
512
+ throw er;
513
+ }
514
+ };
515
+ module.exports = parse2;
516
+ }
517
+ });
518
+
519
+ // node_modules/semver/functions/valid.js
520
+ var require_valid = __commonJS({
521
+ "node_modules/semver/functions/valid.js"(exports, module) {
522
+ "use strict";
523
+ var parse2 = require_parse();
524
+ var valid = (version, options) => {
525
+ const v = parse2(version, options);
526
+ return v ? v.version : null;
527
+ };
528
+ module.exports = valid;
529
+ }
530
+ });
531
+
532
+ // node_modules/semver/functions/clean.js
533
+ var require_clean = __commonJS({
534
+ "node_modules/semver/functions/clean.js"(exports, module) {
535
+ "use strict";
536
+ var parse2 = require_parse();
537
+ var clean = (version, options) => {
538
+ const s = parse2(version.trim().replace(/^[=v]+/, ""), options);
539
+ return s ? s.version : null;
540
+ };
541
+ module.exports = clean;
542
+ }
543
+ });
544
+
545
+ // node_modules/semver/functions/inc.js
546
+ var require_inc = __commonJS({
547
+ "node_modules/semver/functions/inc.js"(exports, module) {
548
+ "use strict";
549
+ var SemVer = require_semver();
550
+ var inc = (version, release, options, identifier, identifierBase) => {
551
+ if (typeof options === "string") {
552
+ identifierBase = identifier;
553
+ identifier = options;
554
+ options = void 0;
555
+ }
556
+ try {
557
+ return new SemVer(
558
+ version instanceof SemVer ? version.version : version,
559
+ options
560
+ ).inc(release, identifier, identifierBase).version;
561
+ } catch (er) {
562
+ return null;
563
+ }
564
+ };
565
+ module.exports = inc;
566
+ }
567
+ });
568
+
569
+ // node_modules/semver/functions/diff.js
570
+ var require_diff = __commonJS({
571
+ "node_modules/semver/functions/diff.js"(exports, module) {
572
+ "use strict";
573
+ var parse2 = require_parse();
574
+ var diff = (version1, version2) => {
575
+ const v1 = parse2(version1, null, true);
576
+ const v2 = parse2(version2, null, true);
577
+ const comparison = v1.compare(v2);
578
+ if (comparison === 0) {
579
+ return null;
580
+ }
581
+ const v1Higher = comparison > 0;
582
+ const highVersion = v1Higher ? v1 : v2;
583
+ const lowVersion = v1Higher ? v2 : v1;
584
+ const highHasPre = !!highVersion.prerelease.length;
585
+ const lowHasPre = !!lowVersion.prerelease.length;
586
+ if (lowHasPre && !highHasPre) {
587
+ if (!lowVersion.patch && !lowVersion.minor) {
588
+ return "major";
589
+ }
590
+ if (lowVersion.compareMain(highVersion) === 0) {
591
+ if (lowVersion.minor && !lowVersion.patch) {
592
+ return "minor";
593
+ }
594
+ return "patch";
595
+ }
596
+ }
597
+ const prefix = highHasPre ? "pre" : "";
598
+ if (v1.major !== v2.major) {
599
+ return prefix + "major";
600
+ }
601
+ if (v1.minor !== v2.minor) {
602
+ return prefix + "minor";
603
+ }
604
+ if (v1.patch !== v2.patch) {
605
+ return prefix + "patch";
606
+ }
607
+ return "prerelease";
608
+ };
609
+ module.exports = diff;
610
+ }
611
+ });
612
+
613
+ // node_modules/semver/functions/major.js
614
+ var require_major = __commonJS({
615
+ "node_modules/semver/functions/major.js"(exports, module) {
616
+ "use strict";
617
+ var SemVer = require_semver();
618
+ var major = (a, loose) => new SemVer(a, loose).major;
619
+ module.exports = major;
620
+ }
621
+ });
622
+
623
+ // node_modules/semver/functions/minor.js
624
+ var require_minor = __commonJS({
625
+ "node_modules/semver/functions/minor.js"(exports, module) {
626
+ "use strict";
627
+ var SemVer = require_semver();
628
+ var minor = (a, loose) => new SemVer(a, loose).minor;
629
+ module.exports = minor;
630
+ }
631
+ });
632
+
633
+ // node_modules/semver/functions/patch.js
634
+ var require_patch = __commonJS({
635
+ "node_modules/semver/functions/patch.js"(exports, module) {
636
+ "use strict";
637
+ var SemVer = require_semver();
638
+ var patch = (a, loose) => new SemVer(a, loose).patch;
639
+ module.exports = patch;
640
+ }
641
+ });
642
+
643
+ // node_modules/semver/functions/prerelease.js
644
+ var require_prerelease = __commonJS({
645
+ "node_modules/semver/functions/prerelease.js"(exports, module) {
646
+ "use strict";
647
+ var parse2 = require_parse();
648
+ var prerelease = (version, options) => {
649
+ const parsed = parse2(version, options);
650
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
651
+ };
652
+ module.exports = prerelease;
653
+ }
654
+ });
655
+
656
+ // node_modules/semver/functions/compare.js
657
+ var require_compare = __commonJS({
658
+ "node_modules/semver/functions/compare.js"(exports, module) {
659
+ "use strict";
660
+ var SemVer = require_semver();
661
+ var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
662
+ module.exports = compare;
663
+ }
664
+ });
665
+
666
+ // node_modules/semver/functions/rcompare.js
667
+ var require_rcompare = __commonJS({
668
+ "node_modules/semver/functions/rcompare.js"(exports, module) {
669
+ "use strict";
670
+ var compare = require_compare();
671
+ var rcompare2 = (a, b, loose) => compare(b, a, loose);
672
+ module.exports = rcompare2;
673
+ }
674
+ });
675
+
676
+ // node_modules/semver/functions/compare-loose.js
677
+ var require_compare_loose = __commonJS({
678
+ "node_modules/semver/functions/compare-loose.js"(exports, module) {
679
+ "use strict";
680
+ var compare = require_compare();
681
+ var compareLoose = (a, b) => compare(a, b, true);
682
+ module.exports = compareLoose;
683
+ }
684
+ });
685
+
686
+ // node_modules/semver/functions/compare-build.js
687
+ var require_compare_build = __commonJS({
688
+ "node_modules/semver/functions/compare-build.js"(exports, module) {
689
+ "use strict";
690
+ var SemVer = require_semver();
691
+ var compareBuild = (a, b, loose) => {
692
+ const versionA = new SemVer(a, loose);
693
+ const versionB = new SemVer(b, loose);
694
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
695
+ };
696
+ module.exports = compareBuild;
697
+ }
698
+ });
699
+
700
+ // node_modules/semver/functions/sort.js
701
+ var require_sort = __commonJS({
702
+ "node_modules/semver/functions/sort.js"(exports, module) {
703
+ "use strict";
704
+ var compareBuild = require_compare_build();
705
+ var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
706
+ module.exports = sort;
707
+ }
708
+ });
709
+
710
+ // node_modules/semver/functions/rsort.js
711
+ var require_rsort = __commonJS({
712
+ "node_modules/semver/functions/rsort.js"(exports, module) {
713
+ "use strict";
714
+ var compareBuild = require_compare_build();
715
+ var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
716
+ module.exports = rsort;
717
+ }
718
+ });
719
+
720
+ // node_modules/semver/functions/gt.js
721
+ var require_gt = __commonJS({
722
+ "node_modules/semver/functions/gt.js"(exports, module) {
723
+ "use strict";
724
+ var compare = require_compare();
725
+ var gt = (a, b, loose) => compare(a, b, loose) > 0;
726
+ module.exports = gt;
727
+ }
728
+ });
729
+
730
+ // node_modules/semver/functions/lt.js
731
+ var require_lt = __commonJS({
732
+ "node_modules/semver/functions/lt.js"(exports, module) {
733
+ "use strict";
734
+ var compare = require_compare();
735
+ var lt = (a, b, loose) => compare(a, b, loose) < 0;
736
+ module.exports = lt;
737
+ }
738
+ });
739
+
740
+ // node_modules/semver/functions/eq.js
741
+ var require_eq = __commonJS({
742
+ "node_modules/semver/functions/eq.js"(exports, module) {
743
+ "use strict";
744
+ var compare = require_compare();
745
+ var eq = (a, b, loose) => compare(a, b, loose) === 0;
746
+ module.exports = eq;
747
+ }
748
+ });
749
+
750
+ // node_modules/semver/functions/neq.js
751
+ var require_neq = __commonJS({
752
+ "node_modules/semver/functions/neq.js"(exports, module) {
753
+ "use strict";
754
+ var compare = require_compare();
755
+ var neq = (a, b, loose) => compare(a, b, loose) !== 0;
756
+ module.exports = neq;
757
+ }
758
+ });
759
+
760
+ // node_modules/semver/functions/gte.js
761
+ var require_gte = __commonJS({
762
+ "node_modules/semver/functions/gte.js"(exports, module) {
763
+ "use strict";
764
+ var compare = require_compare();
765
+ var gte = (a, b, loose) => compare(a, b, loose) >= 0;
766
+ module.exports = gte;
767
+ }
768
+ });
769
+
770
+ // node_modules/semver/functions/lte.js
771
+ var require_lte = __commonJS({
772
+ "node_modules/semver/functions/lte.js"(exports, module) {
773
+ "use strict";
774
+ var compare = require_compare();
775
+ var lte = (a, b, loose) => compare(a, b, loose) <= 0;
776
+ module.exports = lte;
777
+ }
778
+ });
779
+
780
+ // node_modules/semver/functions/cmp.js
781
+ var require_cmp = __commonJS({
782
+ "node_modules/semver/functions/cmp.js"(exports, module) {
783
+ "use strict";
784
+ var eq = require_eq();
785
+ var neq = require_neq();
786
+ var gt = require_gt();
787
+ var gte = require_gte();
788
+ var lt = require_lt();
789
+ var lte = require_lte();
790
+ var cmp = (a, op, b, loose) => {
791
+ switch (op) {
792
+ case "===":
793
+ if (typeof a === "object") {
794
+ a = a.version;
795
+ }
796
+ if (typeof b === "object") {
797
+ b = b.version;
798
+ }
799
+ return a === b;
800
+ case "!==":
801
+ if (typeof a === "object") {
802
+ a = a.version;
803
+ }
804
+ if (typeof b === "object") {
805
+ b = b.version;
806
+ }
807
+ return a !== b;
808
+ case "":
809
+ case "=":
810
+ case "==":
811
+ return eq(a, b, loose);
812
+ case "!=":
813
+ return neq(a, b, loose);
814
+ case ">":
815
+ return gt(a, b, loose);
816
+ case ">=":
817
+ return gte(a, b, loose);
818
+ case "<":
819
+ return lt(a, b, loose);
820
+ case "<=":
821
+ return lte(a, b, loose);
822
+ default:
823
+ throw new TypeError(`Invalid operator: ${op}`);
824
+ }
825
+ };
826
+ module.exports = cmp;
827
+ }
828
+ });
829
+
830
+ // node_modules/semver/functions/coerce.js
831
+ var require_coerce = __commonJS({
832
+ "node_modules/semver/functions/coerce.js"(exports, module) {
833
+ "use strict";
834
+ var SemVer = require_semver();
835
+ var parse2 = require_parse();
836
+ var { safeRe: re, t } = require_re();
837
+ var coerce = (version, options) => {
838
+ if (version instanceof SemVer) {
839
+ return version;
840
+ }
841
+ if (typeof version === "number") {
842
+ version = String(version);
843
+ }
844
+ if (typeof version !== "string") {
845
+ return null;
846
+ }
847
+ options = options || {};
848
+ let match = null;
849
+ if (!options.rtl) {
850
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
851
+ } else {
852
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
853
+ let next;
854
+ while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
855
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
856
+ match = next;
857
+ }
858
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
859
+ }
860
+ coerceRtlRegex.lastIndex = -1;
861
+ }
862
+ if (match === null) {
863
+ return null;
864
+ }
865
+ const major = match[2];
866
+ const minor = match[3] || "0";
867
+ const patch = match[4] || "0";
868
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
869
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
870
+ return parse2(`${major}.${minor}.${patch}${prerelease}${build}`, options);
871
+ };
872
+ module.exports = coerce;
873
+ }
874
+ });
875
+
876
+ // node_modules/semver/functions/truncate.js
877
+ var require_truncate = __commonJS({
878
+ "node_modules/semver/functions/truncate.js"(exports, module) {
879
+ "use strict";
880
+ var parse2 = require_parse();
881
+ var constants2 = require_constants();
882
+ var SemVer = require_semver();
883
+ var truncate = (version, truncation, options) => {
884
+ if (!constants2.RELEASE_TYPES.includes(truncation)) {
885
+ return null;
886
+ }
887
+ const clonedVersion = cloneInputVersion(version, options);
888
+ return clonedVersion && doTruncation(clonedVersion, truncation);
889
+ };
890
+ var cloneInputVersion = (version, options) => {
891
+ const versionStringToParse = version instanceof SemVer ? version.version : version;
892
+ return parse2(versionStringToParse, options);
893
+ };
894
+ var doTruncation = (version, truncation) => {
895
+ if (isPrerelease(truncation)) {
896
+ return version.version;
897
+ }
898
+ version.prerelease = [];
899
+ switch (truncation) {
900
+ case "major":
901
+ version.minor = 0;
902
+ version.patch = 0;
903
+ break;
904
+ case "minor":
905
+ version.patch = 0;
906
+ break;
907
+ }
908
+ return version.format();
909
+ };
910
+ var isPrerelease = (type) => {
911
+ return type.startsWith("pre");
912
+ };
913
+ module.exports = truncate;
914
+ }
915
+ });
916
+
917
+ // node_modules/semver/internal/lrucache.js
918
+ var require_lrucache = __commonJS({
919
+ "node_modules/semver/internal/lrucache.js"(exports, module) {
920
+ "use strict";
921
+ var LRUCache = class {
922
+ constructor() {
923
+ this.max = 1e3;
924
+ this.map = /* @__PURE__ */ new Map();
925
+ }
926
+ get(key) {
927
+ const value = this.map.get(key);
928
+ if (value === void 0) {
929
+ return void 0;
930
+ } else {
931
+ this.map.delete(key);
932
+ this.map.set(key, value);
933
+ return value;
934
+ }
935
+ }
936
+ delete(key) {
937
+ return this.map.delete(key);
938
+ }
939
+ set(key, value) {
940
+ const deleted = this.delete(key);
941
+ if (!deleted && value !== void 0) {
942
+ if (this.map.size >= this.max) {
943
+ const firstKey = this.map.keys().next().value;
944
+ this.delete(firstKey);
945
+ }
946
+ this.map.set(key, value);
947
+ }
948
+ return this;
949
+ }
950
+ };
951
+ module.exports = LRUCache;
952
+ }
953
+ });
954
+
955
+ // node_modules/semver/classes/range.js
956
+ var require_range = __commonJS({
957
+ "node_modules/semver/classes/range.js"(exports, module) {
958
+ "use strict";
959
+ var SPACE_CHARACTERS = /\s+/g;
960
+ var Range = class _Range {
961
+ constructor(range, options) {
962
+ options = parseOptions(options);
963
+ if (range instanceof _Range) {
964
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
965
+ return range;
966
+ } else {
967
+ return new _Range(range.raw, options);
968
+ }
969
+ }
970
+ if (range instanceof Comparator) {
971
+ this.raw = range.value;
972
+ this.set = [[range]];
973
+ this.formatted = void 0;
974
+ return this;
975
+ }
976
+ this.options = options;
977
+ this.loose = !!options.loose;
978
+ this.includePrerelease = !!options.includePrerelease;
979
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
980
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
981
+ if (!this.set.length) {
982
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
983
+ }
984
+ if (this.set.length > 1) {
985
+ const first = this.set[0];
986
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
987
+ if (this.set.length === 0) {
988
+ this.set = [first];
989
+ } else if (this.set.length > 1) {
990
+ for (const c of this.set) {
991
+ if (c.length === 1 && isAny(c[0])) {
992
+ this.set = [c];
993
+ break;
994
+ }
995
+ }
996
+ }
997
+ }
998
+ this.formatted = void 0;
999
+ }
1000
+ get range() {
1001
+ if (this.formatted === void 0) {
1002
+ this.formatted = "";
1003
+ for (let i = 0; i < this.set.length; i++) {
1004
+ if (i > 0) {
1005
+ this.formatted += "||";
1006
+ }
1007
+ const comps = this.set[i];
1008
+ for (let k = 0; k < comps.length; k++) {
1009
+ if (k > 0) {
1010
+ this.formatted += " ";
1011
+ }
1012
+ this.formatted += comps[k].toString().trim();
1013
+ }
1014
+ }
1015
+ }
1016
+ return this.formatted;
1017
+ }
1018
+ format() {
1019
+ return this.range;
1020
+ }
1021
+ toString() {
1022
+ return this.range;
1023
+ }
1024
+ parseRange(range) {
1025
+ range = range.replace(BUILDSTRIPRE, "");
1026
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
1027
+ const memoKey = memoOpts + ":" + range;
1028
+ const cached = cache.get(memoKey);
1029
+ if (cached) {
1030
+ return cached;
1031
+ }
1032
+ const loose = this.options.loose;
1033
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
1034
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
1035
+ debug("hyphen replace", range);
1036
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
1037
+ debug("comparator trim", range);
1038
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
1039
+ debug("tilde trim", range);
1040
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
1041
+ debug("caret trim", range);
1042
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
1043
+ if (loose) {
1044
+ rangeList = rangeList.filter((comp) => {
1045
+ debug("loose invalid filter", comp, this.options);
1046
+ return !!comp.match(re[t.COMPARATORLOOSE]);
1047
+ });
1048
+ }
1049
+ debug("range list", rangeList);
1050
+ const rangeMap = /* @__PURE__ */ new Map();
1051
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
1052
+ for (const comp of comparators) {
1053
+ if (isNullSet(comp)) {
1054
+ return [comp];
1055
+ }
1056
+ rangeMap.set(comp.value, comp);
1057
+ }
1058
+ if (rangeMap.size > 1 && rangeMap.has("")) {
1059
+ rangeMap.delete("");
1060
+ }
1061
+ const result = [...rangeMap.values()];
1062
+ cache.set(memoKey, result);
1063
+ return result;
1064
+ }
1065
+ intersects(range, options) {
1066
+ if (!(range instanceof _Range)) {
1067
+ throw new TypeError("a Range is required");
1068
+ }
1069
+ return this.set.some((thisComparators) => {
1070
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
1071
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
1072
+ return rangeComparators.every((rangeComparator) => {
1073
+ return thisComparator.intersects(rangeComparator, options);
1074
+ });
1075
+ });
1076
+ });
1077
+ });
1078
+ }
1079
+ // if ANY of the sets match ALL of its comparators, then pass
1080
+ test(version) {
1081
+ if (!version) {
1082
+ return false;
1083
+ }
1084
+ if (typeof version === "string") {
1085
+ try {
1086
+ version = new SemVer(version, this.options);
1087
+ } catch (er) {
1088
+ return false;
1089
+ }
1090
+ }
1091
+ for (let i = 0; i < this.set.length; i++) {
1092
+ if (testSet(this.set[i], version, this.options)) {
1093
+ return true;
1094
+ }
1095
+ }
1096
+ return false;
1097
+ }
1098
+ };
1099
+ module.exports = Range;
1100
+ var LRU = require_lrucache();
1101
+ var cache = new LRU();
1102
+ var parseOptions = require_parse_options();
1103
+ var Comparator = require_comparator();
1104
+ var debug = require_debug();
1105
+ var SemVer = require_semver();
1106
+ var {
1107
+ safeRe: re,
1108
+ src,
1109
+ t,
1110
+ comparatorTrimReplace,
1111
+ tildeTrimReplace,
1112
+ caretTrimReplace
1113
+ } = require_re();
1114
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
1115
+ var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
1116
+ var isNullSet = (c) => c.value === "<0.0.0-0";
1117
+ var isAny = (c) => c.value === "";
1118
+ var isSatisfiable = (comparators, options) => {
1119
+ let result = true;
1120
+ const remainingComparators = comparators.slice();
1121
+ let testComparator = remainingComparators.pop();
1122
+ while (result && remainingComparators.length) {
1123
+ result = remainingComparators.every((otherComparator) => {
1124
+ return testComparator.intersects(otherComparator, options);
1125
+ });
1126
+ testComparator = remainingComparators.pop();
1127
+ }
1128
+ return result;
1129
+ };
1130
+ var parseComparator = (comp, options) => {
1131
+ comp = comp.replace(re[t.BUILD], "");
1132
+ debug("comp", comp, options);
1133
+ comp = replaceCarets(comp, options);
1134
+ debug("caret", comp);
1135
+ comp = replaceTildes(comp, options);
1136
+ debug("tildes", comp);
1137
+ comp = replaceXRanges(comp, options);
1138
+ debug("xrange", comp);
1139
+ comp = replaceStars(comp, options);
1140
+ debug("stars", comp);
1141
+ return comp;
1142
+ };
1143
+ var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
1144
+ var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
1145
+ var replaceTildes = (comp, options) => {
1146
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
1147
+ };
1148
+ var replaceTilde = (comp, options) => {
1149
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1150
+ const z = options.includePrerelease ? "-0" : "";
1151
+ return comp.replace(r, (_, M, m, p, pr) => {
1152
+ debug("tilde", comp, _, M, m, p, pr);
1153
+ let ret;
1154
+ if (isX(M)) {
1155
+ ret = "";
1156
+ } else if (isX(m)) {
1157
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1158
+ } else if (isX(p)) {
1159
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1160
+ } else if (pr) {
1161
+ debug("replaceTilde pr", pr);
1162
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1163
+ } else {
1164
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1165
+ }
1166
+ debug("tilde return", ret);
1167
+ return ret;
1168
+ });
1169
+ };
1170
+ var replaceCarets = (comp, options) => {
1171
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
1172
+ };
1173
+ var replaceCaret = (comp, options) => {
1174
+ debug("caret", comp, options);
1175
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1176
+ const z = options.includePrerelease ? "-0" : "";
1177
+ return comp.replace(r, (_, M, m, p, pr) => {
1178
+ debug("caret", comp, _, M, m, p, pr);
1179
+ let ret;
1180
+ if (isX(M)) {
1181
+ ret = "";
1182
+ } else if (isX(m)) {
1183
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1184
+ } else if (isX(p)) {
1185
+ if (M === "0") {
1186
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1187
+ } else {
1188
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1189
+ }
1190
+ } else if (pr) {
1191
+ debug("replaceCaret pr", pr);
1192
+ if (M === "0") {
1193
+ if (m === "0") {
1194
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
1195
+ } else {
1196
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1197
+ }
1198
+ } else {
1199
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
1200
+ }
1201
+ } else {
1202
+ debug("no pr");
1203
+ if (M === "0") {
1204
+ if (m === "0") {
1205
+ ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
1206
+ } else {
1207
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1208
+ }
1209
+ } else {
1210
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
1211
+ }
1212
+ }
1213
+ debug("caret return", ret);
1214
+ return ret;
1215
+ });
1216
+ };
1217
+ var replaceXRanges = (comp, options) => {
1218
+ debug("replaceXRanges", comp, options);
1219
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
1220
+ };
1221
+ var replaceXRange = (comp, options) => {
1222
+ comp = comp.trim();
1223
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1224
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1225
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
1226
+ if (invalidXRangeOrder(M, m, p)) {
1227
+ return comp;
1228
+ }
1229
+ const xM = isX(M);
1230
+ const xm = xM || isX(m);
1231
+ const xp = xm || isX(p);
1232
+ const anyX = xp;
1233
+ if (gtlt === "=" && anyX) {
1234
+ gtlt = "";
1235
+ }
1236
+ pr = options.includePrerelease ? "-0" : "";
1237
+ if (xM) {
1238
+ if (gtlt === ">" || gtlt === "<") {
1239
+ ret = "<0.0.0-0";
1240
+ } else {
1241
+ ret = "*";
1242
+ }
1243
+ } else if (gtlt && anyX) {
1244
+ if (xm) {
1245
+ m = 0;
1246
+ }
1247
+ p = 0;
1248
+ if (gtlt === ">") {
1249
+ gtlt = ">=";
1250
+ if (xm) {
1251
+ M = +M + 1;
1252
+ m = 0;
1253
+ p = 0;
1254
+ } else {
1255
+ m = +m + 1;
1256
+ p = 0;
1257
+ }
1258
+ } else if (gtlt === "<=") {
1259
+ gtlt = "<";
1260
+ if (xm) {
1261
+ M = +M + 1;
1262
+ } else {
1263
+ m = +m + 1;
1264
+ }
1265
+ }
1266
+ if (gtlt === "<") {
1267
+ pr = "-0";
1268
+ }
1269
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
1270
+ } else if (xm) {
1271
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1272
+ } else if (xp) {
1273
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
1274
+ }
1275
+ debug("xRange return", ret);
1276
+ return ret;
1277
+ });
1278
+ };
1279
+ var replaceStars = (comp, options) => {
1280
+ debug("replaceStars", comp, options);
1281
+ return comp.trim().replace(re[t.STAR], "");
1282
+ };
1283
+ var replaceGTE0 = (comp, options) => {
1284
+ debug("replaceGTE0", comp, options);
1285
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
1286
+ };
1287
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
1288
+ if (isX(fM)) {
1289
+ from = "";
1290
+ } else if (isX(fm)) {
1291
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
1292
+ } else if (isX(fp)) {
1293
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
1294
+ } else if (fpr) {
1295
+ from = `>=${from}`;
1296
+ } else {
1297
+ from = `>=${from}${incPr ? "-0" : ""}`;
1298
+ }
1299
+ if (isX(tM)) {
1300
+ to = "";
1301
+ } else if (isX(tm)) {
1302
+ to = `<${+tM + 1}.0.0-0`;
1303
+ } else if (isX(tp)) {
1304
+ to = `<${tM}.${+tm + 1}.0-0`;
1305
+ } else if (tpr) {
1306
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
1307
+ } else if (incPr) {
1308
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
1309
+ } else {
1310
+ to = `<=${to}`;
1311
+ }
1312
+ return `${from} ${to}`.trim();
1313
+ };
1314
+ var testSet = (set, version, options) => {
1315
+ for (let i = 0; i < set.length; i++) {
1316
+ if (!set[i].test(version)) {
1317
+ return false;
1318
+ }
1319
+ }
1320
+ if (version.prerelease.length && !options.includePrerelease) {
1321
+ for (let i = 0; i < set.length; i++) {
1322
+ debug(set[i].semver);
1323
+ if (set[i].semver === Comparator.ANY) {
1324
+ continue;
1325
+ }
1326
+ if (set[i].semver.prerelease.length > 0) {
1327
+ const allowed = set[i].semver;
1328
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
1329
+ return true;
1330
+ }
1331
+ }
1332
+ }
1333
+ return false;
1334
+ }
1335
+ return true;
1336
+ };
1337
+ }
1338
+ });
1339
+
1340
+ // node_modules/semver/classes/comparator.js
1341
+ var require_comparator = __commonJS({
1342
+ "node_modules/semver/classes/comparator.js"(exports, module) {
1343
+ "use strict";
1344
+ var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
1345
+ var Comparator = class _Comparator {
1346
+ static get ANY() {
1347
+ return ANY;
1348
+ }
1349
+ constructor(comp, options) {
1350
+ options = parseOptions(options);
1351
+ if (comp instanceof _Comparator) {
1352
+ if (comp.loose === !!options.loose) {
1353
+ return comp;
1354
+ } else {
1355
+ comp = comp.value;
1356
+ }
1357
+ }
1358
+ comp = comp.trim().split(/\s+/).join(" ");
1359
+ debug("comparator", comp, options);
1360
+ this.options = options;
1361
+ this.loose = !!options.loose;
1362
+ this.parse(comp);
1363
+ if (this.semver === ANY) {
1364
+ this.value = "";
1365
+ } else {
1366
+ this.value = this.operator + this.semver.version;
1367
+ }
1368
+ debug("comp", this);
1369
+ }
1370
+ parse(comp) {
1371
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1372
+ const m = comp.match(r);
1373
+ if (!m) {
1374
+ throw new TypeError(`Invalid comparator: ${comp}`);
1375
+ }
1376
+ this.operator = m[1] !== void 0 ? m[1] : "";
1377
+ if (this.operator === "=") {
1378
+ this.operator = "";
1379
+ }
1380
+ if (!m[2]) {
1381
+ this.semver = ANY;
1382
+ } else {
1383
+ this.semver = new SemVer(m[2], this.options.loose);
1384
+ }
1385
+ }
1386
+ toString() {
1387
+ return this.value;
1388
+ }
1389
+ test(version) {
1390
+ debug("Comparator.test", version, this.options.loose);
1391
+ if (this.semver === ANY || version === ANY) {
1392
+ return true;
1393
+ }
1394
+ if (typeof version === "string") {
1395
+ try {
1396
+ version = new SemVer(version, this.options);
1397
+ } catch (er) {
1398
+ return false;
1399
+ }
1400
+ }
1401
+ return cmp(version, this.operator, this.semver, this.options);
1402
+ }
1403
+ intersects(comp, options) {
1404
+ if (!(comp instanceof _Comparator)) {
1405
+ throw new TypeError("a Comparator is required");
1406
+ }
1407
+ if (this.operator === "") {
1408
+ if (this.value === "") {
1409
+ return true;
1410
+ }
1411
+ return new Range(comp.value, options).test(this.value);
1412
+ } else if (comp.operator === "") {
1413
+ if (comp.value === "") {
1414
+ return true;
1415
+ }
1416
+ return new Range(this.value, options).test(comp.semver);
1417
+ }
1418
+ options = parseOptions(options);
1419
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
1420
+ return false;
1421
+ }
1422
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
1423
+ return false;
1424
+ }
1425
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
1426
+ return true;
1427
+ }
1428
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
1429
+ return true;
1430
+ }
1431
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
1432
+ return true;
1433
+ }
1434
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
1435
+ return true;
1436
+ }
1437
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
1438
+ return true;
1439
+ }
1440
+ return false;
1441
+ }
1442
+ };
1443
+ module.exports = Comparator;
1444
+ var parseOptions = require_parse_options();
1445
+ var { safeRe: re, t } = require_re();
1446
+ var cmp = require_cmp();
1447
+ var debug = require_debug();
1448
+ var SemVer = require_semver();
1449
+ var Range = require_range();
1450
+ }
1451
+ });
1452
+
1453
+ // node_modules/semver/functions/satisfies.js
1454
+ var require_satisfies = __commonJS({
1455
+ "node_modules/semver/functions/satisfies.js"(exports, module) {
1456
+ "use strict";
1457
+ var Range = require_range();
1458
+ var satisfies = (version, range, options) => {
1459
+ try {
1460
+ range = new Range(range, options);
1461
+ } catch (er) {
1462
+ return false;
1463
+ }
1464
+ return range.test(version);
1465
+ };
1466
+ module.exports = satisfies;
1467
+ }
1468
+ });
1469
+
1470
+ // node_modules/semver/ranges/to-comparators.js
1471
+ var require_to_comparators = __commonJS({
1472
+ "node_modules/semver/ranges/to-comparators.js"(exports, module) {
1473
+ "use strict";
1474
+ var Range = require_range();
1475
+ var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
1476
+ module.exports = toComparators;
1477
+ }
1478
+ });
1479
+
1480
+ // node_modules/semver/ranges/max-satisfying.js
1481
+ var require_max_satisfying = __commonJS({
1482
+ "node_modules/semver/ranges/max-satisfying.js"(exports, module) {
1483
+ "use strict";
1484
+ var SemVer = require_semver();
1485
+ var Range = require_range();
1486
+ var maxSatisfying = (versions, range, options) => {
1487
+ let max = null;
1488
+ let maxSV = null;
1489
+ let rangeObj = null;
1490
+ try {
1491
+ rangeObj = new Range(range, options);
1492
+ } catch (er) {
1493
+ return null;
1494
+ }
1495
+ versions.forEach((v) => {
1496
+ if (rangeObj.test(v)) {
1497
+ if (!max || maxSV.compare(v) === -1) {
1498
+ max = v;
1499
+ maxSV = new SemVer(max, options);
1500
+ }
1501
+ }
1502
+ });
1503
+ return max;
1504
+ };
1505
+ module.exports = maxSatisfying;
1506
+ }
1507
+ });
1508
+
1509
+ // node_modules/semver/ranges/min-satisfying.js
1510
+ var require_min_satisfying = __commonJS({
1511
+ "node_modules/semver/ranges/min-satisfying.js"(exports, module) {
1512
+ "use strict";
1513
+ var SemVer = require_semver();
1514
+ var Range = require_range();
1515
+ var minSatisfying = (versions, range, options) => {
1516
+ let min = null;
1517
+ let minSV = null;
1518
+ let rangeObj = null;
1519
+ try {
1520
+ rangeObj = new Range(range, options);
1521
+ } catch (er) {
1522
+ return null;
1523
+ }
1524
+ versions.forEach((v) => {
1525
+ if (rangeObj.test(v)) {
1526
+ if (!min || minSV.compare(v) === 1) {
1527
+ min = v;
1528
+ minSV = new SemVer(min, options);
1529
+ }
1530
+ }
1531
+ });
1532
+ return min;
1533
+ };
1534
+ module.exports = minSatisfying;
1535
+ }
1536
+ });
1537
+
1538
+ // node_modules/semver/ranges/min-version.js
1539
+ var require_min_version = __commonJS({
1540
+ "node_modules/semver/ranges/min-version.js"(exports, module) {
1541
+ "use strict";
1542
+ var SemVer = require_semver();
1543
+ var Range = require_range();
1544
+ var gt = require_gt();
1545
+ var minVersion = (range, loose) => {
1546
+ range = new Range(range, loose);
1547
+ let minver = new SemVer("0.0.0");
1548
+ if (range.test(minver)) {
1549
+ return minver;
1550
+ }
1551
+ minver = new SemVer("0.0.0-0");
1552
+ if (range.test(minver)) {
1553
+ return minver;
1554
+ }
1555
+ minver = null;
1556
+ for (let i = 0; i < range.set.length; ++i) {
1557
+ const comparators = range.set[i];
1558
+ let setMin = null;
1559
+ comparators.forEach((comparator) => {
1560
+ const compver = new SemVer(comparator.semver.version);
1561
+ switch (comparator.operator) {
1562
+ case ">":
1563
+ if (compver.prerelease.length === 0) {
1564
+ compver.patch++;
1565
+ } else {
1566
+ compver.prerelease.push(0);
1567
+ }
1568
+ compver.raw = compver.format();
1569
+ /* fallthrough */
1570
+ case "":
1571
+ case ">=":
1572
+ if (!setMin || gt(compver, setMin)) {
1573
+ setMin = compver;
1574
+ }
1575
+ break;
1576
+ case "<":
1577
+ case "<=":
1578
+ break;
1579
+ /* istanbul ignore next */
1580
+ default:
1581
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
1582
+ }
1583
+ });
1584
+ if (setMin && (!minver || gt(minver, setMin))) {
1585
+ minver = setMin;
1586
+ }
1587
+ }
1588
+ if (minver && range.test(minver)) {
1589
+ return minver;
1590
+ }
1591
+ return null;
1592
+ };
1593
+ module.exports = minVersion;
1594
+ }
1595
+ });
1596
+
1597
+ // node_modules/semver/ranges/valid.js
1598
+ var require_valid2 = __commonJS({
1599
+ "node_modules/semver/ranges/valid.js"(exports, module) {
1600
+ "use strict";
1601
+ var Range = require_range();
1602
+ var validRange = (range, options) => {
1603
+ try {
1604
+ return new Range(range, options).range || "*";
1605
+ } catch (er) {
1606
+ return null;
1607
+ }
1608
+ };
1609
+ module.exports = validRange;
1610
+ }
1611
+ });
1612
+
1613
+ // node_modules/semver/ranges/outside.js
1614
+ var require_outside = __commonJS({
1615
+ "node_modules/semver/ranges/outside.js"(exports, module) {
1616
+ "use strict";
1617
+ var SemVer = require_semver();
1618
+ var Comparator = require_comparator();
1619
+ var { ANY } = Comparator;
1620
+ var Range = require_range();
1621
+ var satisfies = require_satisfies();
1622
+ var gt = require_gt();
1623
+ var lt = require_lt();
1624
+ var lte = require_lte();
1625
+ var gte = require_gte();
1626
+ var outside = (version, range, hilo, options) => {
1627
+ version = new SemVer(version, options);
1628
+ range = new Range(range, options);
1629
+ let gtfn, ltefn, ltfn, comp, ecomp;
1630
+ switch (hilo) {
1631
+ case ">":
1632
+ gtfn = gt;
1633
+ ltefn = lte;
1634
+ ltfn = lt;
1635
+ comp = ">";
1636
+ ecomp = ">=";
1637
+ break;
1638
+ case "<":
1639
+ gtfn = lt;
1640
+ ltefn = gte;
1641
+ ltfn = gt;
1642
+ comp = "<";
1643
+ ecomp = "<=";
1644
+ break;
1645
+ default:
1646
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
1647
+ }
1648
+ if (satisfies(version, range, options)) {
1649
+ return false;
1650
+ }
1651
+ for (let i = 0; i < range.set.length; ++i) {
1652
+ const comparators = range.set[i];
1653
+ let high = null;
1654
+ let low = null;
1655
+ comparators.forEach((comparator) => {
1656
+ if (comparator.semver === ANY) {
1657
+ comparator = new Comparator(">=0.0.0");
1658
+ }
1659
+ high = high || comparator;
1660
+ low = low || comparator;
1661
+ if (gtfn(comparator.semver, high.semver, options)) {
1662
+ high = comparator;
1663
+ } else if (ltfn(comparator.semver, low.semver, options)) {
1664
+ low = comparator;
1665
+ }
1666
+ });
1667
+ if (high.operator === comp || high.operator === ecomp) {
1668
+ return false;
1669
+ }
1670
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
1671
+ return false;
1672
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1673
+ return false;
1674
+ }
1675
+ }
1676
+ return true;
1677
+ };
1678
+ module.exports = outside;
1679
+ }
1680
+ });
1681
+
1682
+ // node_modules/semver/ranges/gtr.js
1683
+ var require_gtr = __commonJS({
1684
+ "node_modules/semver/ranges/gtr.js"(exports, module) {
1685
+ "use strict";
1686
+ var outside = require_outside();
1687
+ var gtr = (version, range, options) => outside(version, range, ">", options);
1688
+ module.exports = gtr;
1689
+ }
1690
+ });
1691
+
1692
+ // node_modules/semver/ranges/ltr.js
1693
+ var require_ltr = __commonJS({
1694
+ "node_modules/semver/ranges/ltr.js"(exports, module) {
1695
+ "use strict";
1696
+ var outside = require_outside();
1697
+ var ltr = (version, range, options) => outside(version, range, "<", options);
1698
+ module.exports = ltr;
1699
+ }
1700
+ });
1701
+
1702
+ // node_modules/semver/ranges/intersects.js
1703
+ var require_intersects = __commonJS({
1704
+ "node_modules/semver/ranges/intersects.js"(exports, module) {
1705
+ "use strict";
1706
+ var Range = require_range();
1707
+ var intersects = (r1, r2, options) => {
1708
+ r1 = new Range(r1, options);
1709
+ r2 = new Range(r2, options);
1710
+ return r1.intersects(r2, options);
1711
+ };
1712
+ module.exports = intersects;
1713
+ }
1714
+ });
1715
+
1716
+ // node_modules/semver/ranges/simplify.js
1717
+ var require_simplify = __commonJS({
1718
+ "node_modules/semver/ranges/simplify.js"(exports, module) {
1719
+ "use strict";
1720
+ var satisfies = require_satisfies();
1721
+ var compare = require_compare();
1722
+ module.exports = (versions, range, options) => {
1723
+ const set = [];
1724
+ let first = null;
1725
+ let prev = null;
1726
+ const v = versions.sort((a, b) => compare(a, b, options));
1727
+ for (const version of v) {
1728
+ const included = satisfies(version, range, options);
1729
+ if (included) {
1730
+ prev = version;
1731
+ if (!first) {
1732
+ first = version;
1733
+ }
1734
+ } else {
1735
+ if (prev) {
1736
+ set.push([first, prev]);
1737
+ }
1738
+ prev = null;
1739
+ first = null;
1740
+ }
1741
+ }
1742
+ if (first) {
1743
+ set.push([first, null]);
1744
+ }
1745
+ const ranges = [];
1746
+ for (const [min, max] of set) {
1747
+ if (min === max) {
1748
+ ranges.push(min);
1749
+ } else if (!max && min === v[0]) {
1750
+ ranges.push("*");
1751
+ } else if (!max) {
1752
+ ranges.push(`>=${min}`);
1753
+ } else if (min === v[0]) {
1754
+ ranges.push(`<=${max}`);
1755
+ } else {
1756
+ ranges.push(`${min} - ${max}`);
1757
+ }
1758
+ }
1759
+ const simplified = ranges.join(" || ");
1760
+ const original = typeof range.raw === "string" ? range.raw : String(range);
1761
+ return simplified.length < original.length ? simplified : range;
1762
+ };
1763
+ }
1764
+ });
1765
+
1766
+ // node_modules/semver/ranges/subset.js
1767
+ var require_subset = __commonJS({
1768
+ "node_modules/semver/ranges/subset.js"(exports, module) {
1769
+ "use strict";
1770
+ var Range = require_range();
1771
+ var Comparator = require_comparator();
1772
+ var { ANY } = Comparator;
1773
+ var satisfies = require_satisfies();
1774
+ var compare = require_compare();
1775
+ var subset = (sub, dom, options = {}) => {
1776
+ if (sub === dom) {
1777
+ return true;
1778
+ }
1779
+ sub = new Range(sub, options);
1780
+ dom = new Range(dom, options);
1781
+ let sawNonNull = false;
1782
+ OUTER: for (const simpleSub of sub.set) {
1783
+ for (const simpleDom of dom.set) {
1784
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
1785
+ sawNonNull = sawNonNull || isSub !== null;
1786
+ if (isSub) {
1787
+ continue OUTER;
1788
+ }
1789
+ }
1790
+ if (sawNonNull) {
1791
+ return false;
1792
+ }
1793
+ }
1794
+ return true;
1795
+ };
1796
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
1797
+ var minimumVersion = [new Comparator(">=0.0.0")];
1798
+ var simpleSubset = (sub, dom, options) => {
1799
+ if (sub === dom) {
1800
+ return true;
1801
+ }
1802
+ if (sub.length === 1 && sub[0].semver === ANY) {
1803
+ if (dom.length === 1 && dom[0].semver === ANY) {
1804
+ return true;
1805
+ } else if (options.includePrerelease) {
1806
+ sub = minimumVersionWithPreRelease;
1807
+ } else {
1808
+ sub = minimumVersion;
1809
+ }
1810
+ }
1811
+ if (dom.length === 1 && dom[0].semver === ANY) {
1812
+ if (options.includePrerelease) {
1813
+ return true;
1814
+ } else {
1815
+ dom = minimumVersion;
1816
+ }
1817
+ }
1818
+ const eqSet = /* @__PURE__ */ new Set();
1819
+ let gt, lt;
1820
+ for (const c of sub) {
1821
+ if (c.operator === ">" || c.operator === ">=") {
1822
+ gt = higherGT(gt, c, options);
1823
+ } else if (c.operator === "<" || c.operator === "<=") {
1824
+ lt = lowerLT(lt, c, options);
1825
+ } else {
1826
+ eqSet.add(c.semver);
1827
+ }
1828
+ }
1829
+ if (eqSet.size > 1) {
1830
+ return null;
1831
+ }
1832
+ let gtltComp;
1833
+ if (gt && lt) {
1834
+ gtltComp = compare(gt.semver, lt.semver, options);
1835
+ if (gtltComp > 0) {
1836
+ return null;
1837
+ } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
1838
+ return null;
1839
+ }
1840
+ }
1841
+ for (const eq of eqSet) {
1842
+ if (gt && !satisfies(eq, String(gt), options)) {
1843
+ return null;
1844
+ }
1845
+ if (lt && !satisfies(eq, String(lt), options)) {
1846
+ return null;
1847
+ }
1848
+ for (const c of dom) {
1849
+ if (!satisfies(eq, String(c), options)) {
1850
+ return false;
1851
+ }
1852
+ }
1853
+ return true;
1854
+ }
1855
+ let higher, lower;
1856
+ let hasDomLT, hasDomGT;
1857
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
1858
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
1859
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
1860
+ needDomLTPre = false;
1861
+ }
1862
+ for (const c of dom) {
1863
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
1864
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
1865
+ if (gt) {
1866
+ if (needDomGTPre) {
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
+ needDomGTPre = false;
1869
+ }
1870
+ }
1871
+ if (c.operator === ">" || c.operator === ">=") {
1872
+ higher = higherGT(gt, c, options);
1873
+ if (higher === c && higher !== gt) {
1874
+ return false;
1875
+ }
1876
+ } else if (gt.operator === ">=" && !c.test(gt.semver)) {
1877
+ return false;
1878
+ }
1879
+ }
1880
+ if (lt) {
1881
+ if (needDomLTPre) {
1882
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
1883
+ needDomLTPre = false;
1884
+ }
1885
+ }
1886
+ if (c.operator === "<" || c.operator === "<=") {
1887
+ lower = lowerLT(lt, c, options);
1888
+ if (lower === c && lower !== lt) {
1889
+ return false;
1890
+ }
1891
+ } else if (lt.operator === "<=" && !c.test(lt.semver)) {
1892
+ return false;
1893
+ }
1894
+ }
1895
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
1896
+ return false;
1897
+ }
1898
+ }
1899
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
1900
+ return false;
1901
+ }
1902
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
1903
+ return false;
1904
+ }
1905
+ if (needDomGTPre || needDomLTPre) {
1906
+ return false;
1907
+ }
1908
+ return true;
1909
+ };
1910
+ var higherGT = (a, b, options) => {
1911
+ if (!a) {
1912
+ return b;
1913
+ }
1914
+ const comp = compare(a.semver, b.semver, options);
1915
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
1916
+ };
1917
+ var lowerLT = (a, b, options) => {
1918
+ if (!a) {
1919
+ return b;
1920
+ }
1921
+ const comp = compare(a.semver, b.semver, options);
1922
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
1923
+ };
1924
+ module.exports = subset;
1925
+ }
1926
+ });
1927
+
1928
+ // node_modules/semver/index.js
1929
+ var require_semver2 = __commonJS({
1930
+ "node_modules/semver/index.js"(exports, module) {
1931
+ "use strict";
1932
+ var internalRe = require_re();
1933
+ var constants2 = require_constants();
1934
+ var SemVer = require_semver();
1935
+ var identifiers = require_identifiers();
1936
+ var parse2 = require_parse();
1937
+ var valid = require_valid();
1938
+ var clean = require_clean();
1939
+ var inc = require_inc();
1940
+ var diff = require_diff();
1941
+ var major = require_major();
1942
+ var minor = require_minor();
1943
+ var patch = require_patch();
1944
+ var prerelease = require_prerelease();
1945
+ var compare = require_compare();
1946
+ var rcompare2 = require_rcompare();
1947
+ var compareLoose = require_compare_loose();
1948
+ var compareBuild = require_compare_build();
1949
+ var sort = require_sort();
1950
+ var rsort = require_rsort();
1951
+ var gt = require_gt();
1952
+ var lt = require_lt();
1953
+ var eq = require_eq();
1954
+ var neq = require_neq();
1955
+ var gte = require_gte();
1956
+ var lte = require_lte();
1957
+ var cmp = require_cmp();
1958
+ var coerce = require_coerce();
1959
+ var truncate = require_truncate();
1960
+ var Comparator = require_comparator();
1961
+ var Range = require_range();
1962
+ var satisfies = require_satisfies();
1963
+ var toComparators = require_to_comparators();
1964
+ var maxSatisfying = require_max_satisfying();
1965
+ var minSatisfying = require_min_satisfying();
1966
+ var minVersion = require_min_version();
1967
+ var validRange = require_valid2();
1968
+ var outside = require_outside();
1969
+ var gtr = require_gtr();
1970
+ var ltr = require_ltr();
1971
+ var intersects = require_intersects();
1972
+ var simplifyRange = require_simplify();
1973
+ var subset = require_subset();
1974
+ module.exports = {
1975
+ parse: parse2,
1976
+ valid,
1977
+ clean,
1978
+ inc,
1979
+ diff,
1980
+ major,
1981
+ minor,
1982
+ patch,
1983
+ prerelease,
1984
+ compare,
1985
+ rcompare: rcompare2,
1986
+ compareLoose,
1987
+ compareBuild,
1988
+ sort,
1989
+ rsort,
1990
+ gt,
1991
+ lt,
1992
+ eq,
1993
+ neq,
1994
+ gte,
1995
+ lte,
1996
+ cmp,
1997
+ coerce,
1998
+ truncate,
1999
+ Comparator,
2000
+ Range,
2001
+ satisfies,
2002
+ toComparators,
2003
+ maxSatisfying,
2004
+ minSatisfying,
2005
+ minVersion,
2006
+ validRange,
2007
+ outside,
2008
+ gtr,
2009
+ ltr,
2010
+ intersects,
2011
+ simplifyRange,
2012
+ subset,
2013
+ SemVer,
2014
+ re: internalRe.re,
2015
+ src: internalRe.src,
2016
+ tokens: internalRe.t,
2017
+ SEMVER_SPEC_VERSION: constants2.SEMVER_SPEC_VERSION,
2018
+ RELEASE_TYPES: constants2.RELEASE_TYPES,
2019
+ compareIdentifiers: identifiers.compareIdentifiers,
2020
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
2021
+ };
2022
+ }
2023
+ });
2024
+
2025
+ // src/core/config.ts
2026
+ import { homedir, platform } from "node:os";
2027
+
2028
+ // src/core/runtime.ts
2029
+ import { readFileSync } from "node:fs";
2030
+ import { dirname, join } from "node:path";
2031
+ import { fileURLToPath } from "node:url";
2032
+ var __filename = fileURLToPath(import.meta.url);
2033
+ var __dirname = dirname(__filename);
2034
+ var UNVERSIONED_DEV_BUILD = "0.0.0-semantically-released";
2035
+ function getVersion() {
2036
+ try {
2037
+ const packageJsonPath = join(__dirname, "..", "..", "package.json");
2038
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
2039
+ return packageJson.version || UNVERSIONED_DEV_BUILD;
2040
+ } catch {
2041
+ return UNVERSIONED_DEV_BUILD;
2042
+ }
2043
+ }
2044
+ var C8ctl = class {
2045
+ _activeProfile;
2046
+ _activeTenant;
2047
+ _outputMode = "text";
2048
+ _fields;
2049
+ _dryRun;
2050
+ _verbose;
2051
+ _quiet;
2052
+ _resolvedBaseUrl;
2053
+ _deps;
2054
+ env = {
2055
+ version: getVersion(),
2056
+ nodeVersion: process.version,
2057
+ platform: process.platform,
2058
+ arch: process.arch,
2059
+ cwd: process.cwd(),
2060
+ rootDir: join(__dirname, "..", "..")
2061
+ };
2062
+ /**
2063
+ * Inject dependencies that cannot be imported at module level
2064
+ * due to circular imports. Must be called once during startup,
2065
+ * before any plugin or command accesses createClient/resolveTenantId/getLogger.
2066
+ */
2067
+ init(deps) {
2068
+ if (this._deps) {
2069
+ throw new Error("c8ctl.init() must only be called once");
2070
+ }
2071
+ this._deps = deps;
2072
+ }
2073
+ createClient(profileFlag, additionalSdkConfig) {
2074
+ if (!this._deps) {
2075
+ throw new Error("c8ctl.init() must be called before createClient()");
2076
+ }
2077
+ return this._deps.createClient(profileFlag, additionalSdkConfig);
2078
+ }
2079
+ resolveTenantId(profileFlag) {
2080
+ if (!this._deps) {
2081
+ throw new Error("c8ctl.init() must be called before resolveTenantId()");
2082
+ }
2083
+ return this._deps.resolveTenantId(profileFlag);
2084
+ }
2085
+ getLogger(mode) {
2086
+ if (!this._deps) {
2087
+ throw new Error("c8ctl.init() must be called before getLogger()");
2088
+ }
2089
+ return this._deps.getLogger(mode);
2090
+ }
2091
+ getUserDataDir() {
2092
+ if (!this._deps) {
2093
+ throw new Error("c8ctl.init() must be called before getUserDataDir()");
2094
+ }
2095
+ return this._deps.getUserDataDir();
2096
+ }
2097
+ getModelerDataDir() {
2098
+ if (!this._deps) {
2099
+ throw new Error("c8ctl.init() must be called before getModelerDataDir()");
2100
+ }
2101
+ return this._deps.getModelerDataDir();
2102
+ }
2103
+ npm(options) {
2104
+ if (!this._deps) {
2105
+ throw new Error("c8ctl.init() must be called before npm()");
2106
+ }
2107
+ return options.stdout === true ? this._deps.npm(options) : this._deps.npm(options);
2108
+ }
2109
+ // Expose env properties directly for plugin compatibility
2110
+ get version() {
2111
+ return this.env.version;
2112
+ }
2113
+ get nodeVersion() {
2114
+ return this.env.nodeVersion;
2115
+ }
2116
+ get platform() {
2117
+ return this.env.platform;
2118
+ }
2119
+ get arch() {
2120
+ return this.env.arch;
2121
+ }
2122
+ get cwd() {
2123
+ return this.env.cwd;
2124
+ }
2125
+ get activeProfile() {
2126
+ return this._activeProfile;
2127
+ }
2128
+ set activeProfile(value) {
2129
+ this._activeProfile = value;
2130
+ }
2131
+ get activeTenant() {
2132
+ return this._activeTenant;
2133
+ }
2134
+ set activeTenant(value) {
2135
+ this._activeTenant = value;
2136
+ }
2137
+ get outputMode() {
2138
+ return this._outputMode;
2139
+ }
2140
+ set outputMode(value) {
2141
+ this._outputMode = value;
2142
+ }
2143
+ get fields() {
2144
+ return this._fields;
2145
+ }
2146
+ set fields(value) {
2147
+ this._fields = value;
2148
+ }
2149
+ get dryRun() {
2150
+ return this._dryRun;
2151
+ }
2152
+ set dryRun(value) {
2153
+ this._dryRun = value;
2154
+ }
2155
+ get verbose() {
2156
+ return this._verbose;
2157
+ }
2158
+ set verbose(value) {
2159
+ this._verbose = value;
2160
+ }
2161
+ get quiet() {
2162
+ return this._quiet;
2163
+ }
2164
+ set quiet(value) {
2165
+ this._quiet = value;
2166
+ }
2167
+ get resolvedBaseUrl() {
2168
+ return this._resolvedBaseUrl;
2169
+ }
2170
+ set resolvedBaseUrl(value) {
2171
+ this._resolvedBaseUrl = value;
2172
+ }
2173
+ };
2174
+ var c8ctl = new C8ctl();
2175
+
2176
+ // src/core/logger.ts
2177
+ function isRecord(value) {
2178
+ return value != null && typeof value === "object" && !Array.isArray(value);
2179
+ }
2180
+
2181
+ // src/core/config.ts
2182
+ var VALIDATION_PATTERNS = {
2183
+ URL: /^https?:\/\//,
2184
+ CAMUNDA_CLOUD_REST_URL: /^https:\/\/[a-z]+-\d+\.zeebe\.camunda\.io(:443|)\/[a-z\d-]+\/?$/
2185
+ };
2186
+ var CAMUNDA_CLOUD_URL_PATTERN = VALIDATION_PATTERNS.CAMUNDA_CLOUD_REST_URL;
2187
+ var isWindows = platform() === "win32";
2188
+
2189
+ // src/core/errors.ts
2190
+ var SilentError = class extends Error {
2191
+ constructor(message) {
2192
+ super(message);
2193
+ this.name = "SilentError";
2194
+ }
2195
+ };
2196
+ function normalizeToError(error, fallbackMessage = "Operation failed") {
2197
+ if (error instanceof Error) {
2198
+ return error;
2199
+ }
2200
+ const raw = isRecord(error) ? error : {};
2201
+ const title = typeof raw.title === "string" ? raw.title : void 0;
2202
+ const detail = typeof raw.detail === "string" ? raw.detail : void 0;
2203
+ const status = typeof raw.status === "number" ? raw.status : void 0;
2204
+ const head = [title ?? fallbackMessage, detail].filter((p) => Boolean(p)).join(": ");
2205
+ const message = status !== void 0 ? `${head} (status ${status})` : head;
2206
+ return new Error(message, { cause: error });
2207
+ }
2208
+ function renderCommandFailure(logger, message, error, { verbose = false } = {}) {
2209
+ const normalizedError = normalizeToError(error, message);
2210
+ if (verbose) {
2211
+ throw normalizedError;
2212
+ }
2213
+ if (error instanceof SilentError) {
2214
+ return;
2215
+ }
2216
+ if (normalizedError.message === message) {
2217
+ logger.error(message);
2218
+ } else {
2219
+ logger.error(message, normalizedError);
2220
+ }
2221
+ logger.info("For more details on the error, run with the --verbose flag", {
2222
+ essential: true
2223
+ });
2224
+ }
2225
+
2226
+ // src/core/update-check.ts
2227
+ var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
2228
+
2229
+ // default-plugins/modeler/install.ts
2230
+ import { spawnSync } from "node:child_process";
2231
+ import {
2232
+ accessSync,
2233
+ constants,
2234
+ createWriteStream,
2235
+ existsSync,
2236
+ mkdirSync,
2237
+ mkdtempSync,
2238
+ realpathSync,
2239
+ renameSync,
2240
+ rmSync,
2241
+ statSync
2242
+ } from "node:fs";
2243
+ import { homedir as homedir2, tmpdir } from "node:os";
2244
+ import { delimiter, join as join2 } from "node:path";
2245
+ import { Readable, Transform } from "node:stream";
2246
+ import { pipeline } from "node:stream/promises";
2247
+
2248
+ // default-plugins/modeler/helpers.ts
2249
+ var import_semver = __toESM(require_semver2(), 1);
2250
+ var MODELER_RELEASE_URL = "https://downloads.camunda.cloud/release/camunda-modeler/";
2251
+ function latestStableModelerVersion(indexHtml) {
2252
+ const versions = Array.from(
2253
+ indexHtml.matchAll(/href=["']([^/"']+)\/["']/g),
2254
+ (match) => match[1]
2255
+ ).filter((version) => version !== void 0);
2256
+ const latest = versions.filter((version) => {
2257
+ const parsed = (0, import_semver.parse)(version);
2258
+ return parsed !== null && parsed.prerelease.length === 0;
2259
+ }).sort(import_semver.rcompare)[0];
2260
+ if (!latest) {
2261
+ throw new Error(
2262
+ `No stable Camunda Modeler release found. Download manually from ${MODELER_RELEASE_URL}`
2263
+ );
2264
+ }
2265
+ return latest;
2266
+ }
2267
+ function modelerMacArchiveName(version, architecture) {
2268
+ if (architecture !== "arm64" && architecture !== "x64") {
2269
+ throw new Error(
2270
+ `Unsupported macOS architecture "${architecture}". Download Camunda Modeler manually from ${MODELER_RELEASE_URL}`
2271
+ );
2272
+ }
2273
+ return `camunda-modeler-${version}-mac-${architecture}.zip`;
2274
+ }
2275
+ var SPINNER = "\u280B\u2819\u2839\u2838\u283C\u2834\u2826\u2827\u2807\u280F";
2276
+ var MAX_BAR_WIDTH = 40;
2277
+ var MIN_BAR_WIDTH = 10;
2278
+ var INFO_WIDTH = 44;
2279
+ var MIN_RATE_SAMPLE_MS = 1e3;
2280
+ function megabytes(bytes) {
2281
+ return (bytes / 1048576).toFixed(1);
2282
+ }
2283
+ function renderDownloadProgress({
2284
+ received,
2285
+ total,
2286
+ elapsedMs,
2287
+ columns,
2288
+ color
2289
+ }) {
2290
+ const rate = elapsedMs >= MIN_RATE_SAMPLE_MS ? received * 1e3 / elapsedMs : 0;
2291
+ const speed = elapsedMs >= MIN_RATE_SAMPLE_MS ? [`${megabytes(rate)} MB/s`] : [];
2292
+ if (total <= 0) {
2293
+ const spinner = SPINNER[Math.floor(elapsedMs / 100) % SPINNER.length];
2294
+ return [`${spinner} ${megabytes(received)} MB`, ...speed].join(" ").slice(0, columns - 1);
2295
+ }
2296
+ const fraction = Math.min(1, received / total);
2297
+ const etaSeconds = fraction < 1 && rate > 0 ? Math.ceil((total - received) / rate) : void 0;
2298
+ const info = [
2299
+ `${Math.floor(fraction * 100)}%`.padStart(4),
2300
+ `${megabytes(received)}/${megabytes(total)} MB`,
2301
+ ...speed,
2302
+ ...etaSeconds === void 0 ? [] : [
2303
+ `eta ${Math.floor(etaSeconds / 60)}:${String(etaSeconds % 60).padStart(2, "0")}`
2304
+ ]
2305
+ ].join(" ");
2306
+ const width = Math.min(MAX_BAR_WIDTH, columns - INFO_WIDTH - 2);
2307
+ if (width < MIN_BAR_WIDTH) return info.slice(0, columns - 1);
2308
+ const filled = Math.floor(fraction * width);
2309
+ const bar = color ? `\x1B[36m${"\u2501".repeat(filled)}\x1B[90m${"\u2501".repeat(width - filled)}\x1B[0m` : `${"\u2588".repeat(filled)}${"\u2591".repeat(width - filled)}`;
2310
+ return `${bar} ${info.slice(0, columns - width - 2)}`;
2311
+ }
2312
+
2313
+ // default-plugins/modeler/install.ts
2314
+ var APP_BUNDLE_NAME = "Camunda Modeler.app";
2315
+ var SYSTEM_APPLICATIONS_DIR = "/Applications";
2316
+ var MANUAL_DOWNLOAD_URL = MODELER_RELEASE_URL;
2317
+ var DOWNLOAD_STALL_TIMEOUT_MS = 6e4;
2318
+ var LAUNCH_SERVICES_REGISTER = "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister";
2319
+ var MODELER_CODE_REQUIREMENT = 'identifier "com.camunda.CamundaModeler" and anchor apple generic and certificate leaf[subject.OU] = "3JVGD57JQZ"';
2320
+ var WINGET_PACKAGE_ID = "Camunda.Modeler";
2321
+ var WINGET_PACKAGE = [
2322
+ "--id",
2323
+ WINGET_PACKAGE_ID,
2324
+ "--exact",
2325
+ "--source",
2326
+ "winget"
2327
+ ];
2328
+ var WINGET_INSTALL_URL = "https://learn.microsoft.com/windows/package-manager/winget/";
2329
+ var WINGET_NO_APPLICATIONS_FOUND = 2316632084;
2330
+ var WINDOWS_EXECUTABLE = "Camunda Modeler.exe";
2331
+ var MODELER_FILE_TYPES = ["bpmn", "dmn", "form", "rpa"];
2332
+ var CREATE_SHORTCUT_SCRIPT = "$ErrorActionPreference = 'Stop'; $shortcut = (New-Object -ComObject WScript.Shell).CreateShortcut($env:C8CTL_SHORTCUT); $shortcut.TargetPath = $env:C8CTL_TARGET; $shortcut.Save()";
2333
+ var LINUX_INSTALL_ROOT = "/usr/bin";
2334
+ var LINUX_EXECUTABLE = "camunda-modeler";
2335
+ function errorMessage(error) {
2336
+ return error instanceof Error ? error.message : String(error);
2337
+ }
2338
+ function reportProgress({ logger, quiet }, message) {
2339
+ if (!quiet) logger.info(message);
2340
+ }
2341
+ function manualDownloadError(message) {
2342
+ return new Error(`${message}. Download manually from ${MANUAL_DOWNLOAD_URL}`);
2343
+ }
2344
+ function formatExitCode(status) {
2345
+ return status !== null && status > 65535 ? `0x${status.toString(16).toUpperCase()}` : String(status);
2346
+ }
2347
+ function runCommand(command, args, {
2348
+ failureMessage,
2349
+ quiet,
2350
+ stdin = "inherit"
2351
+ }) {
2352
+ const result = spawnSync(command, args, {
2353
+ encoding: "utf8",
2354
+ stdio: quiet ? [stdin, "pipe", "pipe"] : [stdin, process.stderr.fd, process.stderr.fd]
2355
+ });
2356
+ const diagnostics = quiet ? `${result.stdout ?? ""}${result.stderr ?? ""}`.trim() : "";
2357
+ const details = diagnostics ? `
2358
+ ${diagnostics}` : "";
2359
+ if (result.error) {
2360
+ throw new Error(`${failureMessage}: ${result.error.message}${details}`);
2361
+ }
2362
+ if (result.status !== 0) {
2363
+ throw new Error(
2364
+ `${failureMessage} (exit code ${formatExitCode(result.status)}).${details}`
2365
+ );
2366
+ }
2367
+ }
2368
+ function registerWithLaunchServices(appPath, logger) {
2369
+ const result = spawnSync(LAUNCH_SERVICES_REGISTER, ["-f", appPath], {
2370
+ stdio: "ignore"
2371
+ });
2372
+ if (result.error || result.status !== 0) {
2373
+ logger.warn(
2374
+ `Could not register ${appPath} with macOS Launch Services. Open Camunda Modeler once so macOS picks up its file associations.`
2375
+ );
2376
+ }
2377
+ }
2378
+ function hasPackageManager(command, name) {
2379
+ const result = spawnSync(command, ["--version"], { stdio: "ignore" });
2380
+ if (result.error) {
2381
+ if ("code" in result.error && result.error.code === "ENOENT") return false;
2382
+ throw new Error(`Could not check ${name}: ${result.error.message}`);
2383
+ }
2384
+ if (result.status !== 0) {
2385
+ throw new Error(
2386
+ `${name} is available but \`${command} --version\` failed (exit code ${formatExitCode(result.status)})`
2387
+ );
2388
+ }
2389
+ return true;
2390
+ }
2391
+ function isInstalledWith({
2392
+ command,
2393
+ args,
2394
+ notInstalledStatus,
2395
+ description
2396
+ }) {
2397
+ const result = spawnSync(command, args, { stdio: "ignore" });
2398
+ if (result.error) {
2399
+ throw new Error(`Could not check ${description}: ${result.error.message}`);
2400
+ }
2401
+ if (result.status === 0) return true;
2402
+ if (result.status === notInstalledStatus) return false;
2403
+ throw new Error(
2404
+ `Could not check ${description} (exit code ${formatExitCode(result.status)})`
2405
+ );
2406
+ }
2407
+ function userApplicationsDir() {
2408
+ return join2(homedir2(), "Applications");
2409
+ }
2410
+ function findInstalledModeler() {
2411
+ return [SYSTEM_APPLICATIONS_DIR, userApplicationsDir()].map((dir) => join2(dir, APP_BUNDLE_NAME)).find((location) => existsSync(location));
2412
+ }
2413
+ function resolveHomebrewModelerPath() {
2414
+ const failureMessage = "Could not locate the Camunda Modeler app installed by Homebrew";
2415
+ const result = spawnSync("brew", ["list", "--cask", "camunda-modeler"], {
2416
+ encoding: "utf8",
2417
+ stdio: ["ignore", "pipe", process.stderr.fd]
2418
+ });
2419
+ if (result.error) {
2420
+ throw new Error(`${failureMessage}: ${result.error.message}`);
2421
+ }
2422
+ if (result.status !== 0) {
2423
+ throw new Error(`${failureMessage} (exit code ${String(result.status)}).`);
2424
+ }
2425
+ const appPath = result.stdout.split(/\r?\n/).find((path) => path.endsWith(`/${APP_BUNDLE_NAME}`));
2426
+ if (!appPath) {
2427
+ throw new Error(
2428
+ `${failureMessage}. Run \`brew list --cask camunda-modeler\` to check the installation.`
2429
+ );
2430
+ }
2431
+ return realpathSync(appPath);
2432
+ }
2433
+ function installApplicationsDir() {
2434
+ try {
2435
+ accessSync(SYSTEM_APPLICATIONS_DIR, constants.W_OK);
2436
+ return SYSTEM_APPLICATIONS_DIR;
2437
+ } catch {
2438
+ return userApplicationsDir();
2439
+ }
2440
+ }
2441
+ async function fetchResponse(url, description, signal) {
2442
+ let response;
2443
+ try {
2444
+ response = await fetch(url, { signal });
2445
+ } catch (error) {
2446
+ throw manualDownloadError(`${description}: ${errorMessage(error)}`);
2447
+ }
2448
+ if (!response.ok) {
2449
+ throw manualDownloadError(
2450
+ `${description} returned HTTP ${response.status}`
2451
+ );
2452
+ }
2453
+ return response;
2454
+ }
2455
+ async function fetchReleaseIndex(signal) {
2456
+ const response = await fetchResponse(
2457
+ MODELER_RELEASE_URL,
2458
+ "Could not check Camunda Modeler releases",
2459
+ AbortSignal.any([signal, AbortSignal.timeout(3e4)])
2460
+ );
2461
+ try {
2462
+ return await response.text();
2463
+ } catch (error) {
2464
+ throw manualDownloadError(
2465
+ `Could not read Camunda Modeler releases: ${errorMessage(error)}`
2466
+ );
2467
+ }
2468
+ }
2469
+ async function downloadArchive({
2470
+ url,
2471
+ destination,
2472
+ logger,
2473
+ quiet,
2474
+ signal: interruptionSignal
2475
+ }) {
2476
+ const controller = new AbortController();
2477
+ const signal = AbortSignal.any([interruptionSignal, controller.signal]);
2478
+ const stallTimer = setTimeout(
2479
+ () => controller.abort(
2480
+ new Error(
2481
+ `no data received for ${DOWNLOAD_STALL_TIMEOUT_MS / 1e3} seconds`
2482
+ )
2483
+ ),
2484
+ DOWNLOAD_STALL_TIMEOUT_MS
2485
+ );
2486
+ const live = !quiet && Boolean(process.stderr.isTTY) && process.env.TERM !== "dumb" && logger.mode === "text";
2487
+ const startedAt = Date.now();
2488
+ let received = 0;
2489
+ let total = 0;
2490
+ let renderedAt = 0;
2491
+ const render = () => {
2492
+ const frame = renderDownloadProgress({
2493
+ received,
2494
+ total,
2495
+ elapsedMs: Date.now() - startedAt,
2496
+ columns: process.stderr.columns || 80,
2497
+ color: process.env.NO_COLOR === void 0
2498
+ });
2499
+ process.stderr.write(`\r\x1B[2K${frame}`);
2500
+ renderedAt = Date.now();
2501
+ };
2502
+ try {
2503
+ const response = await fetchResponse(
2504
+ url,
2505
+ "Could not download Camunda Modeler",
2506
+ signal
2507
+ );
2508
+ if (!response.body) {
2509
+ throw manualDownloadError("The Modeler download returned no file");
2510
+ }
2511
+ total = Number(response.headers.get("content-length")) || 0;
2512
+ try {
2513
+ await pipeline(
2514
+ Readable.fromWeb(response.body),
2515
+ new Transform({
2516
+ transform(chunk, _encoding, callback) {
2517
+ stallTimer.refresh();
2518
+ received += chunk.byteLength;
2519
+ if (live && Date.now() - renderedAt >= 100) render();
2520
+ callback(null, chunk);
2521
+ }
2522
+ }),
2523
+ createWriteStream(destination),
2524
+ { signal }
2525
+ );
2526
+ } catch (error) {
2527
+ const reason = signal.aborted ? signal.reason : error;
2528
+ throw manualDownloadError(
2529
+ `Could not download Camunda Modeler: ${errorMessage(reason)}`
2530
+ );
2531
+ } finally {
2532
+ if (live) {
2533
+ render();
2534
+ process.stderr.write("\n");
2535
+ }
2536
+ }
2537
+ } finally {
2538
+ clearTimeout(stallTimer);
2539
+ }
2540
+ if (!live && !quiet) {
2541
+ logger.info(`Downloaded ${(received / 1048576).toFixed(1)} MB.`);
2542
+ }
2543
+ }
2544
+ async function downloadLatestRelease({
2545
+ dir,
2546
+ platform: platform2,
2547
+ archiveName,
2548
+ logger,
2549
+ quiet,
2550
+ signal
2551
+ }) {
2552
+ const version = latestStableModelerVersion(await fetchReleaseIndex(signal));
2553
+ const name = archiveName(version);
2554
+ const archivePath = join2(dir, name);
2555
+ reportProgress(
2556
+ { logger, quiet },
2557
+ `Downloading Camunda Modeler ${version} for ${platform2}...`
2558
+ );
2559
+ await downloadArchive({
2560
+ url: new URL(`${version}/${name}`, MODELER_RELEASE_URL).toString(),
2561
+ destination: archivePath,
2562
+ logger,
2563
+ quiet,
2564
+ signal
2565
+ });
2566
+ return { version, archivePath };
2567
+ }
2568
+ async function installFromOfficialDownload({
2569
+ applicationsDir,
2570
+ logger,
2571
+ quiet
2572
+ }) {
2573
+ const destination = join2(applicationsDir, APP_BUNDLE_NAME);
2574
+ const tempDir = mkdtempSync(join2(tmpdir(), "c8ctl-modeler-"));
2575
+ const controller = new AbortController();
2576
+ let interruptedSignal;
2577
+ const interrupt = (signal) => {
2578
+ interruptedSignal ??= signal;
2579
+ controller.abort(new Error(`Installation interrupted by ${signal}`));
2580
+ };
2581
+ const onSigint = () => interrupt("SIGINT");
2582
+ const onSigterm = () => interrupt("SIGTERM");
2583
+ process.on("SIGINT", onSigint);
2584
+ process.on("SIGTERM", onSigterm);
2585
+ try {
2586
+ const { version, archivePath } = await downloadLatestRelease({
2587
+ dir: tempDir,
2588
+ platform: "macOS",
2589
+ archiveName: (version2) => modelerMacArchiveName(version2, process.arch),
2590
+ logger,
2591
+ quiet,
2592
+ signal: controller.signal
2593
+ });
2594
+ if (applicationsDir !== SYSTEM_APPLICATIONS_DIR) {
2595
+ mkdirSync(applicationsDir, { recursive: true });
2596
+ }
2597
+ const stagingDir = mkdtempSync(join2(applicationsDir, ".c8ctl-modeler-"));
2598
+ try {
2599
+ reportProgress(
2600
+ { logger, quiet },
2601
+ `Installing Camunda Modeler to ${destination}...`
2602
+ );
2603
+ runCommand("ditto", ["-x", "-k", archivePath, stagingDir], {
2604
+ failureMessage: "Could not extract Camunda Modeler",
2605
+ quiet
2606
+ });
2607
+ const stagedApp = join2(stagingDir, APP_BUNDLE_NAME);
2608
+ if (!existsSync(stagedApp)) {
2609
+ throw manualDownloadError(
2610
+ `The Camunda Modeler ${version} archive did not contain ${APP_BUNDLE_NAME}`
2611
+ );
2612
+ }
2613
+ runCommand(
2614
+ "codesign",
2615
+ [
2616
+ "--verify",
2617
+ "--deep",
2618
+ "--strict",
2619
+ `-R=${MODELER_CODE_REQUIREMENT}`,
2620
+ stagedApp
2621
+ ],
2622
+ {
2623
+ failureMessage: "The downloaded Camunda Modeler is not signed by Camunda; refusing to install it",
2624
+ quiet
2625
+ }
2626
+ );
2627
+ renameSync(stagedApp, destination);
2628
+ } finally {
2629
+ rmSync(stagingDir, { recursive: true, force: true });
2630
+ }
2631
+ registerWithLaunchServices(destination, logger);
2632
+ return { version, destination };
2633
+ } finally {
2634
+ process.off("SIGINT", onSigint);
2635
+ process.off("SIGTERM", onSigterm);
2636
+ rmSync(tempDir, { recursive: true, force: true });
2637
+ if (interruptedSignal) process.kill(process.pid, interruptedSignal);
2638
+ }
2639
+ }
2640
+ function registerWithWindows(executable, logger) {
2641
+ const registered = MODELER_FILE_TYPES.flatMap(
2642
+ (type) => {
2643
+ const progId = `CamundaModeler.${type.toUpperCase()}`;
2644
+ const progIdKey = `HKCU\\Software\\Classes\\${progId}`;
2645
+ return [
2646
+ [`HKCU\\Software\\Classes\\.${type}`, progId],
2647
+ [progIdKey, `${type.toUpperCase()} file`],
2648
+ [`${progIdKey}\\DefaultIcon`, `${executable},0`],
2649
+ [`${progIdKey}\\shell\\open\\command`, `"${executable}" "%1"`]
2650
+ ];
2651
+ }
2652
+ ).every(([key, value]) => {
2653
+ const result2 = spawnSync("reg", ["add", key, "/ve", "/d", value, "/f"], {
2654
+ stdio: "ignore"
2655
+ });
2656
+ return !result2.error && result2.status === 0;
2657
+ });
2658
+ if (!registered) {
2659
+ logger.warn(
2660
+ 'Could not register Camunda Modeler for .bpmn, .dmn, .form, and .rpa files. Choose it with "Open with" instead.'
2661
+ );
2662
+ }
2663
+ const appData = process.env.APPDATA || join2(homedir2(), "AppData", "Roaming");
2664
+ const shortcut = join2(
2665
+ appData,
2666
+ "Microsoft",
2667
+ "Windows",
2668
+ "Start Menu",
2669
+ "Programs",
2670
+ "Camunda Modeler.lnk"
2671
+ );
2672
+ const result = spawnSync(
2673
+ "powershell",
2674
+ ["-NoProfile", "-NonInteractive", "-Command", CREATE_SHORTCUT_SCRIPT],
2675
+ {
2676
+ stdio: "ignore",
2677
+ env: {
2678
+ ...process.env,
2679
+ C8CTL_SHORTCUT: shortcut,
2680
+ C8CTL_TARGET: executable
2681
+ }
2682
+ }
2683
+ );
2684
+ if (result.error || result.status !== 0) {
2685
+ logger.warn(
2686
+ `Could not add Camunda Modeler to the Start Menu. Start it from ${executable}.`
2687
+ );
2688
+ }
2689
+ }
2690
+ function installOnWindows({
2691
+ isDryRun,
2692
+ logger,
2693
+ quiet
2694
+ }) {
2695
+ const localAppData = process.env.LOCALAPPDATA || join2(homedir2(), "AppData", "Local");
2696
+ const installDir = join2(localAppData, "Programs", "Camunda Modeler");
2697
+ const executable = join2(installDir, WINDOWS_EXECUTABLE);
2698
+ if (existsSync(executable)) {
2699
+ return {
2700
+ kind: "info",
2701
+ message: `Camunda Modeler is already installed at ${installDir}; skipping installation.`
2702
+ };
2703
+ }
2704
+ try {
2705
+ if (!hasPackageManager("winget", "winget")) {
2706
+ throw new Error(
2707
+ `winget is not available (install it from ${WINGET_INSTALL_URL})`
2708
+ );
2709
+ }
2710
+ if (isInstalledWith({
2711
+ command: "winget",
2712
+ args: ["list", ...WINGET_PACKAGE],
2713
+ notInstalledStatus: WINGET_NO_APPLICATIONS_FOUND,
2714
+ description: "the winget Modeler package"
2715
+ })) {
2716
+ return {
2717
+ kind: "info",
2718
+ message: "Camunda Modeler is already installed with winget; skipping installation."
2719
+ };
2720
+ }
2721
+ if (isDryRun) {
2722
+ return {
2723
+ kind: "dryRun",
2724
+ info: {
2725
+ dryRun: true,
2726
+ command: "modeler install",
2727
+ message: `Dry run: would install Camunda Modeler to ${installDir} with \`winget install --id ${WINGET_PACKAGE_ID}\`.`
2728
+ }
2729
+ };
2730
+ }
2731
+ reportProgress(
2732
+ { logger, quiet },
2733
+ "Installing Camunda Modeler with winget..."
2734
+ );
2735
+ runCommand(
2736
+ "winget",
2737
+ [
2738
+ "install",
2739
+ ...WINGET_PACKAGE,
2740
+ "--scope",
2741
+ "user",
2742
+ "--location",
2743
+ installDir
2744
+ ],
2745
+ {
2746
+ failureMessage: "winget could not install Camunda Modeler",
2747
+ quiet
2748
+ }
2749
+ );
2750
+ } catch (error) {
2751
+ throw manualDownloadError(errorMessage(error));
2752
+ }
2753
+ registerWithWindows(executable, logger);
2754
+ return {
2755
+ kind: "success",
2756
+ message: `Installed Camunda Modeler with winget to ${installDir}.`
2757
+ };
2758
+ }
2759
+ function findOnPath(command) {
2760
+ const path = process.env.PATH;
2761
+ if (path === void 0) return void 0;
2762
+ return path.split(delimiter).map((dir) => join2(dir || ".", command)).find((path2) => {
2763
+ try {
2764
+ accessSync(path2, constants.X_OK);
2765
+ return statSync(path2).isFile();
2766
+ } catch {
2767
+ return false;
2768
+ }
2769
+ });
2770
+ }
2771
+ function runAsRoot(args, failureMessage, quiet) {
2772
+ const [command, ...rest] = process.getuid?.() === 0 ? args : ["sudo", ...args];
2773
+ try {
2774
+ runCommand(command, rest, { failureMessage, quiet });
2775
+ } catch (error) {
2776
+ throw manualDownloadError(errorMessage(error));
2777
+ }
2778
+ }
2779
+ function registerWithDesktop({
2780
+ installDir,
2781
+ logger,
2782
+ quiet
2783
+ }) {
2784
+ const script = join2(installDir, "support", "xdg_register.sh");
2785
+ if (!findOnPath("xdg-mime")) {
2786
+ logger.warn(
2787
+ `Could not register Camunda Modeler for .bpmn, .dmn, .form, and .rpa files because xdg-utils is not installed. Install xdg-utils, then run ${script}.`
2788
+ );
2789
+ return;
2790
+ }
2791
+ try {
2792
+ runCommand("/bin/bash", [script], {
2793
+ failureMessage: `Could not register Camunda Modeler for .bpmn, .dmn, .form, and .rpa files. Run ${script} to retry.`,
2794
+ quiet,
2795
+ stdin: "ignore"
2796
+ });
2797
+ } catch (error) {
2798
+ logger.warn(errorMessage(error));
2799
+ }
2800
+ }
2801
+ async function installOnLinux({
2802
+ isDryRun,
2803
+ logger,
2804
+ quiet
2805
+ }) {
2806
+ const installedPath = findOnPath(LINUX_EXECUTABLE);
2807
+ if (installedPath) {
2808
+ return {
2809
+ kind: "info",
2810
+ message: `Camunda Modeler is already installed at ${installedPath}; skipping installation.`
2811
+ };
2812
+ }
2813
+ if (process.arch !== "x64") {
2814
+ throw manualDownloadError(
2815
+ `Unsupported Linux architecture "${process.arch}"`
2816
+ );
2817
+ }
2818
+ if (isDryRun) {
2819
+ return {
2820
+ kind: "dryRun",
2821
+ info: {
2822
+ dryRun: true,
2823
+ command: "modeler install",
2824
+ message: `Dry run: would download the latest stable Camunda Modeler and install it to ${LINUX_INSTALL_ROOT} as root.`
2825
+ }
2826
+ };
2827
+ }
2828
+ if (process.getuid?.() !== 0) {
2829
+ reportProgress(
2830
+ { logger, quiet },
2831
+ `Installing to ${LINUX_INSTALL_ROOT} needs root privileges; sudo may ask for your password.`
2832
+ );
2833
+ }
2834
+ runAsRoot(["true"], "Could not get root privileges", quiet);
2835
+ reportProgress(
2836
+ { logger, quiet },
2837
+ "Checking for the latest stable Camunda Modeler release..."
2838
+ );
2839
+ const tempDir = mkdtempSync(join2(tmpdir(), "c8ctl-modeler-"));
2840
+ const controller = new AbortController();
2841
+ let interruptedSignal;
2842
+ const interrupt = (signal) => {
2843
+ interruptedSignal ??= signal;
2844
+ controller.abort(new Error(`Installation interrupted by ${signal}`));
2845
+ };
2846
+ const onSigint = () => interrupt("SIGINT");
2847
+ const onSigterm = () => interrupt("SIGTERM");
2848
+ process.on("SIGINT", onSigint);
2849
+ process.on("SIGTERM", onSigterm);
2850
+ try {
2851
+ const { version, archivePath } = await downloadLatestRelease({
2852
+ dir: tempDir,
2853
+ platform: "Linux",
2854
+ archiveName: (version2) => `camunda-modeler-${version2}-linux-x64.tar.gz`,
2855
+ logger,
2856
+ quiet,
2857
+ signal: controller.signal
2858
+ });
2859
+ const releaseDir = `camunda-modeler-${version}-linux-x64`;
2860
+ const installDir = join2(LINUX_INSTALL_ROOT, releaseDir);
2861
+ const launcher = join2(LINUX_INSTALL_ROOT, LINUX_EXECUTABLE);
2862
+ reportProgress(
2863
+ { logger, quiet },
2864
+ `Installing Camunda Modeler to ${installDir}...`
2865
+ );
2866
+ runAsRoot(["rm", "-f", launcher], `Could not remove ${launcher}`, quiet);
2867
+ runAsRoot(
2868
+ ["tar", "--no-same-owner", "-xzf", archivePath, "-C", LINUX_INSTALL_ROOT],
2869
+ "Could not extract Camunda Modeler",
2870
+ quiet
2871
+ );
2872
+ runAsRoot(
2873
+ ["chmod", "4755", join2(installDir, "chrome-sandbox")],
2874
+ "Could not set up the Camunda Modeler sandbox",
2875
+ quiet
2876
+ );
2877
+ runAsRoot(
2878
+ ["ln", "-sfn", join2(releaseDir, LINUX_EXECUTABLE), launcher],
2879
+ `Could not link ${launcher}`,
2880
+ quiet
2881
+ );
2882
+ registerWithDesktop({ installDir, logger, quiet });
2883
+ return {
2884
+ kind: "success",
2885
+ message: `Installed Camunda Modeler ${version} to ${installDir}.`
2886
+ };
2887
+ } finally {
2888
+ process.off("SIGINT", onSigint);
2889
+ process.off("SIGTERM", onSigterm);
2890
+ rmSync(tempDir, { recursive: true, force: true });
2891
+ if (interruptedSignal) process.kill(process.pid, interruptedSignal);
2892
+ }
2893
+ }
2894
+ async function installDesktopModeler(ctx) {
2895
+ if (process.platform === "win32") return installOnWindows(ctx);
2896
+ if (process.platform === "linux") return installOnLinux(ctx);
2897
+ if (process.platform !== "darwin") {
2898
+ throw new Error(
2899
+ `c8ctl modeler install currently supports macOS, Windows, and Linux only. Download Modeler manually from ${MANUAL_DOWNLOAD_URL}`
2900
+ );
2901
+ }
2902
+ const installedPath = findInstalledModeler();
2903
+ if (installedPath) {
2904
+ return {
2905
+ kind: "info",
2906
+ message: `Camunda Modeler is already installed at ${installedPath}; skipping installation.`
2907
+ };
2908
+ }
2909
+ if (hasPackageManager("brew", "Homebrew")) {
2910
+ if (isInstalledWith({
2911
+ command: "brew",
2912
+ args: ["list", "--cask", "--versions", "camunda-modeler"],
2913
+ notInstalledStatus: 1,
2914
+ description: "the Homebrew Modeler cask"
2915
+ })) {
2916
+ return {
2917
+ kind: "info",
2918
+ message: "Camunda Modeler is already installed with Homebrew; skipping installation."
2919
+ };
2920
+ }
2921
+ if (ctx.isDryRun) {
2922
+ return {
2923
+ kind: "dryRun",
2924
+ info: {
2925
+ dryRun: true,
2926
+ command: "modeler install",
2927
+ message: "Dry run: would install Camunda Modeler with `brew install --cask camunda-modeler`."
2928
+ }
2929
+ };
2930
+ }
2931
+ reportProgress(ctx, "Installing Camunda Modeler with Homebrew...");
2932
+ runCommand("brew", ["install", "--cask", "camunda-modeler"], {
2933
+ failureMessage: "Homebrew could not install Camunda Modeler",
2934
+ quiet: ctx.quiet
2935
+ });
2936
+ const brewInstalledPath = findInstalledModeler() ?? resolveHomebrewModelerPath();
2937
+ registerWithLaunchServices(brewInstalledPath, ctx.logger);
2938
+ return {
2939
+ kind: "success",
2940
+ message: "Installed Camunda Modeler with Homebrew."
2941
+ };
2942
+ }
2943
+ const applicationsDir = installApplicationsDir();
2944
+ if (ctx.isDryRun) {
2945
+ return {
2946
+ kind: "dryRun",
2947
+ info: {
2948
+ dryRun: true,
2949
+ command: "modeler install",
2950
+ message: `Dry run: would download the latest stable Camunda Modeler and install it to ${join2(applicationsDir, APP_BUNDLE_NAME)}.`
2951
+ }
2952
+ };
2953
+ }
2954
+ if (applicationsDir !== SYSTEM_APPLICATIONS_DIR) {
2955
+ reportProgress(
2956
+ ctx,
2957
+ `${SYSTEM_APPLICATIONS_DIR} is not writable; installing to ${applicationsDir} instead.`
2958
+ );
2959
+ }
2960
+ reportProgress(
2961
+ ctx,
2962
+ "Checking for the latest stable Camunda Modeler release..."
2963
+ );
2964
+ const { version, destination } = await installFromOfficialDownload({
2965
+ applicationsDir,
2966
+ logger: ctx.logger,
2967
+ quiet: ctx.quiet
2968
+ });
2969
+ return {
2970
+ kind: "success",
2971
+ message: `Installed Camunda Modeler ${version} to ${destination}.`
2972
+ };
2973
+ }
2974
+
2975
+ // default-plugins/modeler/c8ctl-plugin.ts
2976
+ var metadata = {
2977
+ name: "modeler",
2978
+ description: "Install Camunda Desktop Modeler",
2979
+ commands: {
2980
+ modeler: {
2981
+ description: "Install Camunda Desktop Modeler",
2982
+ helpDescription: "Install the latest stable Camunda Desktop Modeler on macOS, Windows, or Linux, skipping the installation when Modeler is already installed. On macOS, uses Homebrew when available, and otherwise installs the Camunda-signed release into /Applications (or ~/Applications when /Applications is not writable). On Windows, installs it with winget into %LOCALAPPDATA%\\Programs\\Camunda Modeler, then registers its file types and adds it to the Start Menu. On Linux (x64), installs the release into /usr/bin as root, using sudo, as the Camunda documentation describes, then registers its file types with the bundled support/xdg_register.sh.",
2983
+ subcommands: [
2984
+ {
2985
+ name: "install",
2986
+ description: "Install the latest stable Camunda Desktop Modeler"
2987
+ }
2988
+ ],
2989
+ examples: [
2990
+ {
2991
+ command: "c8ctl modeler install",
2992
+ description: "Install the latest stable Camunda Desktop Modeler"
2993
+ }
2994
+ ]
2995
+ }
2996
+ }
2997
+ };
2998
+ async function modelerHandler(args, _flags, ctx) {
2999
+ if (!ctx) throw new Error("modeler requires the plugin host context");
3000
+ const { logger } = ctx;
3001
+ if (args[0] !== "install") {
3002
+ if (args[0] === void 0) {
3003
+ logger.info(
3004
+ "\nUsage: c8ctl modeler install\n\nAvailable resources:\n install",
3005
+ {
3006
+ essential: true
3007
+ }
3008
+ );
3009
+ } else {
3010
+ logger.error(`Unknown command: modeler ${args.join(" ")}`);
3011
+ logger.info('Run "c8 help" for usage information', { essential: true });
3012
+ }
3013
+ process.exitCode = 1;
3014
+ return;
3015
+ }
3016
+ try {
3017
+ const result = await installDesktopModeler({
3018
+ isDryRun: ctx.dryRun,
3019
+ logger,
3020
+ quiet: ctx.quiet
3021
+ });
3022
+ if (result.kind === "dryRun") {
3023
+ logger.json(result.info);
3024
+ } else if (result.kind === "info") {
3025
+ logger.info(result.message, { essential: true });
3026
+ } else {
3027
+ logger.success(result.message);
3028
+ }
3029
+ } catch (error) {
3030
+ renderCommandFailure(logger, "Failed to modeler install", error, {
3031
+ verbose: ctx.verbose
3032
+ });
3033
+ process.exitCode = 1;
3034
+ }
3035
+ }
3036
+ var commands = {
3037
+ modeler: { flags: {}, handler: modelerHandler }
3038
+ };
3039
+ export {
3040
+ commands,
3041
+ metadata
3042
+ };