@nihit_dev/yoo 1.0.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/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # @nihitde_v/yoo
2
+
3
+ npm installer for the `yoo` local project and development-environment CLI.
4
+
5
+ ```bash
6
+ npm install -g @nihitde_v/yoo
7
+ yoo
8
+ ```
9
+
10
+ This package installs the prebuilt binary from the matching GitHub release:
11
+
12
+ - Windows x64
13
+ - Linux x64
14
+ - macOS arm64
15
+
16
+ The Rust crate is available as `yoo` on crates.io:
17
+
18
+ ```bash
19
+ cargo install yoo
20
+ ```
package/bin/yoo.js ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("node:child_process");
4
+ const { existsSync } = require("node:fs");
5
+ const { join } = require("node:path");
6
+
7
+ const exe = process.platform === "win32" ? "yoo.exe" : "yoo";
8
+ const binary = join(__dirname, "..", "vendor", exe);
9
+
10
+ if (!existsSync(binary)) {
11
+ console.error("yoo binary is missing. Try reinstalling @nihitde_v/yoo.");
12
+ process.exit(1);
13
+ }
14
+
15
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
16
+
17
+ if (result.error) {
18
+ console.error(result.error.message);
19
+ process.exit(1);
20
+ }
21
+
22
+ process.exit(result.status ?? 0);
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@nihit_dev/yoo",
3
+ "version": "1.0.0",
4
+ "description": "Local CLI for project, Git, and development environment information.",
5
+ "license": "GPL-3.0-or-later",
6
+ "homepage": "https://github.com/nihitdev/yo-cli#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/nihitdev/yo-cli.git",
10
+ "directory": "packages/npm"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/nihitdev/yo-cli/issues"
14
+ },
15
+ "keywords": [
16
+ "cli",
17
+ "terminal",
18
+ "developer",
19
+ "productivity",
20
+ "rust"
21
+ ],
22
+ "bin": {
23
+ "yoo": "bin/yoo.js"
24
+ },
25
+ "scripts": {
26
+ "postinstall": "node scripts/install.js"
27
+ },
28
+ "files": [
29
+ "bin",
30
+ "scripts",
31
+ "README.md"
32
+ ],
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "engines": {
37
+ "node": ">=18"
38
+ }
39
+ }
@@ -0,0 +1,75 @@
1
+ const { createWriteStream, chmodSync, copyFileSync, existsSync, mkdirSync } = require("node:fs");
2
+ const { get } = require("node:https");
3
+ const { basename, join } = require("node:path");
4
+ const { version } = require("../package.json");
5
+
6
+ const repo = "https://github.com/nihitdev/yo-cli";
7
+ const vendorDir = join(__dirname, "..", "vendor");
8
+
9
+ const targets = {
10
+ "win32-x64": { asset: "yoo-windows-x86_64.exe", exe: "yoo.exe" },
11
+ "linux-x64": { asset: "yoo-linux-x86_64", exe: "yoo" },
12
+ "darwin-arm64": { asset: "yoo-macos-aarch64", exe: "yoo" }
13
+ };
14
+
15
+ function target() {
16
+ const key = `${process.platform}-${process.arch}`;
17
+ const match = targets[key];
18
+
19
+ if (!match) {
20
+ throw new Error(`Unsupported platform for @nihitde_v/yoo: ${key}`);
21
+ }
22
+
23
+ return match;
24
+ }
25
+
26
+ function download(url, destination) {
27
+ return new Promise((resolve, reject) => {
28
+ get(url, (response) => {
29
+ if ([301, 302, 303, 307, 308].includes(response.statusCode)) {
30
+ response.resume();
31
+ download(response.headers.location, destination).then(resolve, reject);
32
+ return;
33
+ }
34
+
35
+ if (response.statusCode !== 200) {
36
+ response.resume();
37
+ reject(new Error(`Failed to download ${basename(destination)}: HTTP ${response.statusCode}`));
38
+ return;
39
+ }
40
+
41
+ const file = createWriteStream(destination, { mode: 0o755 });
42
+ response.pipe(file);
43
+ file.on("finish", () => file.close(resolve));
44
+ file.on("error", reject);
45
+ }).on("error", reject);
46
+ });
47
+ }
48
+
49
+ async function main() {
50
+ mkdirSync(vendorDir, { recursive: true });
51
+
52
+ const selected = target();
53
+ const binaryPath = join(vendorDir, selected.exe);
54
+ const localBinary = process.env.YOO_BINARY_PATH;
55
+
56
+ if (localBinary) {
57
+ if (!existsSync(localBinary)) {
58
+ throw new Error(`YOO_BINARY_PATH does not exist: ${localBinary}`);
59
+ }
60
+
61
+ copyFileSync(localBinary, binaryPath);
62
+ } else {
63
+ const url = `${repo}/releases/download/v${version}/${selected.asset}`;
64
+ await download(url, binaryPath);
65
+ }
66
+
67
+ if (process.platform !== "win32") {
68
+ chmodSync(binaryPath, 0o755);
69
+ }
70
+ }
71
+
72
+ main().catch((error) => {
73
+ console.error(error.message);
74
+ process.exit(1);
75
+ });