@rofy/cli 0.0.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 +22 -0
- package/bin/rofy.js +17 -0
- package/checksums.json +8 -0
- package/install.js +68 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @rofy/cli
|
|
2
|
+
|
|
3
|
+
Make images and videos with Rofy from a terminal, or let an AI assistant do it.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -g @rofy/cli
|
|
7
|
+
rofy auth login
|
|
8
|
+
npx skills add rofy-ai/skills
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Installing fetches the `rofy` program for your computer from the
|
|
12
|
+
[GitHub release](https://github.com/rofy-ai/rofy-cli/releases) and checks its
|
|
13
|
+
SHA-256 fingerprint against the list shipped in this package. It refuses to
|
|
14
|
+
install if they differ.
|
|
15
|
+
|
|
16
|
+
Works on macOS, Linux and Windows, on x64 and arm64.
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
rofy model list
|
|
20
|
+
rofy generate create <model> --prompt "a red fox in the snow" --wait
|
|
21
|
+
rofy help
|
|
22
|
+
```
|
package/bin/rofy.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Hands every argument to the rofy program that install.js put in vendor/.
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const bin = path.join(__dirname, "..", "vendor", process.platform === "win32" ? "rofy.exe" : "rofy");
|
|
7
|
+
const result = spawnSync(bin, process.argv.slice(2), {
|
|
8
|
+
stdio: "inherit",
|
|
9
|
+
// So the program suggests the right command when an update is out.
|
|
10
|
+
env: { ...process.env, ROFY_INSTALL_METHOD: "npm" },
|
|
11
|
+
});
|
|
12
|
+
if (result.error) {
|
|
13
|
+
console.error(`@rofy/cli: could not run ${bin}: ${result.error.message}`);
|
|
14
|
+
console.error("Reinstall with: npm i -g @rofy/cli");
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/checksums.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rofy_darwin_amd64.gz": "4314b03408c62a898a9c8199e3fac36ba7a7fdab8c83da765a5b76eac741fbd3",
|
|
3
|
+
"rofy_darwin_arm64.gz": "f44080f393bb2a5f32aa8203edf8cbd3e74b581314cff80658a083009c03127c",
|
|
4
|
+
"rofy_linux_amd64.gz": "568d6b44e85bddf6d966d6ece7fce2038c1205ed495d85eaf9afc9cf43aebdf0",
|
|
5
|
+
"rofy_linux_arm64.gz": "a05db3a3fa9e909bfb2e3d99fbf289a4aadd2da186a883aa719a3787f44c186b",
|
|
6
|
+
"rofy_windows_amd64.gz": "dba6c1052b6bafe823a54326656c86b43255fbacfa8af5135e0024af4840def7",
|
|
7
|
+
"rofy_windows_arm64.gz": "d6c61c39beb20aa19ed8a58fcf51c6138ba68446be42dbba91f96b3bb42028f0"
|
|
8
|
+
}
|
package/install.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs after `npm i -g @rofy/cli`. This package is only a delivery van: it
|
|
3
|
+
// fetches the rofy program built for this computer and installs it, but only
|
|
4
|
+
// if its fingerprint matches the one published inside this package.
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const zlib = require("zlib");
|
|
8
|
+
const crypto = require("crypto");
|
|
9
|
+
|
|
10
|
+
const { version } = require("./package.json");
|
|
11
|
+
|
|
12
|
+
const os = { darwin: "darwin", linux: "linux", win32: "windows" }[process.platform];
|
|
13
|
+
const arch = { x64: "amd64", arm64: "arm64" }[process.arch];
|
|
14
|
+
const name = `rofy_${os}_${arch}.gz`;
|
|
15
|
+
// The override is for testing and mirrors. It cannot weaken the check below:
|
|
16
|
+
// the expected fingerprint comes from this package, not from the download.
|
|
17
|
+
const base =
|
|
18
|
+
process.env.ROFY_CLI_DOWNLOAD_BASE ||
|
|
19
|
+
`https://github.com/rofy-ai/rofy-cli/releases/download/v${version}`;
|
|
20
|
+
|
|
21
|
+
function get(url, redirects = 0) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
if (redirects > 5) return reject(new Error("too many redirects"));
|
|
24
|
+
const client = url.startsWith("https:") ? require("https") : require("http");
|
|
25
|
+
client
|
|
26
|
+
.get(url, (res) => {
|
|
27
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
28
|
+
res.resume();
|
|
29
|
+
return resolve(get(new URL(res.headers.location, url).toString(), redirects + 1));
|
|
30
|
+
}
|
|
31
|
+
if (res.statusCode !== 200) {
|
|
32
|
+
res.resume();
|
|
33
|
+
return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
|
|
34
|
+
}
|
|
35
|
+
const chunks = [];
|
|
36
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
37
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
38
|
+
res.on("error", reject);
|
|
39
|
+
})
|
|
40
|
+
.on("error", reject);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
(async () => {
|
|
45
|
+
if (!os || !arch) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`unsupported computer ${process.platform}/${process.arch}. Supported: macOS, Linux, Windows on x64 or arm64`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const expected = require("./checksums.json")[name];
|
|
51
|
+
if (!expected) throw new Error(`this package lists no fingerprint for ${name}`);
|
|
52
|
+
|
|
53
|
+
console.log(`@rofy/cli: downloading ${base}/${name}`);
|
|
54
|
+
const packed = await get(`${base}/${name}`);
|
|
55
|
+
const actual = crypto.createHash("sha256").update(packed).digest("hex");
|
|
56
|
+
if (actual !== expected) {
|
|
57
|
+
throw new Error(`the download's fingerprint does not match ${name}. Refusing to install`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const dir = path.join(__dirname, "vendor");
|
|
61
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
62
|
+
const bin = path.join(dir, os === "windows" ? "rofy.exe" : "rofy");
|
|
63
|
+
fs.writeFileSync(bin, zlib.gunzipSync(packed), { mode: 0o755 });
|
|
64
|
+
console.log("@rofy/cli: installed. Next: rofy auth login");
|
|
65
|
+
})().catch((err) => {
|
|
66
|
+
console.error(`@rofy/cli: install failed: ${err.message}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rofy/cli",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Rofy CLI: make images and videos with Rofy from a terminal.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"rofy": "bin/rofy.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node install.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/",
|
|
13
|
+
"install.js",
|
|
14
|
+
"checksums.json",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=16"
|
|
19
|
+
},
|
|
20
|
+
"os": [
|
|
21
|
+
"darwin",
|
|
22
|
+
"linux",
|
|
23
|
+
"win32"
|
|
24
|
+
],
|
|
25
|
+
"cpu": [
|
|
26
|
+
"x64",
|
|
27
|
+
"arm64"
|
|
28
|
+
],
|
|
29
|
+
"license": "UNLICENSED",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/rofy-ai/rofy-cli.git"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|