-
Notifications
You must be signed in to change notification settings - Fork 2
53 lines (51 loc) · 2.38 KB
/
Copy pathci.yml
File metadata and controls
53 lines (51 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
tags: ["v*"]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install
- run: npm run typecheck --if-present
- run: npm run lint --if-present
- run: npm run format --if-present
- run: npm run test --if-present
- run: npm run build
- name: Verify dist externals
run: |
node -e "
const fs = require('fs');
const dist = 'dist/index.js';
if (!fs.existsSync(dist)) process.exit(0);
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
const peerDeps = Object.keys(pkg.peerDependencies || {});
const builtins = new Set(['assert','buffer','child_process','cluster','console','constants','crypto','dgram','dns','domain','events','fs','http','http2','https','inspector','module','net','os','path','perf_hooks','process','punycode','querystring','readline','repl','stream','string_decoder','sys','timers','tls','trace_events','tty','url','util','v8','vm','wasi','worker_threads','zlib']);
const shared = ['@quartz-community/','preact','@jackyzha0/quartz','vfile','unified'];
const content = fs.readFileSync(dist, 'utf-8');
const re = /^\s*(?:import\s+.*\s+from|export\s+.*\s+from)\s+[\"']([^\"'./][^\"']*)[\"']/gm;
const unexpected = new Set();
for (const m of content.matchAll(re)) {
const s = m[1];
if (s.startsWith('node:')) continue;
const bare = s.includes('/') && s.startsWith('@') ? s.split('/').slice(0,2).join('/') : s.split('/')[0];
if (builtins.has(bare)) continue;
if (shared.some(p => s.startsWith(p))) continue;
if (peerDeps.some(d => s === d || s.startsWith(d + '/'))) continue;
unexpected.add(s);
}
if (unexpected.size > 0) {
console.error('ERROR: dist/ has unbundled external imports that will fail at runtime:');
for (const u of unexpected) console.error(' - ' + u);
console.error('Move these from dependencies to devDependencies so tsup bundles them.');
process.exit(1);
}
console.log('dist/ externals verified: all imports are bundled or allowlisted.');
"