@anvil-works/anvil-cli 0.6.2 → 0.6.3
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/package.json +1 -1
- package/scripts/install/install.sh +66 -12
package/package.json
CHANGED
|
@@ -21,6 +21,27 @@ need_cmd() {
|
|
|
21
21
|
command -v "$1" >/dev/null 2>&1 || fail "Required command not found: $1"
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
is_windows_posix() {
|
|
25
|
+
case "$(uname -s 2>/dev/null || true)" in
|
|
26
|
+
MINGW*|MSYS*|CYGWIN*) return 0 ;;
|
|
27
|
+
*) return 1 ;;
|
|
28
|
+
esac
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
windows_posix_node_error() {
|
|
32
|
+
fail "Windows Git Bash installs require existing Node.js v20+ and npm. Use PowerShell instead: irm https://anvil.works/install-cli.ps1 | iex"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
normalize_npm_prefix() {
|
|
36
|
+
prefix="$1"
|
|
37
|
+
if is_windows_posix && command -v cygpath >/dev/null 2>&1; then
|
|
38
|
+
cygpath -u "$prefix" 2>/dev/null || printf '%s\n' "$prefix"
|
|
39
|
+
return
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
printf '%s\n' "$prefix"
|
|
43
|
+
}
|
|
44
|
+
|
|
24
45
|
warn_if_missing_git() {
|
|
25
46
|
if ! command -v git >/dev/null 2>&1; then
|
|
26
47
|
log "Warning: git was not found on PATH."
|
|
@@ -30,11 +51,13 @@ warn_if_missing_git() {
|
|
|
30
51
|
}
|
|
31
52
|
|
|
32
53
|
cleanup_legacy_npm_prefix() {
|
|
33
|
-
current_prefix="$(npm config get prefix 2>/dev/null || true)"
|
|
54
|
+
current_prefix="$(npm config get prefix 2>/dev/null | tr -d '\r' || true)"
|
|
34
55
|
[ -n "$current_prefix" ] || return 0
|
|
35
56
|
|
|
36
57
|
legacy_prefix="$NPM_PREFIX"
|
|
37
|
-
|
|
58
|
+
normalized_current_prefix="$(normalize_npm_prefix "$current_prefix")"
|
|
59
|
+
normalized_legacy_prefix="$(normalize_npm_prefix "$legacy_prefix")"
|
|
60
|
+
if [ "$current_prefix" = "$legacy_prefix" ] || [ "$normalized_current_prefix" = "$normalized_legacy_prefix" ]; then
|
|
38
61
|
log "Detected legacy anvil npm prefix in user config; restoring npm default prefix behavior."
|
|
39
62
|
npm config delete prefix --location=user >/dev/null 2>&1 || true
|
|
40
63
|
fi
|
|
@@ -42,7 +65,11 @@ cleanup_legacy_npm_prefix() {
|
|
|
42
65
|
|
|
43
66
|
append_path_export() {
|
|
44
67
|
profile_file="$1"
|
|
45
|
-
|
|
68
|
+
if is_windows_posix; then
|
|
69
|
+
line='export PATH="$HOME/.anvil-cli/npm-global:$HOME/.anvil-cli/npm-global/bin:$HOME/.anvil-cli/node-v20/bin:$PATH"'
|
|
70
|
+
else
|
|
71
|
+
line='export PATH="$HOME/.anvil-cli/npm-global/bin:$HOME/.anvil-cli/node-v20/bin:$PATH"'
|
|
72
|
+
fi
|
|
46
73
|
|
|
47
74
|
[ -f "$profile_file" ] || touch "$profile_file"
|
|
48
75
|
grep -F "$line" "$profile_file" >/dev/null 2>&1 || {
|
|
@@ -131,23 +158,54 @@ ensure_node() {
|
|
|
131
158
|
log "Using existing Node.js $(node -v)"
|
|
132
159
|
return
|
|
133
160
|
fi
|
|
161
|
+
if is_windows_posix; then
|
|
162
|
+
windows_posix_node_error
|
|
163
|
+
fi
|
|
134
164
|
log "Existing Node.js $(node -v) is too old; installing Node.js v20 user-local"
|
|
135
165
|
install_node_v20
|
|
136
166
|
return
|
|
137
167
|
fi
|
|
138
168
|
|
|
169
|
+
if is_windows_posix; then
|
|
170
|
+
windows_posix_node_error
|
|
171
|
+
fi
|
|
139
172
|
install_node_v20
|
|
140
173
|
}
|
|
141
174
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
175
|
+
configure_current_path() {
|
|
176
|
+
if is_windows_posix; then
|
|
177
|
+
export PATH="$NPM_PREFIX:$NPM_PREFIX/bin:$NODE_DIR/bin:$PATH"
|
|
178
|
+
else
|
|
179
|
+
export PATH="$NPM_PREFIX/bin:$NODE_DIR/bin:$PATH"
|
|
180
|
+
fi
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
anvil_version() {
|
|
184
|
+
if command -v anvil >/dev/null 2>&1 && anvil --version 2>/dev/null; then
|
|
185
|
+
return 0
|
|
186
|
+
fi
|
|
187
|
+
|
|
188
|
+
if [ -f "$NPM_PREFIX/anvil" ] && "$NPM_PREFIX/anvil" --version 2>/dev/null; then
|
|
189
|
+
return 0
|
|
190
|
+
fi
|
|
145
191
|
|
|
192
|
+
if [ -f "$NPM_PREFIX/anvil.cmd" ] && "$NPM_PREFIX/anvil.cmd" --version 2>/dev/null; then
|
|
193
|
+
return 0
|
|
194
|
+
fi
|
|
195
|
+
|
|
196
|
+
if [ -x "$NPM_PREFIX/bin/anvil" ] && "$NPM_PREFIX/bin/anvil" --version 2>/dev/null; then
|
|
197
|
+
return 0
|
|
198
|
+
fi
|
|
199
|
+
|
|
200
|
+
return 1
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
main() {
|
|
146
204
|
mkdir -p "$ANVIL_HOME" "$NPM_PREFIX"
|
|
147
205
|
|
|
148
206
|
ensure_node
|
|
149
207
|
|
|
150
|
-
|
|
208
|
+
configure_current_path
|
|
151
209
|
persist_path_hint
|
|
152
210
|
|
|
153
211
|
need_cmd npm
|
|
@@ -157,11 +215,7 @@ main() {
|
|
|
157
215
|
log "Installing anvil-cli..."
|
|
158
216
|
NPM_CONFIG_PREFIX="$NPM_PREFIX" npm install -g @anvil-works/anvil-cli@latest
|
|
159
217
|
|
|
160
|
-
if
|
|
161
|
-
version="$(anvil --version 2>/dev/null || true)"
|
|
162
|
-
elif [ -x "$NPM_PREFIX/bin/anvil" ]; then
|
|
163
|
-
version="$($NPM_PREFIX/bin/anvil --version 2>/dev/null || true)"
|
|
164
|
-
else
|
|
218
|
+
if ! version="$(anvil_version)"; then
|
|
165
219
|
fail "anvil installed but command not found on PATH"
|
|
166
220
|
fi
|
|
167
221
|
|