@us_momo/dsh-erp-analysis 1.6.1 → 1.7.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/release.mjs CHANGED
@@ -170,7 +170,7 @@ export async function liveLeases(root) {
170
170
  }
171
171
  return live;
172
172
  }
173
- async function installReleaseUnlocked(root, manifest, { defer = true } = {}) {
173
+ async function stageReleaseUnlocked(root, manifest) {
174
174
  const files = validateRelease(manifest);
175
175
  await mkdir(join(root, "versions"), { recursive: true });
176
176
  const target = join(root, "versions", manifest.version);
@@ -206,8 +206,12 @@ async function installReleaseUnlocked(root, manifest, { defer = true } = {}) {
206
206
  }
207
207
  }
208
208
  const marker = { version: manifest.version, fingerprint };
209
+ return { ...marker, path: target };
210
+ }
211
+ async function installReleaseUnlocked(root, manifest, { defer = true } = {}) {
212
+ const { path: target, ...marker } = await stageReleaseUnlocked(root, manifest);
209
213
  const current = await readJson(join(root, "current.json"), null);
210
- if (current?.version === marker.version && current.fingerprint === fingerprint)
214
+ if (current?.version === marker.version && current.fingerprint === marker.fingerprint)
211
215
  return { ...marker, status: "installed" };
212
216
  if (defer && (await liveLeases(root)).length) {
213
217
  await atomicJson(join(root, "pending.json"), marker);
@@ -382,6 +386,10 @@ export async function withActivationLock(root, operation) {
382
386
  await rmdir(lock);
383
387
  }
384
388
  }
389
+ /** Native presets load immutable version resources without replacing a shared workspace. */
390
+ export async function stageRelease(root, manifest) {
391
+ return withActivationLock(root, () => stageReleaseUnlocked(root, manifest));
392
+ }
385
393
  export async function installRelease(root, manifest, options) {
386
394
  return withActivationLock(root, () =>
387
395
  installReleaseUnlocked(root, manifest, options),
@@ -392,21 +400,23 @@ export async function activatePending(root) {
392
400
  }
393
401
  export async function beginBridge(root, { version } = {}) {
394
402
  return withActivationLock(root, async () => {
395
- await activatePendingUnlocked(root);
396
- let release = await currentRelease(root);
403
+ let release;
397
404
  if (version !== undefined) {
398
405
  if (!/^\d+\.\d+\.\d+(?:-[a-z0-9.-]+)?$/.test(version))
399
406
  throw new Error("公司方法版本无效。");
400
407
  const path = join(root, "versions", version);
401
408
  const receipt = await readJson(join(path, "release-receipt.json"));
402
409
  release = { ...receipt, version, path };
410
+ } else {
411
+ await activatePendingUnlocked(root);
412
+ release = await currentRelease(root);
403
413
  }
404
414
  const lease = join(root, "leases", randomUUID() + ".json");
405
415
  await atomicJson(lease, { pid: process.pid, version: release.version });
406
- return { release, lease };
416
+ return { release, lease, pinned: version !== undefined };
407
417
  });
408
418
  }
409
419
  export async function endBridge(root, snapshot) {
410
420
  await rm(snapshot.lease, { force: true });
411
- await activatePending(root);
421
+ if (!snapshot.pinned) await activatePending(root);
412
422
  }