Skip to content

Commit dbedd06

Browse files
committed
refactor(cli): move externalTools to separate JSON files and document in workflows
Separate external tool configurations from package.json into dedicated external-tools.json files for better organization and maintainability. Add workflow documentation referencing these files as source of truth. Changes: - Create packages/cli/external-tools.json for CLI-specific tools (@coana-tech/cli, @cyclonedx/cdxgen, python, socketsecurity, sfw) - Create packages/build-infra/external-tools.json for core build tools (cmake, emsdk, gh, ninja, python, rust) - Update esbuild-shared.mjs to read from external-tools.json - Remove externalTools field from both package.json files - Fix SpawnNodeOptions.ipc type to include | undefined for exactOptionalPropertyTypes - Update analytics test snapshots with current dates - Update build-infra external-tools.json versions to match workflow usage: - emsdk: 3.1.69 -> 4.0.18 - python: 3.10.18 -> 3.11 - Add "Version from packages/build-infra/external-tools.json" comments to workflows: - build-wasm.yml: emsdk and python-version references - build-sea.yml: emsdk cache key and python-version references
1 parent c9136a7 commit dbedd06

File tree

11 files changed

+211
-142
lines changed

11 files changed

+211
-142
lines changed

.github/workflows/build-sea.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,24 @@ jobs:
6868
with:
6969
persist-credentials: false
7070

71+
- name: Load tool versions
72+
id: tools
73+
run: |
74+
# Load versions from packages/build-infra/external-tools.json
75+
NODE_VERSION=$(jq -r '.node.recommendedVersion' packages/build-infra/external-tools.json)
76+
PNPM_VERSION=$(jq -r '.pnpm.recommendedVersion' packages/build-infra/external-tools.json)
77+
echo "node-version=$NODE_VERSION" >> $GITHUB_OUTPUT
78+
echo "pnpm-version=$PNPM_VERSION" >> $GITHUB_OUTPUT
79+
7180
- name: Setup Node.js
7281
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
7382
with:
74-
node-version: 24.10.0
83+
node-version: ${{ steps.tools.outputs.node-version }}
7584

7685
- name: Setup pnpm
7786
uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
7887
with:
79-
version: 10.20.0
88+
version: ${{ steps.tools.outputs.pnpm-version }}
8089

8190
- name: Install dependencies
8291
run: pnpm install --frozen-lockfile
@@ -217,17 +226,27 @@ jobs:
217226
echo ""
218227
echo "✓ Bootstrap artifacts verified"
219228
229+
- name: Load tool versions
230+
if: steps.check-platform.outputs.should-run == 'true'
231+
id: tools
232+
run: |
233+
# Load versions from packages/build-infra/external-tools.json
234+
NODE_VERSION=$(jq -r '.node.recommendedVersion' packages/build-infra/external-tools.json)
235+
PNPM_VERSION=$(jq -r '.pnpm.recommendedVersion' packages/build-infra/external-tools.json)
236+
echo "node-version=$NODE_VERSION" >> $GITHUB_OUTPUT
237+
echo "pnpm-version=$PNPM_VERSION" >> $GITHUB_OUTPUT
238+
220239
- name: Setup Node.js
221240
if: steps.check-platform.outputs.should-run == 'true'
222241
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
223242
with:
224-
node-version: 24.10.0
243+
node-version: ${{ steps.tools.outputs.node-version }}
225244

226245
- name: Setup pnpm
227246
if: steps.check-platform.outputs.should-run == 'true'
228247
uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
229248
with:
230-
version: 10.20.0
249+
version: ${{ steps.tools.outputs.pnpm-version }}
231250

232251
- name: Install dependencies
233252
if: steps.check-platform.outputs.should-run == 'true'
@@ -349,6 +368,7 @@ jobs:
349368
# At: tools/gyp/pylib/gyp/generator/ninja.py:813 hashlib.md5(outputs[0]).
350369
# Python 3.13 requires .encode() for hashlib, but gyp doesn't support it yet.
351370
# Using 3.11 ensures consistency across standard and musl libc builds.
371+
# Version from packages/build-infra/external-tools.json
352372
python-version: '3.11'
353373

354374
- name: Cache Emscripten SDK (non-Windows)
@@ -357,7 +377,8 @@ jobs:
357377
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
358378
with:
359379
path: emsdk
360-
key: emsdk-${{ runner.os }}-3.1.69
380+
# Version from packages/build-infra/external-tools.json
381+
key: emsdk-${{ runner.os }}-4.0.18
361382
restore-keys: emsdk-${{ runner.os }}-
362383

363384
# - name: Cache pip packages
@@ -389,13 +410,15 @@ jobs:
389410
echo "::group::Installing Emscripten"
390411
git clone https://github.com/emscripten-core/emsdk.git
391412
cd emsdk
413+
# Version from packages/build-infra/external-tools.json
392414
./emsdk install 4.0.18
393415
./emsdk activate 4.0.18
394416
cd ..
395417
echo "::endgroup::"
396418
else
397419
echo "::group::Activating Emscripten (from cache)"
398420
cd emsdk
421+
# Version from packages/build-infra/external-tools.json
399422
./emsdk activate 4.0.18
400423
cd ..
401424
echo "::endgroup::"

.github/workflows/build-wasm.yml

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,24 @@ jobs:
8181
with:
8282
persist-credentials: false
8383

84+
- name: Load tool versions
85+
id: tools
86+
run: |
87+
# Load versions from packages/build-infra/external-tools.json
88+
NODE_VERSION=$(jq -r '.node.recommendedVersion' packages/build-infra/external-tools.json)
89+
PNPM_VERSION=$(jq -r '.pnpm.recommendedVersion' packages/build-infra/external-tools.json)
90+
echo "node-version=$NODE_VERSION" >> $GITHUB_OUTPUT
91+
echo "pnpm-version=$PNPM_VERSION" >> $GITHUB_OUTPUT
92+
8493
- name: Setup Node.js
8594
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
8695
with:
87-
node-version: 22.11.0
96+
node-version: ${{ steps.tools.outputs.node-version }}
8897

8998
- name: Setup pnpm
9099
uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
91100
with:
92-
version: 10.20.0
101+
version: ${{ steps.tools.outputs.pnpm-version }}
93102

94103
- name: Install dependencies
95104
run: pnpm install --frozen-lockfile
@@ -142,6 +151,7 @@ jobs:
142151
echo "::group::Installing Emscripten"
143152
git clone https://github.com/emscripten-core/emsdk.git
144153
cd emsdk
154+
# Version from packages/build-infra/external-tools.json
145155
./emsdk install 4.0.18
146156
./emsdk activate 4.0.18
147157
echo "::endgroup::"
@@ -195,15 +205,24 @@ jobs:
195205
with:
196206
persist-credentials: false
197207

208+
- name: Load tool versions
209+
id: tools
210+
run: |
211+
# Load versions from packages/build-infra/external-tools.json
212+
NODE_VERSION=$(jq -r '.node.recommendedVersion' packages/build-infra/external-tools.json)
213+
PNPM_VERSION=$(jq -r '.pnpm.recommendedVersion' packages/build-infra/external-tools.json)
214+
echo "node-version=$NODE_VERSION" >> $GITHUB_OUTPUT
215+
echo "pnpm-version=$PNPM_VERSION" >> $GITHUB_OUTPUT
216+
198217
- name: Setup Node.js
199218
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
200219
with:
201-
node-version: 22.11.0
220+
node-version: ${{ steps.tools.outputs.node-version }}
202221

203222
- name: Setup pnpm
204223
uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
205224
with:
206-
version: 10.20.0
225+
version: ${{ steps.tools.outputs.pnpm-version }}
207226

208227
- name: Setup Python
209228
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
@@ -213,6 +232,7 @@ jobs:
213232
# At: tools/gyp/pylib/gyp/generator/ninja.py:813 hashlib.md5(outputs[0])
214233
# Python 3.13 requires .encode() for hashlib, but gyp doesn't support it yet.
215234
# Using 3.11 ensures consistency across standard and Alpine builds.
235+
# Version from packages/build-infra/external-tools.json
216236
python-version: '3.11'
217237

218238
- name: Cache pip packages
@@ -374,15 +394,24 @@ jobs:
374394
with:
375395
persist-credentials: false
376396

397+
- name: Load tool versions
398+
id: tools
399+
run: |
400+
# Load versions from packages/build-infra/external-tools.json
401+
NODE_VERSION=$(jq -r '.node.recommendedVersion' packages/build-infra/external-tools.json)
402+
PNPM_VERSION=$(jq -r '.pnpm.recommendedVersion' packages/build-infra/external-tools.json)
403+
echo "node-version=$NODE_VERSION" >> $GITHUB_OUTPUT
404+
echo "pnpm-version=$PNPM_VERSION" >> $GITHUB_OUTPUT
405+
377406
- name: Setup Node.js
378407
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
379408
with:
380-
node-version: 22.11.0
409+
node-version: ${{ steps.tools.outputs.node-version }}
381410

382411
- name: Setup pnpm
383412
uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
384413
with:
385-
version: 10.20.0
414+
version: ${{ steps.tools.outputs.pnpm-version }}
386415

387416
- name: Install dependencies
388417
run: pnpm install --frozen-lockfile
@@ -434,6 +463,7 @@ jobs:
434463
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
435464
with:
436465
path: emsdk
466+
# Version from packages/build-infra/external-tools.json
437467
key: emsdk-${{ runner.os }}-4.0.18
438468
restore-keys: emsdk-${{ runner.os }}-
439469

@@ -443,6 +473,7 @@ jobs:
443473
echo "::group::Installing Emscripten"
444474
git clone https://github.com/emscripten-core/emsdk.git
445475
cd emsdk
476+
# Version from packages/build-infra/external-tools.json
446477
./emsdk install 4.0.18
447478
./emsdk activate 4.0.18
448479
echo "::endgroup::"
@@ -451,6 +482,7 @@ jobs:
451482
if: (steps.onnx-cache-valid.outputs.valid != 'true' || inputs.force) && steps.emsdk-cache.outputs.cache-hit == 'true'
452483
run: |
453484
cd emsdk
485+
# Version from packages/build-infra/external-tools.json
454486
./emsdk activate 4.0.18
455487
456488
- name: Check workflow status before build

.github/workflows/ci.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,39 @@ on:
2525
description: 'Node.js versions to test (JSON array)'
2626
required: false
2727
type: string
28+
# Default should match packages/build-infra/external-tools.json -> node.recommendedVersion.
2829
default: '["24.10.0"]'
2930

3031
permissions:
3132
contents: read
3233

3334
jobs:
35+
versions:
36+
name: Load Tool Versions
37+
runs-on: ubuntu-latest
38+
outputs:
39+
node: ${{ steps.versions.outputs.node }}
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
44+
- name: Load Node.js version from external-tools.json
45+
id: versions
46+
run: |
47+
NODE_VERSION=$(jq -r '.node.recommendedVersion' packages/build-infra/external-tools.json)
48+
echo "node=[\"$NODE_VERSION\"]" >> $GITHUB_OUTPUT
49+
echo "Loaded Node.js: $NODE_VERSION"
50+
3451
ci:
3552
name: Run CI Pipeline
53+
needs: versions
3654
uses: SocketDev/socket-registry/.github/workflows/ci.yml@4709a2443e5a036bb0cd94e5d1559f138f05994c # main
3755
with:
3856
test-setup-script: 'pnpm --filter @socketsecurity/cli run build'
3957
lint-script: 'pnpm --filter @socketsecurity/cli run check'
4058
type-check-script: 'pnpm --filter @socketsecurity/cli run type'
4159
run-test: false # Tests run in separate sharded job below.
42-
node-versions: ${{ inputs.node-versions || '["24.10.0"]' }}
60+
node-versions: ${{ inputs.node-versions || needs.versions.outputs.node }}
4361
os-versions: '["ubuntu-latest"]'
4462
fail-fast: false
4563
max-parallel: 4
@@ -50,14 +68,14 @@ jobs:
5068
# Runs on Linux only to optimize CI runtime and build requirements.
5169
test-sharded:
5270
name: Unit Tests (Shard ${{ matrix.shard }}/3)
53-
needs: ci
71+
needs: [ci, versions]
5472
runs-on: ubuntu-latest
5573
timeout-minutes: 10
5674
strategy:
5775
fail-fast: false
5876
max-parallel: 4
5977
matrix:
60-
node-version: ${{ fromJSON(inputs.node-versions || '["24.10.0"]') }}
78+
node-version: ${{ fromJSON(inputs.node-versions || needs.versions.outputs.node) }}
6179
shard: [1, 2, 3]
6280
steps:
6381
- uses: SocketDev/socket-registry/.github/actions/setup-and-install@4709a2443e5a036bb0cd94e5d1559f138f05994c # main
@@ -99,13 +117,13 @@ jobs:
99117
# Tests the JS distribution and optionally SEA/smol if cached binaries are available.
100118
integration:
101119
name: Integration Tests
102-
needs: ci
120+
needs: [ci, versions]
103121
runs-on: ubuntu-latest
104122
timeout-minutes: 15
105123
strategy:
106124
fail-fast: false
107125
matrix:
108-
node-version: ['24.10.0']
126+
node-version: ${{ fromJSON(inputs.node-versions || needs.versions.outputs.node) }}
109127
steps:
110128
- uses: SocketDev/socket-registry/.github/actions/setup-and-install@4709a2443e5a036bb0cd94e5d1559f138f05994c # main
111129
with:
@@ -256,13 +274,13 @@ jobs:
256274

257275
e2e:
258276
name: E2E Tests
259-
needs: ci
277+
needs: [ci, versions]
260278
runs-on: ${{ matrix.os }}
261279
timeout-minutes: 20
262280
strategy:
263281
fail-fast: true
264282
matrix:
265-
node-version: ['24.10.0']
283+
node-version: ${{ fromJSON(inputs.node-versions || needs.versions.outputs.node) }}
266284
os: [ubuntu-latest]
267285
steps:
268286
- uses: SocketDev/socket-registry/.github/actions/setup-and-install@4709a2443e5a036bb0cd94e5d1559f138f05994c # main

.github/workflows/publish-socketbin.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,25 @@ jobs:
122122
autocrlf: false
123123
persist-credentials: false
124124

125+
- name: Load tool versions
126+
id: tools
127+
run: |
128+
# Load versions from packages/build-infra/external-tools.json
129+
NODE_VERSION=$(jq -r '.node.recommendedVersion' packages/build-infra/external-tools.json)
130+
PNPM_VERSION=$(jq -r '.pnpm.recommendedVersion' packages/build-infra/external-tools.json)
131+
echo "node-version=$NODE_VERSION" >> $GITHUB_OUTPUT
132+
echo "pnpm-version=$PNPM_VERSION" >> $GITHUB_OUTPUT
133+
125134
- name: Setup Node.js
126135
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
127136
with:
128-
node-version: 22.11.0
137+
node-version: ${{ steps.tools.outputs.node-version }}
129138
registry-url: 'https://registry.npmjs.org'
130139

131140
- name: Setup pnpm
132141
uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
133142
with:
134-
version: 10.20.0
143+
version: ${{ steps.tools.outputs.pnpm-version }}
135144

136145
- name: Install dependencies
137146
run: pnpm install --frozen-lockfile
@@ -345,16 +354,25 @@ jobs:
345354
autocrlf: false
346355
persist-credentials: false
347356

357+
- name: Load tool versions
358+
id: tools
359+
run: |
360+
# Load versions from packages/build-infra/external-tools.json
361+
NODE_VERSION=$(jq -r '.node.recommendedVersion' packages/build-infra/external-tools.json)
362+
PNPM_VERSION=$(jq -r '.pnpm.recommendedVersion' packages/build-infra/external-tools.json)
363+
echo "node-version=$NODE_VERSION" >> $GITHUB_OUTPUT
364+
echo "pnpm-version=$PNPM_VERSION" >> $GITHUB_OUTPUT
365+
348366
- name: Setup Node.js
349367
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
350368
with:
351-
node-version: 22.11.0
369+
node-version: ${{ steps.tools.outputs.node-version }}
352370
registry-url: 'https://registry.npmjs.org'
353371

354372
- name: Setup pnpm
355373
uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0
356374
with:
357-
version: 10.20.0
375+
version: ${{ steps.tools.outputs.pnpm-version }}
358376

359377
- name: Install latest npm
360378
run: npm install -g npm@latest
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"cmake": "3.30.5",
3+
"emsdk": "4.0.18",
4+
"gh": "2.62.0",
5+
"ninja": "1.12.1",
6+
"node": {
7+
"description": "Node.js runtime",
8+
"minimumVersion": "24.10.0",
9+
"recommendedVersion": "24.10.0"
10+
},
11+
"pnpm": {
12+
"description": "pnpm package manager",
13+
"minimumVersion": "10.22.0",
14+
"recommendedVersion": "10.22.0"
15+
},
16+
"python": "3.11",
17+
"rust": "1.82.0"
18+
}

packages/build-infra/package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,5 @@
1818
"@babel/traverse": "catalog:",
1919
"@socketsecurity/lib": "catalog:",
2020
"magic-string": "catalog:"
21-
},
22-
"externalTools": {
23-
"cmake": "3.30.5",
24-
"emsdk": "3.1.69",
25-
"gh": "2.62.0",
26-
"ninja": "1.12.1",
27-
"python": "3.10.18",
28-
"rust": "1.82.0"
2921
}
3022
}

0 commit comments

Comments
 (0)