@nolgia/cli 0.2.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/README.md +10 -0
- package/bin/nolgia.js +20 -0
- package/package.json +30 -0
- package/scripts/postinstall.js +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @nolgia/cli
|
|
2
|
+
|
|
3
|
+
npm wrapper for the [Nolgia CLI](https://github.com/nolgiacorp/nolgia-cli). Installing this package downloads the prebuilt `nolgia` binary for your platform (macOS universal, Linux x86_64, Windows x86_64) and exposes it as `nolgia` on your PATH.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @nolgia/cli
|
|
7
|
+
nolgia auth login
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
See the [repository README](https://github.com/nolgiacorp/nolgia-cli#readme) for full documentation
|
package/bin/nolgia.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require("node:child_process");
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
9
|
+
const binary = path.join(__dirname, "..", "vendor", `nolgia${ext}`);
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(binary)) {
|
|
12
|
+
console.error(
|
|
13
|
+
"the nolgia binary is missing; reinstall with: npm install -g @nolgia/cli " +
|
|
14
|
+
"(the postinstall step downloads it)"
|
|
15
|
+
);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
20
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nolgia/cli",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Nolgia CLI: generate images, video, and audio on the Nolgia platform",
|
|
5
|
+
"bin": {
|
|
6
|
+
"nolgia": "bin/nolgia.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node scripts/postinstall.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/",
|
|
13
|
+
"scripts/",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/nolgiacorp/nolgia-cli.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/nolgiacorp/nolgia-cli#readme",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"os": [
|
|
23
|
+
"darwin",
|
|
24
|
+
"linux",
|
|
25
|
+
"win32"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Downloads the platform binary for this package version from GitHub releases
|
|
2
|
+
// into vendor/. No runtime dependencies; node >= 18 for global fetch.
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const os = require("node:os");
|
|
8
|
+
|
|
9
|
+
const REPO = "nolgiacorp/nolgia-cli";
|
|
10
|
+
const VERSION = require("../package.json").version;
|
|
11
|
+
|
|
12
|
+
function assetName() {
|
|
13
|
+
const { platform, arch } = process;
|
|
14
|
+
if (platform === "darwin") {
|
|
15
|
+
// Universal binary covers x64 and arm64.
|
|
16
|
+
return "nolgia-x86_64-apple-darwin";
|
|
17
|
+
}
|
|
18
|
+
if (platform === "linux" && arch === "x64") {
|
|
19
|
+
return "nolgia-x86_64-unknown-linux-gnu";
|
|
20
|
+
}
|
|
21
|
+
if (platform === "win32" && arch === "x64") {
|
|
22
|
+
return "nolgia-x86_64-pc-windows-msvc.exe";
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function binaryPath() {
|
|
28
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
29
|
+
return path.join(__dirname, "..", "vendor", `nolgia${ext}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function writeInstallMetadata() {
|
|
33
|
+
try {
|
|
34
|
+
const configHome =
|
|
35
|
+
process.env.XDG_CONFIG_HOME && process.env.XDG_CONFIG_HOME.length > 0
|
|
36
|
+
? process.env.XDG_CONFIG_HOME
|
|
37
|
+
: path.join(os.homedir(), ".config");
|
|
38
|
+
const dir = path.join(configHome, "nolgia");
|
|
39
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
40
|
+
fs.writeFileSync(
|
|
41
|
+
path.join(dir, "install-metadata.json"),
|
|
42
|
+
JSON.stringify({
|
|
43
|
+
method: "npm",
|
|
44
|
+
tag: `v${VERSION}`,
|
|
45
|
+
installed_at: new Date().toISOString(),
|
|
46
|
+
}) + "\n"
|
|
47
|
+
);
|
|
48
|
+
} catch {
|
|
49
|
+
// Metadata is best-effort; the update hint falls back to path inference.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function main() {
|
|
54
|
+
const asset = assetName();
|
|
55
|
+
if (!asset) {
|
|
56
|
+
console.error(
|
|
57
|
+
`@nolgia/cli has no prebuilt binary for ${process.platform}/${process.arch}; ` +
|
|
58
|
+
"install with: cargo install nolgia-cli"
|
|
59
|
+
);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${asset}`;
|
|
64
|
+
const dest = binaryPath();
|
|
65
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
66
|
+
|
|
67
|
+
const response = await fetch(url, { redirect: "follow" });
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
console.error(`failed to download ${url}: HTTP ${response.status}`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
const bytes = Buffer.from(await response.arrayBuffer());
|
|
73
|
+
fs.writeFileSync(dest, bytes);
|
|
74
|
+
if (process.platform !== "win32") {
|
|
75
|
+
fs.chmodSync(dest, 0o755);
|
|
76
|
+
}
|
|
77
|
+
writeInstallMetadata();
|
|
78
|
+
console.log(`nolgia ${VERSION} installed for ${process.platform}/${process.arch}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
main().catch((err) => {
|
|
82
|
+
console.error(err.message || err);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
});
|