querysub 0.709.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.709.0",
3
+ "version": "0.710.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -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
- if (afterGitRef !== prevGitRef || nodeModulesMissing) {
490
- console.log(green(`Yarn installing for ${magenta(screenName)} (ref ${prevGitRef} -> ${afterGitRef}, nodeModulesMissing=${nodeModulesMissing})`));
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
  }