promptkit-os 2.0.0 → 2.0.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.
Files changed (2) hide show
  1. package/bin/promptkit-os.js +33 -14
  2. package/package.json +2 -2
@@ -12,7 +12,6 @@ const { spawnSync } = require("node:child_process");
12
12
  const crypto = require("node:crypto");
13
13
  const fs = require("node:fs");
14
14
  const path = require("node:path");
15
- const os = require("node:os");
16
15
 
17
16
  const PKG = require("../package.json");
18
17
  const REPO = "lowqualityloey/promptkit-os";
@@ -39,7 +38,7 @@ const KIT_DIR = ".promptkit";
39
38
  const TARBALL_SHA256_BY_VERSION = {
40
39
  "1.10.1": "1e55459914a1c46aa71df8f9cb8ce4c9ff37d1c02d67f70e5607b3bfd4f48d4b",
41
40
  "1.11.0": "6503fdfcde286055b8c053aa0ffa8bdf244cf77df3321cccd6a8d8f780195ade",
42
- "2.0.0": "4fb5b9d85e0f19bfe333c361e00465705b60636a8026edd62c15c6f2d61cbf4b",
41
+ "2.0.1": "6f3d667346bbc8cdc42e916fafcbde5dd0e42753398fe528609bf990ea35365b",
43
42
  // @pin-insert
44
43
  };
45
44
 
@@ -61,12 +60,12 @@ function passthroughFlags(argv) {
61
60
  const out = [];
62
61
  for (const arg of argv) {
63
62
  if (arg === "--force") continue; // courier-only flag, never forwarded to the installer
64
- if (known.has(arg) || arg.startsWith("--host=") || arg.startsWith("--target=") || arg.startsWith("--tracking=")) {
63
+ if (known.has(arg) || arg.startsWith("--host=") || arg.startsWith("--add-host=") || arg.startsWith("--target=") || arg.startsWith("--tracking=")) {
65
64
  out.push(arg);
66
65
  } else if (!arg.startsWith("-")) {
67
66
  out.push(arg); // positional project root
68
67
  } else {
69
- die(`unknown flag '${arg}' — pass it through after the install target, or see init --help`);
68
+ die(`unknown flag '${arg}' — the courier forwards a fixed allowlist; run the installer directly for full flags (init.sh --help / init.ps1 --help)`);
70
69
  }
71
70
  }
72
71
  return out;
@@ -144,13 +143,21 @@ async function download(url) {
144
143
  }
145
144
 
146
145
  async function extract(tarball, dest) {
147
- const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "promptkit-os-"));
148
- const tarPath = path.join(tmp, "release.tar.gz");
149
- fs.writeFileSync(tarPath, tarball);
150
-
151
- const res = spawnSync("tar", ["-xzf", tarPath, "-C", dest, "--strip-components=1"], { stdio: "inherit" });
152
- if (res.status !== 0) die("failed to extract release tarball (is `tar` available?)");
153
- fs.rmSync(tmp, { recursive: true, force: true });
146
+ // Every tar operand must stay relative: GNU tar — the first `tar` on PATH inside
147
+ // Git Bash — reads `C:\...` operands as remote host:path and dies with
148
+ // "Cannot connect to C: resolve failed", so the staging-temp-dir + absolute -C
149
+ // form broke the Windows leg wherever Git Bash leads PATH. Staging the archive
150
+ // inside `dest` (created by the caller) and extracting with cwd=dest leaves no
151
+ // absolute path in argv at all, on GNU tar, bsdtar, and POSIX tar alike.
152
+ const stagedTarball = path.join(dest, ".promptkit-release.tar.gz");
153
+ fs.writeFileSync(stagedTarball, tarball);
154
+ const res = spawnSync("tar", ["-xzf", ".promptkit-release.tar.gz", "--strip-components=1"], { cwd: dest, stdio: "inherit" });
155
+ fs.rmSync(stagedTarball, { force: true });
156
+ if (res.error) {
157
+ const hint = res.error.code === "ENOENT" ? "tar not found on PATH" : res.error.message;
158
+ die(`failed to extract release tarball: ${hint}`);
159
+ }
160
+ if (res.status !== 0) die(`failed to extract release tarball (tar exit ${res.status ?? res.signal})`);
154
161
  }
155
162
 
156
163
  function runInstaller(kitDir, args) {
@@ -159,13 +166,25 @@ function runInstaller(kitDir, args) {
159
166
  const ps = path.join(kitDir, "init.ps1");
160
167
  if (!fs.existsSync(ps)) die("init.ps1 missing from release tarball");
161
168
  const res = spawnSync("pwsh", ["-NoProfile", "-File", ps, ...args], { stdio: "inherit" });
162
- if (res.status !== 0) die("init.ps1 failed");
169
+ if (res.error) {
170
+ const hint = res.error.code === "ENOENT"
171
+ ? "pwsh not found — PowerShell 7 is required on Windows (aka.ms/powershell); or use the git-submodule door and run bash .promptkit/init.sh"
172
+ : res.error.message;
173
+ die(`failed to launch init.ps1: ${hint}`);
174
+ }
175
+ if (res.status !== 0) die(`init.ps1 failed (exit ${res.status ?? res.signal})`);
163
176
  } else {
164
177
  const sh = path.join(kitDir, "init.sh");
165
178
  if (!fs.existsSync(sh)) die("init.sh missing from release tarball");
166
179
  fs.chmodSync(sh, 0o755);
167
180
  const res = spawnSync("bash", [sh, ...args], { stdio: "inherit" });
168
- if (res.status !== 0) die("init.sh failed");
181
+ if (res.error) {
182
+ const hint = res.error.code === "ENOENT"
183
+ ? "bash not found — a POSIX shell is required to run init.sh"
184
+ : res.error.message;
185
+ die(`failed to launch init.sh: ${hint}`);
186
+ }
187
+ if (res.status !== 0) die(`init.sh failed (exit ${res.status ?? res.signal})`);
169
188
  }
170
189
  }
171
190
 
@@ -193,7 +212,7 @@ async function main() {
193
212
  " npx promptkit-os@latest --lite\n" +
194
213
  " npx promptkit-os@latest --turbo --experimental\n" +
195
214
  " npx promptkit-os@latest /path/to/project\n\n" +
196
- "Pass-through flags: --lite --balanced --turbo --experimental --host= --target= --tracking= --reconfigure\n" +
215
+ "Pass-through flags: --lite --balanced --turbo --experimental --host= --add-host= --target= --tracking= --reconfigure\n" +
197
216
  "Courier flags: --force (overlay a non-empty .promptkit/; not recommended)\n\n" +
198
217
  "Updating an existing install? Use the canonical path instead:\n" +
199
218
  " git submodule update --remote --merge .promptkit && bash .promptkit/init.sh\n\n" +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptkit-os",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Courier for PromptKit OS: fetches a pinned release tarball and runs the canonical installer. Not a runtime dependency.",
5
5
  "keywords": [
6
6
  "promptkit",
@@ -31,7 +31,7 @@
31
31
  "node": ">=18"
32
32
  },
33
33
  "scripts": {
34
- "test": "bash test/smoke.sh"
34
+ "test": "bash -c 'if [ -d test ]; then bash test/smoke.sh; fi'"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public",