@trackseries/cli 0.1.0-preview.2 → 0.2.0
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 +2 -2
- package/bin/trackseries.js +5 -0
- package/package.json +2 -1
- package/scripts/install.js +28 -6
- package/scripts/platform.js +6 -1
package/README.md
CHANGED
|
@@ -34,10 +34,10 @@ After installation, authenticate and inspect the available commands:
|
|
|
34
34
|
```bash
|
|
35
35
|
trackseries auth login
|
|
36
36
|
trackseries auth status
|
|
37
|
-
trackseries skill
|
|
37
|
+
trackseries --skill
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
`trackseries skill` prints version-matched instructions designed for coding agents and other automated tools.
|
|
40
|
+
`trackseries --skill` prints version-matched instructions designed for coding agents and other automated tools.
|
|
41
41
|
|
|
42
42
|
## Updates
|
|
43
43
|
|
package/bin/trackseries.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { ensureBinary } from "../scripts/install.js";
|
|
6
|
+
import { binaryRoot } from "../scripts/platform.js";
|
|
6
7
|
|
|
7
8
|
let executablePath;
|
|
8
9
|
try {
|
|
@@ -13,6 +14,10 @@ try {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const result = spawnSync(executablePath, process.argv.slice(2), {
|
|
17
|
+
env: {
|
|
18
|
+
...process.env,
|
|
19
|
+
TRACKSERIES_CLI_BINARY_ROOT: binaryRoot()
|
|
20
|
+
},
|
|
16
21
|
stdio: "inherit"
|
|
17
22
|
});
|
|
18
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackseries/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Install and run the TrackSeries CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"fflate": "0.8.3",
|
|
22
|
+
"semver": "7.8.5",
|
|
22
23
|
"tar": "7.5.22"
|
|
23
24
|
},
|
|
24
25
|
"publishConfig": {
|
package/scripts/install.js
CHANGED
|
@@ -4,8 +4,9 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { unzipSync } from "fflate";
|
|
7
|
+
import { gt, valid } from "semver";
|
|
7
8
|
import { x as extractTar } from "tar";
|
|
8
|
-
import { assertSupportedRuntime, binaryDirectory, releaseArtifact } from "./platform.js";
|
|
9
|
+
import { assertSupportedRuntime, binaryDirectory, binaryRoot, releaseArtifact } from "./platform.js";
|
|
9
10
|
|
|
10
11
|
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
12
|
const metadata = JSON.parse(await readFile(resolve(packageRoot, "package.json"), "utf8"));
|
|
@@ -54,11 +55,13 @@ async function isRegularFile(path) {
|
|
|
54
55
|
|
|
55
56
|
export async function ensureBinary() {
|
|
56
57
|
assertSupportedRuntime();
|
|
57
|
-
const
|
|
58
|
+
const root = binaryRoot();
|
|
59
|
+
const version = await resolveBinaryVersion(metadata.version, root);
|
|
60
|
+
const artifact = releaseArtifact(version);
|
|
58
61
|
const releaseBaseUrl =
|
|
59
|
-
process.env.TRACKSERIES_CLI_RELEASE_BASE_URL ?? `https://github.com/TrackSeries/cli/releases/download/cli-v${
|
|
62
|
+
process.env.TRACKSERIES_CLI_RELEASE_BASE_URL ?? `https://github.com/TrackSeries/cli/releases/download/cli-v${version}`;
|
|
60
63
|
const executableName = process.platform === "win32" ? "trackseries.exe" : "trackseries";
|
|
61
|
-
const installedExecutable = resolve(binaryDirectory(
|
|
64
|
+
const installedExecutable = resolve(binaryDirectory(version), executableName);
|
|
62
65
|
|
|
63
66
|
if (await isRegularFile(installedExecutable)) return installedExecutable;
|
|
64
67
|
|
|
@@ -67,7 +70,7 @@ export async function ensureBinary() {
|
|
|
67
70
|
const extractionPath = resolve(temporaryDirectory, "extracted");
|
|
68
71
|
const pendingExecutable = `${installedExecutable}.${process.pid}.tmp`;
|
|
69
72
|
|
|
70
|
-
console.error(`Downloading TrackSeries CLI ${
|
|
73
|
+
console.error(`Downloading TrackSeries CLI ${version} for ${process.platform}-${process.arch}...`);
|
|
71
74
|
|
|
72
75
|
try {
|
|
73
76
|
const [archive, checksumFile] = await Promise.all([
|
|
@@ -119,7 +122,7 @@ export async function ensureBinary() {
|
|
|
119
122
|
} catch (error) {
|
|
120
123
|
const reason = error instanceof Error ? error.message : String(error);
|
|
121
124
|
throw new Error(
|
|
122
|
-
`Unable to install TrackSeries CLI ${
|
|
125
|
+
`Unable to install TrackSeries CLI ${version}: ${reason} Download ${artifact} manually from ${releaseBaseUrl}.`,
|
|
123
126
|
{ cause: error }
|
|
124
127
|
);
|
|
125
128
|
} finally {
|
|
@@ -127,3 +130,22 @@ export async function ensureBinary() {
|
|
|
127
130
|
await rm(temporaryDirectory, { force: true, recursive: true });
|
|
128
131
|
}
|
|
129
132
|
}
|
|
133
|
+
|
|
134
|
+
export async function resolveBinaryVersion(packageVersion, root) {
|
|
135
|
+
const manifestPath = resolve(root, "current.json");
|
|
136
|
+
let manifest;
|
|
137
|
+
try {
|
|
138
|
+
manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
141
|
+
return packageVersion;
|
|
142
|
+
}
|
|
143
|
+
throw new Error(`Unable to read the TrackSeries CLI update state at ${manifestPath}.`, { cause: error });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const activeVersion = typeof manifest?.version === "string" ? valid(manifest.version) : null;
|
|
147
|
+
if (!activeVersion) {
|
|
148
|
+
throw new Error(`The TrackSeries CLI update state at ${manifestPath} contains an invalid version.`);
|
|
149
|
+
}
|
|
150
|
+
return gt(activeVersion, packageVersion) ? activeVersion : packageVersion;
|
|
151
|
+
}
|
package/scripts/platform.js
CHANGED
|
@@ -25,6 +25,11 @@ export function assertSupportedRuntime(platform = process.platform, report = pro
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function binaryDirectory(version, platform = process.platform, environment = process.env, home = homedir()) {
|
|
28
|
+
const path = platform === "win32" ? win32 : posix;
|
|
29
|
+
return path.join(binaryRoot(platform, environment, home), version);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function binaryRoot(platform = process.platform, environment = process.env, home = homedir()) {
|
|
28
33
|
const path = platform === "win32" ? win32 : posix;
|
|
29
34
|
let dataDirectory;
|
|
30
35
|
|
|
@@ -36,5 +41,5 @@ export function binaryDirectory(version, platform = process.platform, environmen
|
|
|
36
41
|
dataDirectory = environment.XDG_DATA_HOME ?? path.join(home, ".local", "share");
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
return path.join(dataDirectory, "trackseries", "bin"
|
|
44
|
+
return path.join(dataDirectory, "trackseries", "bin");
|
|
40
45
|
}
|