@workerstack/clients 1.0.0-rc.23 → 1.0.0-rc.25
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 +67 -11
- package/assets/installers/examples/github.config.ts +21 -0
- package/assets/installers/examples/goreleaser.config.ts +21 -0
- package/assets/installers/examples/raw.config.ts +17 -0
- package/assets/installers/templates/install.ps1 +426 -0
- package/assets/installers/templates/install.sh +412 -0
- package/bin/installgen.js +19 -0
- package/dist/cli.js +4 -0
- package/dist/emit/cli/install.d.ts +8 -5
- package/dist/emit/cli/install.js +14 -7
- package/dist/emit/cli/release.js +8 -7
- package/dist/emit/shared/status-keys.d.ts +2 -2
- package/dist/emit/shared/status-keys.js +2 -2
- package/dist/gen/args.js +4 -0
- package/dist/gen/formatters.d.ts +1 -1
- package/dist/gen/formatters.js +1 -1
- package/dist/gen/targets.d.ts +1 -1
- package/dist/gen/targets.js +1 -1
- package/dist/installers/cli.d.ts +21 -0
- package/dist/installers/cli.js +170 -0
- package/dist/installers/commands/build.d.ts +15 -0
- package/dist/installers/commands/build.js +34 -0
- package/dist/installers/commands/check.d.ts +10 -0
- package/dist/installers/commands/check.js +161 -0
- package/dist/installers/commands/init.d.ts +9 -0
- package/dist/installers/commands/init.js +32 -0
- package/dist/installers/config/define-config.d.ts +100 -0
- package/dist/installers/config/define-config.js +10 -0
- package/dist/installers/config/hooks/bun.d.ts +21 -0
- package/dist/installers/config/hooks/bun.js +21 -0
- package/dist/installers/config/hooks/node.d.ts +9 -0
- package/dist/installers/config/hooks/node.js +16 -0
- package/dist/installers/config/load.d.ts +35 -0
- package/dist/installers/config/load.js +97 -0
- package/dist/installers/config/resolve.d.ts +4 -0
- package/dist/installers/config/resolve.js +281 -0
- package/dist/installers/config/types.d.ts +45 -0
- package/dist/installers/config/types.js +1 -0
- package/dist/installers/errors.d.ts +5 -0
- package/dist/installers/errors.js +5 -0
- package/dist/installers/index.d.ts +11 -0
- package/dist/installers/index.js +11 -0
- package/dist/installers/render/quote.d.ts +7 -0
- package/dist/installers/render/quote.js +34 -0
- package/dist/installers/render/render.d.ts +24 -0
- package/dist/installers/render/render.js +133 -0
- package/dist/installers/ui.d.ts +15 -0
- package/dist/installers/ui.js +14 -0
- package/dist/release/bootstrap.d.ts +61 -0
- package/dist/release/bootstrap.js +191 -0
- package/dist/release/bump-args.d.ts +17 -0
- package/dist/release/bump-args.js +35 -0
- package/dist/release/bump-command.d.ts +18 -0
- package/dist/release/bump-command.js +186 -0
- package/dist/release/bump.d.ts +33 -0
- package/dist/release/bump.js +72 -0
- package/dist/release/cli.d.ts +23 -0
- package/dist/release/cli.js +85 -0
- package/dist/release/codegen.d.ts +6 -0
- package/dist/release/codegen.js +25 -0
- package/dist/release/constants.d.ts +39 -0
- package/dist/release/constants.js +35 -0
- package/dist/release/context.d.ts +33 -0
- package/dist/release/context.js +31 -0
- package/dist/release/digest.d.ts +11 -0
- package/dist/release/digest.js +59 -0
- package/dist/release/git.d.ts +10 -0
- package/dist/release/git.js +64 -0
- package/dist/release/index.d.ts +7 -0
- package/dist/release/index.js +6 -0
- package/dist/release/load.d.ts +30 -0
- package/dist/release/load.js +78 -0
- package/dist/release/manifest.d.ts +15 -0
- package/dist/release/manifest.js +164 -0
- package/dist/release/oasdiff.d.ts +20 -0
- package/dist/release/oasdiff.js +36 -0
- package/dist/release/registries.d.ts +46 -0
- package/dist/release/registries.js +243 -0
- package/dist/release/release-state.d.ts +15 -0
- package/dist/release/release-state.js +21 -0
- package/dist/release/release-workflow.d.ts +5 -0
- package/dist/release/release-workflow.js +72 -0
- package/dist/release/repo-settings.d.ts +22 -0
- package/dist/release/repo-settings.js +53 -0
- package/dist/release/spec-gate.d.ts +28 -0
- package/dist/release/spec-gate.js +107 -0
- package/dist/release/sync-command.d.ts +31 -0
- package/dist/release/sync-command.js +122 -0
- package/dist/release/sync-tree.d.ts +30 -0
- package/dist/release/sync-tree.js +123 -0
- package/dist/release/sync.d.ts +46 -0
- package/dist/release/sync.js +172 -0
- package/dist/release/types.d.ts +149 -0
- package/dist/release/types.js +1 -0
- package/dist/release/version-files.d.ts +16 -0
- package/dist/release/version-files.js +74 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +8 -0
- package/package.json +72 -11
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Literals from the config are single-quoted on purpose: `$`, backticks and `~` in them stay literal.
|
|
3
|
+
# shellcheck disable=SC2016,SC2088
|
|
4
|
+
# Generated by installgen (https://github.com/workerstack/clients). Regenerate it with `installgen build`.
|
|
5
|
+
#
|
|
6
|
+
# curl -fsSL <url> | sh the latest version
|
|
7
|
+
# curl -fsSL <url> | sh -s -- 1.2.3 a specific version
|
|
8
|
+
#
|
|
9
|
+
# Environment: @@ENV_PREFIX@@_VERSION, @@ENV_PREFIX@@_INSTALL_DIR, @@ENV_PREFIX@@_NO_MODIFY_PATH=1,
|
|
10
|
+
# @@ENV_PREFIX@@_INSTALL_VERIFY=require, NO_COLOR.
|
|
11
|
+
# POSIX sh: runs under dash, bash 3.2+, zsh and busybox ash. Everything runs in main, so a truncated download
|
|
12
|
+
# runs nothing.
|
|
13
|
+
set -u
|
|
14
|
+
|
|
15
|
+
setup_ui() {
|
|
16
|
+
c_green=''
|
|
17
|
+
c_yellow=''
|
|
18
|
+
c_bold=''
|
|
19
|
+
c_reset=''
|
|
20
|
+
e_red=''
|
|
21
|
+
e_yellow=''
|
|
22
|
+
e_reset=''
|
|
23
|
+
progress=0
|
|
24
|
+
if [ -z "${NO_COLOR:-}" ]; then
|
|
25
|
+
if [ -t 1 ]; then
|
|
26
|
+
c_green=$(printf '\033[32m')
|
|
27
|
+
c_yellow=$(printf '\033[33m')
|
|
28
|
+
c_bold=$(printf '\033[1m')
|
|
29
|
+
c_reset=$(printf '\033[0m')
|
|
30
|
+
fi
|
|
31
|
+
if [ -t 2 ]; then
|
|
32
|
+
e_red=$(printf '\033[31m')
|
|
33
|
+
e_yellow=$(printf '\033[33m')
|
|
34
|
+
e_reset=$(printf '\033[0m')
|
|
35
|
+
progress=1
|
|
36
|
+
fi
|
|
37
|
+
fi
|
|
38
|
+
case "${LC_ALL:-${LC_CTYPE:-${LANG:-}}}" in
|
|
39
|
+
*UTF-8* | *utf-8* | *UTF8* | *utf8*)
|
|
40
|
+
ok_glyph=$(printf '\342\234\223')
|
|
41
|
+
down_glyph=$(printf '\342\206\223')
|
|
42
|
+
;;
|
|
43
|
+
*)
|
|
44
|
+
ok_glyph='+'
|
|
45
|
+
down_glyph='v'
|
|
46
|
+
;;
|
|
47
|
+
esac
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
row() {
|
|
51
|
+
printf '%s%s%s %-10s %s\n' "$1" "$2" "$c_reset" "$3" "$4"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ok() {
|
|
55
|
+
row "$c_green" "$ok_glyph" "$1" "$2"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
warn_row() {
|
|
59
|
+
row "$c_yellow" '!' "$1" "$2"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
warn() {
|
|
63
|
+
printf '%swarning:%s %s\n' "$e_yellow" "$e_reset" "$1" >&2
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fail() {
|
|
67
|
+
printf '%serror:%s %s\n' "$e_red" "$e_reset" "$1" >&2
|
|
68
|
+
exit 1
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
need() {
|
|
72
|
+
command -v "$1" >/dev/null 2>&1 || fail "$1 is required"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# `~` for paths under $HOME
|
|
76
|
+
display() {
|
|
77
|
+
case "$1" in
|
|
78
|
+
"$HOME"/*) printf '~%s' "${1#"$HOME"}" ;;
|
|
79
|
+
*) printf '%s' "$1" ;;
|
|
80
|
+
esac
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fetch() {
|
|
84
|
+
if [ "$downloader" = curl ]; then
|
|
85
|
+
curl -fsSL @@CURL_FLAGS@@ --retry 3 -o "$2" "$1"
|
|
86
|
+
elif [ "$wget_https" = 1 ]; then
|
|
87
|
+
wget -q "$wget_flags" -O "$2" "$1"
|
|
88
|
+
else
|
|
89
|
+
wget -q -O "$2" "$1"
|
|
90
|
+
fi
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# The asset, with curl's progress bar on a terminal; the bar and its label are erased afterwards.
|
|
94
|
+
fetch_asset() {
|
|
95
|
+
if [ "$downloader" = curl ] && [ "$progress" = 1 ]; then
|
|
96
|
+
printf '%s %s\n' "$down_glyph" "$3" >&2
|
|
97
|
+
curl -fL --progress-bar @@CURL_FLAGS@@ --retry 3 -o "$2" "$1" || return 1
|
|
98
|
+
printf '\033[1A\033[2K\033[1A\033[2K' >&2
|
|
99
|
+
else
|
|
100
|
+
fetch "$1" "$2"
|
|
101
|
+
fi
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
supported() {
|
|
105
|
+
case "$1" in
|
|
106
|
+
@@PLATFORMS@@) return 0 ;;
|
|
107
|
+
esac
|
|
108
|
+
return 1
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# Sets asset_path, format, checksums_path and binary_in_archive from $version and $tag.
|
|
112
|
+
resolve_platform() {
|
|
113
|
+
case "$1" in
|
|
114
|
+
@@PLATFORM_CASES@@
|
|
115
|
+
*) return 1 ;;
|
|
116
|
+
esac
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
sha256_of() {
|
|
120
|
+
case "$hasher" in
|
|
121
|
+
sha256sum) sha256sum "$1" | awk '{ print $1 }' ;;
|
|
122
|
+
shasum) shasum -a 256 "$1" | awk '{ print $1 }' ;;
|
|
123
|
+
*) openssl dgst -sha256 "$1" | awk '{ print $NF }' ;;
|
|
124
|
+
esac
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
main() {
|
|
128
|
+
setup_ui
|
|
129
|
+
name=@@NAME@@
|
|
130
|
+
base_url=@@BASE_URL@@
|
|
131
|
+
latest_url=@@LATEST_URL@@
|
|
132
|
+
default_version=@@DEFAULT_VERSION@@
|
|
133
|
+
tag_prefix=@@TAG_PREFIX@@
|
|
134
|
+
modify_path=@@MODIFY_PATH@@
|
|
135
|
+
message=@@MESSAGE@@
|
|
136
|
+
sh_url=@@SH_URL@@
|
|
137
|
+
ps1_url=@@PS1_URL@@
|
|
138
|
+
|
|
139
|
+
[ -n "${HOME:-}" ] || fail "HOME is not set"
|
|
140
|
+
install_dir="${@@ENV_PREFIX@@_INSTALL_DIR:-}"
|
|
141
|
+
if [ -n "$install_dir" ]; then
|
|
142
|
+
dir_display=$(display "$install_dir")
|
|
143
|
+
else
|
|
144
|
+
install_dir=@@INSTALL_DIR@@
|
|
145
|
+
dir_display=@@INSTALL_DIR_DISPLAY@@
|
|
146
|
+
fi
|
|
147
|
+
[ -z "${@@ENV_PREFIX@@_NO_MODIFY_PATH:-}" ] || modify_path=0
|
|
148
|
+
requested="${1:-${@@ENV_PREFIX@@_VERSION:-}}"
|
|
149
|
+
|
|
150
|
+
printf '%s%s installer%s\n' "$c_bold" "$name" "$c_reset"
|
|
151
|
+
|
|
152
|
+
# Platform
|
|
153
|
+
uname_s=$(uname -s 2>/dev/null) || uname_s=unknown
|
|
154
|
+
uname_m=$(uname -m 2>/dev/null) || uname_m=unknown
|
|
155
|
+
case "$uname_s" in
|
|
156
|
+
Linux) os=linux ;;
|
|
157
|
+
Darwin) os=darwin ;;
|
|
158
|
+
MINGW* | MSYS* | CYGWIN*)
|
|
159
|
+
[ -n "$ps1_url" ] || fail "no $name build for Windows"
|
|
160
|
+
printf 'On Windows, install %s from PowerShell:\n powershell -c "irm %s | iex"\n' "$name" "$ps1_url" >&2
|
|
161
|
+
exit 1
|
|
162
|
+
;;
|
|
163
|
+
*) fail "unsupported OS: $uname_s" ;;
|
|
164
|
+
esac
|
|
165
|
+
case "$uname_m" in
|
|
166
|
+
x86_64 | amd64) arch=amd64 ;;
|
|
167
|
+
arm64 | aarch64 | armv8*) arch=arm64 ;;
|
|
168
|
+
*) fail "unsupported architecture: $uname_m" ;;
|
|
169
|
+
esac
|
|
170
|
+
# An x86_64 shell under Rosetta still runs on Apple Silicon: prefer the native build.
|
|
171
|
+
if [ "$os" = darwin ] && [ "$arch" = amd64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = 1 ]; then
|
|
172
|
+
arch=arm64
|
|
173
|
+
fi
|
|
174
|
+
if ! supported "$os/$arch"; then
|
|
175
|
+
if [ "$os" = darwin ] && [ "$arch" = arm64 ] && supported darwin/amd64; then
|
|
176
|
+
warn "no native Apple Silicon build of $name; installing the Intel build, which needs Rosetta 2"
|
|
177
|
+
arch=amd64
|
|
178
|
+
else
|
|
179
|
+
fail "no $name build for $os/$arch"
|
|
180
|
+
fi
|
|
181
|
+
fi
|
|
182
|
+
ok Detected "$os/$arch"
|
|
183
|
+
|
|
184
|
+
# Preflight: every tool before the first download
|
|
185
|
+
version=''
|
|
186
|
+
tag=''
|
|
187
|
+
resolve_platform "$os/$arch"
|
|
188
|
+
if command -v curl >/dev/null 2>&1; then
|
|
189
|
+
downloader=curl
|
|
190
|
+
elif command -v wget >/dev/null 2>&1; then
|
|
191
|
+
downloader=wget
|
|
192
|
+
else
|
|
193
|
+
fail "curl or wget is required"
|
|
194
|
+
fi
|
|
195
|
+
wget_flags=@@WGET_FLAGS@@
|
|
196
|
+
wget_https=0
|
|
197
|
+
if [ "$downloader" = wget ] && [ -n "$wget_flags" ] && wget --help 2>&1 | grep -q -e "$wget_flags"; then
|
|
198
|
+
wget_https=1
|
|
199
|
+
fi
|
|
200
|
+
need mktemp
|
|
201
|
+
case "$format" in
|
|
202
|
+
tar.gz)
|
|
203
|
+
need tar
|
|
204
|
+
need gzip
|
|
205
|
+
;;
|
|
206
|
+
zip)
|
|
207
|
+
if command -v unzip >/dev/null 2>&1; then
|
|
208
|
+
unzipper=unzip
|
|
209
|
+
elif command -v busybox >/dev/null 2>&1 && busybox --list 2>/dev/null | grep -qx unzip; then
|
|
210
|
+
unzipper=busybox
|
|
211
|
+
elif command -v bsdtar >/dev/null 2>&1; then
|
|
212
|
+
unzipper=bsdtar
|
|
213
|
+
else
|
|
214
|
+
fail "unzip is required (or busybox unzip, or bsdtar)"
|
|
215
|
+
fi
|
|
216
|
+
;;
|
|
217
|
+
esac
|
|
218
|
+
if [ -n "$checksums_path" ]; then
|
|
219
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
220
|
+
hasher=sha256sum
|
|
221
|
+
elif command -v shasum >/dev/null 2>&1; then
|
|
222
|
+
hasher=shasum
|
|
223
|
+
elif command -v openssl >/dev/null 2>&1; then
|
|
224
|
+
hasher=openssl
|
|
225
|
+
else
|
|
226
|
+
fail "sha256sum, shasum or openssl is required to verify the download"
|
|
227
|
+
fi
|
|
228
|
+
fi
|
|
229
|
+
# Signature: cosign checks the checksums file when it is on PATH; <PREFIX>_INSTALL_VERIFY=require refuses without it
|
|
230
|
+
case "${@@ENV_PREFIX@@_INSTALL_VERIFY:-}" in
|
|
231
|
+
'' | require) ;;
|
|
232
|
+
*) fail "@@ENV_PREFIX@@_INSTALL_VERIFY ${@@ENV_PREFIX@@_INSTALL_VERIFY}: want require, or unset" ;;
|
|
233
|
+
esac
|
|
234
|
+
signer=''
|
|
235
|
+
if [ -n "$bundle_path" ] && command -v cosign >/dev/null 2>&1; then
|
|
236
|
+
signer=cosign
|
|
237
|
+
fi
|
|
238
|
+
if [ "${@@ENV_PREFIX@@_INSTALL_VERIFY:-}" = require ]; then
|
|
239
|
+
[ -n "$bundle_path" ] || fail "@@ENV_PREFIX@@_INSTALL_VERIFY=require: no signature is published for this release"
|
|
240
|
+
[ -n "$signer" ] || fail "@@ENV_PREFIX@@_INSTALL_VERIFY=require: cosign is not installed to verify the checksums' signature"
|
|
241
|
+
fi
|
|
242
|
+
|
|
243
|
+
tmp=$(mktemp -d 2>/dev/null || mktemp -d -t "$name") || fail "could not create a temporary directory"
|
|
244
|
+
trap 'rm -rf "$tmp"' EXIT
|
|
245
|
+
trap 'exit 130' INT TERM
|
|
246
|
+
|
|
247
|
+
# Version: $1, then <PREFIX>_VERSION, then the baked default, then the latest file. v1.2.3 and 1.2.3 both work.
|
|
248
|
+
version=$requested
|
|
249
|
+
[ -n "$version" ] || version=$default_version
|
|
250
|
+
from_latest=''
|
|
251
|
+
if [ -z "$version" ] || [ "$version" = latest ]; then
|
|
252
|
+
fetch "$latest_url" "$tmp/latest" || fail "could not resolve the latest version from $latest_url"
|
|
253
|
+
version=$(cat "$tmp/latest")
|
|
254
|
+
from_latest=' (latest)'
|
|
255
|
+
fi
|
|
256
|
+
version=$(printf '%s' "$version" | tr -d ' \t\r\n')
|
|
257
|
+
version=${version#"$tag_prefix"}
|
|
258
|
+
case "$version" in
|
|
259
|
+
'' | *[!A-Za-z0-9._+-]*) fail "invalid version: '$version'" ;;
|
|
260
|
+
esac
|
|
261
|
+
# the platform arms read $tag, or only $version, depending on the config
|
|
262
|
+
# shellcheck disable=SC2034
|
|
263
|
+
tag="$tag_prefix$version"
|
|
264
|
+
resolve_platform "$os/$arch"
|
|
265
|
+
ok Version "$version$from_latest"
|
|
266
|
+
|
|
267
|
+
# Download
|
|
268
|
+
asset_url="$base_url/$asset_path"
|
|
269
|
+
asset_file=${asset_path##*/}
|
|
270
|
+
dl="$tmp/$asset_file"
|
|
271
|
+
fetch_asset "$asset_url" "$dl" "$asset_file" || fail "download failed: $asset_url"
|
|
272
|
+
ok Download "$asset_file"
|
|
273
|
+
|
|
274
|
+
# Verify
|
|
275
|
+
if [ -n "$checksums_path" ]; then
|
|
276
|
+
checksums_url="$base_url/$checksums_path"
|
|
277
|
+
fetch "$checksums_url" "$tmp/checksums" || fail "download failed: $checksums_url"
|
|
278
|
+
if [ -n "$signer" ]; then
|
|
279
|
+
bundle_url="$base_url/$bundle_path"
|
|
280
|
+
fetch "$bundle_url" "$tmp/bundle" || fail "download failed: $bundle_url"
|
|
281
|
+
cosign verify-blob --bundle "$tmp/bundle" --certificate-identity "$identity" \
|
|
282
|
+
--certificate-oidc-issuer "$issuer" "$tmp/checksums" >/dev/null 2>&1 ||
|
|
283
|
+
fail "${checksums_path##*/}: cosign could not verify it as signed by $identity"
|
|
284
|
+
ok Signed cosign
|
|
285
|
+
elif [ -n "$bundle_path" ]; then
|
|
286
|
+
warn_row Signed "skipped: cosign not installed"
|
|
287
|
+
fi
|
|
288
|
+
# `hash file`, `hash *file`, BSD `SHA256 (file) = hash`, or a file holding one bare hash
|
|
289
|
+
expected=$(awk -v f="$asset_file" '
|
|
290
|
+
$1 == "SHA256" && $2 == "(" f ")" && $3 == "=" { print $4; exit }
|
|
291
|
+
NF >= 2 { n = $2; sub(/^\*/, "", n); if (n == f) { print $1; exit } }
|
|
292
|
+
' "$tmp/checksums")
|
|
293
|
+
if [ -z "$expected" ]; then
|
|
294
|
+
expected=$(awk 'NF { c++; h = $1; w = NF } END { if (c == 1 && w == 1) print h }' "$tmp/checksums")
|
|
295
|
+
fi
|
|
296
|
+
[ -n "$expected" ] || fail "no checksum for $asset_file in $checksums_url"
|
|
297
|
+
expected=$(printf '%s' "$expected" | tr 'A-F' 'a-f' | tr -d '\r')
|
|
298
|
+
case "$expected" in
|
|
299
|
+
*[!0-9a-f]*) fail "malformed checksum for $asset_file in $checksums_url" ;;
|
|
300
|
+
esac
|
|
301
|
+
[ "${#expected}" -eq 64 ] || fail "malformed checksum for $asset_file in $checksums_url"
|
|
302
|
+
actual=$(sha256_of "$dl")
|
|
303
|
+
[ "$actual" = "$expected" ] || fail "checksum mismatch for $asset_file: expected $expected, got $actual"
|
|
304
|
+
ok Verified "sha256"
|
|
305
|
+
else
|
|
306
|
+
warn_row Verified "skipped: no checksums published"
|
|
307
|
+
fi
|
|
308
|
+
|
|
309
|
+
# Extract
|
|
310
|
+
case "$format" in
|
|
311
|
+
tar.gz)
|
|
312
|
+
if ! { mkdir "$tmp/x" && gzip -dc "$dl" | tar -xf - -C "$tmp/x"; }; then
|
|
313
|
+
fail "could not extract $asset_file"
|
|
314
|
+
fi
|
|
315
|
+
;;
|
|
316
|
+
zip)
|
|
317
|
+
mkdir "$tmp/x" || fail "could not extract $asset_file"
|
|
318
|
+
case "$unzipper" in
|
|
319
|
+
unzip) unzip -q "$dl" -d "$tmp/x" ;;
|
|
320
|
+
busybox) busybox unzip -q "$dl" -d "$tmp/x" ;;
|
|
321
|
+
*) bsdtar -xf "$dl" -C "$tmp/x" ;;
|
|
322
|
+
esac || fail "could not extract $asset_file"
|
|
323
|
+
;;
|
|
324
|
+
esac
|
|
325
|
+
if [ "$format" = raw ]; then
|
|
326
|
+
bin=$dl
|
|
327
|
+
elif [ -n "$binary_in_archive" ]; then
|
|
328
|
+
bin="$tmp/x/$binary_in_archive"
|
|
329
|
+
else
|
|
330
|
+
# exactly one match: a mispacked archive with two must not install whichever find lists first
|
|
331
|
+
bin=$(find "$tmp/x" -type f -name "$name")
|
|
332
|
+
matches=$(printf '%s\n' "$bin" | grep -c .)
|
|
333
|
+
[ "$matches" -le 1 ] || fail "$asset_file holds $matches files named $name; set binaryInArchive"
|
|
334
|
+
fi
|
|
335
|
+
[ -n "$bin" ] && [ -f "$bin" ] || fail "$name not found in $asset_file"
|
|
336
|
+
|
|
337
|
+
# Install: stage next to the target, then rename over it
|
|
338
|
+
target="$install_dir/$name"
|
|
339
|
+
if [ -e "$target" ]; then verb=Updated; else verb=Installed; fi
|
|
340
|
+
mkdir -p "$install_dir" || fail "could not create $install_dir"
|
|
341
|
+
stage="$install_dir/.$name.$$.tmp"
|
|
342
|
+
if ! { cp "$bin" "$stage" && chmod 755 "$stage" && mv -f "$stage" "$target"; }; then
|
|
343
|
+
rm -f "$stage"
|
|
344
|
+
fail "could not install to $target"
|
|
345
|
+
fi
|
|
346
|
+
if [ "$os" = darwin ] && command -v xattr >/dev/null 2>&1; then
|
|
347
|
+
xattr -d com.apple.quarantine "$target" >/dev/null 2>&1 || true
|
|
348
|
+
fi
|
|
349
|
+
target_display="$dir_display/$name"
|
|
350
|
+
ok "$verb" "$target_display"
|
|
351
|
+
|
|
352
|
+
# PATH
|
|
353
|
+
now_line=''
|
|
354
|
+
case ":$PATH:" in
|
|
355
|
+
*":$install_dir:"*) on_path=1 ;;
|
|
356
|
+
*) on_path=0 ;;
|
|
357
|
+
esac
|
|
358
|
+
if [ "$on_path" = 1 ]; then
|
|
359
|
+
ok PATH "already set"
|
|
360
|
+
elif [ "$modify_path" != 1 ]; then
|
|
361
|
+
warn_row PATH "not changed; add $dir_display to PATH"
|
|
362
|
+
else
|
|
363
|
+
case "$install_dir" in
|
|
364
|
+
*'"'* | *'$'* | *'`'* | *\\*) unsafe=1 ;;
|
|
365
|
+
*) unsafe=0 ;;
|
|
366
|
+
esac
|
|
367
|
+
case "$install_dir" in
|
|
368
|
+
"$HOME"/*) path_expr="\$HOME${install_dir#"$HOME"}" ;;
|
|
369
|
+
*) path_expr=$install_dir ;;
|
|
370
|
+
esac
|
|
371
|
+
profile_line="export PATH=\"$path_expr:\$PATH\""
|
|
372
|
+
case "$(basename "${SHELL:-sh}")" in
|
|
373
|
+
fish)
|
|
374
|
+
profile="${XDG_CONFIG_HOME:-$HOME/.config}/fish/conf.d/$name.fish"
|
|
375
|
+
profile_line="fish_add_path \"$path_expr\""
|
|
376
|
+
;;
|
|
377
|
+
zsh) profile="${ZDOTDIR:-$HOME}/.zshrc" ;;
|
|
378
|
+
bash)
|
|
379
|
+
if [ "$os" = darwin ]; then profile="$HOME/.bash_profile"; else profile="$HOME/.bashrc"; fi
|
|
380
|
+
;;
|
|
381
|
+
*) profile="$HOME/.profile" ;;
|
|
382
|
+
esac
|
|
383
|
+
if [ "$unsafe" = 1 ]; then
|
|
384
|
+
warn_row PATH "not changed: $install_dir has characters a profile line cannot hold; add it by hand"
|
|
385
|
+
elif [ -f "$profile" ] && grep -qxF "$profile_line" "$profile"; then
|
|
386
|
+
ok PATH "already in $(display "$profile")"
|
|
387
|
+
now_line=$profile_line
|
|
388
|
+
elif mkdir -p "$(dirname "$profile")" && printf '\n# %s\n%s\n' "$name" "$profile_line" >>"$profile"; then
|
|
389
|
+
ok PATH "added to $(display "$profile")"
|
|
390
|
+
now_line=$profile_line
|
|
391
|
+
else
|
|
392
|
+
warn_row PATH "could not write $(display "$profile"); add $dir_display to PATH"
|
|
393
|
+
fi
|
|
394
|
+
if [ -n "${GITHUB_PATH:-}" ]; then
|
|
395
|
+
printf '%s\n' "$install_dir" >>"$GITHUB_PATH" || warn "could not append to \$GITHUB_PATH"
|
|
396
|
+
fi
|
|
397
|
+
fi
|
|
398
|
+
# Another copy shadows this one only where PATH stays as it is; a profile edit prepends the install dir.
|
|
399
|
+
found=$(command -v "$name" 2>/dev/null) || found=''
|
|
400
|
+
if [ -z "$now_line" ] && [ -n "$found" ] && [ "$found" != "$target" ]; then
|
|
401
|
+
warn "$found comes first on PATH and shadows the new $name"
|
|
402
|
+
fi
|
|
403
|
+
|
|
404
|
+
if [ "$verb" = Updated ]; then done_word=updated; else done_word=installed; fi
|
|
405
|
+
printf '\n%s%s %s %s.%s\n' "$c_bold" "$name" "$version" "$done_word" "$c_reset"
|
|
406
|
+
[ -z "$message" ] || printf '%s\n' "$message"
|
|
407
|
+
[ -z "$now_line" ] || printf 'Restart your shell, or run: %s\n' "$now_line"
|
|
408
|
+
printf 'To uninstall: rm %s\n' "$target_display"
|
|
409
|
+
printf 'To update: curl -fsSL %s | sh\n' "$sh_url"
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
main "$@"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The installgen bin. A repository checkout (marked by tsconfig.json, which is not published) runs the TypeScript
|
|
3
|
+
// source, natively on Bun and through jiti on Node, so a stale build never runs; an installed package runs the
|
|
4
|
+
// compiled JavaScript (the tarball ships it, not src/).
|
|
5
|
+
import { existsSync } from "node:fs"
|
|
6
|
+
|
|
7
|
+
const checkout = existsSync(new URL("../tsconfig.json", import.meta.url))
|
|
8
|
+
|
|
9
|
+
async function entry() {
|
|
10
|
+
if (checkout) {
|
|
11
|
+
if (typeof globalThis.Bun !== "undefined") return import("../src/installers/cli.ts")
|
|
12
|
+
const { createJiti } = await import("jiti")
|
|
13
|
+
return createJiti(import.meta.url).import("../src/installers/cli.ts")
|
|
14
|
+
}
|
|
15
|
+
return import("../dist/installers/cli.js")
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { start } = await entry()
|
|
19
|
+
await start()
|
package/dist/cli.js
CHANGED
|
@@ -28,6 +28,7 @@ import { checkedMetadata, shippedOf } from "./emit/shared/metadata.js";
|
|
|
28
28
|
import { optionsFor } from "./gen/targets.js";
|
|
29
29
|
import { shippedFiles } from "./gen/shipped.js";
|
|
30
30
|
import { writeTarget } from "./gen/write.js";
|
|
31
|
+
import { release } from "./release/cli.js";
|
|
31
32
|
/** One SDK target's generation: its files, its package's identity on each registry, and what it reports (a name it renamed). */
|
|
32
33
|
function sdkOf(target, document, options, metadata) {
|
|
33
34
|
switch (target) {
|
|
@@ -167,6 +168,9 @@ function watchSpec(run, argv, io, options) {
|
|
|
167
168
|
/** Runs `honey-clients <argv>`: the exit code it ends with (a watch ends only by `options.signal`). */
|
|
168
169
|
export async function main(argv, io = PROCESS_IO, options = {}) {
|
|
169
170
|
try {
|
|
171
|
+
/* release has subcommands of its own, each with its own --help */
|
|
172
|
+
if (argv[0] === "release")
|
|
173
|
+
return await release(argv.slice(1), io, { env: options.env });
|
|
170
174
|
if (argv.length === 0 || argv[0] === "-h" || argv[0] === "--help" || argv.includes("--help")) {
|
|
171
175
|
io.out(`${usage()}\n`);
|
|
172
176
|
return argv.length === 0 ? 1 : 0;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* `layout`, and a test holds the file's scripts byte for byte to the emitted ones. Without a repository there is
|
|
12
12
|
* nowhere to download from, so there are no scripts and no config.
|
|
13
13
|
*/
|
|
14
|
-
import { type InstallgenConfig } from "
|
|
14
|
+
import { type InstallgenConfig } from "../../installers/index.ts";
|
|
15
15
|
/** The options the scripts are written from: the binary, its repository, the variables' prefix, the scripts' URL. */
|
|
16
16
|
export type InstallApp = {
|
|
17
17
|
readonly bin: string;
|
|
@@ -21,16 +21,19 @@ export type InstallApp = {
|
|
|
21
21
|
};
|
|
22
22
|
/** The issuer of the OIDC token a GitHub Actions run signs with. */
|
|
23
23
|
export declare const ISSUER = "https://token.actions.githubusercontent.com";
|
|
24
|
-
/**
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The `npx` that runs installgen from the clients release that wrote the scripts: the release workflow's `check` runs
|
|
26
|
+
* it on installgen.config.mts in the module's root, so the scripts and their check always come from one release.
|
|
27
|
+
*/
|
|
28
|
+
export declare function installgenCommand(): string;
|
|
26
29
|
/** The name `installgen` finds its config by, in the module's root, where the release workflow runs it. */
|
|
27
30
|
export declare const INSTALLGEN_CONFIG = "installgen.config.mts";
|
|
28
31
|
/** installgen's config for `app`, its files under `base` (the repository's GitHub Releases outside a test). */
|
|
29
32
|
export declare function installerConfig(app: InstallApp, base?: string): InstallgenConfig;
|
|
30
33
|
/**
|
|
31
34
|
* `installgen.config.mts` for `app`: `installerConfig`'s config as a module installgen loads with no local install
|
|
32
|
-
* (its one import is type-only, which Node 22.18+ strips), so `
|
|
33
|
-
*
|
|
35
|
+
* (its one import is type-only, which Node 22.18+ strips), so `installgenCommand()`'s `check` runs in the module's root
|
|
36
|
+
* with nothing installed.
|
|
34
37
|
*/
|
|
35
38
|
export declare function installgenConfigFile(app: InstallApp): string;
|
|
36
39
|
/** `install.sh`, `install.ps1` and `installgen.config.mts` for `app`, by file name. */
|
package/dist/emit/cli/install.js
CHANGED
|
@@ -11,11 +11,17 @@
|
|
|
11
11
|
* `layout`, and a test holds the file's scripts byte for byte to the emitted ones. Without a repository there is
|
|
12
12
|
* nowhere to download from, so there are no scripts and no config.
|
|
13
13
|
*/
|
|
14
|
-
import { generateInstallers } from "
|
|
14
|
+
import { generateInstallers } from "../../installers/index.js";
|
|
15
|
+
import { clientsVersion } from "../../version.js";
|
|
15
16
|
/** The issuer of the OIDC token a GitHub Actions run signs with. */
|
|
16
17
|
export const ISSUER = "https://token.actions.githubusercontent.com";
|
|
17
|
-
/**
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The `npx` that runs installgen from the clients release that wrote the scripts: the release workflow's `check` runs
|
|
20
|
+
* it on installgen.config.mts in the module's root, so the scripts and their check always come from one release.
|
|
21
|
+
*/
|
|
22
|
+
export function installgenCommand() {
|
|
23
|
+
return `npx --yes --package @workerstack/clients@${clientsVersion()} installgen`;
|
|
24
|
+
}
|
|
19
25
|
/** The name `installgen` finds its config by, in the module's root, where the release workflow runs it. */
|
|
20
26
|
export const INSTALLGEN_CONFIG = "installgen.config.mts";
|
|
21
27
|
/**
|
|
@@ -51,16 +57,17 @@ export function installerConfig(app, base = `https://github.com/${app.repo}/rele
|
|
|
51
57
|
}
|
|
52
58
|
/**
|
|
53
59
|
* `installgen.config.mts` for `app`: `installerConfig`'s config as a module installgen loads with no local install
|
|
54
|
-
* (its one import is type-only, which Node 22.18+ strips), so `
|
|
55
|
-
*
|
|
60
|
+
* (its one import is type-only, which Node 22.18+ strips), so `installgenCommand()`'s `check` runs in the module's root
|
|
61
|
+
* with nothing installed.
|
|
56
62
|
*/
|
|
57
63
|
export function installgenConfigFile(app) {
|
|
64
|
+
const installgen = installgenCommand();
|
|
58
65
|
const { asset, checksums, identity, plain } = layout(app, `https://github.com/${app.repo}/releases`);
|
|
59
66
|
const value = (key) => `\t${key}: ${JSON.stringify(plain[key])},\n`;
|
|
60
67
|
return `// Code generated by honey. DO NOT EDIT.
|
|
61
68
|
// installgen's config for ${app.bin}'s install scripts, as honey wrote them: the release workflow runs
|
|
62
|
-
//
|
|
63
|
-
import type { InstallgenConfig } from "@
|
|
69
|
+
// \`${installgen} check\` with it to prove a release serves every file they fetch.
|
|
70
|
+
import type { InstallgenConfig } from "@workerstack/clients/installers"
|
|
64
71
|
|
|
65
72
|
export default {
|
|
66
73
|
assetPath: ({ arch, os, tag }) =>
|
package/dist/emit/cli/release.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* validated option (the binary, the module path, the repository, the channels), never spec text.
|
|
18
18
|
*/
|
|
19
19
|
import { channelBlock, SECRETS } from "./channels.js";
|
|
20
|
-
import {
|
|
20
|
+
import { installgenCommand } from "./install.js";
|
|
21
21
|
export { REPO, resolvedRelease } from "./channels.js";
|
|
22
22
|
/* the marker generated YAML carries on its first line */
|
|
23
23
|
const MARKER = "# Code generated by honey. DO NOT EDIT.";
|
|
@@ -92,8 +92,6 @@ changelog:
|
|
|
92
92
|
disable: true
|
|
93
93
|
${github}${(release?.channels ?? []).map((channel) => channelBlock(bin, channel)).join("")}`;
|
|
94
94
|
}
|
|
95
|
-
/** The `npx` that runs the installgen the scripts were written by, on installgen.config.mts in the module's root. */
|
|
96
|
-
const INSTALLGEN = `npx --yes @lovrozagar/installgen@${INSTALLGEN_VERSION}`;
|
|
97
95
|
/**
|
|
98
96
|
* The steps that prove the install scripts work against the release just published, which a release with a repository
|
|
99
97
|
* runs after its attestation. The scripts install `<PREFIX>_VERSION` when it is set and otherwise the tag
|
|
@@ -107,12 +105,14 @@ const INSTALLGEN = `npx --yes @lovrozagar/installgen@${INSTALLGEN_VERSION}`;
|
|
|
107
105
|
* the release goreleaser made, not re-derived from the tag, and latest's URL from `check --list`, the one the
|
|
108
106
|
* scripts read.
|
|
109
107
|
*/
|
|
110
|
-
|
|
108
|
+
function installerChecks() {
|
|
109
|
+
const installgen = installgenCommand();
|
|
110
|
+
return ` - uses: ${RELEASE_ACTIONS.setupNode}
|
|
111
111
|
with:
|
|
112
112
|
node-version: "24"
|
|
113
113
|
package-manager-cache: false
|
|
114
114
|
- name: Check every file the install scripts fetch for this tag
|
|
115
|
-
run: ${
|
|
115
|
+
run: ${installgen} check --default-version "$GITHUB_REF_NAME"
|
|
116
116
|
- name: Check latest reads this tag
|
|
117
117
|
shell: bash
|
|
118
118
|
env:
|
|
@@ -123,13 +123,14 @@ const installerChecks = ` - uses: ${RELEASE_ACTIONS.setupNode}
|
|
|
123
123
|
echo "$GITHUB_REF_NAME is a prerelease: latest stays on the last release"
|
|
124
124
|
exit 0
|
|
125
125
|
fi
|
|
126
|
-
url="$(${
|
|
126
|
+
url="$(${installgen} check --list | awk '$1 == "latest" { print $2 }')"
|
|
127
127
|
latest="$(curl -fsSL --retry 3 "$url" | tr -d '[:space:]')"
|
|
128
128
|
if [ "$latest" != "$GITHUB_REF_NAME" ]; then
|
|
129
129
|
echo "::error::$url reads '$latest', not $GITHUB_REF_NAME"
|
|
130
130
|
exit 1
|
|
131
131
|
fi
|
|
132
132
|
`;
|
|
133
|
+
}
|
|
133
134
|
/**
|
|
134
135
|
* .github/workflows/release.yml: goreleaser on a `v*` tag, publishing the signed release, then attesting it, then,
|
|
135
136
|
* with a repository, checking the install scripts' files against it.
|
|
@@ -179,5 +180,5 @@ jobs:
|
|
|
179
180
|
${secrets.join("")} - uses: ${RELEASE_ACTIONS.attest}
|
|
180
181
|
with:
|
|
181
182
|
subject-checksums: dist/checksums.txt
|
|
182
|
-
${release === undefined ? "" : installerChecks}`;
|
|
183
|
+
${release === undefined ? "" : installerChecks()}`;
|
|
183
184
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP status code → honey's status key (`201` → `created`), as
|
|
3
|
-
* them (gen never imports
|
|
2
|
+
* HTTP status code → honey's status key (`201` → `created`), as backend's response vocabulary names
|
|
3
|
+
* them (gen never imports backend, H2). tests/integration/codegen-tables.test.ts answers each key through a real app, so the two cannot drift.
|
|
4
4
|
*/
|
|
5
5
|
export declare const STATUS_KEYS: Readonly<Record<number, string>>;
|
|
6
6
|
/** The status key of `code`; undefined for a code outside the vocabulary (1xx, a range like `4XX`). */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP status code → honey's status key (`201` → `created`), as
|
|
3
|
-
* them (gen never imports
|
|
2
|
+
* HTTP status code → honey's status key (`201` → `created`), as backend's response vocabulary names
|
|
3
|
+
* them (gen never imports backend, H2). tests/integration/codegen-tables.test.ts answers each key through a real app, so the two cannot drift.
|
|
4
4
|
*/
|
|
5
5
|
export const STATUS_KEYS = {
|
|
6
6
|
200: "ok",
|
package/dist/gen/args.js
CHANGED
|
@@ -21,6 +21,10 @@ export function usage() {
|
|
|
21
21
|
--watch generate again on each change of the spec or the app module
|
|
22
22
|
-h, --help this text
|
|
23
23
|
|
|
24
|
+
Other commands:
|
|
25
|
+
release bump|sync|bootstrap|codegen|toolchains --config <path>
|
|
26
|
+
cut versions, mirror packages, bootstrap mirrors, and run or list codegen's needs from a release config
|
|
27
|
+
|
|
24
28
|
The package metadata every publishing target reads, given once as --metadata-<field> <value> (a target's own
|
|
25
29
|
option of the same meaning wins; authors and keywords comma separated):
|
|
26
30
|
${METADATA_FIELDS.map((field) => `--metadata-${kebab(field)}`).join(" ")}
|
package/dist/gen/formatters.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare const FORMATTERS: Partial<Record<Target, FormatPass>>;
|
|
|
43
43
|
/**
|
|
44
44
|
* The formatter for `target`, or none when its binary is not there. Each factory is named here rather than
|
|
45
45
|
* held in the table's rows: `honey/spawn-timeout` proves which exports reach a spawn by walking named calls
|
|
46
|
-
* (`
|
|
46
|
+
* (the repo lint plugin's `spawners.js`), and a closure in a table is opaque to that walk — which would leave a
|
|
47
47
|
* test calling `generated()` free of the bound it needs, since the spawn is real either way.
|
|
48
48
|
*/
|
|
49
49
|
export declare function formatterFor(target: Target, where: {
|
package/dist/gen/formatters.js
CHANGED
|
@@ -102,7 +102,7 @@ export const FORMATTERS = {
|
|
|
102
102
|
/**
|
|
103
103
|
* The formatter for `target`, or none when its binary is not there. Each factory is named here rather than
|
|
104
104
|
* held in the table's rows: `honey/spawn-timeout` proves which exports reach a spawn by walking named calls
|
|
105
|
-
* (`
|
|
105
|
+
* (the repo lint plugin's `spawners.js`), and a closure in a table is opaque to that walk — which would leave a
|
|
106
106
|
* test calling `generated()` free of the bound it needs, since the spawn is real either way.
|
|
107
107
|
*/
|
|
108
108
|
export async function formatterFor(target, where) {
|
package/dist/gen/targets.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare const TARGET_OPTIONS: {
|
|
|
29
29
|
/**
|
|
30
30
|
* The target options that take no value, since their name already says what they turn on
|
|
31
31
|
* (`--ts-tanstack-query`, not `--ts-query tanstack`). They stay listed in `TARGET_OPTIONS` above, which is what
|
|
32
|
-
* `
|
|
32
|
+
* the repo's README test (`tests/docs/readmes.test.ts`) reads to hold every flag to its README row; this table only
|
|
33
33
|
* says how one is read. Bare is `true` and an inline `true`/`false` is read, exactly as `--watch` is.
|
|
34
34
|
*/
|
|
35
35
|
declare const BOOLEAN_OPTIONS: {
|
package/dist/gen/targets.js
CHANGED
|
@@ -78,7 +78,7 @@ export const TARGET_OPTIONS = {
|
|
|
78
78
|
/**
|
|
79
79
|
* The target options that take no value, since their name already says what they turn on
|
|
80
80
|
* (`--ts-tanstack-query`, not `--ts-query tanstack`). They stay listed in `TARGET_OPTIONS` above, which is what
|
|
81
|
-
* `
|
|
81
|
+
* the repo's README test (`tests/docs/readmes.test.ts`) reads to hold every flag to its README row; this table only
|
|
82
82
|
* says how one is read. Bare is `true` and an inline `true`/`false` is read, exactly as `--watch` is.
|
|
83
83
|
*/
|
|
84
84
|
const BOOLEAN_OPTIONS = { cli: ["aur"], ts: ["tanstackQuery"] };
|