arkroute 0.0.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.
- package/bin/arkroute.js +54 -0
- package/package.json +27 -0
- package/test/launcher.test.js +43 -0
- package/test/package-metadata.test.js +51 -0
package/bin/arkroute.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
export function platformPackageName(platform = process.platform, arch = process.arch) {
|
|
10
|
+
const key = `${platform}-${arch}`;
|
|
11
|
+
switch (key) {
|
|
12
|
+
case "darwin-arm64":
|
|
13
|
+
return "@arkroute/darwin-arm64";
|
|
14
|
+
case "darwin-x64":
|
|
15
|
+
return "@arkroute/darwin-x64";
|
|
16
|
+
case "linux-arm64":
|
|
17
|
+
return "@arkroute/linux-arm64";
|
|
18
|
+
case "linux-x64":
|
|
19
|
+
return "@arkroute/linux-x64";
|
|
20
|
+
case "win32-x64":
|
|
21
|
+
return "@arkroute/win32-x64";
|
|
22
|
+
default:
|
|
23
|
+
throw new Error(`unsupported platform ${key}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function binaryName(platform = process.platform) {
|
|
28
|
+
return platform === "win32" ? "arkroute.exe" : "arkroute";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function resolveBinary(platform = process.platform, arch = process.arch) {
|
|
32
|
+
const packageName = platformPackageName(platform, arch);
|
|
33
|
+
const packageJSON = require.resolve(`${packageName}/package.json`);
|
|
34
|
+
return path.join(path.dirname(packageJSON), "bin", binaryName(platform));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
38
|
+
if (__filename === path.resolve(process.argv[1])) {
|
|
39
|
+
let binary;
|
|
40
|
+
try {
|
|
41
|
+
binary = resolveBinary();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error(`Arkroute binary for ${process.platform}-${process.arch} is not installed.`);
|
|
44
|
+
console.error("Try reinstalling with optional dependencies enabled:");
|
|
45
|
+
console.error(" npm install -g arkroute");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
49
|
+
if (result.error) {
|
|
50
|
+
console.error(result.error.message);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
process.exit(result.status ?? 0);
|
|
54
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "arkroute",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Local AI model router for Claude Code and compatible provider gateways",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/bloodstalk1/arkroute"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"bin": {
|
|
12
|
+
"arkroute": "./bin/arkroute.js"
|
|
13
|
+
},
|
|
14
|
+
"optionalDependencies": {
|
|
15
|
+
"@arkroute/darwin-arm64": "0.0.1",
|
|
16
|
+
"@arkroute/darwin-x64": "0.0.1",
|
|
17
|
+
"@arkroute/linux-arm64": "0.0.1",
|
|
18
|
+
"@arkroute/linux-x64": "0.0.1",
|
|
19
|
+
"@arkroute/win32-x64": "0.0.1"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "node --test test/*.test.js"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { platformPackageName, binaryName, resolveBinary } from "../bin/arkroute.js";
|
|
4
|
+
|
|
5
|
+
test("platformPackageName resolves supported packages", () => {
|
|
6
|
+
assert.equal(platformPackageName("darwin", "arm64"), "@arkroute/darwin-arm64");
|
|
7
|
+
assert.equal(platformPackageName("linux", "x64"), "@arkroute/linux-x64");
|
|
8
|
+
assert.equal(platformPackageName("win32", "x64"), "@arkroute/win32-x64");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("platformPackageName rejects unsupported targets", () => {
|
|
12
|
+
assert.throws(() => platformPackageName("freebsd", "x64"), /unsupported platform/);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("binaryName appends exe on windows", () => {
|
|
16
|
+
assert.equal(binaryName("win32"), "arkroute.exe");
|
|
17
|
+
assert.equal(binaryName("linux"), "arkroute");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("exports are intact after entrypoint refactor", () => {
|
|
21
|
+
assert.equal(typeof platformPackageName, "function");
|
|
22
|
+
assert.equal(typeof binaryName, "function");
|
|
23
|
+
assert.equal(typeof resolveBinary, "function");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("platformPackageName handles all supported platforms including win32", () => {
|
|
27
|
+
// Ensures the win32 platform (which uses backslash paths with spaces)
|
|
28
|
+
// is still a supported target after the portability fix
|
|
29
|
+
const winPkg = platformPackageName("win32", "x64");
|
|
30
|
+
assert.equal(winPkg, "@arkroute/win32-x64");
|
|
31
|
+
assert.equal(binaryName("win32"), "arkroute.exe");
|
|
32
|
+
|
|
33
|
+
// Verify all platforms round-trip correctly
|
|
34
|
+
const platforms = [
|
|
35
|
+
["darwin", "arm64"], ["darwin", "x64"],
|
|
36
|
+
["linux", "arm64"], ["linux", "x64"],
|
|
37
|
+
["win32", "x64"],
|
|
38
|
+
];
|
|
39
|
+
for (const [plat, arch] of platforms) {
|
|
40
|
+
const name = platformPackageName(plat, arch);
|
|
41
|
+
assert.match(name, /^@arkroute\//, `expected scoped package for ${plat}-${arch}`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const npmDir = join(__dirname, "..", "..");
|
|
9
|
+
const repoRoot = join(npmDir, "..");
|
|
10
|
+
const repositoryUrl = "https://github.com/bloodstalk1/arkroute";
|
|
11
|
+
|
|
12
|
+
const publishedPackageJsonPaths = [
|
|
13
|
+
join(npmDir, "arkroute", "package.json"),
|
|
14
|
+
join(npmDir, "platform", "darwin-arm64", "package.json"),
|
|
15
|
+
join(npmDir, "platform", "darwin-x64", "package.json"),
|
|
16
|
+
join(npmDir, "platform", "linux-arm64", "package.json"),
|
|
17
|
+
join(npmDir, "platform", "linux-x64", "package.json"),
|
|
18
|
+
join(npmDir, "platform", "win32-x64", "package.json"),
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
test("published npm packages declare the provenance repository", () => {
|
|
22
|
+
for (const packageJsonPath of publishedPackageJsonPaths) {
|
|
23
|
+
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
24
|
+
|
|
25
|
+
assert.deepEqual(
|
|
26
|
+
pkg.repository,
|
|
27
|
+
{ type: "git", url: repositoryUrl },
|
|
28
|
+
`${pkg.name} must match the GitHub Actions provenance repository`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("publish workflow uses explicit relative local package paths", () => {
|
|
34
|
+
const workflow = readFileSync(join(repoRoot, ".github", "workflows", "publish.yml"), "utf8");
|
|
35
|
+
|
|
36
|
+
assert.doesNotMatch(
|
|
37
|
+
workflow,
|
|
38
|
+
/\bnpm publish npm\//,
|
|
39
|
+
"npm publish treats npm/... as a package spec on GitHub Actions; use ./npm/...",
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("publish workflow skips package versions that already exist", () => {
|
|
44
|
+
const workflow = readFileSync(join(repoRoot, ".github", "workflows", "publish.yml"), "utf8");
|
|
45
|
+
|
|
46
|
+
assert.match(
|
|
47
|
+
workflow,
|
|
48
|
+
/npm view "\$package@\$\{\s*VERSION\s*\}"/,
|
|
49
|
+
"workflow must check npm before publishing so reruns do not fail on already-published versions",
|
|
50
|
+
);
|
|
51
|
+
});
|