fix(runtime): synchronize lockfile after builtin plugin migration
This commit is contained in:
@@ -16,6 +16,16 @@ export const BUILTIN_OVERRIDES = Object.freeze({
|
||||
'@deepseek-ai/schemastery>@standard-schema/spec': 'file:/usr/local/lib/dsh-mgr/spec-1.1.0.tgz',
|
||||
});
|
||||
const sections = ['dependencies', 'devDependencies', 'optionalDependencies'];
|
||||
export const LOCKFILE_PENDING = '.dsh-lockfile-pending';
|
||||
|
||||
export function markLockfilePending(profile) {
|
||||
assertSafeProfile(profile);
|
||||
const fd = openSync(join(profile, LOCKFILE_PENDING), 'w', 0o600);
|
||||
try { writeFileSync(fd, 'builtin profile migration\n'); fsyncSync(fd); }
|
||||
finally { closeSync(fd); }
|
||||
const directoryFd = openSync(profile, 'r');
|
||||
try { fsyncSync(directoryFd); } finally { closeSync(directoryFd); }
|
||||
}
|
||||
const overrideOwners = ['dsh-chat-manager', 'dsh-free-search', 'dsh-free-search', 'dsh-free-search'];
|
||||
const semver = '(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?';
|
||||
|
||||
@@ -72,7 +82,7 @@ export function assertSafeProfile(profile) {
|
||||
if (stat && (!stat.isDirectory() || stat.isSymbolicLink())) throw new Error(`unsafe profile directory: ${dir}`);
|
||||
if (dirname(dir) === dir) break;
|
||||
}
|
||||
for (const name of ['package.json', 'pnpm-workspace.yaml']) {
|
||||
for (const name of ['package.json', 'pnpm-workspace.yaml', 'pnpm-lock.yaml', LOCKFILE_PENDING]) {
|
||||
const path = join(profile, name);
|
||||
const stat = statIfPresent(path);
|
||||
if (stat && (!stat.isFile() || stat.isSymbolicLink())) throw new Error(`unsafe profile file: ${path}`);
|
||||
@@ -111,6 +121,8 @@ export function reconcileProfile(profile, { archiveDirectory = '/usr/local/lib/d
|
||||
fsyncSync(fd);
|
||||
} finally { closeSync(fd); }
|
||||
assertSafeProfile(profile);
|
||||
// Persist before changing the manifest, including across failed installs/restarts.
|
||||
markLockfilePending(profile);
|
||||
renameSync(temporaryPath, path);
|
||||
temporaryCreated = false;
|
||||
syncDirectory();
|
||||
|
||||
Reference in New Issue
Block a user