@persistmemory/cli 0.3.2 → 0.3.3
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/bin.js +28 -6
- package/dist/bin.js.map +2 -2
- package/dist/index.js +28 -6
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1402,7 +1402,7 @@ function shortDate(iso) {
|
|
|
1402
1402
|
}
|
|
1403
1403
|
|
|
1404
1404
|
// src/help.ts
|
|
1405
|
-
var VERSION = true ? "0.3.
|
|
1405
|
+
var VERSION = true ? "0.3.3" : versionFromManifest();
|
|
1406
1406
|
var PACKAGE = "@persistmemory/cli";
|
|
1407
1407
|
var HELP = `
|
|
1408
1408
|
pm \u2014 PersistMemory from your terminal
|
|
@@ -2991,6 +2991,9 @@ import { existsSync as existsSync7, rmSync } from "node:fs";
|
|
|
2991
2991
|
import { spawnSync } from "node:child_process";
|
|
2992
2992
|
import { dirname as dirname4, resolve as resolve7 } from "node:path";
|
|
2993
2993
|
import { fileURLToPath } from "node:url";
|
|
2994
|
+
function installArgs(pkg = PACKAGE) {
|
|
2995
|
+
return ["install", "-g", "--prefer-online", `${pkg}@latest`];
|
|
2996
|
+
}
|
|
2994
2997
|
async function updateCommand(context) {
|
|
2995
2998
|
const manager = installer();
|
|
2996
2999
|
if (!manager) {
|
|
@@ -2999,19 +3002,38 @@ async function updateCommand(context) {
|
|
|
2999
3002
|
);
|
|
3000
3003
|
return 1;
|
|
3001
3004
|
}
|
|
3005
|
+
const before = versionOf(manager);
|
|
3002
3006
|
context.print(`Installing the newest ${PACKAGE}\u2026`);
|
|
3003
|
-
const result = spawnSync(manager,
|
|
3004
|
-
stdio: "inherit"
|
|
3005
|
-
});
|
|
3007
|
+
const result = spawnSync(manager, installArgs(), { stdio: "inherit" });
|
|
3006
3008
|
if (result.status !== 0) {
|
|
3007
3009
|
context.error(
|
|
3008
|
-
|
|
3010
|
+
'That did not work.\n\nIf npm said ETARGET or "no matching version", its cached list of versions is\nstale. Clear it and try again:\n npm cache clean --force\n\nIf it failed on permissions, do NOT re-run it with sudo \u2014 point npm at a\ndirectory you own instead:\n npm config set prefix ~/.npm-global\n export PATH=$HOME/.npm-global/bin:$PATH'
|
|
3009
3011
|
);
|
|
3010
3012
|
return result.status ?? 1;
|
|
3011
3013
|
}
|
|
3012
|
-
|
|
3014
|
+
const after = versionOf(manager);
|
|
3015
|
+
if (after && before && after === before) {
|
|
3016
|
+
context.print(
|
|
3017
|
+
`npm finished, but ${PACKAGE} is still ${after}. That is usually a second copy
|
|
3018
|
+
earlier on your PATH \u2014 check with: which -a pm`
|
|
3019
|
+
);
|
|
3020
|
+
return 1;
|
|
3021
|
+
}
|
|
3022
|
+
context.print(after ? `Done \u2014 now on ${after}.` : "Done.");
|
|
3013
3023
|
return 0;
|
|
3014
3024
|
}
|
|
3025
|
+
function versionOf(manager) {
|
|
3026
|
+
const result = spawnSync(manager, ["ls", "-g", "--depth", "0", "--json", PACKAGE], {
|
|
3027
|
+
encoding: "utf8"
|
|
3028
|
+
});
|
|
3029
|
+
if (result.status !== 0 || !result.stdout) return void 0;
|
|
3030
|
+
try {
|
|
3031
|
+
const parsed = JSON.parse(result.stdout);
|
|
3032
|
+
return parsed.dependencies?.[PACKAGE]?.version;
|
|
3033
|
+
} catch {
|
|
3034
|
+
return void 0;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3015
3037
|
async function uninstallCommand(context) {
|
|
3016
3038
|
const manager = installer();
|
|
3017
3039
|
if (!manager) {
|