Skip to content

Commit 044dc32

Browse files
committed
chore: build website
1 parent 31f0f3b commit 044dc32

32 files changed

+2946
-908
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- uses: pnpm/action-setup@v4
26+
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
cache: pnpm
31+
32+
- run: pnpm install
33+
34+
- name: Build docs
35+
run: pnpm --filter @snapfill/website build
36+
37+
- uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: website/.vitepress/dist
40+
41+
deploy:
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
needs: build
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Deploy to GitHub Pages
49+
id: deployment
50+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ node_modules/
22
dist/
33
.turbo/
44
*.tsbuildinfo
5+
packages/core/src/injectable.gen.ts
56
.DS_Store
67
*.log
78
coverage/
9+
website/.vitepress/dist/
10+
website/.vitepress/cache/
811
.env
912
.env.*

packages/android/src/main/assets/snapfill-fill.js

Lines changed: 1 addition & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/android/src/main/assets/snapfill.js

Lines changed: 3 additions & 257 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
},
2121
"files": ["dist"],
2222
"scripts": {
23+
"prebuild": "node scripts/bundle-injectables.mjs",
2324
"build": "tsup",
2425
"test": "vitest run",
2526
"test:watch": "vitest",
2627
"lint": "eslint src/ --ext .ts",
27-
"clean": "rm -rf dist"
28+
"clean": "rm -rf dist src/injectable.gen.ts"
2829
},
2930
"devDependencies": {
31+
"esbuild": "^0.24.0",
3032
"jsdom": "^25.0.0",
3133
"tsup": "^8.3.0",
3234
"typescript": "^5.6.0",
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Bundles the injectable entry-point scripts into self-contained IIFE strings
5+
* and writes them to src/injectable.gen.ts.
6+
*
7+
* Run before the main tsup build: `node scripts/bundle-injectables.mjs`
8+
*/
9+
10+
import { buildSync } from 'esbuild';
11+
import { writeFileSync } from 'node:fs';
12+
import { dirname, join } from 'node:path';
13+
import { fileURLToPath } from 'node:url';
14+
15+
const __dirname = dirname(fileURLToPath(import.meta.url));
16+
const srcDir = join(__dirname, '..', 'src');
17+
const scriptsDir = join(srcDir, 'scripts');
18+
19+
function bundleEntry(entryFile) {
20+
const result = buildSync({
21+
entryPoints: [join(scriptsDir, entryFile)],
22+
bundle: true,
23+
format: 'iife',
24+
write: false,
25+
minify: true,
26+
target: 'es2020',
27+
platform: 'browser',
28+
});
29+
return result.outputFiles[0].text.trim();
30+
}
31+
32+
const formDetectorScript = bundleEntry('formDetector.entry.ts');
33+
const cartDetectorScript = bundleEntry('cartDetector.entry.ts');
34+
const valueCaptureScript = bundleEntry('valueCapture.entry.ts');
35+
const fillScriptTemplate = bundleEntry('fillForm.entry.ts');
36+
37+
const output = `// AUTO-GENERATED — do not edit manually.
38+
// Run \`node scripts/bundle-injectables.mjs\` to regenerate.
39+
40+
export const formDetectorScript = ${JSON.stringify(formDetectorScript)};
41+
42+
export const cartDetectorScript = ${JSON.stringify(cartDetectorScript)};
43+
44+
export const valueCaptureScript = ${JSON.stringify(valueCaptureScript)};
45+
46+
export const fillScriptTemplate = ${JSON.stringify(fillScriptTemplate)};
47+
`;
48+
49+
const outPath = join(srcDir, 'injectable.gen.ts');
50+
writeFileSync(outPath, output, 'utf-8');
51+
console.log(`Generated ${outPath}`);

0 commit comments

Comments
 (0)