@camunda8/cli 4.6.0-alpha.4 → 4.6.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,6 +49,9 @@ version resolution.
49
49
  use a sibling temp file + `renameSync`. Anything else that
50
50
  overwrites a user-owned file (cache or BPMN) must follow the same
51
51
  pattern — a kill mid-write must not leave a truncated file.
52
+ `atomicOverwriteFile` resolves the target with `realpathSync` first,
53
+ so a symlinked BPMN keeps its link; locks on a BPMN path must use the
54
+ resolved path too.
52
55
  - **`syncTemplates` is serialised by an advisory lockfile.** The
53
56
  helper `withSyncLock` in `cache.ts` holds
54
57
  `<cacheDir>/.sync.lock` while the body runs, with stale-lock
@@ -179,10 +179,14 @@ c8ctl element-template update old.id process.bpmn --dry-run --json
179
179
  `apply --in-place` and `edit --in-place` do not take the lock, but refuse to
180
180
  replace a file whose contents changed since they read it, so they never
181
181
  overwrite a migration that committed in between.
182
+ In-place writes follow symlinks: the link stays and its target receives the new
183
+ XML. The lock and temporary file sit beside the real file, so links to one file
184
+ share a lock. Relative local template lookup starts at the directory of the
185
+ path you pass, not of the link's target. Hard links are not preserved; the file gets a new inode.
182
186
  A killed writer can leave a stale lock and temporary file; confirm no writer is
183
187
  active before inspecting and removing them. Recovery is manual. External edits
184
- between the final comparison and rename and symlink aliases are not covered by
185
- the cooperative lock; this design has no atomic compare-and-swap. Tests cover
188
+ between the final comparison and rename are not covered by the cooperative
189
+ lock; this design has no atomic compare-and-swap. Tests cover
186
190
  injected ENOSPC/EIO before and after actual partial bytes and real SIGINT/SIGTERM
187
191
  termination during paused split writes, preserving original bytes. Physical
188
192
  disk exhaustion and interruption of an executing kernel syscall are not proven.
@@ -8345,6 +8345,7 @@ var import_semver = __toESM(require_semver2(), 1);
8345
8345
  import {
8346
8346
  existsSync,
8347
8347
  readFileSync,
8348
+ realpathSync,
8348
8349
  renameSync,
8349
8350
  unlinkSync,
8350
8351
  writeFileSync
@@ -8877,7 +8878,7 @@ function isRecord(value) {
8877
8878
  }
8878
8879
  var CONCURRENT_EDIT_MESSAGE = "BPMN changed while this command ran; refusing to overwrite concurrent edits.";
8879
8880
  function atomicOverwriteFile(targetPath, contents, expectedContents, directWriteFallback = false) {
8880
- const target = resolvePath(targetPath);
8881
+ const target = realpathSync(targetPath);
8881
8882
  const tmp = `${target}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
8882
8883
  try {
8883
8884
  writeFileSync(tmp, contents, "utf-8");
@@ -8898,6 +8899,9 @@ function atomicOverwriteFile(targetPath, contents, expectedContents, directWrite
8898
8899
  throw error3;
8899
8900
  }
8900
8901
  }
8902
+ function pinFilePath(path) {
8903
+ return existsSync(path) ? realpathSync(path) : path;
8904
+ }
8901
8905
  var ENGINE_VERSION_PATTERN = /^\d+\.\d+(?:\.\d+)?(?:-[0-9A-Za-z.-]+)?$/;
8902
8906
  function isUrl(input) {
8903
8907
  return input.startsWith("https://") || input.startsWith("http://");
@@ -10238,6 +10242,7 @@ async function applySubcommand(args) {
10238
10242
  if (parsed.inPlace && !bpmnFilePath) {
10239
10243
  throw new Error("--in-place cannot be used with stdin input");
10240
10244
  }
10245
+ const writePath = parsed.inPlace && bpmnFilePath ? pinFilePath(bpmnFilePath) : void 0;
10241
10246
  const input = await readBpmnInput(bpmnFilePath);
10242
10247
  if (!input) {
10243
10248
  throw new Error(
@@ -10322,8 +10327,8 @@ async function applySubcommand(args) {
10322
10327
  if (setProperties.length > 0) {
10323
10328
  warnUnmetConditions(logger, resultXml, setProperties);
10324
10329
  }
10325
- if (parsed.inPlace && bpmnFilePath) {
10326
- atomicOverwriteFile(bpmnFilePath, resultXml, input.xml, true);
10330
+ if (writePath) {
10331
+ atomicOverwriteFile(writePath, resultXml, input.xml, true);
10327
10332
  logger.info(`Updated ${bpmnFilePath}`);
10328
10333
  return;
10329
10334
  }
@@ -10488,6 +10493,7 @@ async function editSubcommand(args) {
10488
10493
  if (parsed.inPlace && !bpmnFilePath) {
10489
10494
  throw new Error("--in-place cannot be used with stdin input");
10490
10495
  }
10496
+ const writePath = parsed.inPlace && bpmnFilePath ? pinFilePath(bpmnFilePath) : void 0;
10491
10497
  const input = await readBpmnInput(bpmnFilePath);
10492
10498
  if (!input) {
10493
10499
  throw new Error(
@@ -10555,8 +10561,8 @@ async function editSubcommand(args) {
10555
10561
  }
10556
10562
  const result = await modeler.saveXML({ format: true });
10557
10563
  const resultXml = result.xml;
10558
- if (parsed.inPlace && bpmnFilePath) {
10559
- atomicOverwriteFile(bpmnFilePath, resultXml, input.xml, true);
10564
+ if (writePath) {
10565
+ atomicOverwriteFile(writePath, resultXml, input.xml, true);
10560
10566
  logger.info(`Updated ${bpmnFilePath}`);
10561
10567
  return;
10562
10568
  }
@@ -11227,6 +11233,7 @@ import {
11227
11233
  existsSync as existsSync5,
11228
11234
  openSync as openSync2,
11229
11235
  readFileSync as readFileSync5,
11236
+ realpathSync as realpathSync2,
11230
11237
  unlinkSync as unlinkSync3
11231
11238
  } from "node:fs";
11232
11239
  import { createRequire as createRequire4 } from "node:module";
@@ -13423,7 +13430,7 @@ function describeDropped(report) {
13423
13430
  const unchecked = report.skipped.unchecked.map((u) => u.key);
13424
13431
  return names.length > 0 ? `${names.length} dropped (${names.join(", ")})` : unchecked.length > 0 ? `${unchecked.length} unchecked (${unchecked.join(", ")})` : report.refusal ? `recipe not used: ${report.refusal}` : "values not migrated";
13425
13432
  }
13426
- async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath }, redaction) {
13433
+ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath }, redaction, lockedPath) {
13427
13434
  const logger = c8ctl10.getLogger();
13428
13435
  installStdoutEpipeHandler();
13429
13436
  const dryRun = c8ctl10.dryRun === true;
@@ -13438,7 +13445,8 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13438
13445
  );
13439
13446
  }
13440
13447
  const maps = parsed.maps.map(parseMapArg);
13441
- const input = await readBpmnInput(bpmnFilePath);
13448
+ const bpmnPath = lockedPath ?? bpmnFilePath;
13449
+ const input = await readBpmnInput(bpmnPath);
13442
13450
  if (!input) {
13443
13451
  throw new Error(
13444
13452
  "No BPMN input provided. Pass a file path or pipe BPMN XML via stdin."
@@ -13458,7 +13466,7 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13458
13466
  const valuesOf2 = (element) => enumerateElementValues(getExtensionElements(element.businessObject));
13459
13467
  redaction.values = selected2.flatMap(({ element }) => valuesOf2(element));
13460
13468
  const pool2 = templatePool(
13461
- bpmnFilePath ? dirname6(input.source) : process.cwd()
13469
+ bpmnFilePath ? dirname6(resolvePath4(bpmnFilePath)) : process.cwd()
13462
13470
  );
13463
13471
  const localVersions = pool2.localOf(templateId).map((t) => t.version ?? 0);
13464
13472
  if (selected2.some(
@@ -13671,10 +13679,10 @@ async function runMigrateInternal({ parsed, templateId, elementId, bpmnFilePath
13671
13679
  }
13672
13680
  const canWrite = !dryRun && failed.length === 0 && !wouldBlock;
13673
13681
  const saved = canWrite && updated.length > 0 ? await modeler.saveXML({ format: true }) : void 0;
13674
- if (saved && parsed.inPlace && bpmnFilePath) {
13675
- if (readFileSync5(bpmnFilePath, "utf-8") !== input.xml)
13682
+ if (saved && parsed.inPlace && bpmnPath) {
13683
+ if (readFileSync5(bpmnPath, "utf-8") !== input.xml)
13676
13684
  throw new Error(CONCURRENT_EDIT_MESSAGE);
13677
- atomicOverwriteFile(bpmnFilePath, saved.xml, input.xml);
13685
+ atomicOverwriteFile(bpmnPath, saved.xml, input.xml);
13678
13686
  }
13679
13687
  const summary = {
13680
13688
  updated: updated.length,
@@ -13848,7 +13856,8 @@ async function runLockedMigrate(args, redaction) {
13848
13856
  return runMigrateInternal(resolved, redaction);
13849
13857
  if (!existsSync5(resolvePath4(file)))
13850
13858
  throw new Error(`File not found: ${file}`);
13851
- const lock = `${resolvePath4(file)}.migration.lock`;
13859
+ const lockedPath = realpathSync2(file);
13860
+ const lock = `${lockedPath}.migration.lock`;
13852
13861
  let descriptor;
13853
13862
  try {
13854
13863
  descriptor = openSync2(lock, "wx");
@@ -13860,7 +13869,7 @@ async function runLockedMigrate(args, redaction) {
13860
13869
  }
13861
13870
  let cleanupFailure;
13862
13871
  try {
13863
- await runMigrateInternal(resolved, redaction);
13872
+ await runMigrateInternal(resolved, redaction, lockedPath);
13864
13873
  } finally {
13865
13874
  try {
13866
13875
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda8/cli",
3
- "version": "4.6.0-alpha.4",
3
+ "version": "4.6.0-alpha.5",
4
4
  "description": "Camunda 8 CLI - minimal-dependency CLI for Camunda 8 operations",
5
5
  "type": "module",
6
6
  "engines": {