querysub 0.708.0 → 0.710.0
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/package.json
CHANGED
|
@@ -13,7 +13,7 @@ import { getArchives2 } from "../../-a-archives/archives2";
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
// Snapshot is just a newline delimitted list of files. The name contains the metadata and time of it.
|
|
16
|
-
const snapshots = lazy(() => getArchives2("snapshots"));
|
|
16
|
+
export const snapshots = lazy(() => getArchives2("snapshots"));
|
|
17
17
|
|
|
18
18
|
export type ArchiveSnapshotOverview = {
|
|
19
19
|
// If live, it isn't a real file that can be loaded
|
|
@@ -29,7 +29,7 @@ const thinningRanges: {
|
|
|
29
29
|
];
|
|
30
30
|
|
|
31
31
|
// Unreferenced recycle bin files younger than this are kept. Deleting an unreferenced recycle file too eagerly would destroy the backup of anything recycled since the last kept snapshot, so orphans only die once they have sat unreferenced long enough that nothing could still want them back.
|
|
32
|
-
const RECYCLE_ORPHAN_MIN_AGE =
|
|
32
|
+
const RECYCLE_ORPHAN_MIN_AGE = timeInWeek;
|
|
33
33
|
|
|
34
34
|
const INDEX_KEY = "index";
|
|
35
35
|
const PARALLEL_DELETE_COUNT = 32;
|
|
@@ -247,6 +247,23 @@ function checkGitSyncedAndClean(gitFolder: string, gitRef: string): Promise<bool
|
|
|
247
247
|
return cached;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
async function getQuerysubVersionMismatch(gitFolder: string): Promise<string> {
|
|
251
|
+
let packageJson = JSON.parse(await fs.promises.readFile(gitFolder + "package.json", "utf8")) as { dependencies?: { [name: string]: string } };
|
|
252
|
+
let requested = packageJson.dependencies?.querysub;
|
|
253
|
+
if (!requested || !/^[\^~]?\d+\.\d+\.\d+$/.test(requested)) return "";
|
|
254
|
+
let installedPath = gitFolder + "node_modules/querysub/package.json";
|
|
255
|
+
if (!await fsExistsAsync(installedPath)) return `requested ${requested}, not installed`;
|
|
256
|
+
let installed = (JSON.parse(await fs.promises.readFile(installedPath, "utf8")) as { version: string }).version;
|
|
257
|
+
let installedParts = installed.split(".").map(Number);
|
|
258
|
+
let requestedParts = requested.replace(/^[\^~]/, "").split(".").map(Number);
|
|
259
|
+
for (let i = 0; i < requestedParts.length; i++) {
|
|
260
|
+
if (installedParts[i] === requestedParts[i]) continue;
|
|
261
|
+
if (installedParts[i] > requestedParts[i]) return "";
|
|
262
|
+
return `requested ${requested}, installed ${installed}`;
|
|
263
|
+
}
|
|
264
|
+
return "";
|
|
265
|
+
}
|
|
266
|
+
|
|
250
267
|
const ensureGitSynced = measureWrap(async function ensureGitSynced(config: {
|
|
251
268
|
// Forces the checkout at gitFolder to gitRef. Escalates through increasingly destructive recoveries, but only ever destroys the working tree as an absolute last resort — a network blip must never wipe node_modules out from under a running service.
|
|
252
269
|
gitFolder: string;
|
|
@@ -484,10 +501,10 @@ async function ensureScreen(config: {
|
|
|
484
501
|
} catch { }
|
|
485
502
|
await ensureGitSynced({ gitFolder, repoUrl: parameters.repoUrl, gitRef: parameters.gitRef });
|
|
486
503
|
let afterGitRef = await getGitRefLive(gitFolder);
|
|
487
|
-
// Reinstall when the ref changed OR node_modules is missing. A recovery re-clone can land on the same commit, so a ref-only check would leave the service with no node_modules.
|
|
488
504
|
let nodeModulesMissing = !await fsExistsAsync(gitFolder + "node_modules");
|
|
489
|
-
|
|
490
|
-
|
|
505
|
+
let querysubMismatch = await getQuerysubVersionMismatch(gitFolder);
|
|
506
|
+
if (afterGitRef !== prevGitRef || nodeModulesMissing || querysubMismatch) {
|
|
507
|
+
console.log(green(`Yarn installing for ${magenta(screenName)} (ref ${prevGitRef} -> ${afterGitRef}, nodeModulesMissing=${nodeModulesMissing}, querysubMismatch=${querysubMismatch || "none"})`));
|
|
491
508
|
await runPromise(`yarn install --mutex network`, { cwd: gitFolder });
|
|
492
509
|
}
|
|
493
510
|
}
|