shennian 0.2.77 → 0.2.78
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/dist/src/upgrade/engine.js +20 -1
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ const BACKUP_DIR = resolveShennianPath('backup');
|
|
|
10
10
|
const UPGRADE_ATTEMPT_FILE = resolveShennianPath('upgrade-attempt.json');
|
|
11
11
|
const MAX_CRASH_COUNT = 3;
|
|
12
12
|
const BACKUP_TTL_DAYS = 7;
|
|
13
|
+
const NPM_REGISTRY_FALLBACK = 'https://registry.npmjs.org';
|
|
13
14
|
const RETRY_DELAYS_MS = [
|
|
14
15
|
5 * 60_000,
|
|
15
16
|
30 * 60_000,
|
|
@@ -272,7 +273,7 @@ export async function performUpgrade(targetVersion, onProgress, opts = {}) {
|
|
|
272
273
|
// Step 3: npm install new version
|
|
273
274
|
onProgress({ step: 'installing', version: targetVersion });
|
|
274
275
|
try {
|
|
275
|
-
await
|
|
276
|
+
await installShennianVersion(targetVersion);
|
|
276
277
|
}
|
|
277
278
|
catch (err) {
|
|
278
279
|
// Restore backup and abort
|
|
@@ -318,6 +319,24 @@ export async function performUpgrade(targetVersion, onProgress, opts = {}) {
|
|
|
318
319
|
onProgress({ step: 'restarting', from: currentVersion, to: targetVersion });
|
|
319
320
|
return { ok: true, from: currentVersion, to: targetVersion };
|
|
320
321
|
}
|
|
322
|
+
async function installShennianVersion(targetVersion) {
|
|
323
|
+
try {
|
|
324
|
+
await exec(`npm install -g shennian@${targetVersion}`, { timeout: 120_000, windowsHide: true });
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
const firstMessage = error instanceof Error ? error.message : String(error);
|
|
328
|
+
try {
|
|
329
|
+
await exec(`npm install -g shennian@${targetVersion} --registry ${NPM_REGISTRY_FALLBACK}`, {
|
|
330
|
+
timeout: 120_000,
|
|
331
|
+
windowsHide: true,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
catch (fallbackError) {
|
|
335
|
+
const secondMessage = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
336
|
+
throw new Error(`${firstMessage}\n--- npmjs fallback ---\n${secondMessage}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
321
340
|
export async function checkForUpdate(currentVersion) {
|
|
322
341
|
const current = currentVersion ?? getCurrentVersion();
|
|
323
342
|
const latest = await fetchLatestVersion();
|