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