@lpm-registry/cli 0.74.0-nightly.20260808.135.e24e29a → 0.74.1
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 +4 -0
- package/package.json +7 -7
- package/scripts/install-binary.js +34 -0
package/README.md
CHANGED
|
@@ -46,5 +46,9 @@ can validate the native binary during installation:
|
|
|
46
46
|
npm install -g @lpm-registry/cli --allow-scripts=@lpm-registry/cli
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
Do not run this install with `sudo`. Configure a user-writable npm global
|
|
50
|
+
prefix, or use the Homebrew or standalone installer. Run all LPM CLI user
|
|
51
|
+
commands without `sudo`.
|
|
52
|
+
|
|
49
53
|
Other install methods are documented at
|
|
50
54
|
[github.com/lpm-dev/rust-client](https://github.com/lpm-dev/rust-client).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lpm-registry/cli",
|
|
3
|
-
"version": "0.74.
|
|
3
|
+
"version": "0.74.1",
|
|
4
4
|
"description": "LPM CLI native binary installer for npm",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"README.md"
|
|
27
27
|
],
|
|
28
28
|
"optionalDependencies": {
|
|
29
|
-
"@lpm-registry/cli-darwin-arm64": "0.74.
|
|
30
|
-
"@lpm-registry/cli-darwin-x64": "0.74.
|
|
31
|
-
"@lpm-registry/cli-linux-arm64": "0.74.
|
|
32
|
-
"@lpm-registry/cli-linux-x64": "0.74.
|
|
33
|
-
"@lpm-registry/cli-linux-x64-musl": "0.74.
|
|
34
|
-
"@lpm-registry/cli-win32-x64": "0.74.
|
|
29
|
+
"@lpm-registry/cli-darwin-arm64": "0.74.1",
|
|
30
|
+
"@lpm-registry/cli-darwin-x64": "0.74.1",
|
|
31
|
+
"@lpm-registry/cli-linux-arm64": "0.74.1",
|
|
32
|
+
"@lpm-registry/cli-linux-x64": "0.74.1",
|
|
33
|
+
"@lpm-registry/cli-linux-x64-musl": "0.74.1",
|
|
34
|
+
"@lpm-registry/cli-win32-x64": "0.74.1"
|
|
35
35
|
},
|
|
36
36
|
"type": "module",
|
|
37
37
|
"engines": {
|
|
@@ -18,6 +18,15 @@ const defaultWrapperRoot = path.resolve(scriptDir, "..");
|
|
|
18
18
|
const defaultValidateTimeoutMs = 30_000;
|
|
19
19
|
const commands = ["lpm", "lpx"];
|
|
20
20
|
|
|
21
|
+
export class SudoInstallError extends Error {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(
|
|
24
|
+
"LPM CLI does not support npm installation through sudo. Run the npm install command without sudo.",
|
|
25
|
+
);
|
|
26
|
+
this.name = "SudoInstallError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
export function installNativeBinaries(options = {}) {
|
|
22
31
|
const wrapperRoot = options.wrapperRoot ?? defaultWrapperRoot;
|
|
23
32
|
const platform = options.platform ?? process.platform;
|
|
@@ -30,6 +39,13 @@ export function installNativeBinaries(options = {}) {
|
|
|
30
39
|
const logFn = options.logFn ?? console.log;
|
|
31
40
|
const validateTimeoutMs =
|
|
32
41
|
options.validateTimeoutMs ?? defaultValidateTimeoutMs;
|
|
42
|
+
const geteuid =
|
|
43
|
+
options.geteuid ??
|
|
44
|
+
(typeof process.geteuid === "function" ? () => process.geteuid() : undefined);
|
|
45
|
+
|
|
46
|
+
if (isSudoTransition({ geteuid, env })) {
|
|
47
|
+
throw new SudoInstallError();
|
|
48
|
+
}
|
|
33
49
|
|
|
34
50
|
const key = platformKey(platform, arch, libc);
|
|
35
51
|
const spec = PLATFORMS[key];
|
|
@@ -89,6 +105,19 @@ export function installNativeBinaries(options = {}) {
|
|
|
89
105
|
return { status: "installed", platform: key, package: spec.pkg, optimized };
|
|
90
106
|
}
|
|
91
107
|
|
|
108
|
+
export function isSudoTransition({ geteuid, env = process.env } = {}) {
|
|
109
|
+
if (typeof geteuid !== "function" || geteuid() !== 0) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const sudoUser = env.SUDO_USER;
|
|
114
|
+
return (
|
|
115
|
+
typeof sudoUser === "string" &&
|
|
116
|
+
sudoUser.trim() !== "" &&
|
|
117
|
+
sudoUser.trim() !== "root"
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
92
121
|
export function validateNativeBinary(
|
|
93
122
|
binaryPath,
|
|
94
123
|
{
|
|
@@ -220,6 +249,11 @@ function unlinkIfExists(filePath, fsModule) {
|
|
|
220
249
|
}
|
|
221
250
|
|
|
222
251
|
function printInstallError(error) {
|
|
252
|
+
if (error instanceof SudoInstallError) {
|
|
253
|
+
console.error(`[lpm] ${error.message}`);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
223
257
|
if (error instanceof LpmWrapperError) {
|
|
224
258
|
console.error(`[lpm] ${error.message}`);
|
|
225
259
|
for (const hint of error.hints) {
|