@seyuna/cli 0.0.2 → 0.0.3-dev.1

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.js ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ const { spawn } = require("child_process");
3
+ const path = require("path");
4
+ const os = require("os");
5
+
6
+ const exe = os.platform() === "win32" ? "seyuna.exe" : "seyuna";
7
+ const binPath = path.join(__dirname, exe);
8
+
9
+ const proc = spawn(binPath, process.argv.slice(2), { stdio: "inherit" });
10
+ proc.on("exit", code => process.exit(code));
package/install.js ADDED
@@ -0,0 +1,42 @@
1
+ const os = require("os");
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+
5
+ const platform = os.platform();
6
+ let pkg;
7
+
8
+ switch (platform) {
9
+ case "darwin":
10
+ pkg = "@seyuna/cli-darwin";
11
+ break;
12
+ case "linux":
13
+ pkg = "@seyuna/cli-linux";
14
+ break;
15
+ case "win32":
16
+ pkg = "@seyuna/cli-win32";
17
+ break;
18
+ default:
19
+ console.error(`Unsupported platform: ${platform}`);
20
+ process.exit(1);
21
+ }
22
+
23
+ try {
24
+ const binSrc = require.resolve(`${pkg}/bin/seyuna${platform === "win32" ? ".exe" : ""}`);
25
+ const binDest = path.join(__dirname, "bin", `seyuna${platform === "win32" ? ".exe" : ""}`);
26
+
27
+ fs.mkdirSync(path.dirname(binDest), { recursive: true });
28
+ fs.copyFileSync(binSrc, binDest);
29
+
30
+ if (platform !== "win32") {
31
+ fs.chmodSync(binDest, 0o755);
32
+ } else {
33
+ // Create Windows CMD shim
34
+ const cmdShimPath = path.join(__dirname, "bin", "seyuna.cmd");
35
+ fs.writeFileSync(cmdShimPath, `@echo off\r\n"${binDest}" %*`);
36
+ }
37
+
38
+ console.log(`seyuna installed for ${platform}`);
39
+ } catch (err) {
40
+ console.error(`Failed to install seyuna for ${platform}:`, err);
41
+ process.exit(1);
42
+ }
package/package.json CHANGED
@@ -1,16 +1,22 @@
1
1
  {
2
2
  "name": "@seyuna/cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.3-dev.1",
4
+ "main": "./index.js",
4
5
  "bin": {
5
- "seyuna": "./bin/seyuna"
6
+ "seyuna": "./bin/seyuna.js"
6
7
  },
7
8
  "scripts": {
8
- "prepare": "node node-install.js"
9
+ "postinstall": "node ./install.js"
9
10
  },
10
11
  "description": "Seyuna CLI",
11
12
  "author": "Seyuna",
12
13
  "license": "MIT",
13
14
  "engines": {
14
15
  "node": ">=18"
16
+ },
17
+ "optionalDependencies": {
18
+ "@seyuna/cli-darwin": "0.0.3-dev.1",
19
+ "@seyuna/cli-linux": "0.0.3-dev.1",
20
+ "@seyuna/cli-win32": "0.0.3-dev.1"
15
21
  }
16
- }
22
+ }
package/bin/seyuna DELETED
Binary file
package/deno-install.ts DELETED
@@ -1,62 +0,0 @@
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();
package/deno-wrapper.ts DELETED
@@ -1,42 +0,0 @@
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 DELETED
@@ -1,12 +0,0 @@
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
- }
package/node-install.js DELETED
@@ -1,66 +0,0 @@
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();