gclm-code 1.0.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 (3) hide show
  1. package/README.md +3 -0
  2. package/bin/gc.js +56 -0
  3. package/package.json +27 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # gclm-code
2
+
3
+ Generated binary launcher package.
package/bin/gc.js ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'node:child_process'
3
+ import { existsSync } from 'node:fs'
4
+ import { createRequire } from 'node:module'
5
+ import { dirname, join } from 'node:path'
6
+
7
+ const require = createRequire(import.meta.url)
8
+ const packageMap = {
9
+ "darwin": {
10
+ "x64": "gclm-code-darwin-x64",
11
+ "arm64": "gclm-code-darwin-arm64"
12
+ }
13
+ }
14
+
15
+ function fail(message) {
16
+ process.stderr.write(`[gclm-code] ${message}\n`)
17
+ process.exit(1)
18
+ }
19
+
20
+ const osPackageMap = packageMap[process.platform]
21
+ if (!osPackageMap) {
22
+ fail(`当前暂不支持平台: ${process.platform}`)
23
+ }
24
+
25
+ const packageName = osPackageMap[process.arch]
26
+ if (!packageName) {
27
+ fail(`当前暂不支持平台组合: ${process.platform}/${process.arch}`)
28
+ }
29
+
30
+ let packageJsonPath
31
+ try {
32
+ packageJsonPath = require.resolve(`${packageName}/package.json`)
33
+ } catch {
34
+ fail(`未找到匹配架构包 ${packageName},请重新安装 gclm-code`)
35
+ }
36
+
37
+ const binaryPath = join(dirname(packageJsonPath), 'bin', 'gc')
38
+ if (!existsSync(binaryPath)) {
39
+ fail(`${packageName} 缺少可执行文件: ${binaryPath}`)
40
+ }
41
+
42
+ const child = spawn(binaryPath, process.argv.slice(2), {
43
+ stdio: 'inherit',
44
+ })
45
+
46
+ child.on('error', error => {
47
+ fail(`启动 ${packageName} 失败: ${error.message}`)
48
+ })
49
+
50
+ child.on('exit', (code, signal) => {
51
+ if (signal) {
52
+ process.kill(process.pid, signal)
53
+ return
54
+ }
55
+ process.exit(code ?? 1)
56
+ })
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "gclm-code",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "description": "Binary launcher package for Gclm Code.",
6
+ "type": "module",
7
+ "license": "UNLICENSED",
8
+ "os": [
9
+ "darwin"
10
+ ],
11
+ "cpu": [
12
+ "x64",
13
+ "arm64"
14
+ ],
15
+ "bin": {
16
+ "gc": "./bin/gc.js",
17
+ "claude": "./bin/gc.js"
18
+ },
19
+ "optionalDependencies": {
20
+ "gclm-code-darwin-x64": "1.0.0",
21
+ "gclm-code-darwin-arm64": "1.0.0"
22
+ },
23
+ "files": [
24
+ "bin",
25
+ "README.md"
26
+ ]
27
+ }