tinovio-dev 0.0.0-stage → 0.3.25
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/tinovio-dev.cjs +82 -0
- package/package.json +23 -4
- package/README.md +0 -3
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The npm launcher (O296): it runs the native CLI from the platform package npm installed for this computer, with
|
|
3
|
+
// the same arguments, input, output, and exit code. The listener program sits next to it. One file serves both CLIs
|
|
4
|
+
// (specs/releases/02-cli-channels.md): the launcher `tinovio` runs `@tinovio/cli-<os>-<cpu>`, and `tinovio-dev`
|
|
5
|
+
// runs `@tinovio/cli-dev-<os>-<cpu>`. It reads its channel from its own package name.
|
|
6
|
+
"use strict";
|
|
7
|
+
const { spawnSync } = require("node:child_process");
|
|
8
|
+
const { randomUUID } = require("node:crypto");
|
|
9
|
+
const { mkdirSync, readFileSync, writeFileSync } = require("node:fs");
|
|
10
|
+
const { homedir } = require("node:os");
|
|
11
|
+
const { dirname, join } = require("node:path");
|
|
12
|
+
|
|
13
|
+
const home = dirname(__dirname);
|
|
14
|
+
const own = JSON.parse(readFileSync(join(home, "package.json"), "utf8"));
|
|
15
|
+
const command = own.name;
|
|
16
|
+
const dev = command === "tinovio-dev";
|
|
17
|
+
const version = own.version;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The npm install funnel (T-202): a launcher that cannot start the CLI leaves one metadata record where install.sh
|
|
21
|
+
* leaves its own, and the CLI sends it when it next runs (cli/src/install-activity.ts). A closed reason only.
|
|
22
|
+
*/
|
|
23
|
+
function recordFailure(reason) {
|
|
24
|
+
try {
|
|
25
|
+
const dir = join(
|
|
26
|
+
process.env.TINOVIO_HOME || join(homedir(), dev ? ".tinovio-dev" : ".tinovio"),
|
|
27
|
+
"install-activity",
|
|
28
|
+
);
|
|
29
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
30
|
+
const id = randomUUID();
|
|
31
|
+
const now = Date.now();
|
|
32
|
+
const context = { call_id: randomUUID(), started_at_ms: now, phase: "finished", source: "installer" };
|
|
33
|
+
const event = { id, action: "install", result: "failed", reason, at_ms: now, context };
|
|
34
|
+
const fallback = dev ? "https://api.dev.tinovio.com" : "https://api.tinovio.com";
|
|
35
|
+
const api = (process.env.TINOVIO_API_URL || fallback).replace(/\/$/, "");
|
|
36
|
+
writeFileSync(join(dir, `${id}.json`), JSON.stringify({ api, event }), { mode: 0o600 });
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const os = process.platform;
|
|
41
|
+
const cpu = process.arch;
|
|
42
|
+
// glibcVersionRuntime is absent on musl Linux (the check esbuild uses).
|
|
43
|
+
const musl = os === "linux" && !process.report?.getReport?.().header?.glibcVersionRuntime;
|
|
44
|
+
const target = `cli${dev ? "-dev" : ""}-${os}-${cpu}${musl ? "-musl" : ""}`;
|
|
45
|
+
const name = `@tinovio/${target}`;
|
|
46
|
+
|
|
47
|
+
// T-98: only where npm puts this launcher's build, nested (global) or next to it (local, pnpm). Never
|
|
48
|
+
// require.resolve, which walks up to every parent node_modules and ran a stale 0.2.1 from the home folder.
|
|
49
|
+
const builds = [join(home, "node_modules", "@tinovio", target), join(dirname(home), "@tinovio", target)].flatMap(
|
|
50
|
+
(dir) => {
|
|
51
|
+
try {
|
|
52
|
+
return [{ dir, version: JSON.parse(readFileSync(join(dir, "package.json"), "utf8")).version }];
|
|
53
|
+
} catch {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
const found = builds.find((b) => b.version === version) ?? builds[0];
|
|
59
|
+
if (found?.version !== version) {
|
|
60
|
+
process.stderr.write(
|
|
61
|
+
[
|
|
62
|
+
`Failed: ${command} did not start.`,
|
|
63
|
+
found
|
|
64
|
+
? `Why: the build for this computer, ${name}, is version ${found.version}, not ${version}.`
|
|
65
|
+
: `Why: npm did not install ${name} ${version}, the build for this computer.`,
|
|
66
|
+
`You can: Run npm install -g ${command}@latest again, or npm install ${command}@latest in the folder that holds this install, with optional dependencies allowed.`,
|
|
67
|
+
`Tell your human: No human step needed, unless the reinstall fails. Then: Tinovio could not install its build for ${os} ${cpu}${musl ? " musl" : ""} on this computer.`,
|
|
68
|
+
"",
|
|
69
|
+
].join("\n"),
|
|
70
|
+
);
|
|
71
|
+
recordFailure(found ? "launcher_version_mismatch" : "launcher_no_build");
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
const binary = join(found.dir, "bin", os === "win32" ? `${command}.exe` : command);
|
|
75
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit", windowsHide: false });
|
|
76
|
+
if (result.error) {
|
|
77
|
+
process.stderr.write(`Failed: ${command} did not start.\nWhy: ${result.error.message}\n`);
|
|
78
|
+
recordFailure("launcher_start");
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
if (result.signal) process.kill(process.pid, result.signal);
|
|
82
|
+
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinovio-dev",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.3.25",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"description": "The Tinovio dev CLI, for api.dev.tinovio.com. It has builds nobody tested yet. Install tinovio for Tinovio.",
|
|
6
|
+
"bin": {
|
|
7
|
+
"tinovio-dev": "bin/tinovio-dev.cjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
},
|
|
15
|
+
"optionalDependencies": {
|
|
16
|
+
"@tinovio/cli-dev-win32-x64": "0.3.25",
|
|
17
|
+
"@tinovio/cli-dev-win32-arm64": "0.3.25",
|
|
18
|
+
"@tinovio/cli-dev-darwin-x64": "0.3.25",
|
|
19
|
+
"@tinovio/cli-dev-darwin-arm64": "0.3.25",
|
|
20
|
+
"@tinovio/cli-dev-linux-x64": "0.3.25",
|
|
21
|
+
"@tinovio/cli-dev-linux-arm64": "0.3.25",
|
|
22
|
+
"@tinovio/cli-dev-linux-x64-musl": "0.3.25",
|
|
23
|
+
"@tinovio/cli-dev-linux-arm64-musl": "0.3.25"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/README.md
DELETED