@c-time/frelio-cli 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 +435 -0
- package/dist/commands/add-staging.d.ts +9 -0
- package/dist/commands/add-staging.js +202 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.js +532 -0
- package/dist/commands/update.d.ts +8 -0
- package/dist/commands/update.js +95 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +28 -0
- package/dist/lib/github-release.d.ts +15 -0
- package/dist/lib/github-release.js +41 -0
- package/dist/lib/initial-content.d.ts +5 -0
- package/dist/lib/initial-content.js +1353 -0
- package/dist/lib/shell.d.ts +12 -0
- package/dist/lib/shell.js +40 -0
- package/dist/lib/templates.d.ts +43 -0
- package/dist/lib/templates.js +211 -0
- package/package.json +35 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Release からの tarball ダウンロード
|
|
3
|
+
*/
|
|
4
|
+
import { createWriteStream } from 'node:fs';
|
|
5
|
+
import { pipeline } from 'node:stream/promises';
|
|
6
|
+
import { Readable } from 'node:stream';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
const REPO = 'ctime-projects/frelio';
|
|
9
|
+
export async function getLatestRelease() {
|
|
10
|
+
const res = await fetch(`https://api.github.com/repos/${REPO}/releases/latest`, {
|
|
11
|
+
headers: { Accept: 'application/vnd.github.v3+json' },
|
|
12
|
+
});
|
|
13
|
+
if (!res.ok) {
|
|
14
|
+
throw new Error(`Failed to fetch latest release: ${res.status} ${res.statusText}`);
|
|
15
|
+
}
|
|
16
|
+
return res.json();
|
|
17
|
+
}
|
|
18
|
+
export async function getRelease(version) {
|
|
19
|
+
const tag = version.startsWith('v') ? version : `v${version}`;
|
|
20
|
+
const res = await fetch(`https://api.github.com/repos/${REPO}/releases/tags/${tag}`, {
|
|
21
|
+
headers: { Accept: 'application/vnd.github.v3+json' },
|
|
22
|
+
});
|
|
23
|
+
if (!res.ok) {
|
|
24
|
+
throw new Error(`Release ${tag} not found: ${res.status}`);
|
|
25
|
+
}
|
|
26
|
+
return res.json();
|
|
27
|
+
}
|
|
28
|
+
export async function downloadTarball(release, destDir) {
|
|
29
|
+
const asset = release.assets.find((a) => a.name.endsWith('.tar.gz'));
|
|
30
|
+
if (!asset) {
|
|
31
|
+
throw new Error('No tarball found in release assets');
|
|
32
|
+
}
|
|
33
|
+
const destPath = path.join(destDir, asset.name);
|
|
34
|
+
const res = await fetch(asset.browser_download_url);
|
|
35
|
+
if (!res.ok || !res.body) {
|
|
36
|
+
throw new Error(`Failed to download: ${res.status}`);
|
|
37
|
+
}
|
|
38
|
+
const readable = Readable.fromWeb(res.body);
|
|
39
|
+
await pipeline(readable, createWriteStream(destPath));
|
|
40
|
+
return destPath;
|
|
41
|
+
}
|