@t2code/cli 0.1.1-nightly.20261017.109 → 0.1.4-nightly.20261029.135
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/t2code.mjs +9 -16
- package/dist/bin.mjs +1 -1
- package/package.json +1 -1
package/bin/t2code.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// The `@t2code/cli` npm package. Downloads this version's CLI archive from the
|
|
3
|
-
// Release into <T2 home>/runtime/versions/<version
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// installed before 0.0.41, which start the npm package with Node and talk to
|
|
7
|
-
// it over an IPC channel.
|
|
2
|
+
// The `@t2code/cli` npm package. Downloads this version's CLI archive from the
|
|
3
|
+
// GitHub Release into <T2 home>/runtime/versions/<version>, verifies it against
|
|
4
|
+
// the release's SHA256SUMS, then runs it. `dist/bin.mjs` re-enters here for
|
|
5
|
+
// pre-0.0.41 background services, which start the package with Node over IPC.
|
|
8
6
|
import { spawn, spawnSync } from "node:child_process";
|
|
9
7
|
import crypto from "node:crypto";
|
|
10
8
|
import fs from "node:fs";
|
|
@@ -36,7 +34,6 @@ async function get(url) {
|
|
|
36
34
|
return response;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
/** Downloads `url` to `file` and returns its sha256, showing progress on a terminal. */
|
|
40
37
|
async function download(url, file) {
|
|
41
38
|
const response = await get(url);
|
|
42
39
|
const total = Number(response.headers.get("content-length")) || 0;
|
|
@@ -80,8 +77,7 @@ async function install(dir, key) {
|
|
|
80
77
|
.find((m) => m && m[2] === archive);
|
|
81
78
|
if (!line) throw new Error(`${archive} is not listed in the release's SHA256SUMS`);
|
|
82
79
|
|
|
83
|
-
//
|
|
84
|
-
// interrupted download never leaves a half-installed version behind.
|
|
80
|
+
// Stage beside the destination and rename atomically to avoid half-installed versions.
|
|
85
81
|
fs.mkdirSync(path.dirname(dir), { recursive: true });
|
|
86
82
|
const staging = fs.mkdtempSync(`${dir}.staging-`);
|
|
87
83
|
try {
|
|
@@ -114,10 +110,9 @@ const isComplete = (dir) => {
|
|
|
114
110
|
|
|
115
111
|
/**
|
|
116
112
|
* Moves a finished staging folder to `dir`. Rename never replaces an existing
|
|
117
|
-
* folder, so a complete install
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* cleared before trying again.
|
|
113
|
+
* folder, so a complete install published first is kept, never deleted under a
|
|
114
|
+
* running process. Only a folder without the completion marker, left by an
|
|
115
|
+
* interrupted older installer, is cleared before trying again.
|
|
121
116
|
*/
|
|
122
117
|
function publish(staging, dir) {
|
|
123
118
|
try {
|
|
@@ -141,9 +136,7 @@ async function main() {
|
|
|
141
136
|
const dir = path.join(t2Home(), "runtime", "versions", version);
|
|
142
137
|
if (!isComplete(dir)) await install(dir, key);
|
|
143
138
|
|
|
144
|
-
//
|
|
145
|
-
// signals through. In a terminal, Ctrl-C already reaches the child directly,
|
|
146
|
-
// so forwarding SIGINT too would deliver it twice.
|
|
139
|
+
// Service IPC and signals must reach the child; terminal Ctrl-C already does, so do not forward SIGINT twice.
|
|
147
140
|
const ipc = process.send !== undefined;
|
|
148
141
|
const child = spawn(
|
|
149
142
|
path.join(dir, process.platform === "win32" ? "t2.exe" : "t2"),
|
package/dist/bin.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Legacy background services still enter the npm package through this path.
|
|
2
2
|
import "../bin/t2code.mjs";
|
package/package.json
CHANGED