getzopu 0.5.1 → 0.5.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/README.md CHANGED
@@ -57,6 +57,34 @@ needs no `--package`; it provides the `getzopu` and `zopu` executables. Install
57
57
  with `npm publish --access public`; it takes `NPM_TOKEN` from the environment. Nothing is published
58
58
  from a tree that is not green on `master`.
59
59
 
60
+ ### Without the registry: get.zopu.live
61
+
62
+ The same program also goes to Zopu's own distribution origin, `https://get.zopu.live` — the public
63
+ face of the `zopu-dist` bucket — for a computer that cannot or should not wait on npm, whose review
64
+ of each publish can take a while. `scripts/publish-dist.sh` builds, packs and puts there:
65
+
66
+ - the program as **one file**, per version: `getzopu/<version>/getzopu.mjs`, with its `.sha256`;
67
+ - the npm tarball, per version: `tarballs/getzopu-<version>.tgz`;
68
+ - a manifest per version: `versions/<version>.json` (version, build, both addresses and hashes);
69
+ - the channel's pointers: `latest/manifest.json` and `getzopu/latest/getzopu.mjs`, never cached.
70
+
71
+ A version's files are immutable — the script refuses to replace one with a different program; bump
72
+ the version. A release version moves `latest`; a prerelease (`0.6.0-beta.1`) gets its own channel
73
+ (`latest-beta`). It needs `rclone` and the bucket's key (`ALL_CLOUDFLARE_R2_*` in the root `.env`),
74
+ runs only from a tree with no tracked edits, and downloads every address again before it reports.
75
+
76
+ To connect a computer with nothing but the runtime (Node 24+):
77
+
78
+ ```sh
79
+ curl -fsSL -o getzopu.mjs https://get.zopu.live/getzopu/latest/getzopu.mjs
80
+ node getzopu.mjs machines connect
81
+ ```
82
+
83
+ On Windows, in PowerShell: `curl.exe -fsSL -o getzopu.mjs <the same address>`, then
84
+ `node .\getzopu.mjs machines connect`. The service keeps its own copy of the file, so the download
85
+ may sit in any folder. For a `getzopu` command on the PATH instead:
86
+ `npm install -g https://get.zopu.live/tarballs/getzopu-<version>.tgz`.
87
+
60
88
  ### Machines
61
89
 
62
90
  `getzopu machines connect [--name <name>] [--url <url>] [--foreground]` pairs the computer when
package/dist/getzopu.mjs CHANGED
@@ -751,7 +751,7 @@ Commands:
751
751
  });
752
752
 
753
753
  // src/cli.ts
754
- import { chmod as chmod2, lstat as lstat2, mkdir as mkdir5, readFile as readFile4, rename as rename2, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
754
+ import { chmod as chmod2, lstat as lstat2, mkdir as mkdir5, readFile as readFile4, rename as rename3, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
755
755
  import { homedir as homedir7 } from "node:os";
756
756
  import path6 from "node:path";
757
757
  import { parseArgs } from "node:util";
@@ -26412,7 +26412,7 @@ ${result3.text.slice(0, 4000)}` : "";
26412
26412
  // src/machines.ts
26413
26413
  import { spawn as spawn2 } from "node:child_process";
26414
26414
  import { appendFileSync as appendFileSync2 } from "node:fs";
26415
- import { copyFile, mkdir as mkdir4, readFile as readFile3, stat as stat3, writeFile as writeFile4 } from "node:fs/promises";
26415
+ import { copyFile, mkdir as mkdir4, readFile as readFile3, rename as rename2, stat as stat3, writeFile as writeFile4 } from "node:fs/promises";
26416
26416
  import { hostname as hostname2, platform as platform2 } from "node:os";
26417
26417
  import path4 from "node:path";
26418
26418
  import { setTimeout as pause } from "node:timers/promises";
@@ -27063,6 +27063,17 @@ var renderTask = (options) => {
27063
27063
  ].join(`\r
27064
27064
  `);
27065
27065
  };
27066
+ var satellitePid = (home) => exports_Effect.gen(function* pid() {
27067
+ const text = yield* exports_Effect.result(exports_Effect.tryPromise({
27068
+ catch: (cause) => cause,
27069
+ try: () => fs.readFile(path2.join(home, "state.json"), "utf-8")
27070
+ }));
27071
+ if (exports_Result.isFailure(text)) {
27072
+ return null;
27073
+ }
27074
+ const parsed = yield* exports_Effect.result(exports_Effect.try(() => JSON.parse(text.success).pid));
27075
+ return exports_Result.isSuccess(parsed) && typeof parsed.success === "number" ? parsed.success : null;
27076
+ });
27066
27077
  var windows = (plan) => {
27067
27078
  const name = plan.label;
27068
27079
  const taskFile = path2.join(plan.home, "zopu-machines.task.xml");
@@ -27077,8 +27088,9 @@ var windows = (plan) => {
27077
27088
  return {
27078
27089
  file: taskFile,
27079
27090
  install: [
27080
- writeFile2(launcher, renderLauncher(plan, { logFile: plan.logFile })),
27091
+ writeUtf16(launcher, renderLauncher(plan, { logFile: plan.logFile })),
27081
27092
  writeUtf16(taskFile, renderTask({ launcher, user })),
27093
+ attempt("schtasks", ["/End", "/TN", name]),
27082
27094
  schtasks(["/Create", "/TN", name, "/XML", taskFile, "/F"]),
27083
27095
  schtasks(["/Run", "/TN", name])
27084
27096
  ],
@@ -27086,15 +27098,8 @@ var windows = (plan) => {
27086
27098
  const installed = yield* fileExists(taskFile);
27087
27099
  const shown = yield* exports_Effect.result(state());
27088
27100
  const running = !exports_Result.isFailure(shown) && /\bRunning\b/u.test(shown.success);
27089
- let pid = null;
27090
- if (running) {
27091
- const held = yield* exports_Effect.result(exports_Effect.promise(() => fs.readFile(path2.join(plan.home, "state.json"), "utf-8")));
27092
- if (!exports_Result.isFailure(held)) {
27093
- const parsed = JSON.parse(held.success);
27094
- pid = typeof parsed.pid === "number" ? parsed.pid : null;
27095
- }
27096
- }
27097
- return { installed, linger: "yes", pid, running };
27101
+ const written = yield* satellitePid(plan.home);
27102
+ return { installed, linger: "yes", pid: running ? written : null, running };
27098
27103
  }),
27099
27104
  uninstall: [
27100
27105
  attempt("schtasks", ["/End", "/TN", name]),
@@ -28033,7 +28038,9 @@ var PLAN_FILE = path4.join(HOME, "service.json");
28033
28038
  var writeState = async (link2) => {
28034
28039
  await mkdir4(HOME, { recursive: true });
28035
28040
  const state = { at: Date.now(), link: link2, pid: process.pid };
28036
- await writeFile4(STATE_FILE, JSON.stringify(state));
28041
+ const temporary = `${STATE_FILE}.${process.pid}.tmp`;
28042
+ await writeFile4(temporary, JSON.stringify(state));
28043
+ await rename2(temporary, STATE_FILE);
28037
28044
  };
28038
28045
  var SERVICE_LOG = process.env.ZOPU_MACHINE_LOG;
28039
28046
  var say = (line2) => {
@@ -28101,8 +28108,8 @@ var run2 = async () => {
28101
28108
  };
28102
28109
  var bundlePath = async () => {
28103
28110
  const file = import.meta.filename ?? "";
28104
- if (path4.basename(file) !== "getzopu.mjs" || path4.basename(path4.dirname(file)) !== "dist") {
28105
- throw new Error("The background service needs the published program (npx getzopu …). Run with --foreground from a source checkout.");
28111
+ if (path4.basename(file) !== "getzopu.mjs") {
28112
+ throw new Error("The background service needs the published program, the one file named getzopu.mjs (npx getzopu …, or the file from get.zopu.live). Run with --foreground from a source checkout.");
28106
28113
  }
28107
28114
  await stat3(file);
28108
28115
  return file;
@@ -28129,7 +28136,7 @@ var planService = async () => {
28129
28136
  };
28130
28137
  var describe = (service4) => {
28131
28138
  if (service4.running) {
28132
- return `The service is running (process ${String(service4.pid)}).`;
28139
+ return service4.pid === null ? "The service is running." : `The service is running (process ${String(service4.pid)}).`;
28133
28140
  }
28134
28141
  if (service4.installed) {
28135
28142
  return "The service is installed, not running.";
@@ -28455,7 +28462,7 @@ var main = async () => {
28455
28462
  mode: 384
28456
28463
  });
28457
28464
  await chmod2(temporary, 384);
28458
- await rename2(temporary, configFile);
28465
+ await rename3(temporary, configFile);
28459
28466
  console.log("Signed in. Token saved privately.");
28460
28467
  return;
28461
28468
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getzopu",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Zopu CLI: projects, threads, and connecting your own computer to Zopu.",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {