@camunda8/cli 4.6.0 → 4.6.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,6 +29,10 @@ _Full transparency_:
29
29
  this cli is also a pilot-coding experiment, practicing [Agentic Engineering](https://addyosmani.com/blog/agentic-engineering/).
30
30
  Guided by humans, the codebase is (mostly) built by your friendly neighborhood LLM, fully dogfooding the Human-in-the-Loop pattern.
31
31
 
32
+ Repository automation is documented in the
33
+ [agentic workflows operator guide](.github/AGENTIC-WORKFLOWS.md). Issue implementation,
34
+ dual-engine review, and guarded auto-merge are inactive until explicitly enabled.
35
+
32
36
  ## Installation
33
37
 
34
38
  ### Requirements
@@ -1,8 +1,8 @@
1
1
  # AGENTS.md — `element-template` plugin
2
2
 
3
3
  Read [docs/design.md](./docs/design.md) before changing this plugin. It
4
- covers the **why**: vendor bundle, release-bundle source choice, cache
5
- strategy (`upstreamRef`-keyed dedup), lazy bootstrap, and semver-based
4
+ covers the **why**: vendor bundle, npm package source choice, cache
5
+ strategy (`id@version`-keyed dedup), explicit bootstrap, and semver-based
6
6
  version resolution.
7
7
 
8
8
  ## Where things live
@@ -14,7 +14,6 @@ version resolution.
14
14
  | `migration/` | The migration engine behind `update`: recipe parser (`recipe.ts`, schema in `migrates-from.schema.json`), step resolution (`steps.ts`), value resolution (`plan.ts`), applying to a headless modeler (`apply.ts`) and the report model (`report.ts`). **Self-contained: nothing in this folder may import from c8ctl or from the rest of the plugin**, so it can be lifted out into a library. `migration-output.ts` (outside it) renders the report. |
15
15
  | `template-ref.ts` | `parseTemplateRef`, `readBpmnInput`, `getExecutionPlatformVersion`, `findLocalTemplates` (Modeler-aligned `.camunda/element-templates/` + Modeler user-data lookup), `resolveOotbTemplate`, `resolveTemplateId` (local first, then OOTB — every subcommand's id path), `loadTemplate` |
16
16
  | `cache.ts` | Cache I/O, sync, search, version resolution |
17
- | `releases.ts` | `camunda/connectors` GitHub releases: listing, newest-release-per-minor selection, bundle download, tar.gz reader |
18
17
  | `helpers.ts` | `--set` parsing, file/URL fetch, glob → regex, multi-binding lookup, condition warnings, `atomicOverwriteFile` |
19
18
  | `vendor.ts` | `resolveVendorBundle()` + the minimal bpmn-js `Modeler`/`modeling` type surface shared by `apply`/`edit` |
20
19
  | `vendor-src/bundle-entry.js` | esbuild entry — re-exports `Modeler`, `CloudElementTemplatesCoreModule`, `ZeebeModdleExtension` |
@@ -27,16 +26,16 @@ version resolution.
27
26
  esbuild bundles.
28
27
  - **Cache file shape mirrors Desktop Modeler's
29
28
  `.camunda-connector-templates.json`.** Don't change the format
30
- without reason — `metadata.upstreamRef` is the dedup key for
31
- incremental sync.
29
+ without reason — current package templates replace cached entries
30
+ by `id@version`; `metadata.upstreamRef` records their origin.
32
31
  - **No subcommand auto-bootstraps the cache.** OOTB-id resolution
33
32
  is guarded by `requireCachePresent()` in `cache.ts`, which
34
33
  throws the shared `CACHE_NOT_FOUND_MESSAGE` when the cache is
35
34
  absent. The reason auto-bootstrap is forbidden: bootstrap progress
36
35
  goes through `logger.info`, which writes to stdout in text mode —
37
36
  it would corrupt `apply | bpmn lint` and `get <id> > template.json`
38
- pipelines, and racing cold-cache invocations would both download the
39
- same bundles. Don't re-add a bootstrap call to any subcommand
37
+ pipelines, and racing cold-cache invocations would both install the
38
+ same package. Don't re-add a bootstrap call to any subcommand
40
39
  without changing the logger story first.
41
40
  - **Path/URL refs and local id hits must not trigger the cache check.**
42
41
  Detection happens in `parseTemplateRef()` in `template-ref.ts`
@@ -88,16 +87,12 @@ version resolution.
88
87
  WeakMap-based `sourceByDetail` side table in `loadTemplate` preserves
89
88
  this identity so `get-properties` doesn't collapse them and `--set`
90
89
  writes to all matching duplicates.
91
- - **Templates come from the `camunda/connectors` GitHub releases, not
92
- `raw.githubusercontent.com`** (blocked in many enterprise networks —
93
- c8ctl#530). `sync` keeps the newest release of each of the 4 newest
94
- minor lines (`MAX_MINOR_LINES`), skipping drafts, release candidates
95
- and releases whose bundle asset isn't published yet. A bundle URL
96
- changes with every patch, so `--prune` is skipped whenever a download
97
- failed — otherwise one transient error would drop a whole minor line.
98
- The release listing endpoint is overridable via
99
- `C8CTL_CONNECTORS_RELEASES_URL` — useful for tests against a local
100
- fixture server.
90
+ - **Templates come from `@camunda/connectors-element-templates` via
91
+ `c8ctl.npm`**. Sync installs into a temporary directory under the locked
92
+ cache, then reads `src/element-templates/*.json`;
93
+ `C8CTL_ELEMENT_TEMPLATES_PACKAGE` allows package specs, URLs, and local
94
+ paths. Failed installs or malformed template files retain the old cache
95
+ and skip `--prune`.
101
96
 
102
97
  ## Testing
103
98
 
@@ -114,10 +109,11 @@ Agent v1 to v2 migration against the real templates, fetched at a pinned
114
109
  C8CTL_FIDELITY=1 node --experimental-strip-types --test tests/unit/element-template-migration-upstream-fidelity.test.ts
115
110
  ```
116
111
 
117
- Smoke-test against the live connectors releases (writes to a throwaway
112
+ Smoke-test against the live npm package (writes to a throwaway
118
113
  dir):
119
114
 
120
115
  ```bash
121
- C8CTL_DATA_DIR=/tmp/c8ctl-smoke node --experimental-strip-types src/index.ts \
122
- element-template search "AWS S3"
116
+ export C8CTL_DATA_DIR=/tmp/c8ctl-smoke
117
+ node --experimental-strip-types src/index.ts element-template sync
118
+ node --experimental-strip-types src/index.ts element-template search "AWS S3"
123
119
  ```
@@ -3,8 +3,8 @@
3
3
  A default [c8ctl](https://github.com/camunda/c8ctl) plugin for applying
4
4
  Camunda element templates to BPMN diagrams, inspecting their properties,
5
5
  and exporting raw template JSON. Supports out-of-the-box (OOTB)
6
- connector templates by id (downloaded on demand from the Camunda
7
- marketplace), plus arbitrary local paths and URLs.
6
+ connector templates by id (cached from the Camunda npm package), plus
7
+ arbitrary local paths and URLs.
8
8
 
9
9
  ## Subcommands
10
10
 
@@ -99,9 +99,19 @@ c8ctl element-template get io.camunda.connectors.HttpJson.v2 --no-icon # drop t
99
99
 
100
100
  # Refresh the local OOTB template cache
101
101
  c8ctl element-template sync
102
- c8ctl element-template sync --prune # also drop entries no longer in a selected release
102
+ c8ctl element-template sync --prune # also drop entries absent from the installed package
103
103
  ```
104
104
 
105
+ `sync` installs `@camunda/connectors-element-templates` into a temporary
106
+ directory using npm's user, global, and environment registry, authentication,
107
+ proxy, and CA settings. A project `.npmrc` in the invoking directory is not
108
+ read, because npm runs the install in the temporary directory. Set
109
+ `C8CTL_ELEMENT_TEMPLATES_PACKAGE` to a package spec, tarball URL, or local
110
+ package path for pinned or offline use. Every sync installs afresh, so changes
111
+ to a local source are picked up.
112
+ The override must resolve to one package that ships `src/element-templates`; a
113
+ package that depends on another template package is not supported.
114
+
105
115
  ## Migrating to a newer template
106
116
 
107
117
  `update <template-id>` moves every element that uses that template to a newer
@@ -314,7 +324,7 @@ but sources, groups, guard lists, and value-map rules must be non-empty.
314
324
 
315
325
  c8ctl ships no connector recipes. The AI Agent v2 templates in
316
326
  `camunda/connectors` embed their v1 recipes as `metadata.migratesFrom`,
317
- so `update` picks them up from the cache once a release carries them.
327
+ so `update` picks them up after syncing the npm package.
318
328
 
319
329
  ## Inspecting a template
320
330
 
@@ -517,14 +527,9 @@ warning at the end (the property won't be applied).
517
527
 
518
528
  ## How OOTB templates are resolved
519
529
 
520
- 1. **Source**: the `camunda/connectors` GitHub releases. `sync` lists
521
- the releases, keeps the newest release of each of the 4 newest minor
522
- lines (8.8.x, 8.9.x, ... — alphas count, release candidates don't),
523
- and downloads
524
- each one's `connectors-bundle-templates-<tag>.tar.gz` asset from
525
- `github.com`. `raw.githubusercontent.com` is deliberately not used:
526
- it is blocked in many enterprise networks. Override the release
527
- listing endpoint via `C8CTL_CONNECTORS_RELEASES_URL` for testing.
530
+ 1. **Source**: the
531
+ [`@camunda/connectors-element-templates` npm package](https://www.npmjs.com/package/@camunda/connectors-element-templates).
532
+ `sync` uses npm to install it in a temporary directory.
528
533
  2. **Populate the cache once** via `c8ctl element-template sync`.
529
534
  Subcommands that resolve OOTB ids (`search`, `info`, `get-properties`,
530
535
  `apply`, `get`) exit non-zero with a hint to run `sync` when the
@@ -539,8 +544,7 @@ warning at the end (the property won't be applied).
539
544
  `engines.camunda` constraint. Without `@<version>`, the highest
540
545
  compatible version wins.
541
546
  5. **Stale cache** (>7 days) prints a hint to run `sync`. No automatic
542
- refresh — `sync` only downloads bundles not already cached (release
543
- assets are tag-pinned, so incremental sync is free).
547
+ refresh — each explicit sync stages a new installation.
544
548
  6. **Concurrent syncs** are serialised by an advisory lock at
545
549
  `<cache-dir>/.sync.lock`. A second `sync` started while one is
546
550
  already running exits non-zero rather than racing.
@@ -558,5 +562,5 @@ Set `C8CTL_DATA_DIR` to override.
558
562
  ## Design
559
563
 
560
564
  See [`docs/design.md`](./docs/design.md) for the full reasoning behind
561
- the release-bundle source choice, the vendor bundle, the cache strategy
565
+ the npm source choice, the vendor bundle, the cache strategy
562
566
  (mirrored from Desktop Modeler), and version resolution.
@@ -9186,157 +9186,30 @@ function parseTemplateJson(content) {
9186
9186
  }
9187
9187
 
9188
9188
  // default-plugins/element-template/template-ref.ts
9189
- var import_semver4 = __toESM(require_semver2(), 1);
9190
- import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync3, statSync } from "node:fs";
9189
+ var import_semver3 = __toESM(require_semver2(), 1);
9190
+ import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
9191
9191
  import { createRequire } from "node:module";
9192
9192
  import { dirname as dirname2, join as join2, resolve as resolvePath3 } from "node:path";
9193
9193
 
9194
9194
  // default-plugins/element-template/cache.ts
9195
- var import_semver3 = __toESM(require_semver2(), 1);
9195
+ var import_semver2 = __toESM(require_semver2(), 1);
9196
9196
  import {
9197
9197
  closeSync,
9198
9198
  existsSync as existsSync2,
9199
9199
  mkdirSync,
9200
+ mkdtempSync,
9200
9201
  openSync,
9202
+ readdirSync,
9201
9203
  readFileSync as readFileSync2,
9202
9204
  renameSync as renameSync2,
9205
+ rmSync,
9206
+ statSync,
9203
9207
  unlinkSync as unlinkSync2,
9204
9208
  writeFileSync as writeFileSync2,
9205
9209
  writeSync
9206
9210
  } from "node:fs";
9207
9211
  import { join } from "node:path";
9208
-
9209
- // default-plugins/element-template/releases.ts
9210
- var import_semver2 = __toESM(require_semver2(), 1);
9211
- import { gunzipSync } from "node:zlib";
9212
- var DEFAULT_RELEASES_URL = "https://api.github.com/repos/camunda/connectors/releases?per_page=100";
9213
- var TEMPLATES_ASSET_PREFIX = "connectors-bundle-templates-";
9214
- var TEMPLATES_ASSET_SUFFIX = ".tar.gz";
9215
- var RELEASES_FETCH_TIMEOUT_MS = 3e4;
9216
- var ASSET_FETCH_TIMEOUT_MS = 12e4;
9217
- var MAX_BUNDLE_BYTES = 128 * 1024 * 1024;
9218
- var MAX_MINOR_LINES = 4;
9219
- function getReleasesUrl() {
9220
- return process.env.C8CTL_CONNECTORS_RELEASES_URL || DEFAULT_RELEASES_URL;
9221
- }
9222
- function isReleaseCandidate(version) {
9223
- const prerelease = import_semver2.default.prerelease(version);
9224
- if (!prerelease) return false;
9225
- return prerelease.flatMap((part) => typeof part === "string" ? part.split("-") : []).some((part) => /^rc\d*$/i.test(part));
9226
- }
9227
- function findTemplatesAssetUrl(release) {
9228
- if (!Array.isArray(release.assets)) return null;
9229
- for (const asset of release.assets) {
9230
- if (!isRecord(asset)) continue;
9231
- const { name: name2, browser_download_url: url } = asset;
9232
- if (typeof name2 !== "string" || typeof url !== "string") continue;
9233
- if (name2.startsWith(TEMPLATES_ASSET_PREFIX) && name2.endsWith(TEMPLATES_ASSET_SUFFIX)) {
9234
- return url;
9235
- }
9236
- }
9237
- return null;
9238
- }
9239
- function parseReleases(raw) {
9240
- if (!Array.isArray(raw)) {
9241
- throw new Error("Connector releases response is not a JSON array");
9242
- }
9243
- const releases = [];
9244
- for (const entry of raw) {
9245
- if (!isRecord(entry)) continue;
9246
- if (entry.draft === true) continue;
9247
- const tag = entry.tag_name;
9248
- if (typeof tag !== "string") continue;
9249
- const version = import_semver2.default.valid(tag);
9250
- if (!version || isReleaseCandidate(version)) continue;
9251
- const assetUrl = findTemplatesAssetUrl(entry);
9252
- if (!assetUrl) continue;
9253
- releases.push({ tag, version, assetUrl });
9254
- }
9255
- return releases;
9256
- }
9257
- function selectLatestPerMinor(releases) {
9258
- const latest = /* @__PURE__ */ new Map();
9259
- for (const release of releases) {
9260
- const key = `${import_semver2.default.major(release.version)}.${import_semver2.default.minor(release.version)}`;
9261
- const current = latest.get(key);
9262
- if (!current || import_semver2.default.gt(release.version, current.version)) {
9263
- latest.set(key, release);
9264
- }
9265
- }
9266
- return [...latest.values()].sort((a, b) => import_semver2.default.rcompare(a.version, b.version)).slice(0, MAX_MINOR_LINES);
9267
- }
9268
- async function fetchConnectorReleases() {
9269
- const url = getReleasesUrl();
9270
- const response = await fetch(url, {
9271
- headers: {
9272
- "User-Agent": USER_AGENT,
9273
- Accept: "application/vnd.github+json"
9274
- },
9275
- signal: AbortSignal.timeout(RELEASES_FETCH_TIMEOUT_MS)
9276
- });
9277
- if (!response.ok) {
9278
- const hint = response.status === 403 || response.status === 429 ? "\nThe GitHub API rate limit may be exhausted \u2014 retry later, or point C8CTL_CONNECTORS_RELEASES_URL at a mirror of the release listing." : "";
9279
- throw new Error(
9280
- `HTTP ${response.status} ${response.statusText} for ${url}${hint}`
9281
- );
9282
- }
9283
- return selectLatestPerMinor(parseReleases(await response.json()));
9284
- }
9285
- async function fetchReleaseAsset(url) {
9286
- const response = await fetch(url, {
9287
- headers: { "User-Agent": USER_AGENT },
9288
- signal: AbortSignal.timeout(ASSET_FETCH_TIMEOUT_MS)
9289
- });
9290
- if (!response.ok) {
9291
- throw new Error(
9292
- `HTTP ${response.status} ${response.statusText} for ${url}`
9293
- );
9294
- }
9295
- return new Uint8Array(await response.arrayBuffer());
9296
- }
9297
- var TAR_BLOCK_SIZE = 512;
9298
- function readTarString(tar, offset, length) {
9299
- const raw = tar.toString("utf-8", offset, offset + length);
9300
- const nul = raw.indexOf("\0");
9301
- return nul === -1 ? raw : raw.slice(0, nul);
9302
- }
9303
- function extractJsonEntries(gzipped) {
9304
- const tar = gunzipSync(gzipped, { maxOutputLength: MAX_BUNDLE_BYTES });
9305
- const entries = [];
9306
- let offset = 0;
9307
- while (offset + TAR_BLOCK_SIZE <= tar.length) {
9308
- if (tar.subarray(offset, offset + TAR_BLOCK_SIZE).every((b) => b === 0)) {
9309
- break;
9310
- }
9311
- const name2 = readTarString(tar, offset, 100);
9312
- const prefix2 = readTarString(tar, offset + 345, 155);
9313
- const sizeField = readTarString(tar, offset + 124, 12).trim();
9314
- const size = Number.parseInt(sizeField, 8);
9315
- if (!Number.isFinite(size) || size < 0) {
9316
- throw new Error(
9317
- `Malformed tar header (bad size field) at byte ${offset}`
9318
- );
9319
- }
9320
- const typeFlag = String.fromCharCode(tar[offset + 156]);
9321
- const dataStart = offset + TAR_BLOCK_SIZE;
9322
- const dataEnd = dataStart + size;
9323
- if (dataEnd > tar.length) {
9324
- throw new Error(`Truncated tar entry '${name2}' at byte ${offset}`);
9325
- }
9326
- const fullName = prefix2 ? `${prefix2}/${name2}` : name2;
9327
- if ((typeFlag === "0" || typeFlag === "\0") && fullName.endsWith(".json")) {
9328
- entries.push({
9329
- name: fullName,
9330
- content: tar.toString("utf-8", dataStart, dataEnd)
9331
- });
9332
- }
9333
- offset = dataStart + Math.ceil(size / TAR_BLOCK_SIZE) * TAR_BLOCK_SIZE;
9334
- }
9335
- return entries;
9336
- }
9337
-
9338
- // default-plugins/element-template/cache.ts
9339
- var FETCH_CONCURRENCY = 4;
9212
+ var DEFAULT_PACKAGE = "@camunda/connectors-element-templates";
9340
9213
  var STALE_AFTER_MS = 7 * 24 * 60 * 60 * 1e3;
9341
9214
  var SYNC_LOCK_STALE_AFTER_MS = 60 * 60 * 1e3;
9342
9215
  function getCacheDir() {
@@ -9503,7 +9376,7 @@ function atomicWriteFileSync(target, contents) {
9503
9376
  throw error3;
9504
9377
  }
9505
9378
  }
9506
- function saveCache(templates, { stampFetchedAt = true } = {}) {
9379
+ function saveCache(templates) {
9507
9380
  const dir = getCacheDir();
9508
9381
  mkdirSync(dir, { recursive: true });
9509
9382
  atomicWriteFileSync(
@@ -9511,9 +9384,7 @@ function saveCache(templates, { stampFetchedAt = true } = {}) {
9511
9384
  `${JSON.stringify(templates, null, 2)}
9512
9385
  `
9513
9386
  );
9514
- if (stampFetchedAt) {
9515
- atomicWriteFileSync(getFetchedAtPath(), String(Date.now()));
9516
- }
9387
+ atomicWriteFileSync(getFetchedAtPath(), String(Date.now()));
9517
9388
  }
9518
9389
  function isCacheStale() {
9519
9390
  const fetchedAt = loadFetchedAt();
@@ -9537,52 +9408,139 @@ function nudgeIfStale(logger) {
9537
9408
  function isTemplateLike(value) {
9538
9409
  return isRecord(value) && Array.isArray(value.properties);
9539
9410
  }
9540
- function buildUpstreamRef(assetUrl, entryName) {
9541
- return `${assetUrl}#${entryName}`;
9411
+ function buildUpstreamRef(packageRef, fileName) {
9412
+ return `${packageRef}#src/element-templates/${fileName}`;
9542
9413
  }
9543
- function assetUrlOfRef(ref) {
9544
- const hash = ref.indexOf("#");
9545
- return hash === -1 ? ref : ref.slice(0, hash);
9546
- }
9547
- async function fetchReleaseTemplates(release) {
9548
- const bundle = await fetchReleaseAsset(release.assetUrl);
9549
- const templates = [];
9550
- for (const entry of extractJsonEntries(bundle)) {
9551
- let parsed;
9552
- try {
9553
- parsed = JSON.parse(entry.content);
9554
- } catch {
9555
- continue;
9414
+ function installTemplates(spec, logger) {
9415
+ const c8ctl12 = globalThis.c8ctl;
9416
+ if (!c8ctl12) throw new Error("c8ctl npm runner is not available.");
9417
+ const cacheDir = getCacheDir();
9418
+ for (const entry of readdirSync(cacheDir, { withFileTypes: true })) {
9419
+ if (entry.name.startsWith(".staging-") && entry.isDirectory()) {
9420
+ rmSync(join(cacheDir, entry.name), { recursive: true, force: true });
9556
9421
  }
9557
- if (!isTemplateLike(parsed) || typeof parsed.version !== "number") {
9558
- continue;
9422
+ }
9423
+ const dir = mkdtempSync(join(cacheDir, ".staging-"));
9424
+ try {
9425
+ c8ctl12.npm({
9426
+ args: [
9427
+ "install",
9428
+ spec,
9429
+ "--prefix",
9430
+ dir,
9431
+ "--ignore-scripts",
9432
+ "--no-package-lock"
9433
+ ],
9434
+ stdio: "pipe"
9435
+ });
9436
+ const modulesDir = join(dir, "node_modules");
9437
+ const installed = readdirSync(modulesDir, { withFileTypes: true }).filter(
9438
+ (entry) => !entry.name.startsWith(".") && (entry.isDirectory() || entry.isSymbolicLink())
9439
+ ).flatMap(
9440
+ (entry) => entry.name.startsWith("@") ? readdirSync(join(modulesDir, entry.name), {
9441
+ withFileTypes: true
9442
+ }).filter((child) => child.isDirectory() || child.isSymbolicLink()).map((child) => join(entry.name, child.name)) : [entry.name]
9443
+ );
9444
+ const packageNames = installed.filter(
9445
+ (name2) => existsSync2(join(modulesDir, name2, "src", "element-templates"))
9446
+ );
9447
+ if (packageNames.length !== 1) {
9448
+ const found = (names) => names.join(", ") || "none";
9449
+ throw new Error(
9450
+ packageNames.length === 0 ? `npm install produced no package with src/element-templates (installed: ${found(installed)}).` : `npm install produced several packages with src/element-templates (${found(packageNames)}). Sync supports a single template package; a package that depends on another template package counts as several.`
9451
+ );
9559
9452
  }
9560
- parsed.metadata = {
9561
- ...parsed.metadata,
9562
- upstreamRef: buildUpstreamRef(release.assetUrl, entry.name)
9563
- };
9564
- templates.push(parsed);
9453
+ const packageDir = join(modulesDir, packageNames[0]);
9454
+ const installedManifest = JSON.parse(
9455
+ readFileSync2(join(packageDir, "package.json"), "utf-8")
9456
+ );
9457
+ if (!isRecord(installedManifest) || typeof installedManifest.name !== "string" || typeof installedManifest.version !== "string" || !import_semver2.default.valid(installedManifest.version)) {
9458
+ throw new Error(
9459
+ "Installed template package has no valid name or version."
9460
+ );
9461
+ }
9462
+ const ref = `npm:${installedManifest.name}@${installedManifest.version}`;
9463
+ const templatesDir = join(packageDir, "src", "element-templates");
9464
+ const templates = [];
9465
+ for (const file of readdirSync(templatesDir, { withFileTypes: true })) {
9466
+ if (!file.name.endsWith(".json")) {
9467
+ continue;
9468
+ }
9469
+ const filePath = join(templatesDir, file.name);
9470
+ if (!statSync(filePath, { throwIfNoEntry: false })?.isFile()) {
9471
+ continue;
9472
+ }
9473
+ let parsed;
9474
+ try {
9475
+ parsed = JSON.parse(readFileSync2(filePath, "utf-8"));
9476
+ } catch (error3) {
9477
+ const detail = error3 instanceof Error ? error3.message : String(error3);
9478
+ throw new Error(
9479
+ `Invalid element template JSON in ${file.name}: ${detail}`
9480
+ );
9481
+ }
9482
+ for (const value of Array.isArray(parsed) ? parsed : [parsed]) {
9483
+ if (isRecord(value) && value.version === void 0) continue;
9484
+ if (!isTemplateLike(value) || typeof value.id !== "string" || typeof value.version !== "number") {
9485
+ logger.warn(`Skipping invalid element template in ${file.name}.`);
9486
+ continue;
9487
+ }
9488
+ value.metadata = {
9489
+ ...value.metadata,
9490
+ upstreamRef: buildUpstreamRef(ref, file.name)
9491
+ };
9492
+ templates.push(value);
9493
+ }
9494
+ }
9495
+ if (templates.length === 0) {
9496
+ throw new Error("Package contained no element templates.");
9497
+ }
9498
+ return templates;
9499
+ } finally {
9500
+ rmSync(dir, { recursive: true, force: true });
9565
9501
  }
9566
- if (templates.length === 0) {
9567
- throw new Error(
9568
- `Bundle for release ${release.tag} contained no element templates`
9502
+ }
9503
+ function syncErrorMessage(error3, logger) {
9504
+ if (isRecord(error3) && (Buffer.isBuffer(error3.stderr) || typeof error3.stderr === "string")) {
9505
+ const stderr = String(error3.stderr).trim().replaceAll(/(https?:\/\/)[^/\s@]+@/g, "$1[redacted]@").replaceAll(
9506
+ /([?&](?:token|password|_authToken|key)=)[^&\s]+/gi,
9507
+ "$1[redacted]"
9569
9508
  );
9509
+ logger.debug(`npm install stderr: ${stderr}`);
9510
+ if (globalThis.c8ctl?.verbose && stderr) {
9511
+ logger.warn(`npm install stderr: ${stderr}`);
9512
+ }
9513
+ const code = /^npm (?:error|ERR!) code ([A-Z0-9]+)/m.exec(stderr)?.[1];
9514
+ if (code)
9515
+ return `npm install failed (${code}). Check npm registry settings or run with --verbose for details.`;
9516
+ return "npm install failed. Run with --verbose for npm's error details.";
9570
9517
  }
9571
- return templates;
9518
+ return error3 instanceof Error ? error3.message : String(error3);
9572
9519
  }
9573
- async function pool(items, concurrency, fn) {
9574
- const queue = items.slice();
9575
- const workers = Array.from(
9576
- { length: Math.min(concurrency, queue.length) },
9577
- async () => {
9578
- while (queue.length > 0) {
9579
- const item = queue.shift();
9580
- if (item === void 0) break;
9581
- await fn(item);
9582
- }
9520
+ function mergeTemplates(fresh, existing, prune) {
9521
+ const templates = [];
9522
+ const seen = /* @__PURE__ */ new Set();
9523
+ for (const tpl of sortTemplates(fresh)) {
9524
+ const key = `${tpl.id}@${tpl.version}`;
9525
+ if (seen.has(key)) continue;
9526
+ seen.add(key);
9527
+ templates.push(tpl);
9528
+ }
9529
+ const fetched = templates.length;
9530
+ let cached = 0;
9531
+ let pruned = 0;
9532
+ for (const tpl of sortTemplates(existing)) {
9533
+ const key = `${tpl.id}@${tpl.version}`;
9534
+ if (seen.has(key)) continue;
9535
+ if (prune) {
9536
+ pruned++;
9537
+ continue;
9583
9538
  }
9584
- );
9585
- await Promise.all(workers);
9539
+ seen.add(key);
9540
+ templates.push(tpl);
9541
+ cached++;
9542
+ }
9543
+ return { templates: sortTemplates(templates), fetched, cached, pruned };
9586
9544
  }
9587
9545
  function sortTemplates(templates) {
9588
9546
  return [...templates].sort((a, b) => {
@@ -9601,17 +9559,12 @@ async function syncTemplatesLocked({
9601
9559
  logger,
9602
9560
  prune
9603
9561
  }) {
9604
- const releasesUrl = getReleasesUrl();
9605
- logger.info(`Fetching connector releases from ${releasesUrl} ...`);
9606
- const releases = await fetchConnectorReleases();
9607
- if (releases.length === 0) {
9562
+ const spec = process.env.C8CTL_ELEMENT_TEMPLATES_PACKAGE || DEFAULT_PACKAGE;
9563
+ if (spec.startsWith("-")) {
9608
9564
  throw new Error(
9609
- `No connector release with an element-template bundle found at ${releasesUrl}.`
9565
+ `Invalid C8CTL_ELEMENT_TEMPLATES_PACKAGE '${spec}': a package spec must not start with '-'.`
9610
9566
  );
9611
9567
  }
9612
- logger.info(
9613
- `Latest release per minor: ${releases.map((r) => r.tag).join(", ")}.`
9614
- );
9615
9568
  let existing;
9616
9569
  try {
9617
9570
  existing = loadCache() || [];
@@ -9620,90 +9573,52 @@ async function syncTemplatesLocked({
9620
9573
  logger.warn(`Corrupt cache \u2014 starting fresh: ${message}`);
9621
9574
  existing = [];
9622
9575
  }
9623
- const selectedAssets = new Set(releases.map((r) => r.assetUrl));
9624
- const cachedByAsset = /* @__PURE__ */ new Map();
9625
- const staleCached = [];
9626
- for (const tpl of existing) {
9627
- const ref = tpl.metadata?.upstreamRef;
9628
- const asset = ref ? assetUrlOfRef(ref) : void 0;
9629
- if (asset && selectedAssets.has(asset)) {
9630
- const bucket = cachedByAsset.get(asset);
9631
- if (bucket) bucket.push(tpl);
9632
- else cachedByAsset.set(asset, [tpl]);
9633
- } else {
9634
- staleCached.push(tpl);
9635
- }
9636
- }
9637
- const toFetch = releases.filter((r) => !cachedByAsset.has(r.assetUrl));
9638
- const reusedCount = [...cachedByAsset.values()].reduce(
9639
- (sum, bucket) => sum + bucket.length,
9640
- 0
9641
- );
9642
- logger.info(
9643
- `${reusedCount > 0 ? `Reusing ${reusedCount} cached templates from ${cachedByAsset.size} bundle(s), ` : ""}downloading ${toFetch.length} bundle(s)...`
9644
- );
9645
9576
  let errors = 0;
9646
- let progress = 0;
9647
- const fetchedByAsset = /* @__PURE__ */ new Map();
9648
- await pool(toFetch, FETCH_CONCURRENCY, async (release) => {
9649
- progress += 1;
9650
- const myProgress = progress;
9651
- try {
9652
- const templates = await fetchReleaseTemplates(release);
9653
- fetchedByAsset.set(release.assetUrl, templates);
9654
- logger.info(
9655
- ` [${myProgress}/${toFetch.length}] ${release.tag} \u2014 ${templates.length} templates`
9656
- );
9657
- } catch (error3) {
9658
- errors += 1;
9659
- const message = error3 instanceof Error ? error3.message : String(error3);
9660
- logger.warn(
9661
- ` [${myProgress}/${toFetch.length}] ${release.tag} \u2014 ${message}`
9662
- );
9663
- }
9664
- });
9665
- const next = [];
9666
- const seen = /* @__PURE__ */ new Set();
9667
- let fetched = 0;
9668
- let cached = 0;
9669
- const add = (tpl) => {
9670
- const key = `${tpl.id}@${tpl.version}`;
9671
- if (seen.has(key)) return false;
9672
- seen.add(key);
9673
- next.push(tpl);
9674
- return true;
9675
- };
9676
- for (const release of releases) {
9677
- const fresh = fetchedByAsset.get(release.assetUrl);
9678
- const templates = fresh ?? cachedByAsset.get(release.assetUrl) ?? [];
9679
- for (const tpl of sortTemplates(templates)) {
9680
- if (!add(tpl)) continue;
9681
- if (fresh) fetched += 1;
9682
- else cached += 1;
9683
- }
9684
- }
9685
- const pruning = prune && errors === 0;
9686
- if (prune && errors > 0) {
9577
+ let fresh = [];
9578
+ logger.info("Installing element templates with npm ...");
9579
+ try {
9580
+ fresh = installTemplates(spec, logger);
9581
+ } catch (error3) {
9582
+ errors = 1;
9687
9583
  logger.warn(
9688
- `Skipping prune: ${errors} bundle(s) failed to download \u2014 cached templates were kept.`
9584
+ `Could not install element templates: ${syncErrorMessage(error3, logger)}`
9689
9585
  );
9690
9586
  }
9691
- if (!pruning) {
9692
- for (const tpl of sortTemplates(staleCached)) {
9693
- add(tpl);
9587
+ if (errors > 0) {
9588
+ if (existing.length === 0) {
9589
+ throw new Error(
9590
+ "No element templates could be installed (package install failed). Check the warnings above and retry 'c8ctl element-template sync'."
9591
+ );
9694
9592
  }
9593
+ if (prune) {
9594
+ logger.warn(
9595
+ "Skipping prune: package install failed \u2014 cached templates were kept."
9596
+ );
9597
+ }
9598
+ return {
9599
+ total: existing.length,
9600
+ fetched: 0,
9601
+ cached: existing.length,
9602
+ errors,
9603
+ pruned: 0
9604
+ };
9695
9605
  }
9696
- const pruned = pruning ? staleCached.length : 0;
9606
+ const {
9607
+ templates: next,
9608
+ fetched: added,
9609
+ cached: retained,
9610
+ pruned
9611
+ } = mergeTemplates(fresh, existing, prune);
9697
9612
  if (next.length === 0) {
9698
9613
  throw new Error(
9699
- `No element templates could be downloaded (${errors} bundle(s) failed). Check the warnings above and retry 'c8ctl element-template sync'.`
9614
+ "No element templates could be installed (package was empty). Check the warnings above and retry 'c8ctl element-template sync'."
9700
9615
  );
9701
9616
  }
9702
- saveCache(next, { stampFetchedAt: errors === 0 });
9617
+ saveCache(next);
9703
9618
  const summary = {
9704
9619
  total: next.length,
9705
- fetched,
9706
- cached,
9620
+ fetched: added,
9621
+ cached: retained,
9707
9622
  errors,
9708
9623
  pruned
9709
9624
  };
@@ -9732,12 +9647,12 @@ function pickVersion(templates, { version, executionPlatformVersion } = {}) {
9732
9647
  }
9733
9648
  let candidates = templates.filter((t) => t.version !== void 0);
9734
9649
  if (executionPlatformVersion) {
9735
- const coerced = import_semver3.default.coerce(executionPlatformVersion);
9650
+ const coerced = import_semver2.default.coerce(executionPlatformVersion);
9736
9651
  if (coerced) {
9737
9652
  candidates = candidates.filter((t) => {
9738
9653
  const constraint = t.engines?.camunda;
9739
9654
  if (!constraint) return true;
9740
- return import_semver3.default.satisfies(coerced, constraint);
9655
+ return import_semver2.default.satisfies(coerced, constraint);
9741
9656
  });
9742
9657
  }
9743
9658
  }
@@ -9757,12 +9672,12 @@ function searchTemplates(query, { executionPlatformVersion } = {}) {
9757
9672
  return name2.includes(q) || description.includes(q) || id.includes(q) || keywords.includes(q);
9758
9673
  }).filter((t) => !t.deprecated);
9759
9674
  if (executionPlatformVersion) {
9760
- const coerced = import_semver3.default.coerce(executionPlatformVersion);
9675
+ const coerced = import_semver2.default.coerce(executionPlatformVersion);
9761
9676
  if (coerced) {
9762
9677
  matches = matches.filter((t) => {
9763
9678
  const constraint = t.engines?.camunda;
9764
9679
  if (!constraint) return true;
9765
- return import_semver3.default.satisfies(coerced, constraint);
9680
+ return import_semver2.default.satisfies(coerced, constraint);
9766
9681
  });
9767
9682
  }
9768
9683
  }
@@ -9879,7 +9794,7 @@ async function getExecutionPlatformVersion(xml2, { requireCamunda = false } = {}
9879
9794
  engineVersion
9880
9795
  ))
9881
9796
  return null;
9882
- return import_semver4.default.valid(
9797
+ return import_semver3.default.valid(
9883
9798
  /^\d+\.\d+$/.test(engineVersion) ? `${engineVersion}.0` : engineVersion
9884
9799
  );
9885
9800
  }
@@ -9894,7 +9809,7 @@ function isEngineCompatible(template, engineVersion) {
9894
9809
  if (!isRecord(template.engines)) return false;
9895
9810
  if (!("camunda" in template.engines)) return true;
9896
9811
  const range = template.engines.camunda;
9897
- return typeof range === "string" && range.trim() !== "" && import_semver4.default.validRange(range) !== null && import_semver4.default.satisfies(engineVersion, range);
9812
+ return typeof range === "string" && range.trim() !== "" && import_semver3.default.validRange(range) !== null && import_semver3.default.satisfies(engineVersion, range);
9898
9813
  }
9899
9814
  function isTraversable(value) {
9900
9815
  return typeof value === "object" && value !== null;
@@ -9939,7 +9854,7 @@ function localTemplateDirs(startDir) {
9939
9854
  }
9940
9855
  function isFile(path) {
9941
9856
  try {
9942
- return statSync(path).isFile();
9857
+ return statSync2(path).isFile();
9943
9858
  } catch {
9944
9859
  return false;
9945
9860
  }
@@ -9949,7 +9864,7 @@ function readLocalTemplates(dirs) {
9949
9864
  for (const dir of dirs) {
9950
9865
  let files;
9951
9866
  try {
9952
- files = readdirSync(dir, { recursive: true, withFileTypes: true }).filter((e) => e.name.toLowerCase().endsWith(".json")).map((e) => join2(e.parentPath, e.name)).filter(isFile).sort();
9867
+ files = readdirSync2(dir, { recursive: true, withFileTypes: true }).filter((e) => e.name.toLowerCase().endsWith(".json")).map((e) => join2(e.parentPath, e.name)).filter(isFile).sort();
9953
9868
  } catch {
9954
9869
  continue;
9955
9870
  }
@@ -13615,18 +13530,18 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13615
13530
  const selected2 = selectElements(modeler, templateId, elementId);
13616
13531
  const valuesOf2 = (element) => enumerateElementValues(getExtensionElements(element.businessObject));
13617
13532
  redaction.values = selected2.flatMap(({ element }) => valuesOf2(element));
13618
- const pool2 = templatePool(
13533
+ const pool = templatePool(
13619
13534
  bpmnFilePath ? dirname6(resolvePath4(bpmnFilePath)) : process.cwd()
13620
13535
  );
13621
- const localVersions = pool2.localOf(templateId).map((t) => t.version ?? 0);
13536
+ const localVersions = pool.localOf(templateId).map((t) => t.version ?? 0);
13622
13537
  if (selected2.some(
13623
13538
  ({ element }) => !localVersions.includes(
13624
13539
  readAppliedTemplate(element.businessObject)?.version ?? 0
13625
13540
  )
13626
13541
  )) {
13627
- pool2.cache();
13542
+ pool.cache();
13628
13543
  }
13629
- const lineages = (ids) => migrationTemplates(pool2.pool(ids)).filter((t) => ids.includes(t.id));
13544
+ const lineages = (ids) => migrationTemplates(pool.pool(ids)).filter((t) => ids.includes(t.id));
13630
13545
  redaction.templates = lineages([templateId]);
13631
13546
  const toRef = parseTemplateRef(parsed.to);
13632
13547
  if (toRef?.kind === "id") {
@@ -13642,7 +13557,7 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13642
13557
  templateId,
13643
13558
  to: parsed.to,
13644
13559
  executionPlatformVersion: engineVersion,
13645
- templatePool: pool2
13560
+ templatePool: pool
13646
13561
  });
13647
13562
  redaction.templates = [...lineages([templateId, target.id]), target];
13648
13563
  const targetRecipe = recipe ?? embeddedRecipe(target);
@@ -13654,12 +13569,12 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13654
13569
  );
13655
13570
  const hasFallback = changes.length > floors.length;
13656
13571
  const localCompatibleVersions = compatibleTemplates(
13657
- pool2.localOf(templateId),
13572
+ pool.localOf(templateId),
13658
13573
  engineVersion
13659
13574
  ).flatMap((t) => t.id === templateId ? [t.version ?? 0] : []);
13660
13575
  const newestLocal = Math.max(-1, ...localCompatibleVersions);
13661
13576
  const localLatest = latestOf(
13662
- compatibleTemplates(pool2.localOf(templateId), engineVersion),
13577
+ compatibleTemplates(pool.localOf(templateId), engineVersion),
13663
13578
  templateId
13664
13579
  );
13665
13580
  let localRecipe;
@@ -13679,10 +13594,10 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13679
13594
  );
13680
13595
  return !hasFallback && floors.some((floor) => floor > newestLocal && floor > reached);
13681
13596
  })) {
13682
- pool2.cache();
13597
+ pool.cache();
13683
13598
  }
13684
13599
  const sourceLatest = target.id === templateId ? void 0 : latestOf(
13685
- compatibleTemplates(pool2.pool([templateId]), engineVersion).filter(
13600
+ compatibleTemplates(pool.pool([templateId]), engineVersion).filter(
13686
13601
  (t) => t.id === templateId
13687
13602
  ),
13688
13603
  templateId
@@ -13703,10 +13618,10 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13703
13618
  if (stepVersions.some(
13704
13619
  (v) => v > lowestApplied && !localVersions.includes(v) && !(target.id === templateId && (target.version ?? 0) === v)
13705
13620
  )) {
13706
- pool2.cache();
13621
+ pool.cache();
13707
13622
  }
13708
13623
  const cache = compatibleTemplates(
13709
- pool2.pool([templateId, target.id]),
13624
+ pool.pool([templateId, target.id]),
13710
13625
  engineVersion
13711
13626
  );
13712
13627
  const templates = resolveCatalog(
@@ -24,61 +24,30 @@ shipped layout but during development we run directly from
24
24
 
25
25
  ## OOTB template integration
26
26
 
27
- Four sources publish the OOTB connector templates:
28
-
29
- | | Source-of-truth | Inlines templates? | Has all versions? | Used by |
30
- |---|---|---|---|---|
31
- | `github.com/camunda/connectors` releases (bundle asset) | yes | yes (~1 MB gzip per line) | per minor line | c8ctl |
32
- | `marketplace.cloud.camunda.io/api/v1/ootb-connectors` | mirrors GH | no, URL refs | yes | Desktop Modeler |
33
- | `github.com/camunda/connectors/connector-templates.json` | yes | no, URL refs | yes | (the marketplace) |
34
- | `@camunda/connectors-element-templates` (npm) | derived | yes (~9MB) | yes, may lag | (Web Modeler skill) |
35
-
36
- We use the **release bundle assets** — every connectors release ships a
37
- `connectors-bundle-templates-<tag>.tar.gz` with one JSON file per
38
- template:
39
-
40
- - The marketplace endpoint (Desktop Modeler's source, and c8ctl's
41
- original choice) only publishes *refs* into
42
- `raw.githubusercontent.com`, a host routinely blocked in enterprise
43
- networks — the reason for the switch, see c8ctl#530. Release
44
- downloads are served from `github.com`, which those environments
45
- generally do reach.
46
- - One request per minor line replaces ~650 per-template requests, so a
47
- cold sync is a few MB and a few seconds instead of ~14 MB and ~30 s.
48
- - npm package was rejected: confirmed lag against the GH source and
49
- some entries are missing `version`/`engines` (pre-versioned legacy
50
- templates).
51
-
52
- ### Which releases
53
-
54
- `sync` lists the releases (`api.github.com/repos/camunda/connectors/
55
- releases?per_page=100`, overridable via
56
- `C8CTL_CONNECTORS_RELEASES_URL`) and keeps **the newest release of each
57
- minor line** — 8.8.x, 8.9.x, 8.10.x, ...:
58
-
59
- - Bundles are cumulative within a line, so the newest patch of 8.8
60
- already contains everything 8.8.17 shipped. Across lines they differ,
61
- which is why one release per line is kept rather than just the newest
62
- release overall.
63
- - Alphas count (`8.10.0-alpha3` is the only source for a line that has
64
- no stable release yet); release candidates do not — they are
65
- superseded within days. Note that semver ranks `8.10.0-alpha5-rc3`
66
- *above* `8.10.0-alpha5`, so RCs are filtered explicitly rather than
67
- by ordering.
68
- - Draft releases and releases without a bundle asset (a release that is
69
- still being built) are skipped, so an in-flight release falls back to
70
- the previous one on that line.
71
- - Only the **4 newest minor lines** are kept (`MAX_MINOR_LINES` in
72
- `releases.ts`), roughly Camunda's supported-version window. This keeps
73
- the selection deterministic: the newest release of each selected line
74
- is always within the first page of the listing, whereas an EOL line's
75
- newest release drifts down the listing until it falls off the page and
76
- would silently vanish from the selection.
77
-
78
- Bundles contain a superset of the marketplace index: the `-hybrid`
79
- variants and a few templates the marketplace does not list are cached
80
- too, and templates without a numeric `version` (pre-versioned legacy
81
- entries that version resolution cannot rank) are skipped.
27
+ `sync` reads `@camunda/connectors-element-templates` from npm. npm honours
28
+ the user's registry, scoped registry, proxy, CA and authentication settings.
29
+ The package is published from `camunda/connectors` and includes connector
30
+ templates and their metadata in one archive.
31
+
32
+ The installed package contains arrays of versions in
33
+ `src/element-templates/*.json`. Entries without a numeric `version`
34
+ are legacy duplicates that version resolution cannot rank and are skipped;
35
+ entries without `engines` remain eligible for version selection. Hybrid
36
+ templates are not in the package.
37
+
38
+ Each sync uses `npm install` in a temporary staging directory under the cache
39
+ lock. npm resolves and extracts a single package from
40
+ `C8CTL_ELEMENT_TEMPLATES_PACKAGE` (a package spec, tarball URL or local path)
41
+ or the default package. The package is the one directory in the staging
42
+ `node_modules` that has `src/element-templates`, so discovery does not depend
43
+ on npm's save settings; its name and version come from its installed package
44
+ manifest. npm handles package archive formats and local symlinks; the staging
45
+ directory is removed after reading its templates.
46
+
47
+ Sync ingests one template package: a package that depends on another template
48
+ package fails with an error naming both. Supporting several could ingest every
49
+ template-bearing package in the install tree, with a dependent winning over its
50
+ dependencies and a warning on conflicting `id@version` entries.
82
51
 
83
52
  ## Cache strategy
84
53
 
@@ -90,15 +59,13 @@ We mirror Desktop Modeler's approach
90
59
  Modeler's `.camunda-connector-templates.json` shape).
91
60
  - `fetched-at` — epoch ms of last sync.
92
61
  - Each cached template gets
93
- `metadata.upstreamRef = <assetUrl>#<file-in-bundle>` injected. Release
94
- assets are tag-pinned and therefore immutable, so "asset URL already
95
- in the cache" ⇒ "bundle already ingested" ⇒ no re-download.
96
- - `id@version` is deduplicated across bundles, newest release wins.
97
- - Per-release fetch failures are logged + counted, and never abort the
98
- run — unless *every* bundle failed and nothing was reusable from the
99
- cache, in which case `sync` errors out rather than writing an empty
100
- cache. A partial sync also leaves `fetched-at` untouched, so the
101
- staleness nudge keeps asking for a full refresh.
62
+ `metadata.upstreamRef = npm:<package>@<version>#src/element-templates/<file>` injected.
63
+ The single current package replaces matching `id@version` entries, while
64
+ older entries remain until explicitly pruned. It does not combine multiple
65
+ configured packages.
66
+ - An install failure or malformed template file retains the old cache and
67
+ timestamp, and disables pruning.
68
+ A cold sync fails instead of writing an empty cache.
102
69
 
103
70
  ### Lifecycle
104
71
 
@@ -118,18 +85,14 @@ We mirror Desktop Modeler's approach
118
85
  `c8ctl element-template sync`. We don't auto-refresh — surprise
119
86
  network activity inside `apply` is undesirable and a manual sync is
120
87
  cheap.
121
- - **`sync`** always re-fetches the release listing but only downloads
122
- bundles that aren't cached yet. **`sync --prune`** drops cached
123
- entries that no longer belong to a selected release (opt-in: a user
124
- may keep a legacy line intentionally). Pruning is skipped when any
125
- bundle failed to download: a bundle URL changes with every patch, so
126
- the previous patch's cached templates are always "stale", and dropping
127
- them while their replacement failed would delete a whole minor line
128
- over one transient HTTP error.
88
+ - **`sync`** stages a fresh npm install. **`sync --prune`** drops cached
89
+ entries absent from the current package; a failed install never prunes the
90
+ previous cache.
129
91
  - **Atomicity**: `sync` writes `templates.json` and `fetched-at`
130
92
  via a sibling temp file + `renameSync`, so a kill mid-sync leaves
131
93
  the previous cache intact. `apply --in-place` uses the same recipe
132
- for the user's BPMN file.
94
+ for the user's BPMN file. The temporary installation is created under
95
+ the cache lock and removed after its files have been read.
133
96
  - **Concurrent syncs** are serialised by an advisory lock
134
97
  (`<cacheDir>/.sync.lock`) holding `{pid, startedAt}`. A second
135
98
  `sync` exits non-zero with a pointer to the lockfile; stale locks
@@ -142,8 +105,8 @@ We mirror Desktop Modeler's approach
142
105
 
143
106
  Earlier draft considered fetching only the requested `(id, version)`
144
107
  on demand. Rejected because **search needs the template names**, which
145
- means every template has to be read anyway. Bundles make this moot: the
146
- whole line arrives in one request, so eager bulk fetch is both simpler
108
+ means every template has to be read anyway. Installing the package makes this
109
+ moot: the whole package arrives together, so eager bulk fetch is both simpler
147
110
  and faster than any lazy scheme.
148
111
 
149
112
  ## Version resolution
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda8/cli",
3
- "version": "4.6.0",
3
+ "version": "4.6.1-alpha.1",
4
4
  "description": "Camunda 8 CLI - minimal-dependency CLI for Camunda 8 operations",
5
5
  "type": "module",
6
6
  "engines": {