@felixaihub/snailer 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.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @snailer/cli
2
+
3
+ Installer wrapper that downloads the Snailer binary from GitHub Releases during postinstall.
package/bin/snailer.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ const { spawn } = require('node:child_process');
3
+ const path = require('node:path');
4
+ const os = require('node:os');
5
+ const fs = require('node:fs');
6
+
7
+ const binDir = path.join(__dirname, '..', 'bin');
8
+ const exe = os.platform() === 'win32' ? 'snailer.exe' : 'snailer';
9
+ const bin = path.join(binDir, exe);
10
+
11
+ if (!fs.existsSync(bin)) {
12
+ console.error('[snailer] Binary is missing. Reinstall or download from Releases.');
13
+ process.exit(1);
14
+ }
15
+
16
+ const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit' });
17
+ child.on('exit', (code) => process.exit(code));
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@felixaihub/snailer",
3
+ "version": "0.1.0",
4
+ "description": "AI-powered development CLI (installer wrapper)",
5
+ "bin": { "snailer": "bin/snailer.js" },
6
+ "files": ["bin", "scripts", "README.md", "../EULA.md", "../LICENSE"],
7
+ "scripts": { "postinstall": "node scripts/postinstall.js" },
8
+ "os": ["darwin", "linux", "win32"],
9
+ "cpu": ["x64", "arm64"],
10
+ "engines": { "node": ">=16" },
11
+ "repository": "https://github.com/felixaihub/snailer-cli",
12
+ "license": "MIT",
13
+ "publishConfig": { "access": "public" }
14
+ }
@@ -0,0 +1,49 @@
1
+ const { execSync } = require('node:child_process');
2
+ const os = require('node:os');
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+
6
+ if (process.env.SNAILER_SKIP_POSTINSTALL === '1') {
7
+ console.log('[snailer] Skipping binary download (SNAILER_SKIP_POSTINSTALL=1).');
8
+ process.exit(0);
9
+ }
10
+
11
+ const org = process.env.SNAILER_ORG || 'felixaihub';
12
+ const repo = process.env.SNAILER_REPO || 'snailer-cli';
13
+ const version = 'v' + (process.env.npm_package_version || '0.1.0');
14
+
15
+ function triple() {
16
+ const plat = os.platform();
17
+ const arch = os.arch();
18
+ if (plat === 'darwin' && arch === 'arm64') return 'aarch64-apple-darwin';
19
+ if (plat === 'darwin') return 'x86_64-apple-darwin';
20
+ if (plat === 'linux' && arch === 'arm64') return 'aarch64-unknown-linux-musl';
21
+ if (plat === 'linux') return 'x86_64-unknown-linux-musl';
22
+ if (plat === 'win32') return 'x86_64-pc-windows-msvc';
23
+ throw new Error(`Unsupported platform ${plat}/${arch}`);
24
+ }
25
+
26
+ const plat = os.platform();
27
+ const isWin = plat === 'win32';
28
+ const asset = `snailer-${version}-${triple()}.${isWin ? 'zip' : 'tar.gz'}`;
29
+ const url = `https://github.com/${org}/${repo}/releases/download/${version}/${asset}`;
30
+
31
+ const binDir = path.join(__dirname, '..', 'bin');
32
+ fs.mkdirSync(binDir, { recursive: true });
33
+ const tmp = path.join(os.tmpdir(), asset);
34
+
35
+ try {
36
+ if (isWin) {
37
+ execSync(`powershell -NoProfile -Command \"Invoke-WebRequest -Uri '${url}' -OutFile '${tmp}'; Expand-Archive -LiteralPath '${tmp}' -DestinationPath '${binDir}' -Force\"`, { stdio: 'inherit' });
38
+ } else {
39
+ execSync(`curl -L '${url}' -o '${tmp}'`, { stdio: 'inherit' });
40
+ execSync(`tar -xzf '${tmp}' -C '${binDir}'`, { stdio: 'inherit' });
41
+ execSync(`chmod +x '${path.join(binDir, 'snailer')}'`, { stdio: 'inherit' });
42
+ }
43
+ console.log(`[snailer] Installed binary from ${url}`);
44
+ console.log('[snailer] By installing, you agree to the Snailer EULA: https://github.com/felixaihub/snailer-cli/blob/main/EULA.md');
45
+ } catch (e) {
46
+ console.error('[snailer] Failed to download/install binary.');
47
+ console.error(`[snailer] Manual download: ${url}`);
48
+ process.exit(1);
49
+ }