doge-cc 0.1.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.
Files changed (2) hide show
  1. package/package.json +47 -0
  2. package/run.js +60 -0
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "doge-cc",
3
+ "version": "0.1.0",
4
+ "description": "柴犬 CC 助手初始化 CLI",
5
+ "type": "module",
6
+ "bin": {
7
+ "doge-cc": "./run.js"
8
+ },
9
+ "files": [
10
+ "run.js"
11
+ ],
12
+ "scripts": {
13
+ "start": "node ./run.js",
14
+ "build:current": "node ./build-binaries.mjs --current",
15
+ "build:all": "node ./build-binaries.mjs",
16
+ "check": "node --check ./run.js && go test ./...",
17
+ "test:smoke": "npm run build:current && node ./run.js --help"
18
+ },
19
+ "keywords": [
20
+ "npx",
21
+ "cli",
22
+ "codex",
23
+ "claude-code",
24
+ "shiba"
25
+ ],
26
+ "license": "MIT",
27
+ "os": [
28
+ "darwin",
29
+ "linux",
30
+ "win32"
31
+ ],
32
+ "cpu": [
33
+ "x64",
34
+ "arm64"
35
+ ],
36
+ "optionalDependencies": {
37
+ "doge-cc-darwin-amd64": "0.1.0",
38
+ "doge-cc-darwin-arm64": "0.1.0",
39
+ "doge-cc-linux-amd64": "0.1.0",
40
+ "doge-cc-linux-arm64": "0.1.0",
41
+ "doge-cc-windows-amd64": "0.1.0",
42
+ "doge-cc-windows-arm64": "0.1.0"
43
+ },
44
+ "engines": {
45
+ "node": ">=16"
46
+ }
47
+ }
package/run.js ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execFileSync } from "node:child_process";
4
+ import fs from "node:fs";
5
+ import { createRequire } from "node:module";
6
+ import path from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const require = createRequire(import.meta.url);
11
+ const PLATFORM_MAP = { darwin: "darwin", linux: "linux", win32: "windows" };
12
+ const ARCH_MAP = { x64: "amd64", arm64: "arm64" };
13
+ const BASE_NAME = "doge-cc";
14
+
15
+ main();
16
+
17
+ function main() {
18
+ const platform = mapValue(PLATFORM_MAP, process.platform, "当前系统暂不支持");
19
+ const arch = mapValue(ARCH_MAP, process.arch, "当前架构暂不支持");
20
+ const packageName = `${BASE_NAME}-${platform}-${arch}`;
21
+ const binaryName = process.platform === "win32" ? `${packageName}.exe` : packageName;
22
+ const binaryPath = resolveBinary(packageName, binaryName);
23
+
24
+ if (!binaryPath) {
25
+ console.error(`未找到可执行二进制: ${packageName}`);
26
+ console.error("请先运行 npm run build:current 或重新安装包。");
27
+ process.exit(1);
28
+ }
29
+
30
+ try {
31
+ execFileSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
32
+ } catch (error) {
33
+ process.exit(error.status || 1);
34
+ }
35
+ }
36
+
37
+ function resolveBinary(packageName, binaryName) {
38
+ const localPath = path.join(__dirname, "packages", packageName, "bin", binaryName);
39
+ if (fs.existsSync(localPath)) {
40
+ return localPath;
41
+ }
42
+
43
+ try {
44
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
45
+ const packageDir = path.dirname(packageJsonPath);
46
+ const binaryPath = path.join(packageDir, "bin", binaryName);
47
+ return fs.existsSync(binaryPath) ? binaryPath : "";
48
+ } catch {
49
+ return "";
50
+ }
51
+ }
52
+
53
+ function mapValue(map, key, message) {
54
+ const value = map[key];
55
+ if (value) {
56
+ return value;
57
+ }
58
+ console.error(`${message}: ${key}`);
59
+ process.exit(1);
60
+ }