@adunne09/waldo 0.0.0-dev-202603160229 → 0.0.0-dev-202603161554
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/bin/waldo +54 -11
- package/package.json +6 -6
package/bin/waldo
CHANGED
|
@@ -52,10 +52,10 @@ function run(target) {
|
|
|
52
52
|
process.exit(typeof result.status === "number" ? result.status : 0);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const internalAutoUpdateFlag = "WALDO_INTERNAL_AUTOUPDATE";
|
|
56
|
+
const internalAutoUpdateCurrentVersionKey = "WALDO_INTERNAL_AUTOUPDATE_CURRENT_VERSION";
|
|
57
|
+
const internalAutoUpdateMethodKey = "WALDO_INTERNAL_AUTOUPDATE_METHOD";
|
|
58
|
+
const internalAutoUpdateReleaseTagKey = "WALDO_INTERNAL_AUTOUPDATE_RELEASE_TAG";
|
|
59
59
|
|
|
60
60
|
const scriptPath = fs.realpathSync(fileURLToPath(import.meta.url));
|
|
61
61
|
const scriptDir = path.dirname(scriptPath);
|
|
@@ -67,6 +67,11 @@ const defaultNpmRegistry = "https://registry.npmjs.org";
|
|
|
67
67
|
const publicPackageName = "@adunne09/waldo";
|
|
68
68
|
const defaultReleaseTag = "latest";
|
|
69
69
|
|
|
70
|
+
const envPath = process.env.WALDO_BIN_PATH;
|
|
71
|
+
if (envPath && process.env[internalAutoUpdateFlag] !== "1") {
|
|
72
|
+
run(envPath);
|
|
73
|
+
}
|
|
74
|
+
|
|
70
75
|
let cachedPackageMetadata;
|
|
71
76
|
|
|
72
77
|
function readPackageMetadata() {
|
|
@@ -336,6 +341,45 @@ function formatAutoUpdateSuccessMessage(current, latest) {
|
|
|
336
341
|
return `Updated Waldo from ${current} to ${latest}. Restart to apply changes.`;
|
|
337
342
|
}
|
|
338
343
|
|
|
344
|
+
function startAutoUpdateInBackground(method, current, releaseTag) {
|
|
345
|
+
const child = childProcess.spawn(process.execPath, [scriptPath], {
|
|
346
|
+
cwd: os.homedir(),
|
|
347
|
+
detached: true,
|
|
348
|
+
env: {
|
|
349
|
+
...process.env,
|
|
350
|
+
[internalAutoUpdateFlag]: "1",
|
|
351
|
+
[internalAutoUpdateCurrentVersionKey]: current,
|
|
352
|
+
[internalAutoUpdateMethodKey]: method,
|
|
353
|
+
[internalAutoUpdateReleaseTagKey]: releaseTag,
|
|
354
|
+
},
|
|
355
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
child.unref();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async function runAutoUpdateInBackgroundProcess() {
|
|
362
|
+
const current = process.env[internalAutoUpdateCurrentVersionKey] || resolveCurrentVersion();
|
|
363
|
+
const method = process.env[internalAutoUpdateMethodKey] || resolveInstallMethod();
|
|
364
|
+
const releaseTag = process.env[internalAutoUpdateReleaseTagKey] || resolveReleaseTag();
|
|
365
|
+
|
|
366
|
+
if (method === "unknown") {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
try {
|
|
371
|
+
const latest = await resolveLatestVersion(releaseTag);
|
|
372
|
+
if (current === latest) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
runGlobalUpgrade(method, latest);
|
|
377
|
+
console.log(formatAutoUpdateSuccessMessage(current, latest));
|
|
378
|
+
} catch {
|
|
379
|
+
console.error(`Waldo update failed; continuing with ${current}.`);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
339
383
|
const platformMap = {
|
|
340
384
|
darwin: "darwin",
|
|
341
385
|
linux: "linux",
|
|
@@ -395,19 +439,18 @@ async function maybeAutoUpdate() {
|
|
|
395
439
|
try {
|
|
396
440
|
const current = resolveCurrentVersion();
|
|
397
441
|
const releaseTag = resolveReleaseTag();
|
|
398
|
-
|
|
399
|
-
if (current === latest) {
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
runGlobalUpgrade(method, latest);
|
|
404
|
-
console.error(formatAutoUpdateSuccessMessage(current, latest));
|
|
442
|
+
startAutoUpdateInBackground(method, current, releaseTag);
|
|
405
443
|
} catch {
|
|
406
444
|
const current = resolveCurrentVersion();
|
|
407
445
|
console.error(`Waldo update failed; continuing with ${current}.`);
|
|
408
446
|
}
|
|
409
447
|
}
|
|
410
448
|
|
|
449
|
+
if (process.env[internalAutoUpdateFlag] === "1") {
|
|
450
|
+
await runAutoUpdateInBackgroundProcess();
|
|
451
|
+
process.exit(0);
|
|
452
|
+
}
|
|
453
|
+
|
|
411
454
|
await maybeAutoUpdate();
|
|
412
455
|
|
|
413
456
|
const resolved = resolveBinary();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adunne09/waldo",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-202603161554",
|
|
4
4
|
"waldoReleaseTag": "dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
14
14
|
},
|
|
15
15
|
"optionalDependencies": {
|
|
16
|
-
"@adunne09/waldo-darwin-arm64": "0.0.0-dev-
|
|
17
|
-
"@adunne09/waldo-darwin-x64": "0.0.0-dev-
|
|
18
|
-
"@adunne09/waldo-linux-arm64": "0.0.0-dev-
|
|
19
|
-
"@adunne09/waldo-linux-x64": "0.0.0-dev-
|
|
20
|
-
"@adunne09/waldo-windows-x64": "0.0.0-dev-
|
|
16
|
+
"@adunne09/waldo-darwin-arm64": "0.0.0-dev-202603161554",
|
|
17
|
+
"@adunne09/waldo-darwin-x64": "0.0.0-dev-202603161554",
|
|
18
|
+
"@adunne09/waldo-linux-arm64": "0.0.0-dev-202603161554",
|
|
19
|
+
"@adunne09/waldo-linux-x64": "0.0.0-dev-202603161554",
|
|
20
|
+
"@adunne09/waldo-windows-x64": "0.0.0-dev-202603161554"
|
|
21
21
|
}
|
|
22
22
|
}
|