@4pm/cli 0.4.0 → 0.4.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/dist/index.js +16 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -24638,6 +24638,7 @@ import { createHash as createHash2, createPublicKey, verify } from "crypto";
24638
24638
  import { mkdtempSync, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
24639
24639
  import { tmpdir } from "os";
24640
24640
  import { dirname as dirname2, join as join4, sep } from "path";
24641
+ import { fileURLToPath as fileURLToPath2 } from "url";
24641
24642
 
24642
24643
  // src/config/signing.ts
24643
24644
  var CLI_SIGNING_PUBLIC_KEY = `
@@ -24671,12 +24672,15 @@ function compareSemver(a, b) {
24671
24672
  }
24672
24673
  return 0;
24673
24674
  }
24675
+ function runningInstallRoot() {
24676
+ return dirname2(dirname2(fileURLToPath2(import.meta.url)));
24677
+ }
24674
24678
  function installedViaNpm() {
24675
24679
  return (process.argv[1] ?? "").split(sep).includes("node_modules");
24676
24680
  }
24677
24681
  function readInstalledVersion() {
24678
24682
  try {
24679
- const pkgPath = join4(dirname2(dirname2(process.argv[1] ?? ".")), "package.json");
24683
+ const pkgPath = join4(runningInstallRoot(), "package.json");
24680
24684
  return JSON.parse(readFileSync5(pkgPath, "utf8")).version ?? "0.0.0";
24681
24685
  } catch {
24682
24686
  return "0.0.0";
@@ -24710,7 +24714,7 @@ async function updateViaDownload(tarballUrl, checksum, signature) {
24710
24714
  }
24711
24715
  const tmp = join4(mkdtempSync(join4(tmpdir(), "4pm-update-")), "cli.tgz");
24712
24716
  writeFileSync3(tmp, buf);
24713
- const installRoot = dirname2(dirname2(process.argv[1] ?? "."));
24717
+ const installRoot = runningInstallRoot();
24714
24718
  execSync2(`tar -xzf "${tmp}" -C "${installRoot}" --strip-components=1`, {
24715
24719
  stdio: "inherit"
24716
24720
  });
@@ -24731,10 +24735,17 @@ async function updateToLatest(serverUrl) {
24731
24735
  meta.source.signature
24732
24736
  );
24733
24737
  }
24734
- return { action: "updated", version: meta.latest };
24735
24738
  } catch (err) {
24736
24739
  return { action: "failed", error: String(err) };
24737
24740
  }
24741
+ const installed = readInstalledVersion();
24742
+ if (compareSemver(installed, meta.latest) < 0) {
24743
+ return {
24744
+ action: "failed",
24745
+ error: `update ran but the installed version is still ${installed} (expected ${meta.latest}) \u2014 it did not apply to the running install at ${runningInstallRoot()}.`
24746
+ };
24747
+ }
24748
+ return { action: "updated", version: meta.latest };
24738
24749
  }
24739
24750
  async function checkAndUpdate(serverUrl, autoUpdate) {
24740
24751
  if (CLI_VERSION.startsWith("0.0.0")) return { action: "none" };
@@ -25656,12 +25667,12 @@ ${stderr}`;
25656
25667
  import { cp, mkdir, writeFile } from "fs/promises";
25657
25668
  import { execFile as execFile4 } from "child_process";
25658
25669
  import { dirname as dirname4, join as join8, resolve as resolve4 } from "path";
25659
- import { fileURLToPath as fileURLToPath2 } from "url";
25670
+ import { fileURLToPath as fileURLToPath3 } from "url";
25660
25671
  import { promisify as promisify4 } from "util";
25661
25672
  var run4 = promisify4(execFile4);
25662
25673
  function sampleDir() {
25663
25674
  if (process.env.SCAFFOLD_SAMPLE_DIR) return process.env.SCAFFOLD_SAMPLE_DIR;
25664
- const here = dirname4(fileURLToPath2(import.meta.url));
25675
+ const here = dirname4(fileURLToPath3(import.meta.url));
25665
25676
  return resolve4(here, "../../project-sample");
25666
25677
  }
25667
25678
  async function scaffoldProject(payload, onProgress) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4pm/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "private": false,
5
5
  "description": "4PM CLI — drives Claude/Codex CLIs on AI worker machines (Node + TypeScript)",
6
6
  "type": "module",