@seyuna/cli 0.0.2-dev.9 → 0.0.3-dev.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/bin/seyuna.js +10 -0
- package/install.js +42 -0
- package/package.json +10 -4
- package/node-install.js +0 -60
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.
|
|
3
|
+
"version": "0.0.3-dev.0",
|
|
4
|
+
"main": "./index.js",
|
|
4
5
|
"bin": {
|
|
5
|
-
"seyuna": "./bin/seyuna"
|
|
6
|
+
"seyuna": "./bin/seyuna.js"
|
|
6
7
|
},
|
|
7
8
|
"scripts": {
|
|
8
|
-
"postinstall": "node
|
|
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.0",
|
|
19
|
+
"@seyuna/cli-linux": "0.0.3-dev.0",
|
|
20
|
+
"@seyuna/cli-win32": "0.0.3-dev.0"
|
|
15
21
|
}
|
|
16
|
-
}
|
|
22
|
+
}
|
package/node-install.js
DELETED
|
@@ -1,60 +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
|
-
const version = "0.0.2-dev.9";
|
|
10
|
-
|
|
11
|
-
async function downloadFile(url, dest) {
|
|
12
|
-
const res = await fetch(url);
|
|
13
|
-
if (!res.ok) {
|
|
14
|
-
throw new Error(`Failed to download ${url}: ${res.status} ${res.statusText}`);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
await mkdir(path.dirname(dest), { recursive: true });
|
|
18
|
-
|
|
19
|
-
const readable = Readable.fromWeb(res.body);
|
|
20
|
-
const fileStream = createWriteStream(dest);
|
|
21
|
-
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
readable.pipe(fileStream);
|
|
24
|
-
readable.on("error", reject);
|
|
25
|
-
fileStream.on("finish", resolve);
|
|
26
|
-
fileStream.on("error", reject);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function main() {
|
|
31
|
-
|
|
32
|
-
const platform = process.platform;
|
|
33
|
-
let target;
|
|
34
|
-
if (platform === "win32") {
|
|
35
|
-
target = "seyuna-windows.exe";
|
|
36
|
-
} else if (platform === "darwin") {
|
|
37
|
-
target = "seyuna-macos";
|
|
38
|
-
} else if (platform === "linux") {
|
|
39
|
-
target = "seyuna-linux";
|
|
40
|
-
} else {
|
|
41
|
-
console.error(`Unsupported platform: ${platform}`);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const releaseUrl = `https://github.com/seyuna-corp/seyuna-cli/releases/download/v${version}/${target}`;
|
|
46
|
-
const dest = path.join(__dirname, "bin", "seyuna");
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
await downloadFile(releaseUrl, dest);
|
|
50
|
-
if (platform !== "win32") {
|
|
51
|
-
await chmod(dest, 0o755);
|
|
52
|
-
}
|
|
53
|
-
console.log(`seyuna CLI v${version} installed to ${dest}`);
|
|
54
|
-
} catch (err) {
|
|
55
|
-
console.error(err);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
main();
|