aerostack 1.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 +41 -0
- package/bin/run.js +101 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# aerostack
|
|
2
|
+
|
|
3
|
+
Aerostack CLI - Zero-config serverless development for Cloudflare.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
**npm**
|
|
8
|
+
```bash
|
|
9
|
+
npm install -g aerostack
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**pnpm**
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add -g aerostack
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**yarn**
|
|
18
|
+
```bash
|
|
19
|
+
yarn global add aerostack
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**bun**
|
|
23
|
+
```bash
|
|
24
|
+
bun install -g aerostack
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**npx (no install)**
|
|
28
|
+
```bash
|
|
29
|
+
npx aerostack init my-app
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
aerostack init my-app
|
|
36
|
+
cd my-app
|
|
37
|
+
aerostack dev
|
|
38
|
+
aerostack deploy
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The first run downloads the binary from GitHub releases. Subsequent runs use the cached binary at `~/.aerostack/bin` (shared with the curl install).
|
package/bin/run.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Aerostack CLI - npm/pnpm/yarn wrapper
|
|
4
|
+
* Downloads the Go binary from GitHub releases on first run.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { spawn } = require("child_process");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
|
|
11
|
+
const REPO = "aerostackdev/cli";
|
|
12
|
+
const BINARY = "aerostack";
|
|
13
|
+
const INSTALL_DIR = process.env.AEROSTACK_INSTALL_DIR || path.join(process.env.HOME || process.env.USERPROFILE, ".aerostack", "bin");
|
|
14
|
+
|
|
15
|
+
function getPlatform() {
|
|
16
|
+
const platform = process.platform;
|
|
17
|
+
const arch = process.arch;
|
|
18
|
+
const map = {
|
|
19
|
+
darwin: { arm64: "darwin_arm64", x64: "darwin_amd64" },
|
|
20
|
+
linux: { arm64: "linux_arm64", x64: "linux_amd64" },
|
|
21
|
+
win32: { arm64: "windows_arm64", x64: "windows_amd64" },
|
|
22
|
+
};
|
|
23
|
+
const p = map[platform]?.[arch];
|
|
24
|
+
if (!p) throw new Error(`Unsupported platform: ${platform}-${arch}`);
|
|
25
|
+
return { platform, arch, asset: p };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function getLatestVersion() {
|
|
29
|
+
const res = await fetch(`https://api.github.com/repos/${REPO}/releases/latest`, {
|
|
30
|
+
headers: { "User-Agent": "aerostack-cli-npm/1.0" },
|
|
31
|
+
});
|
|
32
|
+
if (!res.ok) throw new Error("Failed to fetch latest version");
|
|
33
|
+
const data = await res.text();
|
|
34
|
+
const m = data.match(/"tag_name":\s*"v([^"]+)"/);
|
|
35
|
+
if (!m) throw new Error("Could not parse version");
|
|
36
|
+
return m[1];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function downloadBinary(version, asset) {
|
|
40
|
+
const ext = asset.startsWith("windows") ? "zip" : "tar.gz";
|
|
41
|
+
const archive = `${BINARY}_${version}_${asset}.${ext}`;
|
|
42
|
+
const url = `https://github.com/${REPO}/releases/download/v${version}/${archive}`;
|
|
43
|
+
|
|
44
|
+
const tmpDir = path.join(require("os").tmpdir(), `aerostack-${Date.now()}`);
|
|
45
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
46
|
+
const archivePath = path.join(tmpDir, archive);
|
|
47
|
+
|
|
48
|
+
const res = await fetch(url, {
|
|
49
|
+
headers: { "User-Agent": "aerostack-cli-npm/1.0" },
|
|
50
|
+
redirect: "follow",
|
|
51
|
+
});
|
|
52
|
+
if (!res.ok) throw new Error(`Download failed: ${url}`);
|
|
53
|
+
const buffer = Buffer.from(await res.arrayBuffer());
|
|
54
|
+
fs.writeFileSync(archivePath, buffer);
|
|
55
|
+
|
|
56
|
+
const binDir = INSTALL_DIR;
|
|
57
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
58
|
+
const binPath = path.join(binDir, process.platform === "win32" ? `${BINARY}.exe` : BINARY);
|
|
59
|
+
|
|
60
|
+
if (ext === "zip") {
|
|
61
|
+
const AdmZip = require("adm-zip");
|
|
62
|
+
const zip = new AdmZip(archivePath);
|
|
63
|
+
zip.extractAllTo(tmpDir, true);
|
|
64
|
+
const extracted = path.join(tmpDir, `${BINARY}.exe`);
|
|
65
|
+
fs.renameSync(extracted, binPath);
|
|
66
|
+
} else {
|
|
67
|
+
const tar = require("tar");
|
|
68
|
+
await tar.x({ file: archivePath, cwd: tmpDir });
|
|
69
|
+
fs.renameSync(path.join(tmpDir, BINARY), binPath);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fs.chmodSync(binPath, 0o755);
|
|
73
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
74
|
+
return binPath;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function ensureBinary() {
|
|
78
|
+
const binPath = path.join(INSTALL_DIR, process.platform === "win32" ? `${BINARY}.exe` : BINARY);
|
|
79
|
+
if (fs.existsSync(binPath)) return binPath;
|
|
80
|
+
|
|
81
|
+
const { asset } = getPlatform();
|
|
82
|
+
const version = await getLatestVersion();
|
|
83
|
+
console.error(`Downloading Aerostack CLI v${version}...`);
|
|
84
|
+
return downloadBinary(version, asset);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function main() {
|
|
88
|
+
try {
|
|
89
|
+
const binPath = await ensureBinary();
|
|
90
|
+
const child = spawn(binPath, process.argv.slice(2), {
|
|
91
|
+
stdio: "inherit",
|
|
92
|
+
shell: false,
|
|
93
|
+
});
|
|
94
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
95
|
+
} catch (err) {
|
|
96
|
+
console.error("Error:", err.message);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aerostack",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Aerostack CLI - Zero-config serverless development for Cloudflare",
|
|
5
|
+
"files": ["bin"],
|
|
6
|
+
"bin": {
|
|
7
|
+
"aerostack": "bin/run.js"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"adm-zip": "^0.5.16",
|
|
11
|
+
"tar": "^7.0.0"
|
|
12
|
+
},
|
|
13
|
+
"keywords": ["aerostack", "cloudflare", "workers", "serverless", "cli"],
|
|
14
|
+
"author": "Aerostack",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/aerostackdev/cli.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://aerostack.dev",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
}
|
|
24
|
+
}
|