@seyuna/cli 0.0.2

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/seyuna ADDED
Binary file
@@ -0,0 +1,62 @@
1
+ // deno-install.ts
2
+ import { join, dirname } from "jsr:@std/path@^0.224.0";
3
+ import { ensureDir } from "jsr:@std/fs@^0.224.0";
4
+
5
+ async function getVersion(): Promise<string> {
6
+ const text = await Deno.readTextFile("deno.json");
7
+ const config = JSON.parse(text);
8
+ return config.version;
9
+ }
10
+
11
+ async function downloadFile(url: string, dest: string): Promise<void> {
12
+ const res = await fetch(url);
13
+ if (!res.ok || !res.body) {
14
+ throw new Error(`Failed to download ${url}: ${res.status} ${res.statusText}`);
15
+ }
16
+
17
+ await ensureDir(dirname(dest));
18
+ const file = await Deno.open(dest, { create: true, write: true, truncate: true });
19
+ await res.body.pipeTo(file.writable);
20
+ }
21
+
22
+ async function main() {
23
+ const version = await getVersion();
24
+ const platform = Deno.build.os;
25
+
26
+ let target: string;
27
+ let output: string;
28
+
29
+ switch (platform) {
30
+ case "windows":
31
+ target = "seyuna-windows.exe";
32
+ output = "seyuna.exe";
33
+ break;
34
+ case "darwin":
35
+ target = "seyuna-macos";
36
+ output = "seyuna";
37
+ break;
38
+ case "linux":
39
+ target = "seyuna-linux";
40
+ output = "seyuna";
41
+ break;
42
+ default:
43
+ console.error(`Unsupported platform: ${platform}`);
44
+ Deno.exit(1);
45
+ }
46
+
47
+ const destPath = join("bin", output);
48
+ const releaseUrl = `https://github.com/seyuna-corp/seyuna-cli/releases/download/v${version}/${target}`;
49
+
50
+ try {
51
+ await downloadFile(releaseUrl, destPath);
52
+ if (platform !== "windows") {
53
+ await Deno.chmod(destPath, 0o755);
54
+ }
55
+ console.log(`seyuna CLI v${version} installed to ${destPath}`);
56
+ } catch (err) {
57
+ console.error("Installation failed:", err);
58
+ Deno.exit(1);
59
+ }
60
+ }
61
+
62
+ await main();
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env -S deno run --allow-run --allow-read --allow-write --allow-net
2
+
3
+ import { join } from "jsr:@std/path@1";
4
+ import { existsSync } from "jsr:@std/fs@1";
5
+
6
+ async function main() {
7
+ const platform = Deno.build.os; // "windows", "linux", or "darwin"
8
+ const binName = platform === "windows" ? "seyuna.exe" : "seyuna";
9
+ const binPath = join(Deno.cwd(), "bin", binName);
10
+
11
+ // If binary does not exist, run deno-install.ts to download it
12
+ if (!existsSync(binPath)) {
13
+ console.log("seyuna binary not found, running deno-install.ts to download it...");
14
+ const installProcess = Deno.run({
15
+ cmd: ["deno", "run", "--allow-write", "--allow-net", "deno-install.ts"],
16
+ stdin: "inherit",
17
+ stdout: "inherit",
18
+ stderr: "inherit",
19
+ });
20
+ const installStatus = await installProcess.status();
21
+ installProcess.close();
22
+ if (!installStatus.success) {
23
+ console.error("Failed to run deno-install.ts");
24
+ Deno.exit(installStatus.code);
25
+ }
26
+ }
27
+
28
+ // Now run the seyuna binary with passed arguments
29
+ const cmd = [binPath, ...Deno.args];
30
+ const process = Deno.run({
31
+ cmd,
32
+ stdin: "inherit",
33
+ stdout: "inherit",
34
+ stderr: "inherit",
35
+ });
36
+
37
+ const status = await process.status();
38
+ process.close();
39
+ Deno.exit(status.code);
40
+ }
41
+
42
+ main();
package/deno.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@seyuna/cli",
3
+ "version": "0.0.2",
4
+ "description": "Seyuna CLI",
5
+ "exports": {
6
+ "seyuna": "./deno-wrapper.ts"
7
+ },
8
+ "license": "MIT",
9
+ "tasks": {
10
+ "install": "deno run --allow-write --allow-net deno-install.ts"
11
+ }
12
+ }
@@ -0,0 +1,66 @@
1
+ import { mkdir, chmod, readFile } from "fs/promises";
2
+ import { createWriteStream } from "fs";
3
+ import { Readable } from "stream";
4
+ import path from "path";
5
+ import { fileURLToPath } from "url";
6
+ import process from "process";
7
+
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
+
10
+ async function downloadFile(url, dest) {
11
+ const res = await fetch(url);
12
+ if (!res.ok) {
13
+ throw new Error(`Failed to download ${url}: ${res.status} ${res.statusText}`);
14
+ }
15
+
16
+ await mkdir(path.dirname(dest), { recursive: true });
17
+
18
+ const readable = Readable.fromWeb(res.body);
19
+ const fileStream = createWriteStream(dest);
20
+
21
+ return new Promise((resolve, reject) => {
22
+ readable.pipe(fileStream);
23
+ readable.on("error", reject);
24
+ fileStream.on("finish", resolve);
25
+ fileStream.on("error", reject);
26
+ });
27
+ }
28
+
29
+ async function getVersion() {
30
+ const pkgPath = path.join(__dirname, "package.json");
31
+ const pkgJson = await readFile(pkgPath, "utf8");
32
+ return JSON.parse(pkgJson).version;
33
+ }
34
+
35
+ async function main() {
36
+ const version = await getVersion();
37
+
38
+ const platform = process.platform;
39
+ let target;
40
+ if (platform === "win32") {
41
+ target = "seyuna-windows.exe";
42
+ } else if (platform === "darwin") {
43
+ target = "seyuna-macos";
44
+ } else if (platform === "linux") {
45
+ target = "seyuna-linux";
46
+ } else {
47
+ console.error(`Unsupported platform: ${platform}`);
48
+ process.exit(1);
49
+ }
50
+
51
+ const releaseUrl = `https://github.com/seyuna-corp/seyuna-cli/releases/download/v${version}/${target}`;
52
+ const dest = path.join(__dirname, "bin", platform === "win32" ? "seyuna.exe" : "seyuna");
53
+
54
+ try {
55
+ await downloadFile(releaseUrl, dest);
56
+ if (platform !== "win32") {
57
+ await chmod(dest, 0o755);
58
+ }
59
+ console.log(`seyuna CLI v${version} installed to ${dest}`);
60
+ } catch (err) {
61
+ console.error(err);
62
+ process.exit(1);
63
+ }
64
+ }
65
+
66
+ main();
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@seyuna/cli",
3
+ "version": "0.0.2",
4
+ "bin": {
5
+ "seyuna": "./bin/seyuna"
6
+ },
7
+ "scripts": {
8
+ "prepare": "node node-install.js"
9
+ },
10
+ "description": "Seyuna CLI",
11
+ "author": "Seyuna",
12
+ "license": "MIT",
13
+ "engines": {
14
+ "node": ">=18"
15
+ }
16
+ }