Skip to content

Commit 2670460

Browse files
authored
chore: fold spx asset prep into npm lifecycle (#2549)
- Run `install-spx.sh` on `postinstall` and `predev` builds Wasm assets - Make install/build scripts `cd`-safe and skip re-download when dir exists - Rely on lifecycle hooks in Docker/Vercel builds, drop redundant calls - Remove explicit spx install step from `validate.yml` workflow Signed-off-by: Aofei Sheng <[email protected]>
1 parent 0d6fa7e commit 2670460

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

.github/workflows/validate.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ jobs:
3636
- name: Install Node modules
3737
run: npm ci --prefer-offline
3838

39-
- name: Install spx
40-
run: ./install-spx.sh
41-
4239
- name: Run Vue TSC
4340
run: npm run type-check
4441

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ FROM ${NODE_BASE_IMAGE} AS frontend-builder
2525
WORKDIR /app/spx-gui
2626

2727
COPY spx-gui/package.json spx-gui/package-lock.json .
28-
ARG NPM_CONFIG_REGISTRY
29-
RUN npm install
30-
3128
COPY spx-gui/public ./public
3229
COPY spx-gui/install-spx.sh .
33-
RUN ./install-spx.sh
30+
ARG NPM_CONFIG_REGISTRY
31+
RUN npm install
3432

3533
COPY spx-gui .
3634
COPY docs ../docs

spx-gui/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
```bash
1111
npm install
12-
./install-spx.sh
1312
```
1413

1514
## Run the Project in Development Mode
1615

1716
```bash
18-
./build-wasm.sh
1917
npm run dev
2018
```
2119

spx-gui/build-wasm.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/bin/bash
22
set -e
33

4-
echo "Run this script from 'spx-gui' directory"
4+
cd "$(dirname "$0")"
55

66
# Copy Go wasm_exec.js
77
cp -f "$(go env GOROOT)/lib/wasm/wasm_exec.js" src/assets/wasm/wasm_exec.js
88

9-
109
# Build and copy spxls.wasm and spxls-pkgdata.zip
1110
( cd ../tools/spxls && ./build.sh )
1211
cp ../tools/spxls/spxls.wasm src/assets/wasm/spxls.wasm

spx-gui/install-spx.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
#!/bin/bash
22
set -e
33

4+
cd "$(dirname "$0")"
5+
46
# Version of spx, keep in sync with the version in `.env`.
57
SPX_VERSION=2.0.0-pre.36
68
SPX_NAME="spx_${SPX_VERSION}"
79
SPX_FILE_NAME="${SPX_NAME}.zip"
810
SPX_FILE_URL="https://github.com/goplus/spx/releases/download/v${SPX_VERSION}/spx_web.zip"
11+
SPX_TARGET_DIR="./public/${SPX_NAME}"
12+
13+
if [[ -d "${SPX_TARGET_DIR}" ]]; then
14+
exit 0
15+
fi
916

1017
wget -O "${SPX_FILE_NAME}" "${SPX_FILE_URL}"
11-
unzip -o "${SPX_FILE_NAME}" -d "./public/${SPX_NAME}"
18+
unzip -o "${SPX_FILE_NAME}" -d "${SPX_TARGET_DIR}"
1219
rm "${SPX_FILE_NAME}"

spx-gui/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7+
"postinstall": "./install-spx.sh",
8+
"predev": "./install-spx.sh && ./build-wasm.sh",
79
"dev": "vite",
810
"build": "vue-tsc --build --force && vite build --mode ${NODE_ENV:-production}",
911
"preview": "vite preview",

spx-gui/vercel-install.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ tar -C /usr/local -xzf ./go1.24.4.linux-amd64.tar.gz
1111
/usr/local/go/bin/go version
1212

1313
npm install
14-
./install-spx.sh

0 commit comments

Comments
 (0)