@jskit-ai/create-app 0.1.10 → 0.1.12
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/templates/base-shell/README.md +0 -10
- package/templates/base-shell/gitignore +0 -2
- package/templates/base-shell/package.json +1 -3
- package/templates/base-shell/tests/server/minimalShell.validator.test.js +0 -1
- package/templates/base-shell/app.scripts.config.mjs +0 -3
- package/templates/base-shell/scripts/dev-bootstrap-jskit.sh +0 -110
- package/templates/base-shell/scripts/just_run_verde +0 -37
- package/templates/base-shell/scripts/verdaccio/config.yaml +0 -26
- package/templates/base-shell/scripts/verdaccio-reset-and-publish-packages.sh +0 -314
package/package.json
CHANGED
|
@@ -9,16 +9,6 @@ npm install
|
|
|
9
9
|
npm run dev
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
## Package Bootstrap
|
|
13
|
-
|
|
14
|
-
`npm install` runs `scripts/dev-bootstrap-jskit.sh` through `preinstall`.
|
|
15
|
-
|
|
16
|
-
- Default mode is `JSKIT_DEV_BOOTSTRAP=auto`.
|
|
17
|
-
- In Dokku (`DOKKU_APP_NAME`/`DOKKU_APP_TYPE` detected), auto mode runs bootstrap.
|
|
18
|
-
- Outside Dokku, auto mode skips bootstrap (local dev stays quiet).
|
|
19
|
-
|
|
20
|
-
Set `JSKIT_GITHUB_TARBALL_URL` in Dokku when local JSKIT packages are not published to npm yet.
|
|
21
|
-
|
|
22
12
|
Refresh JSKIT dependencies to the latest published versions:
|
|
23
13
|
|
|
24
14
|
```bash
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"server:admin": "SERVER_SURFACE=admin node ./bin/server.js",
|
|
19
19
|
"start": "node ./bin/server.js",
|
|
20
20
|
"link:local:jskit": "bash ./scripts/link-local-jskit-packages.sh",
|
|
21
|
-
"verdaccio:reset:publish": "bash ./scripts/verdaccio-reset-and-publish-packages.sh",
|
|
22
21
|
"dev": "vite",
|
|
23
22
|
"dev:all": "vite",
|
|
24
23
|
"dev:home": "VITE_SURFACE=home vite",
|
|
@@ -39,7 +38,6 @@
|
|
|
39
38
|
"lint": "eslint .",
|
|
40
39
|
"test": "node --test",
|
|
41
40
|
"test:client": "vitest run tests/client",
|
|
42
|
-
"preinstall": "bash ./scripts/dev-bootstrap-jskit.sh",
|
|
43
41
|
"jskit:update": "bash ./scripts/update-jskit-packages.sh"
|
|
44
42
|
},
|
|
45
43
|
"dependencies": {
|
|
@@ -54,7 +52,7 @@
|
|
|
54
52
|
},
|
|
55
53
|
"devDependencies": {
|
|
56
54
|
"@jskit-ai/config-eslint": "0.1.8",
|
|
57
|
-
"@jskit-ai/jskit-cli": "0.2.
|
|
55
|
+
"@jskit-ai/jskit-cli": "0.2.10",
|
|
58
56
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
59
57
|
"eslint": "^9.39.1",
|
|
60
58
|
"unplugin-vue-router": "^0.19.2",
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
|
|
4
|
-
APP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
-
BOOTSTRAP_MODE_RAW="${JSKIT_DEV_BOOTSTRAP:-auto}"
|
|
6
|
-
BOOTSTRAP_MODE="$(echo "$BOOTSTRAP_MODE_RAW" | tr '[:upper:]' '[:lower:]')"
|
|
7
|
-
|
|
8
|
-
is_valid_jskit_repo_root() {
|
|
9
|
-
local candidate_root="$1"
|
|
10
|
-
[[ -d "$candidate_root/packages" && -d "$candidate_root/packages/kernel" && -d "$candidate_root/tooling" ]]
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
find_jskit_repo_root() {
|
|
14
|
-
local current_dir="$1"
|
|
15
|
-
while true; do
|
|
16
|
-
if is_valid_jskit_repo_root "$current_dir"; then
|
|
17
|
-
echo "$current_dir"
|
|
18
|
-
return 0
|
|
19
|
-
fi
|
|
20
|
-
if [[ "$current_dir" == "/" ]]; then
|
|
21
|
-
return 1
|
|
22
|
-
fi
|
|
23
|
-
current_dir="$(dirname "$current_dir")"
|
|
24
|
-
done
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
resolve_local_repo_root() {
|
|
28
|
-
if [[ -n "${JSKIT_REPO_ROOT:-}" ]]; then
|
|
29
|
-
echo "$JSKIT_REPO_ROOT"
|
|
30
|
-
return 0
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
find_jskit_repo_root "$APP_ROOT" || true
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
is_dokku_environment() {
|
|
37
|
-
[[ -n "${DOKKU_APP_NAME:-}" || -n "${DOKKU_APP_TYPE:-}" ]]
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
resolve_bootstrap_mode() {
|
|
41
|
-
local normalized_mode="$1"
|
|
42
|
-
if [[ "$normalized_mode" != "auto" ]]; then
|
|
43
|
-
echo "$normalized_mode"
|
|
44
|
-
return 0
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
if is_dokku_environment; then
|
|
48
|
-
echo "on"
|
|
49
|
-
return 0
|
|
50
|
-
fi
|
|
51
|
-
|
|
52
|
-
echo "off"
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
BOOTSTRAP_MODE="$(resolve_bootstrap_mode "$BOOTSTRAP_MODE")"
|
|
56
|
-
LOCAL_REPO_ROOT="$(resolve_local_repo_root)"
|
|
57
|
-
|
|
58
|
-
if [[ "$BOOTSTRAP_MODE" == "0" || "$BOOTSTRAP_MODE" == "false" || "$BOOTSTRAP_MODE" == "off" ]]; then
|
|
59
|
-
echo "[dev-bootstrap] skipped (JSKIT_DEV_BOOTSTRAP disabled)."
|
|
60
|
-
exit 0
|
|
61
|
-
fi
|
|
62
|
-
|
|
63
|
-
if is_valid_jskit_repo_root "$LOCAL_REPO_ROOT"; then
|
|
64
|
-
echo "[dev-bootstrap] using local JSKIT repo: $LOCAL_REPO_ROOT"
|
|
65
|
-
JSKIT_REPO_ROOT="$LOCAL_REPO_ROOT" bash "$APP_ROOT/scripts/verdaccio-reset-and-publish-packages.sh"
|
|
66
|
-
exit 0
|
|
67
|
-
fi
|
|
68
|
-
|
|
69
|
-
if [[ "$BOOTSTRAP_MODE" != "1" && "$BOOTSTRAP_MODE" != "true" && "$BOOTSTRAP_MODE" != "on" ]]; then
|
|
70
|
-
echo "[dev-bootstrap] skipped (no local JSKIT repo at $LOCAL_REPO_ROOT)."
|
|
71
|
-
echo "[dev-bootstrap] set JSKIT_DEV_BOOTSTRAP=1 and JSKIT_GITHUB_TARBALL_URL to force remote bootstrap."
|
|
72
|
-
exit 0
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
|
-
JSKIT_GITHUB_TARBALL_URL="${JSKIT_GITHUB_TARBALL_URL:-}"
|
|
76
|
-
if [[ -z "$JSKIT_GITHUB_TARBALL_URL" ]]; then
|
|
77
|
-
echo "[dev-bootstrap] failed: local JSKIT repo not found at $LOCAL_REPO_ROOT and JSKIT_GITHUB_TARBALL_URL is not set." >&2
|
|
78
|
-
echo "[dev-bootstrap] set JSKIT_REPO_ROOT to a local checkout or set JSKIT_GITHUB_TARBALL_URL to an accessible tarball URL." >&2
|
|
79
|
-
exit 1
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
TMP_DIR="$(mktemp -d)"
|
|
83
|
-
TARBALL_PATH="$TMP_DIR/jskit-ai.tar.gz"
|
|
84
|
-
EXTRACT_DIR="$TMP_DIR/extracted"
|
|
85
|
-
|
|
86
|
-
cleanup() {
|
|
87
|
-
rm -rf "$TMP_DIR"
|
|
88
|
-
}
|
|
89
|
-
trap cleanup EXIT
|
|
90
|
-
|
|
91
|
-
echo "[dev-bootstrap] downloading $JSKIT_GITHUB_TARBALL_URL"
|
|
92
|
-
curl -fsSL "$JSKIT_GITHUB_TARBALL_URL" -o "$TARBALL_PATH"
|
|
93
|
-
|
|
94
|
-
mkdir -p "$EXTRACT_DIR"
|
|
95
|
-
tar -xzf "$TARBALL_PATH" -C "$EXTRACT_DIR"
|
|
96
|
-
|
|
97
|
-
JSKIT_REPO_ROOT="$(find "$EXTRACT_DIR" -mindepth 1 -maxdepth 1 -type d | head -n 1 || true)"
|
|
98
|
-
if [[ -z "${JSKIT_REPO_ROOT:-}" ]]; then
|
|
99
|
-
echo "[dev-bootstrap] failed: extracted archive is empty." >&2
|
|
100
|
-
exit 1
|
|
101
|
-
fi
|
|
102
|
-
|
|
103
|
-
if [[ ! -d "$JSKIT_REPO_ROOT/packages" || ! -d "$JSKIT_REPO_ROOT/packages/kernel" || ! -d "$JSKIT_REPO_ROOT/tooling" ]]; then
|
|
104
|
-
echo "[dev-bootstrap] failed: extracted archive does not look like jskit-ai monorepo." >&2
|
|
105
|
-
echo "[dev-bootstrap] extracted root: $JSKIT_REPO_ROOT" >&2
|
|
106
|
-
exit 1
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
echo "[dev-bootstrap] publishing packages from extracted repo: $JSKIT_REPO_ROOT"
|
|
110
|
-
JSKIT_REPO_ROOT="$JSKIT_REPO_ROOT" bash "$APP_ROOT/scripts/verdaccio-reset-and-publish-packages.sh"
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Starts a local Verdaccio registry for JSKIT package publish/install testing.
|
|
3
|
-
# - Default: runs in background (nohup) and prints PID/log file locations.
|
|
4
|
-
# - --fg: runs Verdaccio in foreground for interactive debugging.
|
|
5
|
-
#
|
|
6
|
-
# Env overrides:
|
|
7
|
-
# - VERDACCIO_LISTEN (default: 127.0.0.1:4873)
|
|
8
|
-
# - VERDACCIO_CONFIG (default: ./scripts/verdaccio/config.yaml, fallback ~/.config/verdaccio/config.yaml)
|
|
9
|
-
# - VERDACCIO_LOG_FILE (default: /tmp/verdaccio.log)
|
|
10
|
-
# - VERDACCIO_PID_FILE (default: /tmp/verdaccio.pid)
|
|
11
|
-
set -euo pipefail
|
|
12
|
-
|
|
13
|
-
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
14
|
-
VERDACCIO_LISTEN="${VERDACCIO_LISTEN:-127.0.0.1:4873}"
|
|
15
|
-
DEFAULT_VERDACCIO_CONFIG="$ROOT_DIR/scripts/verdaccio/config.yaml"
|
|
16
|
-
if [[ -f "$DEFAULT_VERDACCIO_CONFIG" ]]; then
|
|
17
|
-
VERDACCIO_CONFIG="${VERDACCIO_CONFIG:-$DEFAULT_VERDACCIO_CONFIG}"
|
|
18
|
-
else
|
|
19
|
-
VERDACCIO_CONFIG="${VERDACCIO_CONFIG:-$HOME/.config/verdaccio/config.yaml}"
|
|
20
|
-
fi
|
|
21
|
-
VERDACCIO_LOG_FILE="${VERDACCIO_LOG_FILE:-/tmp/verdaccio.log}"
|
|
22
|
-
VERDACCIO_PID_FILE="${VERDACCIO_PID_FILE:-/tmp/verdaccio.pid}"
|
|
23
|
-
CONFIG_DIR="$(cd "$(dirname "$VERDACCIO_CONFIG")" && pwd)"
|
|
24
|
-
|
|
25
|
-
if [[ "${1:-}" == "--fg" ]]; then
|
|
26
|
-
cd "$CONFIG_DIR"
|
|
27
|
-
exec npx verdaccio --listen "$VERDACCIO_LISTEN" --config "$VERDACCIO_CONFIG"
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
cd "$CONFIG_DIR"
|
|
32
|
-
nohup npx verdaccio --listen "$VERDACCIO_LISTEN" --config "$VERDACCIO_CONFIG" >"$VERDACCIO_LOG_FILE" 2>&1 &
|
|
33
|
-
echo "$!" >"$VERDACCIO_PID_FILE"
|
|
34
|
-
)
|
|
35
|
-
echo "Verdaccio started in background."
|
|
36
|
-
echo "PID file: $VERDACCIO_PID_FILE"
|
|
37
|
-
echo "Log file: $VERDACCIO_LOG_FILE"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
storage: ./storage
|
|
2
|
-
|
|
3
|
-
auth:
|
|
4
|
-
htpasswd:
|
|
5
|
-
file: ./htpasswd
|
|
6
|
-
|
|
7
|
-
uplinks:
|
|
8
|
-
npmjs:
|
|
9
|
-
url: https://registry.npmjs.org/
|
|
10
|
-
|
|
11
|
-
packages:
|
|
12
|
-
"@jskit-ai/*":
|
|
13
|
-
access: $all
|
|
14
|
-
publish: $all
|
|
15
|
-
unpublish: $all
|
|
16
|
-
|
|
17
|
-
"**":
|
|
18
|
-
access: $all
|
|
19
|
-
publish: $all
|
|
20
|
-
unpublish: $all
|
|
21
|
-
proxy: npmjs
|
|
22
|
-
|
|
23
|
-
log:
|
|
24
|
-
- type: stdout
|
|
25
|
-
format: pretty
|
|
26
|
-
level: http
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
|
|
4
|
-
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
-
DEFAULT_VERDACCIO_CONFIG="$ROOT_DIR/scripts/verdaccio/config.yaml"
|
|
6
|
-
if [[ -f "$DEFAULT_VERDACCIO_CONFIG" ]]; then
|
|
7
|
-
VERDACCIO_CONFIG="${VERDACCIO_CONFIG:-$DEFAULT_VERDACCIO_CONFIG}"
|
|
8
|
-
else
|
|
9
|
-
VERDACCIO_CONFIG="${VERDACCIO_CONFIG:-$HOME/.config/verdaccio/config.yaml}"
|
|
10
|
-
fi
|
|
11
|
-
VERDACCIO_LISTEN="${VERDACCIO_LISTEN:-127.0.0.1:4873}"
|
|
12
|
-
VERDACCIO_REGISTRY="${VERDACCIO_REGISTRY:-http://$VERDACCIO_LISTEN}"
|
|
13
|
-
VERDACCIO_REGISTRY="${VERDACCIO_REGISTRY%/}"
|
|
14
|
-
VERDACCIO_LOG_FILE="${VERDACCIO_LOG_FILE:-/tmp/verdaccio-jskit.log}"
|
|
15
|
-
VERDACCIO_PID_FILE="${VERDACCIO_PID_FILE:-/tmp/verdaccio-jskit.pid}"
|
|
16
|
-
PUBLISH_CONCURRENCY="${PUBLISH_CONCURRENCY:-10}"
|
|
17
|
-
JSKIT_REPO_ROOT="${JSKIT_REPO_ROOT:-}"
|
|
18
|
-
PACKAGES_DIR="${PACKAGES_DIR:-}"
|
|
19
|
-
TOOLING_DIR="${TOOLING_DIR:-}"
|
|
20
|
-
|
|
21
|
-
is_valid_jskit_repo_root() {
|
|
22
|
-
local candidate_root="$1"
|
|
23
|
-
[[ -d "$candidate_root/packages" && -d "$candidate_root/packages/kernel" && -d "$candidate_root/tooling" ]]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
resolve_jskit_repo_root() {
|
|
27
|
-
if [[ -n "$JSKIT_REPO_ROOT" ]]; then
|
|
28
|
-
echo "$JSKIT_REPO_ROOT"
|
|
29
|
-
return 0
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
local current_dir="$ROOT_DIR"
|
|
33
|
-
while true; do
|
|
34
|
-
if is_valid_jskit_repo_root "$current_dir"; then
|
|
35
|
-
echo "$current_dir"
|
|
36
|
-
return 0
|
|
37
|
-
fi
|
|
38
|
-
if [[ "$current_dir" == "/" ]]; then
|
|
39
|
-
return 1
|
|
40
|
-
fi
|
|
41
|
-
current_dir="$(dirname "$current_dir")"
|
|
42
|
-
done
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
configure_source_dirs() {
|
|
46
|
-
if [[ -z "$PACKAGES_DIR" || -z "$TOOLING_DIR" ]]; then
|
|
47
|
-
local detected_root
|
|
48
|
-
detected_root="$(resolve_jskit_repo_root || true)"
|
|
49
|
-
if [[ -n "$detected_root" ]]; then
|
|
50
|
-
JSKIT_REPO_ROOT="$detected_root"
|
|
51
|
-
if [[ -z "$PACKAGES_DIR" ]]; then
|
|
52
|
-
PACKAGES_DIR="$JSKIT_REPO_ROOT/packages"
|
|
53
|
-
fi
|
|
54
|
-
if [[ -z "$TOOLING_DIR" ]]; then
|
|
55
|
-
TOOLING_DIR="$JSKIT_REPO_ROOT/tooling"
|
|
56
|
-
fi
|
|
57
|
-
fi
|
|
58
|
-
fi
|
|
59
|
-
|
|
60
|
-
if [[ -z "$PACKAGES_DIR" ]]; then
|
|
61
|
-
echo "Packages directory not configured." >&2
|
|
62
|
-
echo "Set PACKAGES_DIR directly, or set JSKIT_REPO_ROOT to a local jskit-ai checkout." >&2
|
|
63
|
-
exit 1
|
|
64
|
-
fi
|
|
65
|
-
|
|
66
|
-
if [[ -z "$TOOLING_DIR" ]]; then
|
|
67
|
-
TOOLING_DIR="/dev/null"
|
|
68
|
-
fi
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
resolve_storage_dir() {
|
|
72
|
-
if [[ -n "${VERDACCIO_STORAGE_DIR:-}" ]]; then
|
|
73
|
-
echo "$VERDACCIO_STORAGE_DIR"
|
|
74
|
-
return
|
|
75
|
-
fi
|
|
76
|
-
|
|
77
|
-
if [[ -f "$VERDACCIO_CONFIG" ]]; then
|
|
78
|
-
local configured_storage=""
|
|
79
|
-
configured_storage="$(sed -nE 's/^[[:space:]]*storage:[[:space:]]*([^#]+).*$/\1/p' "$VERDACCIO_CONFIG" | head -n 1 | xargs || true)"
|
|
80
|
-
if [[ -n "$configured_storage" ]]; then
|
|
81
|
-
if [[ "$configured_storage" = /* ]]; then
|
|
82
|
-
echo "$configured_storage"
|
|
83
|
-
else
|
|
84
|
-
echo "$(cd "$(dirname "$VERDACCIO_CONFIG")" && pwd)/$configured_storage"
|
|
85
|
-
fi
|
|
86
|
-
return
|
|
87
|
-
fi
|
|
88
|
-
fi
|
|
89
|
-
|
|
90
|
-
echo "$HOME/.local/share/verdaccio/storage"
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
stop_verdaccio() {
|
|
94
|
-
local listen_port
|
|
95
|
-
listen_port="${VERDACCIO_LISTEN##*:}"
|
|
96
|
-
|
|
97
|
-
if [[ -f "$VERDACCIO_PID_FILE" ]]; then
|
|
98
|
-
local pid
|
|
99
|
-
pid="$(cat "$VERDACCIO_PID_FILE" || true)"
|
|
100
|
-
if [[ -n "${pid:-}" ]] && kill -0 "$pid" 2>/dev/null; then
|
|
101
|
-
kill "$pid" || true
|
|
102
|
-
fi
|
|
103
|
-
rm -f "$VERDACCIO_PID_FILE"
|
|
104
|
-
fi
|
|
105
|
-
|
|
106
|
-
if command -v lsof >/dev/null 2>&1; then
|
|
107
|
-
local listener_pids
|
|
108
|
-
listener_pids="$(lsof -tiTCP:"$listen_port" -sTCP:LISTEN 2>/dev/null || true)"
|
|
109
|
-
if [[ -n "$listener_pids" ]]; then
|
|
110
|
-
for pid in $listener_pids; do
|
|
111
|
-
if [[ "$pid" != "$$" ]]; then
|
|
112
|
-
kill "$pid" >/dev/null 2>&1 || true
|
|
113
|
-
fi
|
|
114
|
-
done
|
|
115
|
-
fi
|
|
116
|
-
|
|
117
|
-
local attempts=0
|
|
118
|
-
while lsof -tiTCP:"$listen_port" -sTCP:LISTEN >/dev/null 2>&1; do
|
|
119
|
-
attempts=$((attempts + 1))
|
|
120
|
-
if (( attempts > 20 )); then
|
|
121
|
-
break
|
|
122
|
-
fi
|
|
123
|
-
sleep 0.25
|
|
124
|
-
done
|
|
125
|
-
|
|
126
|
-
listener_pids="$(lsof -tiTCP:"$listen_port" -sTCP:LISTEN 2>/dev/null || true)"
|
|
127
|
-
if [[ -n "$listener_pids" ]]; then
|
|
128
|
-
for pid in $listener_pids; do
|
|
129
|
-
if [[ "$pid" != "$$" ]]; then
|
|
130
|
-
kill -9 "$pid" >/dev/null 2>&1 || true
|
|
131
|
-
fi
|
|
132
|
-
done
|
|
133
|
-
fi
|
|
134
|
-
fi
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
start_verdaccio() {
|
|
138
|
-
local cmd=(npx --yes verdaccio --listen "$VERDACCIO_LISTEN")
|
|
139
|
-
local config_dir
|
|
140
|
-
config_dir="$(pwd)"
|
|
141
|
-
if [[ -f "$VERDACCIO_CONFIG" ]]; then
|
|
142
|
-
cmd+=(--config "$VERDACCIO_CONFIG")
|
|
143
|
-
config_dir="$(cd "$(dirname "$VERDACCIO_CONFIG")" && pwd)"
|
|
144
|
-
fi
|
|
145
|
-
|
|
146
|
-
(
|
|
147
|
-
cd "$config_dir"
|
|
148
|
-
nohup "${cmd[@]}" >"$VERDACCIO_LOG_FILE" 2>&1 &
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
local attempts=0
|
|
152
|
-
until curl -fsS "$VERDACCIO_REGISTRY/-/ping" >/dev/null 2>&1; do
|
|
153
|
-
attempts=$((attempts + 1))
|
|
154
|
-
if (( attempts > 60 )); then
|
|
155
|
-
echo "Verdaccio did not become ready at $VERDACCIO_REGISTRY within 60s." >&2
|
|
156
|
-
echo "See log: $VERDACCIO_LOG_FILE" >&2
|
|
157
|
-
exit 1
|
|
158
|
-
fi
|
|
159
|
-
sleep 1
|
|
160
|
-
done
|
|
161
|
-
|
|
162
|
-
local listen_port
|
|
163
|
-
listen_port="${VERDACCIO_LISTEN##*:}"
|
|
164
|
-
local listener_pid
|
|
165
|
-
listener_pid="$(lsof -tiTCP:"$listen_port" -sTCP:LISTEN 2>/dev/null | head -n 1 || true)"
|
|
166
|
-
if [[ -n "$listener_pid" ]]; then
|
|
167
|
-
echo "$listener_pid" >"$VERDACCIO_PID_FILE"
|
|
168
|
-
fi
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
publish_packages() {
|
|
172
|
-
if [[ ! -d "$PACKAGES_DIR" ]]; then
|
|
173
|
-
echo "Packages directory not found: $PACKAGES_DIR" >&2
|
|
174
|
-
echo "Set PACKAGES_DIR to your monorepo packages path, or set JSKIT_REPO_ROOT." >&2
|
|
175
|
-
exit 1
|
|
176
|
-
fi
|
|
177
|
-
|
|
178
|
-
local dirs=()
|
|
179
|
-
if [[ -d "$TOOLING_DIR" ]]; then
|
|
180
|
-
while IFS= read -r dir; do
|
|
181
|
-
if [[ ! -f "$dir/package.json" ]]; then
|
|
182
|
-
continue
|
|
183
|
-
fi
|
|
184
|
-
local package_name
|
|
185
|
-
package_name="$(cd "$dir" && node -p "require('./package.json').name || ''" 2>/dev/null || true)"
|
|
186
|
-
if [[ "$package_name" == @jskit-ai/* ]]; then
|
|
187
|
-
dirs+=("$dir")
|
|
188
|
-
fi
|
|
189
|
-
done < <(find "$TOOLING_DIR" -mindepth 1 -maxdepth 1 -type d | sort)
|
|
190
|
-
fi
|
|
191
|
-
while IFS= read -r dir; do
|
|
192
|
-
dirs+=("$dir")
|
|
193
|
-
done < <(find "$PACKAGES_DIR" -mindepth 1 -maxdepth 1 -type d | sort)
|
|
194
|
-
|
|
195
|
-
if (( ${#dirs[@]} > 1 )); then
|
|
196
|
-
local deduped=()
|
|
197
|
-
local seen=":"
|
|
198
|
-
for dir in "${dirs[@]}"; do
|
|
199
|
-
if [[ "$seen" != *":$dir:"* ]]; then
|
|
200
|
-
deduped+=("$dir")
|
|
201
|
-
seen="${seen}${dir}:"
|
|
202
|
-
fi
|
|
203
|
-
done
|
|
204
|
-
dirs=("${deduped[@]}")
|
|
205
|
-
fi
|
|
206
|
-
|
|
207
|
-
if (( ${#dirs[@]} == 0 )); then
|
|
208
|
-
echo "No package directories found under $PACKAGES_DIR" >&2
|
|
209
|
-
exit 1
|
|
210
|
-
fi
|
|
211
|
-
|
|
212
|
-
local npm_userconfig
|
|
213
|
-
local registry_with_slash
|
|
214
|
-
local verdaccio_auth_token
|
|
215
|
-
npm_userconfig="$(mktemp)"
|
|
216
|
-
registry_with_slash="${VERDACCIO_REGISTRY%/}/"
|
|
217
|
-
verdaccio_auth_token="${VERDACCIO_AUTH_TOKEN:-dev-local-token}"
|
|
218
|
-
printf "@jskit-ai:registry=%s\nregistry=%s\n//%s/:_authToken=%s\n" \
|
|
219
|
-
"$registry_with_slash" \
|
|
220
|
-
"$registry_with_slash" \
|
|
221
|
-
"${VERDACCIO_LISTEN}" \
|
|
222
|
-
"$verdaccio_auth_token" >"$npm_userconfig"
|
|
223
|
-
|
|
224
|
-
if [[ ! "$PUBLISH_CONCURRENCY" =~ ^[0-9]+$ ]] || (( PUBLISH_CONCURRENCY < 1 )); then
|
|
225
|
-
echo "PUBLISH_CONCURRENCY must be a positive integer (got: $PUBLISH_CONCURRENCY)." >&2
|
|
226
|
-
exit 1
|
|
227
|
-
fi
|
|
228
|
-
|
|
229
|
-
echo "Publishing with concurrency=$PUBLISH_CONCURRENCY"
|
|
230
|
-
|
|
231
|
-
publish_one_package() {
|
|
232
|
-
local dir="$1"
|
|
233
|
-
local npm_userconfig="$2"
|
|
234
|
-
if [[ ! -f "$dir/package.json" ]]; then
|
|
235
|
-
return 0
|
|
236
|
-
fi
|
|
237
|
-
|
|
238
|
-
local package_name
|
|
239
|
-
local publish_dir
|
|
240
|
-
package_name="$(cd "$dir" && node -p "require('./package.json').name || ''")"
|
|
241
|
-
echo "Publishing $package_name from $dir"
|
|
242
|
-
|
|
243
|
-
publish_dir="$(mktemp -d)"
|
|
244
|
-
(
|
|
245
|
-
cd "$dir"
|
|
246
|
-
tar --exclude='./node_modules' -cf - .
|
|
247
|
-
) | (
|
|
248
|
-
cd "$publish_dir"
|
|
249
|
-
tar -xf -
|
|
250
|
-
)
|
|
251
|
-
node -e 'const fs=require("node:fs");const p=process.argv[1];const j=JSON.parse(fs.readFileSync(p,"utf8"));delete j.private;fs.writeFileSync(p,`${JSON.stringify(j,null,2)}\n`);' "$publish_dir/package.json"
|
|
252
|
-
(
|
|
253
|
-
cd "$publish_dir"
|
|
254
|
-
npm publish \
|
|
255
|
-
--registry "$VERDACCIO_REGISTRY" \
|
|
256
|
-
--access public \
|
|
257
|
-
--workspaces=false \
|
|
258
|
-
--userconfig "$npm_userconfig"
|
|
259
|
-
)
|
|
260
|
-
rm -rf "$publish_dir"
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
local running_jobs=0
|
|
264
|
-
local publish_failed=0
|
|
265
|
-
for dir in "${dirs[@]}"; do
|
|
266
|
-
publish_one_package "$dir" "$npm_userconfig" &
|
|
267
|
-
running_jobs=$((running_jobs + 1))
|
|
268
|
-
|
|
269
|
-
if (( running_jobs >= PUBLISH_CONCURRENCY )); then
|
|
270
|
-
if ! wait -n; then
|
|
271
|
-
publish_failed=1
|
|
272
|
-
fi
|
|
273
|
-
running_jobs=$((running_jobs - 1))
|
|
274
|
-
fi
|
|
275
|
-
done
|
|
276
|
-
|
|
277
|
-
while (( running_jobs > 0 )); do
|
|
278
|
-
if ! wait -n; then
|
|
279
|
-
publish_failed=1
|
|
280
|
-
fi
|
|
281
|
-
running_jobs=$((running_jobs - 1))
|
|
282
|
-
done
|
|
283
|
-
|
|
284
|
-
if (( publish_failed != 0 )); then
|
|
285
|
-
echo "One or more package publishes failed." >&2
|
|
286
|
-
exit 1
|
|
287
|
-
fi
|
|
288
|
-
|
|
289
|
-
rm -f "$npm_userconfig"
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
main() {
|
|
293
|
-
configure_source_dirs
|
|
294
|
-
|
|
295
|
-
local storage_dir
|
|
296
|
-
storage_dir="$(resolve_storage_dir)"
|
|
297
|
-
|
|
298
|
-
echo "Stopping Verdaccio..."
|
|
299
|
-
stop_verdaccio
|
|
300
|
-
|
|
301
|
-
echo "Clearing Verdaccio storage: $storage_dir"
|
|
302
|
-
rm -rf "$storage_dir"
|
|
303
|
-
mkdir -p "$storage_dir"
|
|
304
|
-
|
|
305
|
-
echo "Starting Verdaccio at $VERDACCIO_REGISTRY..."
|
|
306
|
-
start_verdaccio
|
|
307
|
-
|
|
308
|
-
echo "Publishing packages from $PACKAGES_DIR and tooling in $TOOLING_DIR..."
|
|
309
|
-
publish_packages
|
|
310
|
-
|
|
311
|
-
echo "Done. Verdaccio is running at $VERDACCIO_REGISTRY"
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
main "$@"
|