cicy-code 2.1.46 → 2.1.47
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/cicy-code.js +28 -90
- package/package.json +8 -6
- package/scripts/install.js +0 -60
package/bin/cicy-code.js
CHANGED
|
@@ -1,96 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// Thin launcher: resolves the prebuilt binary that ships in the
|
|
3
|
+
// platform-specific optionalDependency (cicy-code-<os>-<cpu>) and execs it.
|
|
4
|
+
// No network, no postinstall download — npm installs only the sub-package
|
|
5
|
+
// matching the current os/cpu (the others are skipped via their os/cpu
|
|
6
|
+
// fields), so a CN user pulls just their ~30MB slice from npmmirror.
|
|
7
|
+
const { spawn } = require('child_process');
|
|
4
8
|
const fs = require('fs');
|
|
5
|
-
const https = require('https');
|
|
6
9
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function checkUpdate() {
|
|
22
|
-
const registry = cn
|
|
23
|
-
? 'https://registry.npmmirror.com/cicy-code/latest'
|
|
24
|
-
: 'https://registry.npmjs.org/cicy-code/latest';
|
|
25
|
-
if (cn) console.log(` [mirror] Registry: registry.npmmirror.com`);
|
|
26
|
-
return new Promise((resolve) => {
|
|
27
|
-
https.get(registry, (res) => {
|
|
28
|
-
let data = '';
|
|
29
|
-
res.on('data', (c) => data += c);
|
|
30
|
-
res.on('end', () => {
|
|
31
|
-
try {
|
|
32
|
-
const latest = JSON.parse(data).version;
|
|
33
|
-
if (latest && latest !== pkg.version) {
|
|
34
|
-
resolve(latest);
|
|
35
|
-
} else {
|
|
36
|
-
resolve(null);
|
|
37
|
-
}
|
|
38
|
-
} catch { resolve(null); }
|
|
39
|
-
});
|
|
40
|
-
}).on('error', () => resolve(null));
|
|
41
|
-
});
|
|
10
|
+
const platformPkg = `cicy-code-${process.platform}-${process.arch}`;
|
|
11
|
+
|
|
12
|
+
let binPath;
|
|
13
|
+
try {
|
|
14
|
+
// require.resolve finds the binary inside the installed sub-package,
|
|
15
|
+
// wherever the package manager hoisted it.
|
|
16
|
+
binPath = require.resolve(`${platformPkg}/cicy-code`);
|
|
17
|
+
} catch {
|
|
18
|
+
console.error(`cicy-code: no prebuilt binary for ${process.platform}-${process.arch}.`);
|
|
19
|
+
console.error(`The optional dependency "${platformPkg}" is not installed.`);
|
|
20
|
+
console.error(`Supported platforms: darwin-arm64, darwin-x64, linux-x64, linux-arm64.`);
|
|
21
|
+
console.error(`Reinstall: npm install -g cicy-code` +
|
|
22
|
+
` (in China add --registry=https://registry.npmmirror.com)`);
|
|
23
|
+
process.exit(1);
|
|
42
24
|
}
|
|
43
25
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
checkUpdate(),
|
|
48
|
-
new Promise(r => setTimeout(() => r(null), 3000))
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
if (latest && !process.env.CICY_SKIP_UPDATE) {
|
|
52
|
-
console.log(`\n Update available: ${pkg.version} → ${latest}`);
|
|
53
|
-
console.log(` Updating...\n`);
|
|
54
|
-
try {
|
|
55
|
-
const npmCmd = cn
|
|
56
|
-
? `npm install -g cicy-code@${latest} --registry=https://registry.npmmirror.com`
|
|
57
|
-
: `npm install -g cicy-code@${latest}`;
|
|
58
|
-
execSync(npmCmd, { stdio: 'inherit' });
|
|
59
|
-
console.log(`\n Updated to ${latest}! Restarting...\n`);
|
|
60
|
-
// Re-exec with new version
|
|
61
|
-
const child = spawn('cicy-code', process.argv.slice(2), { stdio: 'inherit', env: process.env });
|
|
62
|
-
child.on('exit', (code) => process.exit(code || 0));
|
|
63
|
-
return;
|
|
64
|
-
} catch (e) {
|
|
65
|
-
console.log(` Update failed, running current version.\n`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Install globally if not already
|
|
70
|
-
try {
|
|
71
|
-
const globalBin = execSync('npm prefix -g', { encoding: 'utf8' }).trim() + '/bin/cicy-code';
|
|
72
|
-
if (!fs.existsSync(globalBin)) throw new Error('not installed');
|
|
73
|
-
} catch {
|
|
74
|
-
console.log(' Installing cicy-code globally...');
|
|
75
|
-
try {
|
|
76
|
-
const npmCmd = cn
|
|
77
|
-
? 'npm install -g cicy-code --registry=https://registry.npmmirror.com'
|
|
78
|
-
: 'npm install -g cicy-code';
|
|
79
|
-
execSync(npmCmd, { stdio: 'inherit' });
|
|
80
|
-
console.log(' Installed! You can now run: cicy-code\n');
|
|
81
|
-
} catch {}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (!fs.existsSync(binPath)) {
|
|
85
|
-
console.error('Binary not found. Reinstall: npm install -g cicy-code');
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const child = spawn(binPath, process.argv.slice(2), {
|
|
90
|
-
stdio: 'inherit',
|
|
91
|
-
env: process.env
|
|
92
|
-
});
|
|
93
|
-
child.on('exit', (code) => process.exit(code || 0));
|
|
94
|
-
}
|
|
26
|
+
// npm restores the 0755 mode from the tarball, but chmod defensively in case
|
|
27
|
+
// a mirror or extraction stripped the exec bit.
|
|
28
|
+
try { fs.chmodSync(binPath, 0o755); } catch {}
|
|
95
29
|
|
|
96
|
-
|
|
30
|
+
const child = spawn(binPath, process.argv.slice(2), { stdio: 'inherit', env: process.env });
|
|
31
|
+
child.on('exit', (code, signal) => {
|
|
32
|
+
if (signal) process.kill(process.pid, signal);
|
|
33
|
+
else process.exit(code == null ? 0 : code);
|
|
34
|
+
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "2.1.
|
|
6
|
+
"version": "2.1.47",
|
|
7
7
|
"description": "CiCy Code - AI-powered development environment",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "cicybot",
|
|
@@ -12,13 +12,15 @@
|
|
|
12
12
|
"bin": {
|
|
13
13
|
"cicy-code": "bin/cicy-code.js"
|
|
14
14
|
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"postinstall": "node scripts/install.js"
|
|
17
|
-
},
|
|
18
15
|
"files": [
|
|
19
|
-
"bin/cicy-code.js"
|
|
20
|
-
"scripts/"
|
|
16
|
+
"bin/cicy-code.js"
|
|
21
17
|
],
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"cicy-code-darwin-arm64": "2.1.47",
|
|
20
|
+
"cicy-code-darwin-x64": "2.1.47",
|
|
21
|
+
"cicy-code-linux-x64": "2.1.47",
|
|
22
|
+
"cicy-code-linux-arm64": "2.1.47"
|
|
23
|
+
},
|
|
22
24
|
"repository": {
|
|
23
25
|
"type": "git",
|
|
24
26
|
"url": "git+https://github.com/cicy-ai/cicy-code.git"
|
package/scripts/install.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const https = require('https');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
const VERSION = require('../package.json').version;
|
|
6
|
-
const GH_URL = `https://github.com/cicy-ai/cicy-code/releases/download/v${VERSION}`;
|
|
7
|
-
const CN_URL = `https://gh-proxy.com/https://github.com/cicy-ai/cicy-code/releases/download/v${VERSION}`;
|
|
8
|
-
|
|
9
|
-
const cn = process.env.CN_MIRROR === '1' || process.argv.includes('--cn');
|
|
10
|
-
const BASE_URL = cn ? CN_URL : GH_URL;
|
|
11
|
-
|
|
12
|
-
const PLATFORMS = {
|
|
13
|
-
'darwin-arm64': 'cicy-code-darwin-arm64',
|
|
14
|
-
'darwin-x64': 'cicy-code-darwin-amd64',
|
|
15
|
-
'linux-x64': 'cicy-code-linux-amd64',
|
|
16
|
-
'linux-arm64': 'cicy-code-linux-arm64',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const key = `${process.platform}-${process.arch}`;
|
|
20
|
-
const binName = PLATFORMS[key];
|
|
21
|
-
|
|
22
|
-
if (!binName) {
|
|
23
|
-
if (process.platform === 'win32') {
|
|
24
|
-
console.error('Windows is not supported natively. Please use WSL:\n wsl --install\n wsl npx cicy-code');
|
|
25
|
-
} else {
|
|
26
|
-
console.error(`Unsupported platform: ${key}`);
|
|
27
|
-
}
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const binDir = path.join(__dirname, '..', 'bin');
|
|
32
|
-
const binPath = path.join(binDir, 'cicy-code');
|
|
33
|
-
const url = `${BASE_URL}/${binName}`;
|
|
34
|
-
|
|
35
|
-
console.log(`Downloading ${binName}${cn ? ' (CN mirror: gh-proxy.com)' : ''}...`);
|
|
36
|
-
console.log(` URL: ${url}`);
|
|
37
|
-
|
|
38
|
-
function download(url, dest, redirects = 5) {
|
|
39
|
-
return new Promise((resolve, reject) => {
|
|
40
|
-
if (redirects === 0) return reject(new Error('Too many redirects'));
|
|
41
|
-
const proto = url.startsWith('https') ? https : require('http');
|
|
42
|
-
proto.get(url, (res) => {
|
|
43
|
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
44
|
-
return download(res.headers.location, dest, redirects - 1).then(resolve).catch(reject);
|
|
45
|
-
}
|
|
46
|
-
if (res.statusCode !== 200) return reject(new Error(`HTTP ${res.statusCode}`));
|
|
47
|
-
const file = fs.createWriteStream(dest);
|
|
48
|
-
res.pipe(file);
|
|
49
|
-
file.on('finish', () => { file.close(); fs.chmodSync(dest, 0o755); resolve(); });
|
|
50
|
-
}).on('error', reject);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
download(url, binPath)
|
|
55
|
-
.then(() => console.log('Done!'))
|
|
56
|
-
.catch((err) => {
|
|
57
|
-
console.error('Download failed:', err.message);
|
|
58
|
-
if (!cn) console.error('Try: CN_MIRROR=1 npx cicy-code');
|
|
59
|
-
process.exit(1);
|
|
60
|
-
});
|