@gizai/cli 2.1.1 → 2.2.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 +190 -9
- package/cli/codex-relay.mjs +46 -0
- package/cli/computer-identity.mjs +76 -0
- package/cli/engine.mjs +58 -0
- package/cli/giz.mjs +1129 -0
- package/cli/gizdb.mjs +8 -0
- package/cli/mcp-stdio-client.mjs +81 -0
- package/cli/media-capture.mjs +321 -0
- package/cli/toolchain.mjs +71 -0
- package/cli/update.mjs +150 -0
- package/mcp.json +6 -0
- package/package.json +47 -15
- package/plugin.json +10 -0
- package/LICENSE +0 -21
- package/bin/giz.js +0 -78
- package/bin/install.sh +0 -268
package/package.json
CHANGED
|
@@ -1,27 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gizai/cli",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "The official command-line interface for giz.ai: run AI models, Drive, Computers and Apps, connect Claude Code, Codex and other agents over MCP, and run Gizlang (giz init, run, deploy), installed on first use.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"giz",
|
|
7
|
+
"giz.ai",
|
|
8
|
+
"cli",
|
|
9
|
+
"mcp",
|
|
10
|
+
"model-context-protocol",
|
|
11
|
+
"ai",
|
|
12
|
+
"llm",
|
|
13
|
+
"agent",
|
|
14
|
+
"claude-code",
|
|
15
|
+
"codex",
|
|
16
|
+
"image-generation",
|
|
17
|
+
"video-generation"
|
|
18
|
+
],
|
|
19
|
+
"homepage": "https://www.giz.ai/mcp/",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"email": "support@giz.ai",
|
|
22
|
+
"url": "https://www.giz.ai/mcp/"
|
|
9
23
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "Giz Inc.",
|
|
26
|
+
"url": "https://www.giz.ai"
|
|
13
27
|
},
|
|
28
|
+
"license": "UNLICENSED",
|
|
29
|
+
"type": "module",
|
|
14
30
|
"bin": {
|
|
15
|
-
"giz": "
|
|
31
|
+
"giz": "cli/giz.mjs",
|
|
32
|
+
"gizdb": "cli/gizdb.mjs"
|
|
16
33
|
},
|
|
17
34
|
"files": [
|
|
18
|
-
"
|
|
19
|
-
"skills"
|
|
35
|
+
"cli",
|
|
36
|
+
"skills",
|
|
37
|
+
"plugin.json",
|
|
38
|
+
"mcp.json",
|
|
39
|
+
"README.md"
|
|
20
40
|
],
|
|
21
41
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
42
|
+
"node": ">=20.12"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
46
|
+
"proper-lockfile": "4.1.2"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/gizai/giz.git",
|
|
51
|
+
"directory": "apps/giz/external"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
23
55
|
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
56
|
+
"scripts": {
|
|
57
|
+
"check": "node --check cli/giz.mjs && node --test test/*.test.mjs"
|
|
26
58
|
}
|
|
27
59
|
}
|
package/plugin.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
|
+
"name": "giz",
|
|
4
|
+
"version": "2.0.1",
|
|
5
|
+
"description": "Run Giz models, media generation, Drive, tables, Apps and Computers from any agent: the giz skill plus the Giz MCP server.",
|
|
6
|
+
"author": { "name": "Giz", "url": "https://www.giz.ai" },
|
|
7
|
+
"homepage": "https://www.giz.ai/mcp/",
|
|
8
|
+
"license": "UNLICENSED",
|
|
9
|
+
"keywords": ["giz", "mcp", "media", "drive", "computer"]
|
|
10
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Giz Systems Inc. and the Gizlang contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/bin/giz.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// The npm entry of GizStack 0.1.0-preview.20261023.5 (generated by tools/distribution/channels).
|
|
3
|
-
// The giz.ai commands (auth api-key credits model models chat generate job drive table upload computer app connection plugin agent invoke mcp skill engine update __update-check), help and --version run the command line binary of this platform's package
|
|
4
|
-
// (@gizai/cli-OS-CPU, an optional dependency), which needs no toolchain: giz.ai CLI 2.0's users keep working right after
|
|
5
|
-
// `npm install`. Every other command needs the toolchain: the first such run installs this version with install.sh, which
|
|
6
|
-
// finds the platform, downloads its installer from the content address, checks the SHA-256 against the table in this
|
|
7
|
-
// package, and runs it; the installer checks the release signature and every file. Then each run executes the installed
|
|
8
|
-
// giz, which selects the version (a project pin or the active one).
|
|
9
|
-
"use strict";
|
|
10
|
-
const { spawnSync } = require("child_process");
|
|
11
|
-
const fs = require("fs");
|
|
12
|
-
const os = require("os");
|
|
13
|
-
const path = require("path");
|
|
14
|
-
|
|
15
|
-
const VERSION = "0.1.0-preview.20261023.5";
|
|
16
|
-
const ACCOUNT = new Set("auth api-key credits model models chat generate job drive table upload computer app connection plugin agent invoke mcp skill engine update __update-check".split(" ").filter(Boolean));
|
|
17
|
-
// 2.0's flags that take no value: the command is the first word that is not a flag or a flag's value.
|
|
18
|
-
const BOOLEANS = new Set(["help", "json", "no-open", "version", "device"]);
|
|
19
|
-
|
|
20
|
-
function fail(message) {
|
|
21
|
-
process.stderr.write("giz: " + message + "\n");
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
function commandOf(argv) {
|
|
25
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
26
|
-
const word = argv[i];
|
|
27
|
-
if (word === "--") return argv[i + 1] || "";
|
|
28
|
-
if (!word.startsWith("--")) return word;
|
|
29
|
-
const name = word.slice(2).split("=")[0];
|
|
30
|
-
if (!word.includes("=") && !BOOLEANS.has(name) && argv[i + 1] && !argv[i + 1].startsWith("--")) i += 1;
|
|
31
|
-
}
|
|
32
|
-
return "";
|
|
33
|
-
}
|
|
34
|
-
// The package manager that installed this package, for `giz update`.
|
|
35
|
-
function installer() {
|
|
36
|
-
const at = __dirname.toLowerCase();
|
|
37
|
-
if (at.includes(path.sep + ".pnpm" + path.sep) || /[\\/]pnpm[\\/]global[\\/]/.test(at)) return "pnpm";
|
|
38
|
-
if (at.includes(path.sep + ".bun" + path.sep)) return "bun";
|
|
39
|
-
if (at.includes(path.sep + ".yarn" + path.sep) || at.includes(path.sep + "yarn" + path.sep + "global" + path.sep)) return "yarn";
|
|
40
|
-
return "npm";
|
|
41
|
-
}
|
|
42
|
-
function bundled() {
|
|
43
|
-
const system = { linux: "linux", darwin: "darwin", win32: "win32" }[process.platform];
|
|
44
|
-
const cpu = { x64: "x64", arm64: "arm64" }[process.arch];
|
|
45
|
-
if (!system || !cpu || ACCOUNT.size === 0) return undefined;
|
|
46
|
-
try {
|
|
47
|
-
const file = path.join(path.dirname(require.resolve("@gizai/cli-" + system + "-" + cpu + "/package.json")), "bin", "giz" + (system === "win32" ? ".exe" : ""));
|
|
48
|
-
return fs.existsSync(file) ? file : undefined;
|
|
49
|
-
} catch { return undefined; }
|
|
50
|
-
}
|
|
51
|
-
function run(file, standalone) {
|
|
52
|
-
const env = { ...process.env, GIZ_INSTALLER: installer(), GIZ_SELF: process.argv[1],
|
|
53
|
-
GIZ_SKILLS: path.join(__dirname, "..", "skills") };
|
|
54
|
-
if (standalone) env.GIZ_STANDALONE = "1";
|
|
55
|
-
const ran = spawnSync(file, process.argv.slice(2), { stdio: "inherit", env });
|
|
56
|
-
if (ran.error) fail(ran.error.message);
|
|
57
|
-
if (ran.signal) process.kill(process.pid, ran.signal);
|
|
58
|
-
process.exit(ran.status === null ? 1 : ran.status);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const argv = process.argv.slice(2);
|
|
62
|
-
const command = commandOf(argv);
|
|
63
|
-
const own = bundled();
|
|
64
|
-
if (process.platform === "win32") {
|
|
65
|
-
if (!own) fail("the Windows binary package was not installed; reinstall without --omit=optional");
|
|
66
|
-
run(own, true);
|
|
67
|
-
}
|
|
68
|
-
// `--version` goes to the toolchain: it names the toolchain's version, and the install guide's first command fetches it.
|
|
69
|
-
if (own && (ACCOUNT.has(command) || argv.length === 0 || command === "help" || command === "-h" || (command === "" && argv.includes("--help")))) {
|
|
70
|
-
run(own, true);
|
|
71
|
-
}
|
|
72
|
-
const root = process.env.GIZ_INSTALL || path.join(os.homedir(), ".giz");
|
|
73
|
-
const bin = path.join(root, "bin", "giz");
|
|
74
|
-
const installed = spawnSync("sh", [path.join(__dirname, "install.sh"), ..."".split(" ").filter(Boolean), "--if-missing", "--no-modify-path", "--version", VERSION],
|
|
75
|
-
{ stdio: ["inherit", process.stderr, "inherit"], env: { ...process.env, GIZ_INSTALL: root } });
|
|
76
|
-
if (installed.error) fail("cannot run sh: " + installed.error.message + ". Supported platforms: https://gizstack.com/download");
|
|
77
|
-
if (installed.status !== 0) process.exit(installed.status === null ? 1 : installed.status);
|
|
78
|
-
run(bin, false);
|
package/bin/install.sh
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# Install GizStack: curl -fsSL https://gizstack.com/install | sh
|
|
3
|
-
# Install the GizDB server alone: curl -fsSL https://gizstack.com/install | sh -s -- --only gizdb
|
|
4
|
-
# While gizstack.com is in private preview, the command on your signed-in page adds
|
|
5
|
-
# -H "Authorization: Bearer TOKEN": the script served for it carries that access token
|
|
6
|
-
# and stores it in ~/.config/gizstack/access-token, where the installer and
|
|
7
|
-
# `giz upgrade` read it.
|
|
8
|
-
#
|
|
9
|
-
# This script downloads the official installer for your platform from its
|
|
10
|
-
# content address, checks its SHA-256 against that address and runs it. The
|
|
11
|
-
# installer verifies the release signature and every file hash before it
|
|
12
|
-
# activates the version. Nothing needs root. Docs: https://gizstack.com/docs/start
|
|
13
|
-
#
|
|
14
|
-
# Options (sh -s -- OPTION...):
|
|
15
|
-
# --only gizdb install only the GizDB server (bin/gizdb): the same
|
|
16
|
-
# signed release, without the compiler, into ~/.gizdb
|
|
17
|
-
# --version VERSION install this published version (default: the newest)
|
|
18
|
-
# --no-modify-path do not add the bin directory to shell profiles
|
|
19
|
-
# --installer FILE use this downloaded installer (the npm and Homebrew
|
|
20
|
-
# packages carry it); its SHA-256 is checked the same way
|
|
21
|
-
# --if-missing do nothing when this version is installed already
|
|
22
|
-
# (the package wrappers run it before each command)
|
|
23
|
-
# Environment: GIZ_INSTALL (default ~/.giz; with --only gizdb,
|
|
24
|
-
# GIZDB_INSTALL, default ~/.gizdb), NO_MODIFY_PATH=1.
|
|
25
|
-
#
|
|
26
|
-
# Everything runs inside main(), called on the last line, so a download that
|
|
27
|
-
# is cut off does nothing.
|
|
28
|
-
|
|
29
|
-
set -u
|
|
30
|
-
|
|
31
|
-
SITE="https://gizstack.com"
|
|
32
|
-
# The access token this script was served for (the server writes it here), or empty.
|
|
33
|
-
ACCESS=''
|
|
34
|
-
|
|
35
|
-
# Published installers: product (toolchain, or gizdb for the server alone),
|
|
36
|
-
# target, version, installer SHA-256.
|
|
37
|
-
# Generated from $SITE/api/releases when this script was served.
|
|
38
|
-
releases() {
|
|
39
|
-
cat <<'RELEASES'
|
|
40
|
-
toolchain x86_64-unknown-linux-gnu 0.1.0-preview.20261023.5 1f73b27cdf6024e1f1dee7b428bb1210cc2933851fff75e35361d27a4ad1ef31
|
|
41
|
-
gizdb x86_64-unknown-linux-gnu 0.1.0-preview.20261015.5 cc102bb96abcbe04a98dbc697595310e28b7d997a716f979258ff2afaf4620c6
|
|
42
|
-
RELEASES
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
say() { printf '%s\n' "$*"; }
|
|
46
|
-
fail() { printf 'giz-install: %s\n' "$*" >&2; exit 1; }
|
|
47
|
-
|
|
48
|
-
detect_target() {
|
|
49
|
-
os=$(uname -s)
|
|
50
|
-
arch=$(uname -m)
|
|
51
|
-
case "$arch" in
|
|
52
|
-
x86_64 | amd64) arch=x86_64 ;;
|
|
53
|
-
aarch64 | arm64) arch=aarch64 ;;
|
|
54
|
-
*) fail "unsupported CPU architecture: $arch. Supported platforms: $SITE/download" ;;
|
|
55
|
-
esac
|
|
56
|
-
case "$os" in
|
|
57
|
-
Linux)
|
|
58
|
-
libc=gnu
|
|
59
|
-
if ls /lib/ld-musl-* >/dev/null 2>&1 || (ldd --version 2>&1 | grep -qi musl); then libc=musl; fi
|
|
60
|
-
target="$arch-unknown-linux-$libc" ;;
|
|
61
|
-
Darwin)
|
|
62
|
-
# A shell under Rosetta reports x86_64 on Apple Silicon.
|
|
63
|
-
if [ "$arch" = x86_64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = 1 ]; then arch=aarch64; fi
|
|
64
|
-
target="$arch-apple-darwin" ;;
|
|
65
|
-
MINGW* | MSYS* | CYGWIN* | Windows_NT)
|
|
66
|
-
fail "on Windows, run in PowerShell: irm $SITE/install.ps1 | iex" ;;
|
|
67
|
-
*) fail "unsupported operating system: $os. Supported platforms: $SITE/download" ;;
|
|
68
|
-
esac
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
# Sets digest and version from the table, or explains what exists.
|
|
72
|
-
select_release() {
|
|
73
|
-
digest=""
|
|
74
|
-
[ -n "$(releases)" ] || fail "no GizStack release supports this install script yet. Download an installer: $SITE/download"
|
|
75
|
-
found=$(releases | while read -r p t v d; do
|
|
76
|
-
if [ "$p" = "$product" ] && [ "$t" = "$target" ] && { [ -z "$wanted" ] || [ "$v" = "$wanted" ]; }; then say "$v $d"; break; fi
|
|
77
|
-
done)
|
|
78
|
-
if [ -n "$found" ]; then version=${found% *}; digest=${found#* }; return; fi
|
|
79
|
-
available=$(releases | while read -r p t v d; do if [ "$p" = "$product" ] && [ "$t" = "$target" ]; then printf ' %s' "$v"; fi; done)
|
|
80
|
-
if [ -n "$available" ]; then fail "$name $wanted is not published for $target. Published:$available"; fi
|
|
81
|
-
platforms=$(releases | while read -r p t v d; do if [ "$p" = "$product" ]; then printf '\n %s' "$t"; fi; done)
|
|
82
|
-
[ -n "$platforms" ] || fail "no $name release supports this install script yet. Release status: $SITE/download"
|
|
83
|
-
fail "no $name release for $target yet. Published platforms:$platforms
|
|
84
|
-
Use the browser Playground meanwhile: $SITE/play. Release status: $SITE/download"
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
download() { # URL FILE
|
|
88
|
-
if command -v curl >/dev/null 2>&1; then
|
|
89
|
-
if [ -n "$KEY" ]; then curl --proto '=https' --tlsv1.2 -fsSL --retry 3 -H "Authorization: Bearer $KEY" -o "$2" "$1"
|
|
90
|
-
else curl --proto '=https' --tlsv1.2 -fsSL --retry 3 -o "$2" "$1"; fi
|
|
91
|
-
elif command -v wget >/dev/null 2>&1; then
|
|
92
|
-
if [ -n "$KEY" ]; then wget --https-only -q --header="Authorization: Bearer $KEY" -O "$2" "$1"
|
|
93
|
-
else wget --https-only -q -O "$2" "$1"; fi
|
|
94
|
-
elif command -v node >/dev/null 2>&1; then
|
|
95
|
-
# The npm package runs this script, so Node.js is there even where curl and wget are not (node:*-slim, a minimal WSL).
|
|
96
|
-
node -e 'const [u, f, k] = process.argv.slice(1); if (!u.startsWith("https://")) { console.error("not https: " + u); process.exit(1); }
|
|
97
|
-
require("https").get(u, { headers: k ? { Authorization: "Bearer " + k } : {} }, (r) => {
|
|
98
|
-
if (r.statusCode !== 200) { console.error("HTTP " + r.statusCode + " for " + u); process.exit(1); }
|
|
99
|
-
r.pipe(require("fs").createWriteStream(f)).on("error", (e) => { console.error(e.message); process.exit(1); });
|
|
100
|
-
}).on("error", (e) => { console.error(e.message); process.exit(1); });' "$1" "$2" "$KEY"
|
|
101
|
-
else
|
|
102
|
-
fail "curl, wget or node is required"
|
|
103
|
-
fi
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
sha256() {
|
|
107
|
-
if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d ' ' -f 1
|
|
108
|
-
elif command -v shasum >/dev/null 2>&1; then shasum -a 256 "$1" | cut -d ' ' -f 1
|
|
109
|
-
elif command -v openssl >/dev/null 2>&1; then openssl dgst -sha256 -r "$1" | cut -d ' ' -f 1
|
|
110
|
-
else fail "sha256sum, shasum or openssl is required to check the installer"
|
|
111
|
-
fi
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
add_line() { # FILE LINE: append LINE once
|
|
115
|
-
if [ -f "$1" ] && grep -qxF "$2" "$1"; then return; fi
|
|
116
|
-
printf '\n%s\n' "$2" >>"$1" && changed="$changed $1"
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
# One line in each profile sources $root/env, which adds bin to PATH once.
|
|
120
|
-
modify_path() {
|
|
121
|
-
bin="$root/bin"
|
|
122
|
-
cat >"$root/env" <<ENV
|
|
123
|
-
# Added by the $name installer.
|
|
124
|
-
case ":\${PATH}:" in *":$bin:"*) ;; *) export PATH="$bin:\$PATH" ;; esac
|
|
125
|
-
ENV
|
|
126
|
-
cat >"$root/env.fish" <<ENV
|
|
127
|
-
# Added by the $name installer.
|
|
128
|
-
if not contains -- "$bin" \$PATH; set -gx PATH "$bin" \$PATH; end
|
|
129
|
-
ENV
|
|
130
|
-
line=". \"$root/env\""
|
|
131
|
-
zshrc="${ZDOTDIR:-$HOME}/.zshrc"
|
|
132
|
-
for profile in "$HOME/.profile" "$HOME/.bashrc" "$HOME/.bash_profile" "$zshrc"; do
|
|
133
|
-
case "$profile" in
|
|
134
|
-
"$HOME/.bash_profile") [ -f "$profile" ] || continue ;;
|
|
135
|
-
"$zshrc") [ -f "$profile" ] || command -v zsh >/dev/null 2>&1 || continue ;;
|
|
136
|
-
esac
|
|
137
|
-
add_line "$profile" "$line"
|
|
138
|
-
done
|
|
139
|
-
if command -v fish >/dev/null 2>&1 || [ -d "$HOME/.config/fish" ]; then
|
|
140
|
-
mkdir -p "$HOME/.config/fish/conf.d"
|
|
141
|
-
fishline="source \"$root/env.fish\""
|
|
142
|
-
fishrc="$HOME/.config/fish/conf.d/$command.fish"
|
|
143
|
-
add_line "$fishrc" "$fishline"
|
|
144
|
-
fi
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
# The installer, `giz upgrade` and package reads send this token to gizstack.com.
|
|
148
|
-
store_access() {
|
|
149
|
-
[ -n "$ACCESS" ] || return 0
|
|
150
|
-
config="${XDG_CONFIG_HOME:-$HOME/.config}/gizstack"
|
|
151
|
-
(umask 077 && mkdir -p "$config" && printf '%s\n' "$ACCESS" >"$config/access-token.new" && mv "$config/access-token.new" "$config/access-token") || fail "cannot store the access token in $config"
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
# A script not served with a key (npm, or a rerun) takes the key the way access.giz does: GIZ_ACCESS_TOKEN, else the
|
|
155
|
-
# file. Only the downloads below use it, and only from $SITE. A value outside the token alphabet is refused whole, as
|
|
156
|
-
# access.giz refuses it, so a bad value is never sent.
|
|
157
|
-
resolve_access() {
|
|
158
|
-
KEY=$ACCESS
|
|
159
|
-
if [ -z "$KEY" ]; then KEY=$(printf '%s' "${GIZ_ACCESS_TOKEN:-}" | tr -d ' \t\r\n'); fi
|
|
160
|
-
if [ -z "$KEY" ] && [ -n "${HOME:-}" ]; then
|
|
161
|
-
KEY=$(tr -d ' \t\r\n' 2>/dev/null <"${XDG_CONFIG_HOME:-$HOME/.config}/gizstack/access-token")
|
|
162
|
-
fi
|
|
163
|
-
case "$KEY" in *[!0-9a-z_]*) KEY='' ;; esac
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
main() {
|
|
167
|
-
wanted=""
|
|
168
|
-
local_installer=""
|
|
169
|
-
if_missing=0
|
|
170
|
-
product=toolchain
|
|
171
|
-
path_changes=1
|
|
172
|
-
if [ -n "${NO_MODIFY_PATH:-}" ]; then path_changes=0; fi
|
|
173
|
-
while [ $# -gt 0 ]; do
|
|
174
|
-
case "$1" in
|
|
175
|
-
--only) [ $# -ge 2 ] || fail "--only needs a value"; [ "$2" = gizdb ] || fail "--only takes gizdb (the GizDB server alone), not $2"; product=gizdb; shift 2 ;;
|
|
176
|
-
--version) [ $# -ge 2 ] || fail "--version needs a value"; wanted=$2; shift 2 ;;
|
|
177
|
-
--no-modify-path) path_changes=0; shift ;;
|
|
178
|
-
--if-missing) if_missing=1; shift ;;
|
|
179
|
-
--installer) [ $# -ge 2 ] || fail "--installer needs a value"; local_installer=$2; shift 2 ;;
|
|
180
|
-
-h | --help) say "Usage: curl -fsSL $SITE/install | sh -s -- [--only gizdb] [--version VERSION] [--no-modify-path]"; say "Docs: $SITE/docs/start"; exit 0 ;;
|
|
181
|
-
*) fail "unknown option: $1 (see $SITE/docs/start)" ;;
|
|
182
|
-
esac
|
|
183
|
-
done
|
|
184
|
-
# The GizDB server alone is its own installation, beside a toolchain's, never inside it.
|
|
185
|
-
if [ "$product" = gizdb ]; then
|
|
186
|
-
name=GizDB; command=gizdb; variable=GIZDB_INSTALL; root="${GIZDB_INSTALL:-}"; home=.gizdb
|
|
187
|
-
else
|
|
188
|
-
name=GizStack; command=giz; variable=GIZ_INSTALL; root="${GIZ_INSTALL:-}"; home=.giz
|
|
189
|
-
fi
|
|
190
|
-
if [ -z "$root" ]; then
|
|
191
|
-
[ -n "${HOME:-}" ] || fail "HOME is not set; set $variable to the installation directory"
|
|
192
|
-
root="$HOME/$home"
|
|
193
|
-
# An install from before the command was gizstack (~/.gizlang) is upgraded in place: the installer then removes
|
|
194
|
-
# its gizlang command, and no second command stays on PATH.
|
|
195
|
-
if [ "$product" != gizdb ] && [ ! -e "$root" ] && [ -f "$HOME/.gizlang/active-toolchain" ]; then root="$HOME/.gizlang"; fi
|
|
196
|
-
fi
|
|
197
|
-
if [ "$wanted" = latest ]; then wanted=""; fi
|
|
198
|
-
case "$root" in
|
|
199
|
-
/*) ;;
|
|
200
|
-
*) fail "$variable must be an absolute path: $root" ;;
|
|
201
|
-
esac
|
|
202
|
-
case "$root" in
|
|
203
|
-
*[\"\$\`\\]*) fail "$variable cannot contain quotes, \$, backquotes or backslashes: $root" ;;
|
|
204
|
-
esac
|
|
205
|
-
|
|
206
|
-
detect_target
|
|
207
|
-
select_release
|
|
208
|
-
if [ "$if_missing" = 1 ]; then
|
|
209
|
-
for installed in "$root/versions/$product-$target-$version-"*; do
|
|
210
|
-
if [ -f "$installed/release.json" ]; then exit 0; fi
|
|
211
|
-
done
|
|
212
|
-
fi
|
|
213
|
-
|
|
214
|
-
work=$(mktemp -d 2>/dev/null || mktemp -d -t giz) || fail "cannot create a temporary directory"
|
|
215
|
-
trap 'rm -rf "$work"' EXIT
|
|
216
|
-
installer="$work/$command-installer"
|
|
217
|
-
if [ -n "$local_installer" ]; then
|
|
218
|
-
cp "$local_installer" "$installer" || fail "cannot read the installer $local_installer"
|
|
219
|
-
else
|
|
220
|
-
say "Downloading the $name $version installer for $target"
|
|
221
|
-
resolve_access
|
|
222
|
-
if ! download "$SITE/objects/sha256/$digest" "$installer"; then
|
|
223
|
-
[ -n "$KEY" ] || fail "the installer download was refused: $name is in private preview. Signed in at $SITE, your install command on $SITE/download carries your access key (or set GIZ_ACCESS_TOKEN). No invitation yet: $SITE/access-request"
|
|
224
|
-
fail "the installer download failed: $SITE/objects/sha256/$digest"
|
|
225
|
-
fi
|
|
226
|
-
fi
|
|
227
|
-
actual=$(sha256 "$installer")
|
|
228
|
-
[ "$actual" = "$digest" ] || fail "the installer SHA-256 is $actual, not $digest; nothing was installed"
|
|
229
|
-
chmod u+x "$installer"
|
|
230
|
-
# A copy that came through a browser or an archive tool carries the macOS
|
|
231
|
-
# quarantine attribute, and Gatekeeper then refuses the ad-hoc signed program.
|
|
232
|
-
# The SHA-256 check above replaces what the attribute would have asked the user to trust.
|
|
233
|
-
if [ "$os" = Darwin ] && command -v xattr >/dev/null 2>&1; then xattr -d com.apple.quarantine "$installer" 2>/dev/null || :; fi
|
|
234
|
-
|
|
235
|
-
store_access
|
|
236
|
-
mkdir -p "$root" || fail "cannot create $root"
|
|
237
|
-
"$installer" --root "$root" || fail "the installer failed; the previous version, if any, stays active"
|
|
238
|
-
|
|
239
|
-
changed=""
|
|
240
|
-
if [ "$path_changes" = 1 ]; then modify_path; fi
|
|
241
|
-
say ""
|
|
242
|
-
if [ "$product" = gizdb ]; then
|
|
243
|
-
# gizdb has no --version; its usage proves the installed server runs here.
|
|
244
|
-
"$root/bin/gizdb" --help >/dev/null || fail "$root/bin/gizdb does not run on this computer"
|
|
245
|
-
say "GizDB $version for $target is installed: $root/bin/gizdb"
|
|
246
|
-
else
|
|
247
|
-
"$root/bin/giz" --version || fail "$root/bin/giz does not run on this computer"
|
|
248
|
-
fi
|
|
249
|
-
say ""
|
|
250
|
-
if [ -n "$changed" ]; then
|
|
251
|
-
say "Added $root/bin to PATH in:$changed"
|
|
252
|
-
say "Open a new terminal, or run: . \"$root/env\""
|
|
253
|
-
elif [ "$path_changes" = 1 ]; then
|
|
254
|
-
say "$root/bin is already on PATH in your shell profiles."
|
|
255
|
-
else
|
|
256
|
-
say "Add $root/bin to PATH to run $command."
|
|
257
|
-
fi
|
|
258
|
-
say ""
|
|
259
|
-
if [ "$product" = gizdb ]; then
|
|
260
|
-
say "Next: GIZDB_PASSWORD=... gizdb serve --dir ~/gizdb-data --port 5432"
|
|
261
|
-
say "Docs: $SITE/docs/operations/gizdb-server (systemd unit, backups, upgrades)"
|
|
262
|
-
else
|
|
263
|
-
say "Next: giz init hello && cd hello && giz run main.giz"
|
|
264
|
-
say "Docs: $SITE/docs/start"
|
|
265
|
-
fi
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
main "$@"
|