Skip to content

Commit d8f31db

Browse files
authored
Merge pull request #59 from manicinc/fix/dependabot-alerts
build(deps): close 345 of the 349 open Dependabot alerts
2 parents 9f56263 + 3f90ba4 commit d8f31db

23 files changed

Lines changed: 5786 additions & 16847 deletions

‎.github/workflows/auto-format.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Setup Node.js
3030
uses: actions/setup-node@v4
3131
with:
32-
node-version: '18'
32+
node-version: '22'
3333
cache: 'pnpm'
3434

3535
- name: Install dependencies

‎.github/workflows/ci.yml‎

Lines changed: 89 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
env:
22-
NODE_VERSION: '18'
22+
NODE_VERSION: '22'
2323

2424
jobs:
2525
pre-check:
@@ -114,7 +114,7 @@ jobs:
114114
# strategy:
115115
# fail-fast: false
116116
# matrix:
117-
# node: ['18', '20']
117+
# node: ['22', '24']
118118
steps:
119119
- uses: actions/checkout@v4
120120

@@ -135,14 +135,14 @@ jobs:
135135
run: pnpm run test:coverage
136136

137137
- name: Upload coverage artifact
138-
# if: matrix.node == '18' # UNCOMMENT FOR MATRIX
138+
# if: matrix.node == '22' # UNCOMMENT FOR MATRIX
139139
uses: actions/upload-artifact@v4
140140
with:
141141
name: coverage-${{ github.sha }}
142142
path: coverage
143143

144144
- name: Upload to Codecov
145-
# if: matrix.node == '18' # UNCOMMENT FOR MATRIX
145+
# if: matrix.node == '22' # UNCOMMENT FOR MATRIX
146146
uses: codecov/codecov-action@v5
147147
with:
148148
token: ${{ secrets.CODECOV_TOKEN }}
@@ -167,7 +167,7 @@ jobs:
167167
# fail-fast: false
168168
# matrix:
169169
# os: [windows-latest, macos-latest]
170-
# node: ['20']
170+
# node: ['22']
171171
# runs-on: ${{ matrix.os }}
172172
# steps:
173173
# - uses: actions/checkout@v4
@@ -256,7 +256,20 @@ jobs:
256256
# own name, and a GitHub release holds one asset per name.
257257
- name: Check the release assets
258258
run: node scripts/check-release-assets.js
259-
259+
260+
# The tarball npm would publish, for the runtime-floor job to install as a consumer does.
261+
- name: Pack the package
262+
run: |
263+
mkdir -p "$RUNNER_TEMP/package"
264+
npm pack --ignore-scripts --pack-destination "$RUNNER_TEMP/package"
265+
266+
- name: Upload the packed package
267+
uses: actions/upload-artifact@v4
268+
with:
269+
name: package-${{ github.sha }}
270+
path: ${{ runner.temp }}/package/*.tgz
271+
if-no-files-found: error
272+
260273
- name: Bundle size check
261274
run: pnpm run size:check
262275

@@ -284,6 +297,53 @@ jobs:
284297
name: dist-${{ github.sha }}
285298
path: dist
286299

300+
# engines.node in package.json is the oldest Node a consumer may run magiclogger on. This
301+
# installs the packed package with npm on that Node, as a consumer would, and loads both entry
302+
# points through scripts/check-runtime-floor.cjs. The suite runs from src on Node 22 and
303+
# cannot see a build that needs a newer Node than engines claims.
304+
runtime-floor:
305+
runs-on: ubuntu-latest
306+
needs: build
307+
timeout-minutes: 10
308+
steps:
309+
- uses: actions/checkout@v4
310+
with:
311+
persist-credentials: false
312+
313+
- name: Read the oldest Node that engines allows
314+
id: floor
315+
run: |
316+
floor=$(node -p '(/^>=\s*(\d+\.\d+\.\d+)$/.exec(require("./package.json").engines.node) || [])[1] || ""')
317+
if [ -z "$floor" ]; then
318+
echo "::error::engines.node in package.json must read >=x.y.z"
319+
exit 1
320+
fi
321+
echo "version=$floor" >> "$GITHUB_OUTPUT"
322+
323+
- name: Download the packed package
324+
uses: actions/download-artifact@v4
325+
with:
326+
name: package-${{ github.sha }}
327+
path: ${{ runner.temp }}/package
328+
329+
- name: Setup Node.js ${{ steps.floor.outputs.version }}
330+
uses: actions/setup-node@v4
331+
with:
332+
node-version: ${{ steps.floor.outputs.version }}
333+
334+
- name: Install the package as a consumer
335+
working-directory: ${{ runner.temp }}
336+
run: |
337+
mkdir consumer
338+
cd consumer
339+
npm init -y > /dev/null
340+
npm install --no-audit --no-fund ../package/*.tgz
341+
cp "$GITHUB_WORKSPACE/scripts/check-runtime-floor.cjs" .
342+
343+
- name: Load both entry points
344+
working-directory: ${{ runner.temp }}/consumer
345+
run: node check-runtime-floor.cjs
346+
287347
release-draft:
288348
name: Update Release Draft
289349
runs-on: ubuntu-latest
@@ -317,50 +377,15 @@ jobs:
317377
node-version: ${{ env.NODE_VERSION }}
318378
cache: 'pnpm'
319379

320-
- name: Cache website dependencies
321-
uses: actions/cache@v4
322-
with:
323-
path: website/node_modules
324-
key: ${{ runner.os }}-website-${{ hashFiles('website/package-lock.json') }}
325-
restore-keys: |
326-
${{ runner.os }}-website-
327-
328-
- name: Install root dependencies
329-
run: pnpm install --frozen-lockfile
330-
331-
- name: Build library (minified production)
332-
run: |
333-
echo "Building minified production library..."
334-
NODE_ENV=production pnpm run build
335-
env:
336-
NODE_ENV: production
337-
338-
- name: Generate API documentation
339-
run: |
340-
echo "Generating TypeDoc API documentation..."
341-
pnpm run docs:api
342-
343-
- name: Install website dependencies
344-
working-directory: ./website
345-
run: |
346-
# Use pnpm for consistency with root project
347-
pnpm install --frozen-lockfile
348-
349-
- name: Sync documentation
350-
run: |
351-
if [ -f "scripts/sync-docs.js" ]; then
352-
node scripts/sync-docs.js
353-
else
354-
cp -r docs/* website/docs/ 2>/dev/null || true
355-
fi
356-
357-
- name: Build Docusaurus (production minified)
358-
working-directory: ./website
359-
run: |
360-
echo "Building minified Docusaurus site..."
361-
NODE_ENV=production pnpm run build
380+
# The install, the library build, the API pages and the Docusaurus build, as docs-build.yml
381+
# runs them on pull requests, after the same setup steps. No website/node_modules cache is
382+
# restored first: the one that stood here keyed on website/package-lock.json, which does
383+
# not exist, so its key never changed and every deploy restored the folder one master run
384+
# saved, from an older dependency tree than the lockfile, before an install no
385+
# pull-request check ran from. setup-node's pnpm cache holds the store.
386+
- name: Build the site
387+
run: bash scripts/build-docs-site.sh
362388
env:
363-
NODE_ENV: production
364389
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
365390
MS_CLARITY_ID: ${{ secrets.MS_CLARITY_ID }}
366391

@@ -381,9 +406,21 @@ jobs:
381406
382407
all-checks:
383408
runs-on: ubuntu-latest
384-
needs: [quality, test-linux, build, security]
385-
# needs: [quality, test-linux, test-cross, build, security] # UNCOMMENT FOR CROSS-PLATFORM
409+
needs: [quality, test-linux, build, security, runtime-floor]
410+
# needs: [quality, test-linux, test-cross, build, security, runtime-floor] # UNCOMMENT FOR CROSS-PLATFORM
386411
if: always()
387412
steps:
413+
# if: always() runs this job after a failed or skipped job too, so the needed jobs'
414+
# results decide it; an echo alone passed while test-linux or build had failed.
388415
- name: Final status
389-
run: echo "✅ Core CI jobs completed"
416+
env:
417+
RESULTS: ${{ join(needs.*.result, ' ') }}
418+
run: |
419+
echo "Needed jobs: $RESULTS"
420+
for result in $RESULTS; do
421+
if [ "$result" != success ]; then
422+
echo "::error::a needed job ended $result"
423+
exit 1
424+
fi
425+
done
426+
echo "Core CI jobs passed"

‎.github/workflows/deploy-docs.yml‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,16 @@ jobs:
2929
- name: Setup Node.js
3030
uses: actions/setup-node@v4
3131
with:
32-
node-version: '20'
32+
node-version: '22'
3333
cache: 'pnpm'
3434

35-
- name: Install dependencies
36-
run: pnpm install --frozen-lockfile
37-
38-
- name: Build library
39-
run: pnpm run build
40-
41-
- name: Generate API documentation
42-
run: pnpm run docs:api
43-
44-
- name: Install website dependencies
45-
run: cd website && pnpm install --frozen-lockfile
46-
47-
- name: Build website
48-
run: cd website && pnpm run build
35+
# The install, the library build, the API pages and the Docusaurus build, as docs-build.yml
36+
# runs them on pull requests and ci.yml's deploy-docs job runs them before its own publish.
37+
- name: Build the site
38+
run: bash scripts/build-docs-site.sh
39+
env:
40+
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
41+
MS_CLARITY_ID: ${{ secrets.MS_CLARITY_ID }}
4942

5043
- name: Deploy to GitHub Pages
5144
uses: peaceiris/actions-gh-pages@v3

‎.github/workflows/docs-build.yml‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Docs build
2+
3+
# Builds the documentation site with scripts/build-docs-site.sh, the script ci.yml's deploy-docs
4+
# job and deploy-docs.yml run after a push to master, and deploys nothing. Without it, a pull
5+
# request that breaks the site (a Docusaurus or webpack release in pnpm-lock.yaml, a page in
6+
# docs/, a change to the build commands) passes every check and the break first shows in the
7+
# deploy on master. The setup steps and the gh-pages publish stay in each deploy workflow.
8+
on:
9+
pull_request:
10+
branches: [master, main]
11+
paths:
12+
- 'docs/**'
13+
- 'website/**'
14+
# TypeDoc reads the source, README.md and tsconfig.json for the API pages, and checks
15+
# their links (typedoc.json validation.invalidLink).
16+
- 'src/**'
17+
- 'README.md'
18+
- 'tsconfig.json'
19+
# The library build that runs first, as in the deploy.
20+
- 'tsup.config.ts'
21+
- 'tsconfig.build.json'
22+
- 'package.json'
23+
- 'pnpm-lock.yaml'
24+
- 'pnpm-workspace.yaml'
25+
- 'typedoc.json'
26+
- 'scripts/build-docs-site.sh'
27+
- '.github/workflows/docs-build.yml'
28+
29+
permissions:
30+
contents: read
31+
32+
concurrency:
33+
group: docs-build-${{ github.event.pull_request.number }}
34+
cancel-in-progress: true
35+
36+
jobs:
37+
docs-build:
38+
name: docs-build
39+
runs-on: ubuntu-latest
40+
timeout-minutes: 20
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
persist-credentials: false
45+
46+
- name: Setup pnpm
47+
uses: pnpm/action-setup@v4
48+
49+
- name: Setup Node.js
50+
uses: actions/setup-node@v4
51+
with:
52+
node-version: '22'
53+
cache: 'pnpm'
54+
55+
# Both deploys build with the analytics ids set, so this build sets stand-ins and takes the
56+
# same branches of website/src/plugins/analyticsPlugin.js. Nothing here is deployed.
57+
- name: Build the site
58+
run: bash scripts/build-docs-site.sh
59+
env:
60+
GA_TRACKING_ID: G-DOCSBUILD
61+
MS_CLARITY_ID: docsbuild
62+
63+
# A release that stops the plugin's tags reaching the pages would otherwise first show on
64+
# the live site, and show nowhere in a run.
65+
- name: Check the analytics tags reached the pages
66+
run: |
67+
page=website/build/index.html
68+
for wanted in 'googletagmanager.com/gtag/js?id=G-DOCSBUILD' 'clarity.ms/tag/' 'docsbuild'; do
69+
if ! grep -Fq "$wanted" "$page"; then
70+
echo "::error::$page does not carry $wanted"
71+
exit 1
72+
fi
73+
done
74+
75+
# docusaurus start is how the site is worked on (pnpm run docs). A Docusaurus or
76+
# webpack-dev-server release in pnpm-lock.yaml changes it, and the build above never runs
77+
# it. webpack-dev-server answers once the first bundle has compiled. The server rewrites an
78+
# unknown path that accepts HTML to the home page, so the bundle request asks for JavaScript
79+
# and reads the type that comes back.
80+
- name: Check the dev server serves the site
81+
working-directory: website
82+
run: |
83+
log="$RUNNER_TEMP/docs-start.log"
84+
pnpm run start --no-open > "$log" 2>&1 &
85+
server=$!
86+
trap 'kill "$server" 2>/dev/null || true' EXIT
87+
for attempt in $(seq 1 40); do
88+
if curl -fsS --max-time 10 http://localhost:3000/ 2>/dev/null | grep -q 'id="__docusaurus"' \
89+
&& curl -fsS --max-time 10 -H 'Accept: application/javascript' -o /dev/null \
90+
-w '%{content_type}' http://localhost:3000/main.js | grep -q javascript; then
91+
if grep -Eiq 'compiled with ([0-9]+ |some )?(errors?|problems?)' "$log"; then
92+
cat "$log"
93+
echo "::error::the dev server compiled with errors"
94+
exit 1
95+
fi
96+
echo "the dev server served the page and its bundle on attempt $attempt"
97+
exit 0
98+
fi
99+
if ! kill -0 "$server" 2>/dev/null; then
100+
cat "$log"
101+
echo "::error::the dev server exited"
102+
exit 1
103+
fi
104+
sleep 5
105+
done
106+
cat "$log"
107+
echo "::error::the dev server did not serve the site in time"
108+
exit 1

0 commit comments

Comments
 (0)