From 99e1b27cb6aa639caa118d6afd206358ba06bc25 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 11 Oct 2026 14:17:39 +0000 Subject: [PATCH] Add GitHub CI and Pages so the converter publishes from the repo. The live Vercel preview already converts files; this wires GitHub Actions so typecheck/lint/unit tests run on PRs and a subdirectory GitHub Pages build can ship from main. Co-authored-by: Andromeda --- .github/workflows/ci.yml | 20 +++++++++++++++++ .github/workflows/pages.yml | 44 +++++++++++++++++++++++++++++++++++++ README.md | 10 ++++++++- tests/unit/registry.test.ts | 8 +++++++ vite.config.ts | 21 +++++++++++------- 5 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pages.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b93f3ba --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + - run: npm ci + - run: npm run typecheck + - run: npm run lint + - run: npm test diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..549e6df --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,44 @@ +name: GitHub Pages + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + env: + VITE_BASE: /convert-everything-studio/ + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + - run: npm ci + - run: npm run build + - run: cp dist/index.html dist/404.html + - uses: actions/configure-pages@v5 + - uses: actions/upload-pages-artifact@v3 + with: + path: dist + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index b85aac6..67ddd86 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ **Website:** https://convert-everything-preview.vercel.app +Same app, production Vercel hostname: https://convert-everything-one.vercel.app +Source: https://github.com/heyandromeda/convert-everything-studio +GitHub Pages (after this workflow runs on `main`): https://heyandromeda.github.io/convert-everything-studio/ + This is a website. Open that address in Safari, Chrome, or Firefox. There is no app to install and no App Store listing. On an iPhone, use Safari. Share → Add to Home Screen only saves a shortcut to this same website. It converts files in the browser tab. Images, documents, spreadsheets, data files, subtitles, archives, audio and video stay on the device and are converted with JavaScript and WebAssembly. Nothing is uploaded. @@ -235,7 +239,11 @@ LIVE_URL=https://convert-everything-preview.vercel.app npx playwright test live- - Root `vercel.json` (generated from `security-headers.mjs` by `node scripts/write-vercel-config.mjs`; a unit test keeps them in sync) for Git-based Vercel builds. - The CSP is also embedded as a `` tag, so it applies even on hosts that ignore header files. -**Vercel (current preview host):** `npm run deploy:preview` builds locally, uploads a preview deployment with the Vercel CLI (after `vercel login` and `vercel link`), and points the stable preview address at that deployment: https://convert-everything-preview.vercel.app. It does not publish a production release. The project has Vercel Authentication and the preview feedback toolbar turned off: the toolbar injects a third-party script, which the e2e cross-origin guard flags. +**Vercel:** `npm run deploy:preview` builds locally, uploads a preview deployment with the Vercel CLI (after `vercel login` and `vercel link`), and points the stable preview address at that deployment: https://convert-everything-preview.vercel.app. Production on this Vercel team is https://convert-everything-one.vercel.app (the shorter `convert-everything.vercel.app` name is already taken). The project has Vercel Authentication and the preview feedback toolbar turned off: the toolbar injects a third-party script, which the e2e cross-origin guard flags. + +**GitHub Pages:** `.github/workflows/pages.yml` builds with `VITE_BASE=/convert-everything-studio/` and publishes to https://heyandromeda.github.io/convert-everything-studio/ on pushes to `main`. GitHub does not send `dist/_headers`; the CSP meta tag still applies. + +**GitHub CI:** `.github/workflows/ci.yml` runs typecheck, lint, and unit tests on pull requests and on `main`. `netlify.toml` configures Git-based Netlify builds (`npm run build`, publish `dist`). No server-side code or functions exist in this project. diff --git a/tests/unit/registry.test.ts b/tests/unit/registry.test.ts index 9c4059b..9262107 100644 --- a/tests/unit/registry.test.ts +++ b/tests/unit/registry.test.ts @@ -131,4 +131,12 @@ describe('deployment config', () => { expect(csp).toContain("connect-src 'self' blob: data:") expect(csp).not.toMatch(/https?:/) }) + + it('Vite base comes from VITE_BASE so GitHub Pages can live under /convert-everything-studio/', async () => { + const { readFileSync } = await import('node:fs') + const src = readFileSync(new URL('../../vite.config.ts', import.meta.url), 'utf8') + expect(src).toContain("process.env.VITE_BASE") + expect(src).toContain('const base') + expect(src).toContain('withBase') + }) }) diff --git a/vite.config.ts b/vite.config.ts index 3287c02..3e11617 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,6 +5,10 @@ import { defineConfig, type Plugin } from 'vite' import { VitePWA } from 'vite-plugin-pwa' import { CSP, SECURITY_HEADERS, vercelConfig } from './security-headers.mjs' +/** Root-relative base. GitHub Pages uses `/convert-everything-studio/`; Vercel stays `/`. */ +const base = (process.env.VITE_BASE || '/').replace(/\/?$/, '/') +const withBase = (path: string) => `${base}${path.replace(/^\//, '')}` + /** Injects the CSP meta tag and writes host header files (Netlify `_headers`, `vercel.json`). */ function securityHeaders(): Plugin { return { @@ -23,6 +27,7 @@ function securityHeaders(): Plugin { } export default defineConfig({ + base, plugins: [ react(), tailwindcss(), @@ -38,12 +43,12 @@ export default defineConfig({ theme_color: '#ffffff', background_color: '#ffffff', display: 'standalone', - start_url: '/', - scope: '/', + start_url: withBase(''), + scope: withBase(''), icons: [ - { src: '/icons/icon-192.png', sizes: '192x192', type: 'image/png' }, - { src: '/icons/icon-512.png', sizes: '512x512', type: 'image/png' }, - { src: '/icons/icon-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' }, + { src: withBase('icons/icon-192.png'), sizes: '192x192', type: 'image/png' }, + { src: withBase('icons/icon-512.png'), sizes: '512x512', type: 'image/png' }, + { src: withBase('icons/icon-maskable-512.png'), sizes: '512x512', type: 'image/png', purpose: 'maskable' }, ], }, workbox: { @@ -58,16 +63,16 @@ export default defineConfig({ warnings: [], }), ], - navigateFallback: '/index.html', + navigateFallback: withBase('index.html'), runtimeCaching: [ { - urlPattern: ({ url }) => url.pathname.startsWith('/vendor/'), + urlPattern: ({ url }) => url.pathname.includes('/vendor/'), handler: 'CacheFirst', options: { cacheName: 'ce-engines', expiration: { maxEntries: 400 }, cacheableResponse: { statuses: [0, 200] } }, }, { // Hashed build assets that were too large to precache. - urlPattern: ({ url }) => url.pathname.startsWith('/assets/'), + urlPattern: ({ url }) => url.pathname.includes('/assets/'), handler: 'CacheFirst', options: { cacheName: 'ce-engines-assets', expiration: { maxEntries: 200 }, cacheableResponse: { statuses: [0, 200] } }, },