@seyuna/cli 0.0.2-dev → 0.0.2-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 CHANGED
Binary file
package/deno-wrapper.ts CHANGED
@@ -1,34 +1,71 @@
1
1
  #!/usr/bin/env -S deno run --allow-run --allow-read --allow-write --allow-net
2
2
 
3
- import { join } from "jsr:@std/path@1";
4
- import { existsSync } from "jsr:@std/fs@1";
3
+ import { join, dirname } from "jsr:@std/path@^0.224.0";
4
+ import { ensureDir, existsSync } from "jsr:@std/fs@^0.224.0";
5
5
 
6
+ // Get version from deno.json
7
+ async function getVersion(): Promise<string> {
8
+ const text = await Deno.readTextFile("deno.json");
9
+ const config = JSON.parse(text);
10
+ return config.version;
11
+ }
12
+
13
+ // Download a file from a URL to a destination path
14
+ async function downloadFile(url: string, dest: string): Promise<void> {
15
+ const res = await fetch(url);
16
+ if (!res.ok || !res.body) {
17
+ throw new Error(`Failed to download ${url}: ${res.status} ${res.statusText}`);
18
+ }
19
+
20
+ await ensureDir(dirname(dest));
21
+ const file = await Deno.open(dest, { create: true, write: true, truncate: true });
22
+ await res.body.pipeTo(file.writable);
23
+ }
24
+
25
+ // Main execution
6
26
  async function main() {
7
27
  const platform = Deno.build.os; // "windows", "linux", or "darwin"
8
28
  const binName = platform === "windows" ? "seyuna.exe" : "seyuna";
9
29
  const binPath = join(Deno.cwd(), "bin", binName);
10
30
 
11
- // If binary does not exist, run deno-install.ts to download it
12
31
  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);
32
+ console.log("seyuna binary not found, downloading...");
33
+
34
+ const version = await getVersion();
35
+
36
+ let target: string;
37
+ switch (platform) {
38
+ case "windows":
39
+ target = "seyuna-windows.exe";
40
+ break;
41
+ case "darwin":
42
+ target = "seyuna-macos";
43
+ break;
44
+ case "linux":
45
+ target = "seyuna-linux";
46
+ break;
47
+ default:
48
+ console.error(`Unsupported platform: ${platform}`);
49
+ Deno.exit(1);
50
+ }
51
+
52
+ const releaseUrl = `https://github.com/seyuna-corp/seyuna-cli/releases/download/v${version}/${target}`;
53
+
54
+ try {
55
+ await downloadFile(releaseUrl, binPath);
56
+ if (platform !== "windows") {
57
+ await Deno.chmod(binPath, 0o755);
58
+ }
59
+ console.log(`seyuna CLI v${version} installed to ${binPath}`);
60
+ } catch (err) {
61
+ console.error("Installation failed:", err);
62
+ Deno.exit(1);
25
63
  }
26
64
  }
27
65
 
28
- // Now run the seyuna binary with passed arguments
29
- const cmd = [binPath, ...Deno.args];
66
+ // Forward all arguments to the actual binary
30
67
  const process = Deno.run({
31
- cmd,
68
+ cmd: [binPath, ...Deno.args],
32
69
  stdin: "inherit",
33
70
  stdout: "inherit",
34
71
  stderr: "inherit",
@@ -39,4 +76,4 @@ async function main() {
39
76
  Deno.exit(status.code);
40
77
  }
41
78
 
42
- main();
79
+ await main();
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seyuna/cli",
3
- "version": "0.0.2-dev",
3
+ "version": "0.0.2-dev.1",
4
4
  "description": "Seyuna CLI",
5
5
  "bin": {
6
6
  "seyuna": "./deno-wrapper.ts"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seyuna/cli",
3
- "version": "0.0.2-dev",
3
+ "version": "0.0.2-dev.1",
4
4
  "bin": {
5
5
  "seyuna": "./bin/seyuna"
6
6
  },
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();