@grrocloud/cli 0.0.0-stage → 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 +14 -2
- package/bin/grro.js +17 -0
- package/install.js +58 -0
- package/package.json +13 -4
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @grrocloud/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Grro Cloud command line tool.
|
|
4
|
+
|
|
5
|
+
npm install -g @grrocloud/cli
|
|
6
|
+
grro login
|
|
7
|
+
grro help
|
|
8
|
+
|
|
9
|
+
Deploy and watch the build, follow logs, roll back, set variables, scale, add
|
|
10
|
+
domains and databases, take backups, schedule jobs and more. Full guide:
|
|
11
|
+
https://usegrro.com/docs/cli
|
|
12
|
+
|
|
13
|
+
Installing downloads the grro program for your computer from usegrro.com and
|
|
14
|
+
checks it against its published SHA-256 checksum. Update with
|
|
15
|
+
`npm install -g @grrocloud/cli@latest`.
|
package/bin/grro.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs the grro program that install.js downloaded.
|
|
3
|
+
"use strict";
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const { spawnSync } = require("child_process");
|
|
7
|
+
const bin = path.join(__dirname, "..", "vendor", process.platform === "win32" ? "grro.exe" : "grro");
|
|
8
|
+
if (!fs.existsSync(bin)) {
|
|
9
|
+
console.error("grro: the program is missing. Reinstall it: npm install -g @grrocloud/cli");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
const r = spawnSync(bin, process.argv.slice(2), { stdio: "inherit", env: { ...process.env, GRRO_INSTALLED_BY: "npm" } });
|
|
13
|
+
if (r.error) {
|
|
14
|
+
console.error(`grro: ${r.error.message}`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
process.exit(r.status === null ? 1 : r.status);
|
package/install.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Downloads the grro program for this computer from the GitHub release of
|
|
3
|
+
// the same version when the npm package is installed, checks it against the published SHA-256 checksum and keeps it
|
|
4
|
+
// in vendor/. Set GRRO_CLI_BASE to download from somewhere else.
|
|
5
|
+
"use strict";
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const https = require("https");
|
|
9
|
+
const http = require("http");
|
|
10
|
+
const crypto = require("crypto");
|
|
11
|
+
|
|
12
|
+
const version = require("./package.json").version;
|
|
13
|
+
const base = (process.env.GRRO_CLI_BASE || "https://github.com/grro-cloud/cli/releases/download").replace(/\/$/, "");
|
|
14
|
+
const os = { darwin: "darwin", linux: "linux", win32: "windows" }[process.platform];
|
|
15
|
+
const arch = { x64: "amd64", arm64: "arm64" }[process.arch];
|
|
16
|
+
if (!os || !arch || (os === "windows" && arch === "arm64")) {
|
|
17
|
+
console.error(`grro: there is no build for ${process.platform}/${process.arch} yet.`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const file = `grro-${os}-${arch}${os === "windows" ? ".exe" : ""}`;
|
|
21
|
+
const dir = path.join(__dirname, "vendor");
|
|
22
|
+
const dest = path.join(dir, os === "windows" ? "grro.exe" : "grro");
|
|
23
|
+
|
|
24
|
+
function get(url, redirects = 5) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
(url.startsWith("http:") ? http : https)
|
|
27
|
+
.get(url, { headers: { "User-Agent": `grro-npm/${version}` } }, (res) => {
|
|
28
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location && redirects > 0) {
|
|
29
|
+
res.resume();
|
|
30
|
+
return resolve(get(new URL(res.headers.location, url).toString(), redirects - 1));
|
|
31
|
+
}
|
|
32
|
+
if (res.statusCode !== 200) {
|
|
33
|
+
res.resume();
|
|
34
|
+
return reject(new Error(`${url} answered ${res.statusCode}`));
|
|
35
|
+
}
|
|
36
|
+
const chunks = [];
|
|
37
|
+
res.on("data", (c) => chunks.push(c));
|
|
38
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
39
|
+
})
|
|
40
|
+
.on("error", reject);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
(async () => {
|
|
45
|
+
const root = `${base}/v${version}`;
|
|
46
|
+
const sums = (await get(`${root}/SHA256SUMS`)).toString("utf8");
|
|
47
|
+
const want = sums.split("\n").map((l) => l.trim().split(/\s+/)).find((p) => p[1] === file)?.[0];
|
|
48
|
+
if (!want) throw new Error(`no checksum for ${file} in ${root}/SHA256SUMS`);
|
|
49
|
+
const bin = await get(`${root}/${file}`);
|
|
50
|
+
const got = crypto.createHash("sha256").update(bin).digest("hex");
|
|
51
|
+
if (got !== want) throw new Error("the download doesn't match its checksum, so it was not installed");
|
|
52
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
53
|
+
fs.writeFileSync(dest, bin, { mode: 0o755 });
|
|
54
|
+
console.log(`grro ${version} installed. Run: grro login`);
|
|
55
|
+
})().catch((e) => {
|
|
56
|
+
console.error(`grro: ${e.message}. Try again, or install with: curl -fsSL https://github.com/grro-cloud/cli/releases/latest/download/install.sh | sh`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grrocloud/cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The Grro Cloud command line tool: deploy, logs, variables, domains, databases and more from your terminal.",
|
|
5
|
+
"homepage": "https://usegrro.com/docs/cli",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": { "grro": "bin/grro.js" },
|
|
8
|
+
"scripts": { "postinstall": "node install.js" },
|
|
9
|
+
"files": ["bin/grro.js", "install.js", "README.md"],
|
|
10
|
+
"os": ["darwin", "linux", "win32"],
|
|
11
|
+
"cpu": ["x64", "arm64"],
|
|
12
|
+
"engines": { "node": ">=16" },
|
|
13
|
+
"publishConfig": { "access": "public" },
|
|
14
|
+
"keywords": ["grro", "grro cloud", "paas", "deploy", "cli", "heroku"]
|
|
15
|
+
}
|