@neuvertex/nv 0.4.11 → 0.4.12
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/README.md +6 -0
- package/bin/preinstall.js +76 -0
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -14,3 +14,9 @@ Scripts and CI: `nv auth init --api-key-stdin < key.txt`.
|
|
|
14
14
|
Supported: macOS (Apple silicon and Intel), Linux x64 and arm64 (any
|
|
15
15
|
distribution), Windows x64. nv keeps its settings in `~/.neuvertex`
|
|
16
16
|
(`%USERPROFILE%\.neuvertex` on Windows) and tokens in the OS keychain.
|
|
17
|
+
|
|
18
|
+
A global install never replaces another program named `nv`: if one is already
|
|
19
|
+
where npm would put `nv` and it does not answer `nv --nv-identity` as
|
|
20
|
+
NeuVertex's, the install stops and says how to move it aside
|
|
21
|
+
(`mv <path>/nv <path>/nv-legacy`). Other tools join `nv` as plugins named
|
|
22
|
+
`nv-<category>` (`nv plugins cli list`).
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Before `npm i -g @neuvertex/nv` writes `nv`: refuse to replace another
|
|
3
|
+
// program named nv (DevLoops/nv-unify design §2 rule 5). Ours is the npm link
|
|
4
|
+
// to this package, or a program that answers `nv --nv-identity` with
|
|
5
|
+
// owner NV-Harness; anything else is moved aside by its owner first, never
|
|
6
|
+
// overwritten (npm --force would overwrite it, so this check runs regardless).
|
|
7
|
+
// A local (non-global) install writes no `nv` on PATH: nothing to check.
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const { spawnSync } = require("child_process");
|
|
13
|
+
|
|
14
|
+
function globalBinDir() {
|
|
15
|
+
const prefix = process.env.npm_config_prefix;
|
|
16
|
+
if (!prefix) return null;
|
|
17
|
+
return process.platform === "win32" ? prefix : path.join(prefix, "bin");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// The link or shim npm made for an earlier @neuvertex/nv.
|
|
21
|
+
function isOurNpmLink(p) {
|
|
22
|
+
try {
|
|
23
|
+
if (fs.lstatSync(p).isSymbolicLink()) {
|
|
24
|
+
return fs.realpathSync(p).split(path.sep).join("/").includes("/@neuvertex/nv/");
|
|
25
|
+
}
|
|
26
|
+
if (process.platform === "win32") {
|
|
27
|
+
return /@neuvertex[\\/]nv[\\/]/.test(fs.readFileSync(p, "utf8"));
|
|
28
|
+
}
|
|
29
|
+
} catch (_) {
|
|
30
|
+
// unreadable: decided by its identity below
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isOurs(p) {
|
|
36
|
+
if (isOurNpmLink(p)) return true;
|
|
37
|
+
const r = spawnSync(p, ["--nv-identity"], { encoding: "utf8", timeout: 5000, stdio: ["ignore", "pipe", "ignore"] });
|
|
38
|
+
try {
|
|
39
|
+
const id = JSON.parse((r.stdout || "").trim().split("\n")[0]);
|
|
40
|
+
return id.cli === "nv" && id.owner === "NV-Harness";
|
|
41
|
+
} catch (_) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function main() {
|
|
47
|
+
if (process.env.npm_config_global !== "true") return 0;
|
|
48
|
+
const dir = globalBinDir();
|
|
49
|
+
if (!dir) return 0;
|
|
50
|
+
const names = process.platform === "win32" ? ["nv.cmd", "nv.exe", "nv"] : ["nv"];
|
|
51
|
+
for (const n of names) {
|
|
52
|
+
const p = path.join(dir, n);
|
|
53
|
+
if (!fs.existsSync(p) && !isSymlink(p)) continue;
|
|
54
|
+
if (isOurs(p)) continue;
|
|
55
|
+
const legacy = path.join(dir, n.replace(/^nv/, "nv-legacy"));
|
|
56
|
+
console.error(
|
|
57
|
+
`nv: ${p} is another program named nv, not NeuVertex's (it does not answer nv --nv-identity as NV-Harness).\n` +
|
|
58
|
+
` It was left as it is. Move it aside, then install again:\n` +
|
|
59
|
+
` ${process.platform === "win32" ? "move" : "mv"} "${p}" "${legacy}"\n` +
|
|
60
|
+
` npm i -g @neuvertex/nv`
|
|
61
|
+
);
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isSymlink(p) {
|
|
68
|
+
try {
|
|
69
|
+
return fs.lstatSync(p).isSymbolicLink();
|
|
70
|
+
} catch (_) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (require.main === module) process.exit(main());
|
|
76
|
+
module.exports = { isOurs, isOurNpmLink };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neuvertex/nv",
|
|
3
3
|
"description": "nv: the NeuVertex command line. Sign in, run a local harness, install NeuApps and Edge Appliances.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.12",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://neuvertex.ai",
|
|
7
7
|
"repository": {
|
|
@@ -11,18 +11,22 @@
|
|
|
11
11
|
"bin": {
|
|
12
12
|
"nv": "bin/nv.js"
|
|
13
13
|
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"preinstall": "node bin/preinstall.js"
|
|
16
|
+
},
|
|
14
17
|
"files": [
|
|
15
18
|
"bin/nv.js",
|
|
19
|
+
"bin/preinstall.js",
|
|
16
20
|
"README.md"
|
|
17
21
|
],
|
|
18
22
|
"engines": {
|
|
19
23
|
"node": ">=18"
|
|
20
24
|
},
|
|
21
25
|
"optionalDependencies": {
|
|
22
|
-
"@neuvertex/nv-darwin-arm64": "0.4.
|
|
23
|
-
"@neuvertex/nv-darwin-x64": "0.4.
|
|
24
|
-
"@neuvertex/nv-linux-arm64": "0.4.
|
|
25
|
-
"@neuvertex/nv-linux-x64": "0.4.
|
|
26
|
-
"@neuvertex/nv-win32-x64": "0.4.
|
|
26
|
+
"@neuvertex/nv-darwin-arm64": "0.4.12",
|
|
27
|
+
"@neuvertex/nv-darwin-x64": "0.4.12",
|
|
28
|
+
"@neuvertex/nv-linux-arm64": "0.4.12",
|
|
29
|
+
"@neuvertex/nv-linux-x64": "0.4.12",
|
|
30
|
+
"@neuvertex/nv-win32-x64": "0.4.12"
|
|
27
31
|
}
|
|
28
32
|
}
|