voinznext 0.1.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/cli.js +21 -0
- package/install.js +82 -0
- package/package.json +41 -0
package/cli.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require("child_process");
|
|
3
|
+
const { existsSync } = require("fs");
|
|
4
|
+
const { join } = require("path");
|
|
5
|
+
const { platform } = require("process");
|
|
6
|
+
|
|
7
|
+
const binaryName = platform === "win32" ? "voinznext.exe" : "voinznext";
|
|
8
|
+
const binaryPath = join(__dirname, "bin", binaryName);
|
|
9
|
+
|
|
10
|
+
if (!existsSync(binaryPath)) {
|
|
11
|
+
console.error(" ✘ Binary not found. Run `npm install` or `npx voinznext` to download it.");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
16
|
+
|
|
17
|
+
child.on("exit", (code) => process.exit(code));
|
|
18
|
+
child.on("error", (err) => {
|
|
19
|
+
console.error(" ✘ Failed to run voinznext:", err.message);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
package/install.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { createWriteStream, existsSync, mkdirSync, chmodSync } = require("fs");
|
|
3
|
+
const { get } = require("https");
|
|
4
|
+
const { join } = require("path");
|
|
5
|
+
const { platform, arch } = require("process");
|
|
6
|
+
|
|
7
|
+
const REPO = "VoinzzZ/VoinzNext";
|
|
8
|
+
const APP = "voinznext";
|
|
9
|
+
|
|
10
|
+
const PLATFORM_MAP = { win32: "windows", darwin: "darwin", linux: "linux" };
|
|
11
|
+
const ARCH_MAP = { x64: "amd64", arm64: "arm64" };
|
|
12
|
+
|
|
13
|
+
function getPlatform() {
|
|
14
|
+
const p = PLATFORM_MAP[platform];
|
|
15
|
+
if (!p) throw new Error(`Unsupported platform: ${platform}`);
|
|
16
|
+
return p;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getArch() {
|
|
20
|
+
const a = ARCH_MAP[arch];
|
|
21
|
+
if (!a) throw new Error(`Unsupported architecture: ${arch}`);
|
|
22
|
+
return a;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getBinaryName() {
|
|
26
|
+
const p = getPlatform();
|
|
27
|
+
const a = getArch();
|
|
28
|
+
const name = `${APP}-${p}-${a}`;
|
|
29
|
+
return p === "windows" ? `${name}.exe` : name;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getLatestVersion() {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const url = `https://api.github.com/repos/${REPO}/releases/latest`;
|
|
35
|
+
get(url, { headers: { "Accept": "application/vnd.github.v3+json", "User-Agent": "voinznext-installer" } }, (res) => {
|
|
36
|
+
let data = "";
|
|
37
|
+
res.on("data", (chunk) => (data += chunk));
|
|
38
|
+
res.on("end", () => {
|
|
39
|
+
try {
|
|
40
|
+
const json = JSON.parse(data);
|
|
41
|
+
resolve(json.tag_name);
|
|
42
|
+
} catch {
|
|
43
|
+
reject(new Error(`Failed to parse latest release response: ${data}`));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}).on("error", reject);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function install() {
|
|
51
|
+
const binDir = join(__dirname, "bin");
|
|
52
|
+
if (!existsSync(binDir)) mkdirSync(binDir, { recursive: true });
|
|
53
|
+
|
|
54
|
+
const binaryName = getBinaryName();
|
|
55
|
+
const targetPath = join(binDir, "voinznext.exe");
|
|
56
|
+
|
|
57
|
+
console.log(` ● Downloading ${APP} binary for ${platform}-${arch}...`);
|
|
58
|
+
|
|
59
|
+
const version = await getLatestVersion();
|
|
60
|
+
const downloadUrl = `https://github.com/${REPO}/releases/download/${version}/${binaryName}`;
|
|
61
|
+
|
|
62
|
+
await new Promise((resolve, reject) => {
|
|
63
|
+
get(downloadUrl, { headers: { "User-Agent": "voinznext-installer" } }, (res) => {
|
|
64
|
+
if (res.statusCode !== 200) {
|
|
65
|
+
reject(new Error(`Download failed with status ${res.statusCode}`));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const file = createWriteStream(targetPath);
|
|
69
|
+
res.pipe(file);
|
|
70
|
+
file.on("finish", () => file.close(resolve));
|
|
71
|
+
file.on("error", reject);
|
|
72
|
+
}).on("error", reject);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (platform !== "win32") chmodSync(targetPath, 0o755);
|
|
76
|
+
console.log(` ✔ Installed to ${targetPath}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
install().catch((err) => {
|
|
80
|
+
console.error(" ✘ Installation failed:", err.message);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "voinznext",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Interactive CLI tool for scaffolding Next.js projects with your preferred tech stack",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nextjs",
|
|
7
|
+
"scaffold",
|
|
8
|
+
"cli",
|
|
9
|
+
"starter",
|
|
10
|
+
"generator"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/VoinzzZ/VoinzNext",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/VoinzzZ/VoinzNext.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "VoinzzZ",
|
|
19
|
+
"bin": {
|
|
20
|
+
"voinznext": "cli.js"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"postinstall": "node install.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"cli.js",
|
|
27
|
+
"install.js"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"os": [
|
|
33
|
+
"win32",
|
|
34
|
+
"darwin",
|
|
35
|
+
"linux"
|
|
36
|
+
],
|
|
37
|
+
"cpu": [
|
|
38
|
+
"x64",
|
|
39
|
+
"arm64"
|
|
40
|
+
]
|
|
41
|
+
}
|