@lmzhen/dsh-evolution-commands 0.3.30 → 0.3.31
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/lib/index.js +12 -4
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -382,34 +382,42 @@ function atomicWriteFiles(targetDir, writes, fs = defaultFs) {
|
|
|
382
382
|
const bakPath = join(targetDir, `${name}.bak`);
|
|
383
383
|
if (fs.existsSync(finalPath) && !fs.existsSync(bakPath)) fs.copyFileSync(finalPath, bakPath);
|
|
384
384
|
}
|
|
385
|
+
const committed = [];
|
|
385
386
|
for (const { name } of writes) {
|
|
386
387
|
const finalPath = join(targetDir, name);
|
|
387
388
|
const bakPath = join(targetDir, `${name}.bak`);
|
|
388
389
|
const tmp = stage(name);
|
|
389
390
|
try {
|
|
390
391
|
fs.renameSync(tmp, finalPath);
|
|
392
|
+
committed.push(name);
|
|
391
393
|
} catch {
|
|
392
394
|
fs.rmSync(finalPath, { force: true });
|
|
393
395
|
try {
|
|
394
396
|
fs.renameSync(tmp, finalPath);
|
|
397
|
+
committed.push(name);
|
|
395
398
|
} catch (renameError) {
|
|
399
|
+
const already = committed.length > 0 ? `; already committed: ${committed.join(", ")}` : "";
|
|
396
400
|
if (fs.existsSync(bakPath)) {
|
|
397
401
|
try {
|
|
398
402
|
fs.copyFileSync(bakPath, finalPath);
|
|
399
403
|
} catch {
|
|
400
|
-
throw new Error(`atomicWriteFiles: "${name}" was removed but recovery from ${bakPath} failed (${renameError instanceof Error ? renameError.message : String(renameError)}); verify the file manually`);
|
|
404
|
+
throw new Error(`atomicWriteFiles: "${name}" was removed but recovery from ${bakPath} failed (${renameError instanceof Error ? renameError.message : String(renameError)}); verify the file manually${already}`);
|
|
401
405
|
}
|
|
402
406
|
const bakMtime = fs.mtime?.(bakPath);
|
|
403
407
|
const when = bakMtime !== null && bakMtime !== void 0 && Number.isFinite(bakMtime) ? ` (bak mtime ${new Date(bakMtime).toISOString()})` : "";
|
|
404
|
-
throw new Error(`atomicWriteFiles: "${name}" was removed during commit and restored from the last good generation ${bakPath}${when}; original error: ${renameError instanceof Error ? renameError.message : String(renameError)}`);
|
|
408
|
+
throw new Error(`atomicWriteFiles: "${name}" was removed during commit and restored from the last good generation ${bakPath}${when}; original error: ${renameError instanceof Error ? renameError.message : String(renameError)}${already}`);
|
|
405
409
|
}
|
|
406
|
-
throw renameError;
|
|
410
|
+
throw new Error(`${renameError instanceof Error ? renameError.message : String(renameError)}${already}`);
|
|
407
411
|
}
|
|
408
412
|
}
|
|
409
413
|
}
|
|
410
414
|
for (const { name } of writes) {
|
|
411
415
|
const finalPath = join(targetDir, name);
|
|
412
|
-
|
|
416
|
+
try {
|
|
417
|
+
if (fs.existsSync(finalPath)) fs.copyFileSync(finalPath, join(targetDir, `${name}.bak`));
|
|
418
|
+
} catch (refreshError) {
|
|
419
|
+
console.warn(`atomicWriteFiles: committed "${name}" but failed to refresh its .bak (${refreshError instanceof Error ? refreshError.message : String(refreshError)}); a later failed commit will recover to an OLDER generation`);
|
|
420
|
+
}
|
|
413
421
|
}
|
|
414
422
|
} catch (error) {
|
|
415
423
|
for (const { name } of writes) fs.rmSync(stage(name), {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-commands",
|
|
3
3
|
"description": "Human commands for the evolution family (community build)",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.31",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
],
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lmzhen/dsh-evolution-approval": "^0.3.
|
|
34
|
-
"@lmzhen/dsh-evolution-core": "^0.3.
|
|
35
|
-
"@lmzhen/dsh-evolution-maintenance": "^0.3.
|
|
33
|
+
"@lmzhen/dsh-evolution-approval": "^0.3.31",
|
|
34
|
+
"@lmzhen/dsh-evolution-core": "^0.3.31",
|
|
35
|
+
"@lmzhen/dsh-evolution-maintenance": "^0.3.31"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@deepseek-ai/cordis": "^4.0.1",
|