pacework 1.2.0 → 1.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.
@@ -17,6 +17,7 @@ import { spawn, execFileSync, execSync } from "node:child_process"
17
17
  import { fileURLToPath } from "node:url"
18
18
  import { agentSecretsFrom, detectSetupCommand } from "../lib/environment.mjs"
19
19
  import { runTriageLoop } from "../lib/triage-worker.mjs"
20
+ import { NPM_PACKAGE, isNewerVersion, latestPublishedVersion } from "../lib/version.mjs"
20
21
  import { EXECUTORS, EXECUTOR_DEFAULT_NAMES, checkBinaryExists, executorLabel } from "../lib/executors.mjs"
21
22
  import { BANNER_LINES } from "../lib/ui.mjs"
22
23
  import {
@@ -62,12 +63,10 @@ const LOCAL_VERSION = (() => {
62
63
  async function checkForUpdate() {
63
64
  if (!LOCAL_VERSION) return
64
65
  try {
65
- const res = await fetch("https://registry.npmjs.org/pacework-runner/latest", { signal: AbortSignal.timeout(4000) })
66
- if (!res.ok) return
67
- const { version: latest } = await res.json()
68
- if (latest && latest !== LOCAL_VERSION) {
69
- console.log(`\n⚠ Update available: pacework-runner ${LOCAL_VERSION} → ${latest}`)
70
- console.log(` Run: npm install -g pacework\n`)
66
+ const latest = await latestPublishedVersion()
67
+ if (latest && isNewerVersion(latest, LOCAL_VERSION)) {
68
+ console.log(`\n⚠ Update available: ${NPM_PACKAGE} ${LOCAL_VERSION} → ${latest}`)
69
+ console.log(` Run: pacework update\n`)
71
70
  }
72
71
  } catch {}
73
72
  }
@@ -1435,7 +1434,7 @@ else if (command === "shell" || command === "sh") {
1435
1434
  console.log(cmd("use <executor>", "Switch executor"))
1436
1435
  console.log(cmd("rename <name>", "Set runner display name"))
1437
1436
  console.log(cmd("doctor", "Check all dependencies"))
1438
- console.log(cmd("update", "Upgrade pacework-runner"))
1437
+ console.log(cmd("update", "Upgrade pacework to the latest version"))
1439
1438
  console.log(cmd("login", "Authenticate via browser"))
1440
1439
  console.log(cmd("logout", "Revoke API key and clear credentials"))
1441
1440
  console.log(sec("SHELL"))
@@ -2495,13 +2494,13 @@ else if (command === "shell" || command === "sh") {
2495
2494
  case "update": {
2496
2495
  console.log("Checking for updates…")
2497
2496
  try {
2498
- const res = await fetch("https://registry.npmjs.org/pacework-runner/latest", { signal: AbortSignal.timeout(4000) })
2499
- const { version: latest } = await res.json()
2500
- if (latest === LOCAL_VERSION) {
2497
+ const latest = await latestPublishedVersion()
2498
+ if (!latest) throw new Error("no version")
2499
+ if (!isNewerVersion(latest, LOCAL_VERSION)) {
2501
2500
  console.log(`\x1b[32m✓\x1b[0m Already on latest (\x1b[1m${LOCAL_VERSION}\x1b[0m)`)
2502
2501
  } else {
2503
2502
  console.log(`Updating ${LOCAL_VERSION} → \x1b[1m${latest}\x1b[0m…`)
2504
- const child = spawn("npm", ["install", "-g", "pacework-runner"], { stdio: "inherit" })
2503
+ const child = spawn("npm", ["install", "-g", `${NPM_PACKAGE}@${latest}`], { stdio: "inherit" })
2505
2504
  await new Promise(r => child.on("exit", r))
2506
2505
  }
2507
2506
  } catch { console.log("\x1b[31mCould not reach npm registry.\x1b[0m") }
@@ -2668,7 +2667,7 @@ else if (command === "shell" || command === "sh") {
2668
2667
  { name: "open", desc: "Open workspace in browser" },
2669
2668
  { name: "config", desc: "View or set config values" },
2670
2669
  { name: "doctor", desc: "Check dependencies" },
2671
- { name: "update", desc: "Upgrade pacework-runner" },
2670
+ { name: "update", desc: "Upgrade pacework to the latest version" },
2672
2671
  { name: "login", desc: "Authenticate via browser" },
2673
2672
  { name: "logout", desc: "Revoke API key and clear credentials" },
2674
2673
  { name: "help", desc: "Show this help screen" },