@penvhq/cli 1.0.0-beta.2 → 1.0.0-beta.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/bin/penv.js +51 -15
- package/package.json +7 -7
package/bin/penv.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
// npm installs one of the six @penvhq/cli-<platform> packages and skips the rest,
|
|
5
5
|
// so this shim runs whichever one landed. There is no postinstall step.
|
|
6
|
-
const {
|
|
6
|
+
const { spawn } = require("node:child_process");
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const PUBLISHED = ["darwin-arm64", "darwin-x64", "linux-arm64", "linux-x64", "win32-arm64", "win32-x64"];
|
|
9
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
10
|
+
const pkg = `@penvhq/cli-${platform}`;
|
|
9
11
|
const inside = `${pkg}/bin/penv${process.platform === "win32" ? ".exe" : ""}`;
|
|
10
12
|
|
|
11
13
|
let binary;
|
|
@@ -13,22 +15,56 @@ try {
|
|
|
13
15
|
binary = require.resolve(inside);
|
|
14
16
|
} catch {
|
|
15
17
|
process.stderr.write(
|
|
16
|
-
|
|
17
|
-
`
|
|
18
|
-
|
|
18
|
+
PUBLISHED.includes(platform)
|
|
19
|
+
? `penv: ${pkg} is missing, and npm skips an optional dependency it could not install without saying so. ` +
|
|
20
|
+
`Reinstall with npm i -g @penvhq/cli, or install without npm: curl -fsSL https://penv.cloud/install | sh, ` +
|
|
21
|
+
`or on Windows irm https://penv.cloud/install.ps1 | iex\n`
|
|
22
|
+
: `penv: there is no penv build for ${platform}. The releases cover ${PUBLISHED.join(", ")}.\n`,
|
|
19
23
|
);
|
|
20
24
|
process.exit(1);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const child = spawn(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
28
|
+
|
|
29
|
+
// Passed on, so a signal sent to the launcher alone (kill, timeout, a CI cancel)
|
|
30
|
+
// reaches penv; one the terminal also sent penv is not passed to its child twice.
|
|
31
|
+
// Windows' kill ends a process outright, and its console sends Ctrl-C to both,
|
|
32
|
+
// so there the launcher only waits.
|
|
33
|
+
const windows = process.platform === "win32";
|
|
34
|
+
const ignore = () => {};
|
|
35
|
+
const forward = (signal) => () => {
|
|
36
|
+
try {
|
|
37
|
+
child.kill(signal);
|
|
38
|
+
} catch {
|
|
39
|
+
// A signal this platform cannot send.
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const handlers = [
|
|
43
|
+
["SIGINT", windows ? ignore : forward("SIGINT")],
|
|
44
|
+
["SIGQUIT", windows ? ignore : forward("SIGQUIT")],
|
|
45
|
+
["SIGTERM", forward("SIGTERM")],
|
|
46
|
+
["SIGHUP", forward("SIGHUP")],
|
|
47
|
+
];
|
|
48
|
+
for (const [signal, handler] of handlers) {
|
|
49
|
+
try {
|
|
50
|
+
process.on(signal, handler);
|
|
51
|
+
} catch {
|
|
52
|
+
// Windows has no SIGQUIT.
|
|
53
|
+
}
|
|
27
54
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
process.
|
|
31
|
-
// Reached only when the signal was ignored, so there is still a code to answer with.
|
|
55
|
+
|
|
56
|
+
child.on("error", (error) => {
|
|
57
|
+
process.stderr.write(`penv: ${binary} could not be run: ${error.message}\n`);
|
|
32
58
|
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
child.on("exit", (code, signal) => {
|
|
62
|
+
// Re-raised rather than translated, so a caller sees the signal that stopped penv.
|
|
63
|
+
if (signal) {
|
|
64
|
+
for (const [name, handler] of handlers) process.removeListener(name, handler);
|
|
65
|
+
process.kill(process.pid, signal);
|
|
66
|
+
// Reached only when the signal was ignored, so there is still a code to answer with.
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
process.exit(code === null ? 1 : code);
|
|
70
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@penvhq/cli",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "penv, the CLI of penv.cloud: validate your .env, type it, and keep it out of your coding agent's reach.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://penv.cloud",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"bin/penv.js"
|
|
15
15
|
],
|
|
16
16
|
"optionalDependencies": {
|
|
17
|
-
"@penvhq/cli-linux-x64": "1.0.0-beta.
|
|
18
|
-
"@penvhq/cli-linux-arm64": "1.0.0-beta.
|
|
19
|
-
"@penvhq/cli-darwin-x64": "1.0.0-beta.
|
|
20
|
-
"@penvhq/cli-darwin-arm64": "1.0.0-beta.
|
|
21
|
-
"@penvhq/cli-win32-x64": "1.0.0-beta.
|
|
22
|
-
"@penvhq/cli-win32-arm64": "1.0.0-beta.
|
|
17
|
+
"@penvhq/cli-linux-x64": "1.0.0-beta.3",
|
|
18
|
+
"@penvhq/cli-linux-arm64": "1.0.0-beta.3",
|
|
19
|
+
"@penvhq/cli-darwin-x64": "1.0.0-beta.3",
|
|
20
|
+
"@penvhq/cli-darwin-arm64": "1.0.0-beta.3",
|
|
21
|
+
"@penvhq/cli-win32-x64": "1.0.0-beta.3",
|
|
22
|
+
"@penvhq/cli-win32-arm64": "1.0.0-beta.3"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|