catsift 0.3.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 +10 -0
- package/bin/catsift-bin-darwin-amd64 +0 -0
- package/bin/catsift-bin-darwin-arm64 +0 -0
- package/bin/catsift-bin-linux-amd64 +0 -0
- package/bin/catsift-bin-linux-arm64 +0 -0
- package/bin/catsift-bin-windows-amd64.exe +0 -0
- package/bin/catsift-bin-windows-arm64.exe +0 -0
- package/bin/catsift.js +40 -0
- package/package.json +39 -0
- package/scripts/platform.js +39 -0
package/README.md
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/catsift.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const { spawnSync } = require("node:child_process");
|
|
8
|
+
const { nativeBinaryName, targetFor } = require("../scripts/platform.js");
|
|
9
|
+
|
|
10
|
+
function nativeBinaryPath(platform = process.platform, arch = process.arch) {
|
|
11
|
+
return path.join(__dirname, nativeBinaryName(targetFor(platform, arch)));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function run(args) {
|
|
15
|
+
let nativePath;
|
|
16
|
+
try {
|
|
17
|
+
nativePath = nativeBinaryPath();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error(`catsift: ${error.message}`);
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!fs.existsSync(nativePath)) {
|
|
24
|
+
console.error("catsift: bundled native binary is missing; reinstall catsift");
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = spawnSync(nativePath, args, { stdio: "inherit" });
|
|
29
|
+
if (result.error) {
|
|
30
|
+
console.error(`[catsift] ${result.error.message}`);
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
return result.status ?? 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (require.main === module) {
|
|
37
|
+
process.exitCode = run(process.argv.slice(2));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = { nativeBinaryPath, run };
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "catsift",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "CLI for inspecting Codex usage",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"catsift": "bin/catsift.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"scripts",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"os": [
|
|
18
|
+
"darwin",
|
|
19
|
+
"linux",
|
|
20
|
+
"win32"
|
|
21
|
+
],
|
|
22
|
+
"cpu": [
|
|
23
|
+
"x64",
|
|
24
|
+
"arm64"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/xkumiyu/catsift.git"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/xkumiyu/catsift",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
33
|
+
"registry": "https://registry.npmjs.org"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "node --test",
|
|
37
|
+
"prepublishOnly": "npm test"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const GO_OS_BY_NODE_PLATFORM = {
|
|
4
|
+
darwin: "darwin",
|
|
5
|
+
linux: "linux",
|
|
6
|
+
win32: "windows",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const GO_ARCH_BY_NODE_ARCH = {
|
|
10
|
+
arm64: "arm64",
|
|
11
|
+
x64: "amd64",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function targetFor(platform, arch) {
|
|
15
|
+
const goOS = GO_OS_BY_NODE_PLATFORM[platform];
|
|
16
|
+
const goArch = GO_ARCH_BY_NODE_ARCH[arch];
|
|
17
|
+
|
|
18
|
+
if (!goOS || !goArch) {
|
|
19
|
+
throw new Error(`Unsupported platform or architecture: ${platform}/${arch}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return { os: goOS, arch: goArch };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function assetName(version, target) {
|
|
26
|
+
const name = `catsift_${version}_${target.os}_${target.arch}`;
|
|
27
|
+
return target.os === "windows" ? `${name}.exe` : name;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function nativeBinaryName(target) {
|
|
31
|
+
const name = `catsift-bin-${target.os}-${target.arch}`;
|
|
32
|
+
return target.os === "windows" ? `${name}.exe` : name;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
assetName,
|
|
37
|
+
nativeBinaryName,
|
|
38
|
+
targetFor,
|
|
39
|
+
};
|