From 9eb436ba6c7947bf90387b00200b22bfe8e7d8b7 Mon Sep 17 00:00:00 2001 From: DanieCuevas <43822444+DanielCuevas1208@users.noreply.github.com> Date: Mon, 3 Aug 2026 07:45:19 -0700 Subject: [PATCH] feat: extend engineer profile --- .github/workflows/ci.yml | 5 +- .github/workflows/deploy.yml | 58 +++++ .github/workflows/refresh.yml | 2 +- .nvmrc | 2 +- CONTRIBUTING.md | 11 +- README.md | 68 ++++- engineer-profile.config.json | 4 + package-lock.json | 462 ++-------------------------------- package.json | 7 +- src/config/loader.ts | 42 +++- src/deploy/index.ts | 144 +++++++++++ src/index.ts | 44 +++- src/ingest/github.ts | 2 +- src/publish/site.ts | 41 ++- src/refresh/run.ts | 4 + src/theme/index.ts | 148 +++++++++++ src/types.ts | 15 ++ tests/config.test.ts | 46 ++++ tests/deploy.test.ts | 99 ++++++++ tests/refresh.test.ts | 23 +- tests/site.test.ts | 23 ++ tests/theme.test.ts | 43 ++++ vitest.config.mjs | 8 +- vitest.config.ts | 6 + 24 files changed, 812 insertions(+), 495 deletions(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 src/deploy/index.ts create mode 100644 src/theme/index.ts create mode 100644 tests/deploy.test.ts create mode 100644 tests/theme.test.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eae27d9..4dd660a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: "20" + node-version: "22" cache: npm - name: Install dependencies @@ -44,6 +44,9 @@ jobs: - name: Run fixture demo run: node dist/index.js demo + - name: Verify deployment metadata + run: node dist/index.js deploy --adapter netlify --output output/ + - name: Store demo output if: success() uses: actions/upload-artifact@v4 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..a91fa80 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,58 @@ +name: Deploy portfolio to GitHub Pages + +on: + schedule: + - cron: "23 5 * * 1" + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: engineer-profile-pages + cancel-in-progress: true + +jobs: + deploy: + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.pages.outputs.base_url }} + env: + GITHUB_TOKEN: ${{ github.token }} + steps: + - name: Check out source + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Install Chromium + run: npx playwright install chromium --with-deps + + - name: Refresh portfolio + run: npm run refresh -- --config engineer-profile.config.json + + - name: Stage deployment files + run: node dist/index.js deploy --output output/ + + - name: Configure GitHub Pages + id: pages + uses: actions/configure-pages@v5 + + - name: Upload site artifact + uses: actions/upload-pages-artifact@v3 + with: + path: output/ + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/refresh.yml b/.github/workflows/refresh.yml index 360cd31..cb2d121 100644 --- a/.github/workflows/refresh.yml +++ b/.github/workflows/refresh.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: "20" + node-version: "22" cache: npm - name: Install dependencies diff --git a/.nvmrc b/.nvmrc index 209e3ef..2bd5a0a 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20 +22 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7802f1c..e25a910 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ ## Local checks -Use Node.js 20 or newer. +Use Node.js 22 or newer. ```bash npm ci @@ -19,4 +19,11 @@ Do not add credentials, private repository data, or generated output. Explain the user value and the data path. List the checks that you ran. -Keep public claims tied to repository evidence. \ No newline at end of file +Keep public claims tied to repository evidence. + +## Release checklist + +Bump the version in `package.json`. +Run the demo to confirm the fixture pipeline. +Run all checks from the local checklist. +Update the roadmap in the README. diff --git a/README.md b/README.md index f1a2a81..ba2752c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ paths in SQLite. It publishes a static site from these records. - Refresh project cards from public GitHub repositories. - Build release notes from releases or conventional commits. - Capture repeatable project previews with Playwright. +- Choose a site theme from a checked-in token set. +- Write deployment metadata for common static hosts. - Hide projects and redact author emails before publication. - Run one configured refresh from a scheduled workflow. @@ -27,23 +29,27 @@ flowchart LR D --> L[Changelog] D --> P[Privacy] D --> S[Playwright] - L --> W[Publisher] + T[Theme] --> W[Publisher] + L --> W P --> W S --> W W --> O[Static output] + O --> A[Deploy adapter] ``` | Area | Responsibility | | --- | --- | -| `engineer-profile.config.json` | Store owner, presentation, refresh, paths, and privacy settings. | +| `engineer-profile.config.json` | Store owner, theme, presentation, refresh, deploy, and privacy settings. | | `src/config/` | Validate checked-in JSON and merge safe defaults. | -| `src/refresh/` | Coordinate ingest, best-effort capture, and static publishing. | +| `src/theme/` | Resolve site themes and render CSS tokens. | +| `src/refresh/` | Coordinate ingest, best-effort capture, publishing, and deployment files. | | `src/ingest/` | Fetch public GitHub data and map it to records. | | `src/db/` | Store projects, commits, changelogs, and audit events. | | `src/changelog/` | Prefer release notes and fall back to commit groups. | | `src/privacy/` | Hide projects and block sensitive commit messages. | | `src/preview/` | Capture fixed viewport screenshots with Playwright. | -| `src/publish/` | Render HTML, changelog files, and preview assets. | +| `src/publish/` | Render themed HTML, changelog files, and preview assets. | +| `src/deploy/` | Write metadata files for static hosts. | | `fixtures/` | Provide deterministic demo data and local preview pages. | The refresh command runs each stage in a fixed order. @@ -51,7 +57,7 @@ If a preview fails, the command reports the skip and keeps the rest of the snaps ## Setup -Use Node.js 20 or newer. +Use Node.js 22 or newer. ```bash npm ci @@ -68,7 +74,7 @@ Both directories are ignored by Git. ## Configuration `engineer-profile.config.json` is the checked-in source for scheduled refreshes. -It sets the GitHub owner, site presentation, repository limit, paths, and privacy controls. +It sets the GitHub owner, theme, site presentation, repository limit, deploy settings, and privacy controls. The loader accepts repository limits from 1 through 100. It rejects malformed values before network access. @@ -81,7 +87,7 @@ npm run refresh ``` The refresh command reads public repositories, captures previews, publishes HTML, -and reports skipped captures. +writes deploy metadata, and reports skipped captures. GitHub ingestion uses the public API. Set `GITHUB_TOKEN` for a higher rate limit. @@ -94,6 +100,37 @@ npm run refresh Do not put a token in repository files. Use `.env.example` as a variable reference. +### Themes + +Set `theme` in the configuration file. +Run `node dist/index.js theme` to list the built-in themes. + +| Theme | Color scheme | +| --- | --- | +| `dark` | Night field | +| `light` | Daylight | +| `paper` | Archive paper | + +The publisher renders the selected theme into the site. +Each theme defines a full token set for text, panels, accents, and shadows. + +### Deployment adapters + +Set `deploy.adapter` in the configuration file. +Run `node dist/index.js deploy --list` to list the built-in adapters. + +| Adapter | Writes | +| --- | --- | +| `gh-pages` | `.nojekyll`, optional `CNAME` | +| `vercel` | `vercel.json` with long cache headers | +| `netlify` | `netlify.toml` with long cache headers | +| `surge` | `CNAME` when a domain is set | +| `none` | No files | + +Set `deploy.domain` for adapters that need a custom domain. +The refresh command writes adapter files into the output directory. +A scheduled GitHub Pages workflow publishes the output. + ## Sample output The fixture set contains `signal-router` and `metrics-kit`. @@ -106,6 +143,7 @@ Captured demo-engineer-signal-router. Captured demo-engineer-metrics-kit. Published 2 projects to output/index.html. Copied 2 available preview screenshots. +Prepared deployment for gh-pages. Open output/index.html in a browser. ``` @@ -123,7 +161,10 @@ Build before direct CLI commands. | `npm run ingest -- --fixture` | Load fixture records only. | | `npm run capture -- --fixture` | Capture local fixture pages. | | `npm run publish` | Rebuild the site from SQLite. | -| `npm run refresh` | Run configured ingest, capture, and publish stages. | +| `npm run deploy` | Write metadata for the configured adapter. | +| `npm run refresh` | Run configured ingest, capture, publish, and deploy stages. | +| `node dist/index.js theme` | List available site themes. | +| `node dist/index.js deploy --list` | List available deployment adapters. | | `node dist/index.js status` | Show visibility and recent operations. | | `npm test` | Run deterministic unit and integration tests. | | `npm run typecheck` | Validate TypeScript types. | @@ -154,16 +195,21 @@ The site displays visible projects only. It links project cards to repositories. It links release notes to their release pages. It records local operations in an audit table. +It records deployment preparation with the adapter name. ## CI and test status The regular CI workflow runs typecheck, build, tests, the fixture demo, and artifact upload. +It also verifies deployment metadata generation. The scheduled refresh workflow runs each Monday and supports manual dispatch. It uploads the generated site as a workflow artifact. +The GitHub Pages workflow publishes the site on a schedule or on demand. The test suite covers these core behaviors: - Configuration validation and default merging. +- Theme resolution and deterministic CSS output. +- Deployment adapter file generation. - Conventional commit parsing. - Release-first changelog generation. - SQLite upserts and changelog replacement. @@ -196,8 +242,10 @@ The fixture pipeline provides deterministic data for repeatable checks. - Changelog quality depends on releases or conventional commits. - External pages can fail during capture. - Capture failures are reported and do not stop publishing. +- Deployment adapters write local files. They do not upload them. - Publishing creates local files. It does not deploy them. - Scheduled runs upload artifacts. They do not commit generated output. +- GitHub Pages publishing needs Pages enabled in repository settings. ## Roadmap @@ -205,8 +253,8 @@ The fixture pipeline provides deterministic data for repeatable checks. | --- | --- | --- | | v0.1 | Complete | Fixture demo, GitHub ingest, changelog, capture, publish, and privacy controls. | | v0.2 | Complete | Checked-in configuration, coordinated refresh command, and scheduled artifact workflow. | -| v0.3 | Next | Custom themes and deployment adapters. | -| v0.4 | Later | Commit-diff summaries and an RSS feed. | +| v0.3 | Complete | Custom themes, deployment adapters, and a GitHub Pages workflow. | +| v0.4 | Next | Commit-diff summaries and an RSS feed. | ## License diff --git a/engineer-profile.config.json b/engineer-profile.config.json index 81008fb..b752eda 100644 --- a/engineer-profile.config.json +++ b/engineer-profile.config.json @@ -2,9 +2,13 @@ "owner": "DanielCuevas1208", "title": "EngineerProfile", "tagline": "A living index of shipped systems, maintained from repository evidence", + "theme": "dark", "repositoryLimit": 5, "dataDir": "data", "outputDir": "output", + "deploy": { + "adapter": "gh-pages" + }, "privacy": { "hiddenProjects": [], "redactEmails": true, diff --git a/package-lock.json b/package-lock.json index 87f5d51..3b0753c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "engineer-profile", - "version": "0.2.0", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "engineer-profile", - "version": "0.2.0", + "version": "0.3.0", "license": "MIT", "dependencies": { - "better-sqlite3": "^11.8.1", + "better-sqlite3": "^13.0.2", "commander": "^15.0.0" }, "bin": { @@ -25,7 +25,7 @@ "vitest": "^3.0.5" }, "engines": { - "node": ">=20" + "node": ">=22" } }, "node_modules/@esbuild/aix-ppc64": { @@ -1353,79 +1353,16 @@ "node": ">=12" } }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/better-sqlite3": { - "version": "11.10.0", - "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.10.0.tgz", - "integrity": "sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==", - "hasInstallScript": true, + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-13.0.2.tgz", + "integrity": "sha512-jW6oufeDhXZaiX9Lw5A+oerVClx4iFrI6uDj1zu7SqUAjak9vbJvA0NEcKLNxHiQHb6kYCoFzzXYV0YOauhV3g==", "license": "MIT", "dependencies": { - "bindings": "^1.5.0", - "prebuild-install": "^7.1.1" - } - }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "license": "MIT", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, - "node_modules/bl": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "license": "MIT", - "dependencies": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } - }, - "node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" + "node-addon-api": "^8.0.0" + }, + "engines": { + "node": ">=22" } }, "node_modules/cac": { @@ -1465,12 +1402,6 @@ "node": ">= 16" } }, - "node_modules/chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", - "license": "ISC" - }, "node_modules/commander": { "version": "15.0.0", "resolved": "https://registry.npmjs.org/commander/-/commander-15.0.0.tgz", @@ -1498,21 +1429,6 @@ } } }, - "node_modules/decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "license": "MIT", - "dependencies": { - "mimic-response": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/deep-eql": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", @@ -1523,33 +1439,6 @@ "node": ">=6" } }, - "node_modules/deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "license": "MIT", - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/detect-libc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", - "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "license": "Apache-2.0", - "engines": { - "node": ">=8" - } - }, - "node_modules/end-of-stream": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", - "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", - "license": "MIT", - "dependencies": { - "once": "^1.4.0" - } - }, "node_modules/es-module-lexer": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", @@ -1609,15 +1498,6 @@ "@types/estree": "^1.0.0" } }, - "node_modules/expand-template": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", - "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", - "license": "(MIT OR WTFPL)", - "engines": { - "node": ">=6" - } - }, "node_modules/expect-type": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", @@ -1646,18 +1526,6 @@ } } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "license": "MIT" - }, - "node_modules/fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", - "license": "MIT" - }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -1673,44 +1541,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/github-from-package": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", - "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", - "license": "MIT" - }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "BSD-3-Clause" - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "license": "ISC" - }, - "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "license": "ISC" - }, "node_modules/js-tokens": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", @@ -1735,33 +1565,6 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, - "node_modules/mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "license": "MIT" - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -1788,31 +1591,13 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, - "node_modules/napi-build-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz", - "integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==", - "license": "MIT" - }, - "node_modules/node-abi": { - "version": "3.94.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.94.0.tgz", - "integrity": "sha512-W5ZNO5KRPB5TkYmGVD9F6YqhsglXJzE6etpbmT+f6EQElhiX/UTG551cnsRGvLG3fyZEg9HwaDmNmj5nwJ4z9g==", + "node_modules/node-addon-api": { + "version": "8.9.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.9.1.tgz", + "integrity": "sha512-4eUQWVPCUUUiBjLnHS3cXWeC6ryoPUc0U3rP7IuzapoGbzMqd/r6KKO0clr0b+snQhsrueFEhCZDdK+LK7hxKg==", "license": "MIT", - "dependencies": { - "semver": "^7.3.5" - }, "engines": { - "node": ">=10" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "license": "ISC", - "dependencies": { - "wrappy": "1" + "node": "^18 || ^20 || >= 21" } }, "node_modules/pathe": { @@ -1845,6 +1630,7 @@ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -1913,72 +1699,6 @@ "node": "^10 || ^12 || >=14" } }, - "node_modules/prebuild-install": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz", - "integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==", - "deprecated": "No longer maintained. Please contact the author of the relevant native addon; alternatives are available.", - "license": "MIT", - "dependencies": { - "detect-libc": "^2.0.0", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.3", - "mkdirp-classic": "^0.5.3", - "napi-build-utils": "^2.0.0", - "node-abi": "^3.3.0", - "pump": "^3.0.0", - "rc": "^1.2.7", - "simple-get": "^4.0.0", - "tar-fs": "^2.0.0", - "tunnel-agent": "^0.6.0" - }, - "bin": { - "prebuild-install": "bin.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/pump": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", - "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", - "license": "MIT", - "dependencies": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "node_modules/rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "license": "(BSD-2-Clause OR MIT OR Apache-2.0)", - "dependencies": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "bin": { - "rc": "cli.js" - } - }, - "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "license": "MIT", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/rollup": { "version": "4.62.3", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.3.tgz", @@ -2024,38 +1744,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -2063,51 +1751,6 @@ "dev": true, "license": "ISC" }, - "node_modules/simple-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", - "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/simple-get": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", - "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "decompress-response": "^6.0.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -2132,24 +1775,6 @@ "dev": true, "license": "MIT" }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/strip-literal": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", @@ -2163,34 +1788,6 @@ "url": "https://github.com/sponsors/antfu" } }, - "node_modules/tar-fs": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.5.tgz", - "integrity": "sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw==", - "license": "MIT", - "dependencies": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "node_modules/tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "license": "MIT", - "dependencies": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", @@ -2286,18 +1883,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "license": "Apache-2.0", - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, "node_modules/typescript": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", @@ -2340,18 +1925,13 @@ "dev": true, "license": "MIT" }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "license": "MIT" - }, "node_modules/vite": { "version": "7.3.6", "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.6.tgz", "integrity": "sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.27.0 || ^0.28.0", "fdir": "^6.5.0", @@ -2548,12 +2128,6 @@ "engines": { "node": ">=8" } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "license": "ISC" } } } diff --git a/package.json b/package.json index d36edbe..ce5bc49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "engineer-profile", - "version": "0.2.0", + "version": "0.3.0", "description": "Self-maintaining engineering portfolio from repository activity", "type": "module", "main": "dist/index.js", @@ -18,10 +18,11 @@ "ingest": "npm run build && node dist/index.js ingest", "publish": "npm run build && node dist/index.js publish", "capture": "npm run build && node dist/index.js capture", + "deploy": "npm run build && node dist/index.js deploy", "refresh": "npm run build && node dist/index.js refresh" }, "engines": { - "node": ">=20" + "node": ">=22" }, "keywords": [ "portfolio", @@ -40,7 +41,7 @@ }, "homepage": "https://github.com/DanielCuevas1208/engineer-profile#readme", "dependencies": { - "better-sqlite3": "^11.8.1", + "better-sqlite3": "^13.0.2", "commander": "^15.0.0" }, "devDependencies": { diff --git a/src/config/loader.ts b/src/config/loader.ts index 406896b..8a34321 100644 --- a/src/config/loader.ts +++ b/src/config/loader.ts @@ -1,7 +1,9 @@ import { readFileSync } from "node:fs"; -import type { PortfolioConfig, PrivacyConfig } from "../types.js"; -import { DEFAULT_CONFIG, DEFAULT_PRIVACY } from "../types.js"; +import type { DeployConfig, PortfolioConfig, PrivacyConfig } from "../types.js"; +import { DEFAULT_CONFIG, DEFAULT_DEPLOY, DEFAULT_PRIVACY, DEFAULT_THEME } from "../types.js"; import { mergePrivacy } from "../privacy/controls.js"; +import { listThemes } from "../theme/index.js"; +import { listDeployAdapters } from "../deploy/index.js"; export const DEFAULT_CONFIG_PATH = "engineer-profile.config.json"; @@ -56,6 +58,40 @@ function readPrivacy(source: ConfigValue): PrivacyConfig { }); } +function readTheme(source: ConfigValue): string { + if (!("theme" in source)) return DEFAULT_THEME; + const value = source.theme; + if (typeof value !== "string" || !listThemes().some((theme) => theme.name === value)) { + const names = listThemes().map((theme) => theme.name).join(", "); + throw new Error(`Configuration field "theme" must be one of: ${names}.`); + } + return value; +} + +function readDeploy(source: ConfigValue): DeployConfig { + if (!("deploy" in source)) return DEFAULT_DEPLOY; + if (!isConfigValue(source.deploy)) { + throw new Error('Configuration field "deploy" must be an object.'); + } + + const adapter = "adapter" in source.deploy ? source.deploy.adapter : DEFAULT_DEPLOY.adapter; + if (typeof adapter !== "string" || !listDeployAdapters().some((candidate) => candidate.name === adapter)) { + const names = listDeployAdapters().map((candidate) => candidate.name).join(", "); + throw new Error(`Configuration field "deploy.adapter" must be one of: ${names}.`); + } + + let domain: string | undefined; + if ("domain" in source.deploy) { + const value = source.deploy.domain; + if (typeof value !== "string" || value.trim() === "") { + throw new Error('Configuration field "deploy.domain" must be a non-empty string.'); + } + domain = value.trim(); + } + + return { adapter, domain }; +} + export function loadPortfolioConfig( path: string = DEFAULT_CONFIG_PATH, clock: () => string = DEFAULT_CONFIG.clock @@ -75,10 +111,12 @@ export function loadPortfolioConfig( owner: readString(parsed, "owner", DEFAULT_CONFIG.owner), title: readString(parsed, "title", DEFAULT_CONFIG.title), tagline: readString(parsed, "tagline", DEFAULT_CONFIG.tagline), + theme: readTheme(parsed), repositoryLimit: readLimit(parsed, "repositoryLimit", DEFAULT_CONFIG.repositoryLimit), dataDir: readString(parsed, "dataDir", DEFAULT_CONFIG.dataDir), outputDir: readString(parsed, "outputDir", DEFAULT_CONFIG.outputDir), privacy: readPrivacy(parsed), + deploy: readDeploy(parsed), clock, }; } diff --git a/src/deploy/index.ts b/src/deploy/index.ts new file mode 100644 index 0000000..16663ae --- /dev/null +++ b/src/deploy/index.ts @@ -0,0 +1,144 @@ +import { mkdirSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { openDatabase } from "../db/client.js"; +import type { PortfolioConfig } from "../types.js"; + +export interface DeployFile { + path: string; + content: string; +} + +export interface DeployAdapter { + name: string; + label: string; + files: (domain: string | undefined) => DeployFile[]; +} + +export interface DeployResult { + adapter: string; + domain?: string; + files: string[]; +} + +const GITHUB_PAGES: DeployAdapter = { + name: "gh-pages", + label: "GitHub Pages", + files: (domain) => { + const files: DeployFile[] = [{ path: ".nojekyll", content: "" }]; + if (domain) files.push({ path: "CNAME", content: `${domain}\n` }); + return files; + }, +}; + +const VERCEL: DeployAdapter = { + name: "vercel", + label: "Vercel", + files: () => [ + { + path: "vercel.json", + content: `${JSON.stringify( + { + cleanUrls: true, + headers: [ + { + source: "/assets/screenshots/(.*)", + headers: [ + { + key: "Cache-Control", + value: "public, max-age=31536000, immutable", + }, + ], + }, + ], + }, + null, + 2 + )}\n`, + }, + ], +}; + +const NETLIFY: DeployAdapter = { + name: "netlify", + label: "Netlify", + files: () => [ + { + path: "netlify.toml", + content: `[build] +publish = "." + +[[headers]] + for = "/assets/screenshots/*" + [headers.values] + Cache-Control = "public, max-age=31536000, immutable" +`, + }, + ], +}; + +const SURGE: DeployAdapter = { + name: "surge", + label: "Surge", + files: (domain) => { + if (!domain) return []; + return [{ path: "CNAME", content: `${domain}\n` }]; + }, +}; + +const NONE: DeployAdapter = { + name: "none", + label: "Local files only", + files: () => [], +}; + +export const DEPLOY_ADAPTERS: DeployAdapter[] = [ + GITHUB_PAGES, + VERCEL, + NETLIFY, + SURGE, + NONE, +]; + +export function listDeployAdapters(): DeployAdapter[] { + return DEPLOY_ADAPTERS.map((adapter) => ({ ...adapter, files: adapter.files })); +} + +export function resolveAdapter(name: string): DeployAdapter { + const adapter = DEPLOY_ADAPTERS.find((candidate) => candidate.name === name); + if (!adapter) { + const names = DEPLOY_ADAPTERS.map((candidate) => candidate.name).join(", "); + throw new Error(`Unknown deployment adapter "${name}". Available adapters: ${names}.`); + } + return adapter; +} + +export function applyDeployAdapter( + config: PortfolioConfig, + adapterOverride?: string, + domainOverride?: string +): DeployResult { + const adapterName = adapterOverride ?? config.deploy.adapter; + const domain = domainOverride ?? config.deploy.domain; + const adapter = resolveAdapter(adapterName); + const files = adapter.files(domain); + + mkdirSync(config.outputDir, { recursive: true }); + for (const file of files) { + writeFileSync(join(config.outputDir, file.path), file.content, "utf-8"); + } + + if (adapterName !== "none") { + const db = openDatabase(config.dataDir, config.clock); + try { + db.logIngest("deploy", `${adapterName}${domain ? ` -> ${domain}` : ""}`); + } finally { + db.close(); + } + } + + return { + adapter: adapterName, + domain, + files: files.map((file) => file.path), + }; +} diff --git a/src/index.ts b/src/index.ts index aea5c27..ee290d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,8 @@ import { Command } from "commander"; import { ingestOwnerRepos, ingestRepository } from "./ingest/orchestrator.js"; import { captureAllProjects, captureLocalHtml, closeBrowser } from "./preview/capture.js"; import { copyScreenshotsToOutput, publishSite } from "./publish/site.js"; +import { applyDeployAdapter, listDeployAdapters } from "./deploy/index.js"; +import { listThemes } from "./theme/index.js"; import { loadAllFixtures } from "./fixtures/loader.js"; import { openDatabase } from "./db/client.js"; import { DEFAULT_CONFIG, type PortfolioConfig } from "./types.js"; @@ -16,7 +18,7 @@ const program = new Command(); program .name("engineer-profile") .description("Build a local engineering portfolio from public repository evidence") - .version("0.2.0"); + .version("0.3.0"); function resolveConfig(options: { config?: string; data?: string; output?: string }): PortfolioConfig { const base = options.config @@ -65,8 +67,10 @@ addConfigOption(program const result = publishSite(config); const copied = copyScreenshotsToOutput(config); + const deployment = applyDeployAdapter(config); console.log(`Published ${result.projectCount} projects to ${result.indexPath}.`); console.log(`Copied ${copied} available preview screenshots.`); + console.log(`Prepared deployment for ${deployment.adapter}${deployment.domain ? ` (${deployment.domain})` : ""}.`); console.log("Open output/index.html in a browser."); })); @@ -129,8 +133,10 @@ addConfigOption(program const config = resolveConfig(options); const result = publishSite(config); const copied = copyScreenshotsToOutput(config); + const deployment = applyDeployAdapter(config); console.log(`Published ${result.projectCount} projects to ${result.indexPath}.`); console.log(`Copied ${copied} available preview screenshots.`); + console.log(`Prepared deployment for ${deployment.adapter}${deployment.domain ? ` (${deployment.domain})` : ""}.`); })); addConfigOption(program @@ -146,6 +152,7 @@ addConfigOption(program console.log(`Captured ${result.captured} project previews.`); console.log(`Published ${result.published.projectCount} projects to ${result.published.indexPath}.`); console.log(`Copied ${result.copiedScreenshots} available preview screenshots.`); + console.log(`Prepared deployment for ${result.deployment.adapter}${result.deployment.domain ? ` (${result.deployment.domain})` : ""}.`); for (const error of result.captureErrors) { console.warn(`Skipped ${error.slug}: ${error.message}`); } @@ -200,4 +207,39 @@ addConfigOption(program } })); +program + .command("theme") + .description("List available site themes") + .action(() => { + for (const theme of listThemes()) { + console.log(`${theme.name} - ${theme.label} (${theme.colorScheme})`); + } + }); + +addConfigOption(program + .command("deploy") + .description("Write deployment metadata for the configured adapter") + .option("-a, --adapter ", "Deployment adapter name") + .option("--domain ", "Custom domain for the adapter") + .option("--list", "List available adapters") + .option("-d, --data ", "Data directory") + .option("-o, --output ", "Output directory") + .action((options) => { + if (options.list) { + for (const adapter of listDeployAdapters()) { + console.log(`${adapter.name} - ${adapter.label}`); + } + return; + } + const config = resolveConfig(options); + const result = applyDeployAdapter(config, options.adapter, options.domain); + console.log(`Prepared deployment for ${result.adapter}${result.domain ? ` (${result.domain})` : ""}.`); + if (result.files.length === 0) { + console.log("No metadata files were required."); + } + for (const file of result.files) { + console.log(` Wrote ${file}.`); + } + })); + await program.parseAsync(); diff --git a/src/ingest/github.ts b/src/ingest/github.ts index 6ed0fa7..4b1ee2d 100644 --- a/src/ingest/github.ts +++ b/src/ingest/github.ts @@ -15,7 +15,7 @@ export class GitHubClient { private headers(): Record { const headers: Record = { Accept: "application/vnd.github+json", - "User-Agent": "engineer-profile/0.1.0", + "User-Agent": "engineer-profile/0.3.0", }; if (this.token) headers.Authorization = `Bearer ${this.token}`; return headers; diff --git a/src/publish/site.ts b/src/publish/site.ts index d382163..e826fd8 100644 --- a/src/publish/site.ts +++ b/src/publish/site.ts @@ -2,6 +2,7 @@ import { cpSync, existsSync, mkdirSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { formatChangelogMarkdown } from "../changelog/generator.js"; import { openDatabase } from "../db/client.js"; +import { resolveTheme, themeRootCss, type SiteTheme } from "../theme/index.js"; import type { ChangelogEntry, PortfolioConfig, ProjectRecord } from "../types.js"; function escapeHtml(text: string): string { @@ -124,24 +125,9 @@ function projectCard( `; } -function siteCss(): string { +function siteCss(theme: SiteTheme): string { return ` -:root { - color-scheme: dark; - --ink: #08111f; - --ink-soft: #0d1a2d; - --panel: #112139; - --panel-strong: #172a46; - --line: rgba(169, 195, 222, 0.18); - --text: #f3f7fb; - --muted: #9db0c7; - --blue: #67b7ff; - --blue-soft: #b8dcff; - --mint: #a7f3d0; - --orange: #ffb86b; - --shadow: 0 24px 60px rgba(0, 0, 0, 0.24); - font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -} +${themeRootCss(theme)} * { box-sizing: border-box; } html { scroll-behavior: smooth; } body { margin: 0; min-width: 320px; background: var(--ink); color: var(--text); line-height: 1.5; } @@ -158,7 +144,7 @@ a { color: inherit; } .kicker { color: var(--mint); margin: 0 0 22px; } h1 { max-width: 760px; margin: 0; font-size: clamp(3.2rem, 8vw, 6.4rem); font-weight: 650; letter-spacing: -0.08em; line-height: 0.94; } .hero-copy { max-width: 530px; margin: 28px 0 0; color: var(--blue-soft); font-size: 1.12rem; } -.hero-aside { padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, rgba(23, 42, 70, 0.92), rgba(13, 26, 45, 0.72)); box-shadow: var(--shadow); } +.hero-aside { padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, var(--panel-from), var(--panel-to)); box-shadow: var(--shadow); } .aside-index { display: flex; justify-content: space-between; color: var(--orange); font: 0.68rem/1 "SFMono-Regular", Consolas, monospace; letter-spacing: 0.12em; text-transform: uppercase; } .hero-aside p { margin: 24px 0 4px; color: var(--text); font-size: 1rem; } .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); } @@ -166,19 +152,19 @@ h1 { max-width: 760px; margin: 0; font-size: clamp(3.2rem, 8vw, 6.4rem); font-we .stat:last-child { border-right: 0; } .stat strong { display: block; color: var(--text); font-size: 1.8rem; font-weight: 600; letter-spacing: -0.04em; } .stat span { color: var(--muted); font: 0.7rem/1.3 "SFMono-Regular", Consolas, monospace; letter-spacing: 0.08em; text-transform: uppercase; } -.audit-panel { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; margin: 26px 0 80px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 10px; background: rgba(17, 33, 57, 0.66); } +.audit-panel { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; margin: 26px 0 80px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--ink-soft); } .audit-copy { color: var(--muted); font-size: 0.88rem; } .audit-copy strong { color: var(--text); font-weight: 500; } .audit-time { color: var(--blue); font: 0.7rem/1.4 "SFMono-Regular", Consolas, monospace; text-align: right; } .index-header { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; } .index-header h2 { margin: 0; font-size: 2rem; font-weight: 550; letter-spacing: -0.05em; } .index-header p { max-width: 350px; margin: 0; color: var(--muted); font-size: 0.88rem; text-align: right; } -.project-card { display: grid; grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr); overflow: hidden; margin-bottom: 24px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(135deg, rgba(23, 42, 70, 0.98), rgba(13, 26, 45, 0.96)); box-shadow: var(--shadow); } -.project-visual { position: relative; min-height: 310px; background: #0a1525; } +.project-card { display: grid; grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr); overflow: hidden; margin-bottom: 24px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(135deg, var(--panel-from), var(--panel-to)); box-shadow: var(--shadow); } +.project-visual { position: relative; min-height: 310px; background: var(--visual); } .screenshot { display: block; width: 100%; height: 100%; min-height: 310px; object-fit: cover; opacity: 0.9; } -.placeholder { display: flex; min-height: 310px; align-items: center; justify-content: center; flex-direction: column; gap: 7px; color: var(--blue); background: repeating-linear-gradient(135deg, rgba(103, 183, 255, 0.05), rgba(103, 183, 255, 0.05) 1px, transparent 1px, transparent 14px); } +.placeholder { display: flex; min-height: 310px; align-items: center; justify-content: center; flex-direction: column; gap: 7px; color: var(--blue); background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--blue) 5%, transparent), color-mix(in srgb, var(--blue) 5%, transparent) 1px, transparent 1px, transparent 14px); } .placeholder small { color: var(--muted); font: 0.68rem/1 "SFMono-Regular", Consolas, monospace; text-transform: uppercase; } -.visual-label { position: absolute; right: 16px; bottom: 16px; padding: 7px 9px; border: 1px solid rgba(255,255,255,0.18); border-radius: 5px; background: rgba(8, 17, 31, 0.72); color: var(--blue-soft); } +.visual-label { position: absolute; right: 16px; bottom: 16px; padding: 7px 9px; border: 1px solid rgba(255,255,255,0.18); border-radius: 5px; background: var(--overlay); color: var(--blue-soft); } .project-body { padding: 30px 34px 32px; } .card-topline { display: flex; justify-content: space-between; gap: 12px; color: var(--blue); } .project-body h2 { margin: 18px 0 8px; font-size: 2.1rem; font-weight: 560; letter-spacing: -0.06em; } @@ -187,7 +173,7 @@ h1 { max-width: 760px; margin: 0; font-size: clamp(3.2rem, 8vw, 6.4rem); font-we .facts { display: flex; flex-wrap: wrap; gap: 22px; margin: 24px 0 16px; color: var(--muted); font: 0.76rem/1 "SFMono-Regular", Consolas, monospace; } .facts strong { color: var(--text); font-size: 1rem; font-weight: 600; } .tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 26px; } -.tag { padding: 5px 9px; border: 1px solid rgba(167, 243, 208, 0.26); border-radius: 999px; color: var(--mint); font: 0.68rem/1 "SFMono-Regular", Consolas, monospace; } +.tag { padding: 5px 9px; border: 1px solid color-mix(in srgb, var(--mint) 26%, transparent); border-radius: 999px; color: var(--mint); font: 0.68rem/1 "SFMono-Regular", Consolas, monospace; } .change-log { padding: 18px 0 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); } .section-heading { display: flex; justify-content: space-between; color: var(--orange); } .source-badge { color: var(--muted); } @@ -197,7 +183,7 @@ h1 { max-width: 760px; margin: 0; font-size: clamp(3.2rem, 8vw, 6.4rem); font-we .change-preview h3, .change-preview h4 { margin: 12px 0 4px; color: var(--text); font-size: 0.78rem; font-weight: 600; } .change-preview p { margin: 3px 0; } .change-preview li { margin: 3px 0 3px 18px; } -.change-preview code { padding: 2px 4px; border-radius: 3px; color: var(--mint); background: rgba(167, 243, 208, 0.08); font: 0.76rem "SFMono-Regular", Consolas, monospace; } +.change-preview code { padding: 2px 4px; border-radius: 3px; color: var(--mint); background: color-mix(in srgb, var(--mint) 8%, transparent); font: 0.76rem "SFMono-Regular", Consolas, monospace; } .text-link { display: inline-block; margin-top: 14px; color: var(--blue); font: 0.73rem/1 "SFMono-Regular", Consolas, monospace; text-decoration: none; text-transform: uppercase; } .card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; } .button { display: inline-block; padding: 10px 14px; border-radius: 7px; font: 0.72rem/1 "SFMono-Regular", Consolas, monospace; letter-spacing: 0.04em; text-decoration: none; text-transform: uppercase; } @@ -210,7 +196,7 @@ h1 { max-width: 760px; margin: 0; font-size: clamp(3.2rem, 8vw, 6.4rem); font-we .source-trail h2 { margin: 0 0 8px; font-size: 1.2rem; font-weight: 550; } .source-trail p { margin: 0; color: var(--muted); font-size: 0.86rem; } .audit-list { margin: 0; padding: 0; list-style: none; } -.audit-list li { display: grid; grid-template-columns: 150px 72px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(169, 195, 222, 0.1); color: var(--muted); font: 0.72rem/1.4 "SFMono-Regular", Consolas, monospace; } +.audit-list li { display: grid; grid-template-columns: 150px 72px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--muted); font: 0.72rem/1.4 "SFMono-Regular", Consolas, monospace; } .audit-list time { color: var(--blue); } .audit-list strong { color: var(--orange); font-weight: 500; text-transform: uppercase; } .site-footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font: 0.7rem/1.4 "SFMono-Regular", Consolas, monospace; } @@ -250,6 +236,7 @@ export function publishSite(config: PortfolioConfig): PublishResult { try { const projects = db.listProjects(true); const generatedAt = config.clock(); + const theme = resolveTheme(config.theme); const views = projects.map((project) => ({ project, changelog: db.getChangelog(project.id), @@ -279,7 +266,7 @@ export function publishSite(config: PortfolioConfig): PublishResult { ${escapeHtml(config.title)} / Portfolio - +
diff --git a/src/refresh/run.ts b/src/refresh/run.ts index acc9e53..55e27a4 100644 --- a/src/refresh/run.ts +++ b/src/refresh/run.ts @@ -1,6 +1,7 @@ import { ingestOwnerRepos } from "../ingest/orchestrator.js"; import { captureAllProjects } from "../preview/capture.js"; import { copyScreenshotsToOutput, publishSite, type PublishResult } from "../publish/site.js"; +import { applyDeployAdapter, type DeployResult } from "../deploy/index.js"; import type { FixtureData } from "../ingest/orchestrator.js"; import { DEFAULT_CONFIG, type PortfolioConfig } from "../types.js"; @@ -15,6 +16,7 @@ export interface RefreshResult { copiedScreenshots: number; captureErrors: Array<{ slug: string; message: string }>; published: PublishResult; + deployment: DeployResult; } export async function refreshPortfolio( @@ -36,6 +38,7 @@ export async function refreshPortfolio( (slug, error) => captureErrors.push({ slug, message: error.message }) ); const published = publishSite(config); + const deployment = applyDeployAdapter(config); return { ingested: ingested.length, @@ -43,5 +46,6 @@ export async function refreshPortfolio( copiedScreenshots: copyScreenshotsToOutput(config), captureErrors, published, + deployment, }; } diff --git a/src/theme/index.ts b/src/theme/index.ts new file mode 100644 index 0000000..8125a51 --- /dev/null +++ b/src/theme/index.ts @@ -0,0 +1,148 @@ +export interface ThemeTokens { + ink: string; + inkSoft: string; + panel: string; + panelStrong: string; + panelFrom: string; + panelTo: string; + visual: string; + overlay: string; + line: string; + text: string; + muted: string; + blue: string; + blueSoft: string; + mint: string; + orange: string; + shadow: string; +} + +export interface SiteTheme { + name: string; + label: string; + colorScheme: "dark" | "light"; + tokens: ThemeTokens; +} + +export const THEME_KEYS: Array = [ + "ink", + "inkSoft", + "panel", + "panelStrong", + "panelFrom", + "panelTo", + "visual", + "overlay", + "line", + "text", + "muted", + "blue", + "blueSoft", + "mint", + "orange", + "shadow", +]; + +const DARK: SiteTheme = { + name: "dark", + label: "Night field", + colorScheme: "dark", + tokens: { + ink: "#08111f", + inkSoft: "#0d1a2d", + panel: "#112139", + panelStrong: "#172a46", + panelFrom: "#172a46", + panelTo: "#0d1a2d", + visual: "#0a1525", + overlay: "rgba(8, 17, 31, 0.72)", + line: "rgba(169, 195, 222, 0.18)", + text: "#f3f7fb", + muted: "#9db0c7", + blue: "#67b7ff", + blueSoft: "#b8dcff", + mint: "#a7f3d0", + orange: "#ffb86b", + shadow: "0 24px 60px rgba(0, 0, 0, 0.24)", + }, +}; + +const LIGHT: SiteTheme = { + name: "light", + label: "Daylight", + colorScheme: "light", + tokens: { + ink: "#f4f7fb", + inkSoft: "#e9eef5", + panel: "#ffffff", + panelStrong: "#fbfdff", + panelFrom: "#ffffff", + panelTo: "#e9eef5", + visual: "#dde6f0", + overlay: "rgba(255, 255, 255, 0.86)", + line: "rgba(13, 26, 45, 0.14)", + text: "#101828", + muted: "#5b6b80", + blue: "#1d63d8", + blueSoft: "#2f6fe4", + mint: "#0e7a57", + orange: "#a34e0e", + shadow: "0 24px 60px rgba(16, 24, 40, 0.12)", + }, +}; + +const PAPER: SiteTheme = { + name: "paper", + label: "Archive paper", + colorScheme: "light", + tokens: { + ink: "#fbfaf6", + inkSoft: "#f1efe8", + panel: "#ffffff", + panelStrong: "#f7f5ef", + panelFrom: "#ffffff", + panelTo: "#f1efe8", + visual: "#eae5da", + overlay: "rgba(251, 250, 246, 0.9)", + line: "rgba(35, 31, 26, 0.18)", + text: "#231f19", + muted: "#6c6659", + blue: "#3f5d7d", + blueSoft: "#4a6b8c", + mint: "#5f6f3a", + orange: "#8a5a2b", + shadow: "0 24px 60px rgba(35, 31, 26, 0.14)", + }, +}; + +export const THEMES: SiteTheme[] = [DARK, LIGHT, PAPER]; + +function cloneTheme(theme: SiteTheme): SiteTheme { + return { ...theme, tokens: { ...theme.tokens } }; +} + +export function listThemes(): SiteTheme[] { + return THEMES.map(cloneTheme); +} + +export function resolveTheme(name: string): SiteTheme { + const theme = THEMES.find((candidate) => candidate.name === name); + if (!theme) { + const names = THEMES.map((candidate) => candidate.name).join(", "); + throw new Error(`Unknown theme "${name}". Available themes: ${names}.`); + } + return cloneTheme(theme); +} + +export function themeRootCss(theme: SiteTheme): string { + const lines = [ + ":root {", + ` color-scheme: ${theme.colorScheme};`, + ` font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;`, + ]; + for (const key of THEME_KEYS) { + lines.push(` --${key}: ${theme.tokens[key]};`); + } + lines.push("}"); + return lines.join("\n"); +} diff --git a/src/types.ts b/src/types.ts index 92c30da..e35c6ae 100644 --- a/src/types.ts +++ b/src/types.ts @@ -78,14 +78,21 @@ export interface PrivacyConfig { maxCommitsPerProject: number; } +export interface DeployConfig { + adapter: string; + domain?: string; +} + export interface PortfolioConfig { owner: string; title: string; tagline: string; + theme: string; repositoryLimit?: number; dataDir: string; outputDir: string; privacy: PrivacyConfig; + deploy: DeployConfig; clock: () => string; } @@ -95,13 +102,21 @@ export const DEFAULT_PRIVACY: PrivacyConfig = { maxCommitsPerProject: 50, }; +export const DEFAULT_THEME = "dark"; + +export const DEFAULT_DEPLOY: DeployConfig = { + adapter: "none", +}; + export const DEFAULT_CONFIG = { owner: "demo-engineer", title: "EngineerProfile", tagline: "A living index of shipped systems, maintained from repository evidence", + theme: DEFAULT_THEME, repositoryLimit: 5, dataDir: "data", outputDir: "output", privacy: DEFAULT_PRIVACY, + deploy: DEFAULT_DEPLOY, clock: () => new Date().toISOString(), } satisfies PortfolioConfig; diff --git a/tests/config.test.ts b/tests/config.test.ts index 44e2720..7a481f2 100644 --- a/tests/config.test.ts +++ b/tests/config.test.ts @@ -14,7 +14,9 @@ describe("portfolio configuration", () => { writeFileSync(TEST_FILE, JSON.stringify({ owner: "owner", title: "Evidence Index", + theme: "light", repositoryLimit: 3, + deploy: { adapter: "vercel" }, privacy: { hiddenProjects: ["owner-hidden"], redactEmails: false }, })); @@ -22,13 +24,26 @@ describe("portfolio configuration", () => { expect(config.owner).toBe("owner"); expect(config.title).toBe("Evidence Index"); + expect(config.theme).toBe("light"); expect(config.repositoryLimit).toBe(3); + expect(config.deploy.adapter).toBe("vercel"); + expect(config.deploy.domain).toBeUndefined(); expect(config.privacy.hiddenProjects).toEqual(["owner-hidden"]); expect(config.privacy.redactEmails).toBe(false); expect(config.privacy.maxCommitsPerProject).toBe(50); expect(config.clock()).toBe("2026-07-31T00:00:00.000Z"); }); + it("applies default theme and deployment settings", () => { + mkdirSync(TEST_DIR, { recursive: true }); + writeFileSync(TEST_FILE, JSON.stringify({ owner: "owner" })); + + const config = loadPortfolioConfig(TEST_FILE); + + expect(config.theme).toBe("dark"); + expect(config.deploy.adapter).toBe("none"); + }); + it("rejects invalid repository limits", () => { mkdirSync(TEST_DIR, { recursive: true }); writeFileSync(TEST_FILE, JSON.stringify({ repositoryLimit: 0 })); @@ -37,4 +52,35 @@ describe("portfolio configuration", () => { 'Configuration field "repositoryLimit" must be an integer from 1 to 100.' ); }); + + it("rejects unknown theme names", () => { + mkdirSync(TEST_DIR, { recursive: true }); + writeFileSync(TEST_FILE, JSON.stringify({ theme: "rainbow" })); + + expect(() => loadPortfolioConfig(TEST_FILE)).toThrow( + 'Configuration field "theme" must be one of:' + ); + }); + + it("rejects unknown deploy adapters", () => { + mkdirSync(TEST_DIR, { recursive: true }); + writeFileSync(TEST_FILE, JSON.stringify({ deploy: { adapter: "ftp" } })); + + expect(() => loadPortfolioConfig(TEST_FILE)).toThrow( + 'Configuration field "deploy.adapter" must be one of:' + ); + }); + + it("accepts a deploy domain and rejects empty domains", () => { + mkdirSync(TEST_DIR, { recursive: true }); + writeFileSync(TEST_FILE, JSON.stringify({ + deploy: { adapter: "gh-pages", domain: "docs.example.dev" }, + })); + expect(loadPortfolioConfig(TEST_FILE).deploy.domain).toBe("docs.example.dev"); + + writeFileSync(TEST_FILE, JSON.stringify({ deploy: { adapter: "gh-pages", domain: " " } })); + expect(() => loadPortfolioConfig(TEST_FILE)).toThrow( + 'Configuration field "deploy.domain" must be a non-empty string.' + ); + }); }); diff --git a/tests/deploy.test.ts b/tests/deploy.test.ts new file mode 100644 index 0000000..966a2c5 --- /dev/null +++ b/tests/deploy.test.ts @@ -0,0 +1,99 @@ +import { afterEach, describe, expect, it } from "vitest"; +import { existsSync, readFileSync, rmSync } from "node:fs"; +import { join } from "node:path"; +import { + applyDeployAdapter, + listDeployAdapters, + resolveAdapter, +} from "../src/deploy/index.js"; +import { openDatabase } from "../src/db/client.js"; +import { DEFAULT_CONFIG } from "../src/types.js"; + +const TEST_DATA = join("data", "test-deploy"); +const TEST_OUTPUT = join("output", "test-deploy"); + +function deployConfig(outputDir: string) { + return { ...DEFAULT_CONFIG, dataDir: TEST_DATA, outputDir }; +} + +afterEach(() => { + rmSync(TEST_DATA, { recursive: true, force: true }); + rmSync(TEST_OUTPUT, { recursive: true, force: true }); +}); + +describe("deployment adapters", () => { + it("registers the built-in adapters", () => { + expect(listDeployAdapters().map((adapter) => adapter.name)).toEqual([ + "gh-pages", + "vercel", + "netlify", + "surge", + "none", + ]); + }); + + it("writes nojekyll and CNAME for GitHub Pages with a domain", () => { + const result = applyDeployAdapter( + { ...deployConfig(TEST_OUTPUT), deploy: { adapter: "gh-pages", domain: "example.dev" } } + ); + expect(result.files).toEqual([".nojekyll", "CNAME"]); + expect(existsSync(join(TEST_OUTPUT, ".nojekyll"))).toBe(true); + expect(readFileSync(join(TEST_OUTPUT, "CNAME"), "utf-8").trim()).toBe("example.dev"); + }); + + it("writes only nojekyll for GitHub Pages without a domain", () => { + const result = applyDeployAdapter( + { ...deployConfig(TEST_OUTPUT), deploy: { adapter: "gh-pages" } } + ); + expect(result.files).toEqual([".nojekyll"]); + expect(existsSync(join(TEST_OUTPUT, "CNAME"))).toBe(false); + }); + + it("writes a caching config for Vercel", () => { + applyDeployAdapter({ ...deployConfig(TEST_OUTPUT), deploy: { adapter: "vercel" } }); + const vercel = JSON.parse(readFileSync(join(TEST_OUTPUT, "vercel.json"), "utf-8")) as { + cleanUrls: boolean; + headers: Array<{ source: string }>; + }; + expect(vercel.cleanUrls).toBe(true); + expect(vercel.headers[0].source).toBe("/assets/screenshots/(.*)"); + }); + + it("writes cache headers for Netlify", () => { + applyDeployAdapter({ ...deployConfig(TEST_OUTPUT), deploy: { adapter: "netlify" } }); + const toml = readFileSync(join(TEST_OUTPUT, "netlify.toml"), "utf-8"); + expect(toml).toContain("[build]"); + expect(toml).toContain("max-age=31536000"); + }); + + it("requires a domain for Surge", () => { + const result = applyDeployAdapter( + { ...deployConfig(TEST_OUTPUT), deploy: { adapter: "surge", domain: "site.surge.sh" } } + ); + expect(result.files).toEqual(["CNAME"]); + expect(readFileSync(join(TEST_OUTPUT, "CNAME"), "utf-8").trim()).toBe("site.surge.sh"); + }); + + it("writes nothing for the local-only adapter", () => { + const result = applyDeployAdapter({ ...deployConfig(TEST_OUTPUT), deploy: { adapter: "none" } }); + expect(result.files).toEqual([]); + expect(existsSync(join(TEST_OUTPUT, ".nojekyll"))).toBe(false); + expect(existsSync(join(TEST_OUTPUT, "CNAME"))).toBe(false); + }); + + it("rejects unknown adapters", () => { + expect(() => resolveAdapter("unknown")).toThrow(/Unknown deployment adapter "unknown"/); + expect(() => applyDeployAdapter({ ...deployConfig(TEST_OUTPUT), deploy: { adapter: "unknown" } })) + .toThrow(/Unknown deployment adapter "unknown"/); + }); + + it("records the deployment in the audit log", () => { + applyDeployAdapter( + { ...deployConfig(TEST_OUTPUT), deploy: { adapter: "vercel" } } + ); + const db = openDatabase(TEST_DATA); + const log = db.getIngestLog(5); + db.close(); + expect(log.some((entry) => entry.action === "deploy" && entry.detail === "vercel")).toBe(true); + }); +}); diff --git a/tests/refresh.test.ts b/tests/refresh.test.ts index d119d9b..eecdbee 100644 --- a/tests/refresh.test.ts +++ b/tests/refresh.test.ts @@ -1,5 +1,5 @@ import { afterEach, describe, expect, it } from "vitest"; -import { existsSync, rmSync } from "node:fs"; +import { existsSync, readFileSync, rmSync } from "node:fs"; import { join } from "node:path"; import { loadAllFixtures } from "../src/fixtures/loader.js"; import { refreshPortfolio } from "../src/refresh/run.js"; @@ -33,6 +33,27 @@ describe("configured refresh", () => { expect(result.captureErrors).toEqual([]); expect(result.published.projectCount).toBe(2); expect(result.copiedScreenshots).toBe(0); + expect(result.deployment.adapter).toBe("none"); expect(existsSync(join(TEST_OUTPUT, "index.html"))).toBe(true); }); + + it("writes deployment metadata for a configured adapter", async () => { + const config = { + ...DEFAULT_CONFIG, + dataDir: TEST_DATA, + outputDir: TEST_OUTPUT, + repositoryLimit: 2, + deploy: { adapter: "gh-pages", domain: "docs.example.dev" }, + clock: () => "2026-07-31T00:00:00.000Z", + }; + + const result = await refreshPortfolio(config, { + fixtureRepos: loadAllFixtures(), + capture: false, + }); + + expect(result.deployment.adapter).toBe("gh-pages"); + expect(existsSync(join(TEST_OUTPUT, ".nojekyll"))).toBe(true); + expect(readFileSync(join(TEST_OUTPUT, "CNAME"), "utf-8").trim()).toBe("docs.example.dev"); + }); }); diff --git a/tests/site.test.ts b/tests/site.test.ts index 03061cf..6be2b09 100644 --- a/tests/site.test.ts +++ b/tests/site.test.ts @@ -87,6 +87,29 @@ describe("database and publish pipeline", () => { expect(html).toContain("total stars"); }); + it("renders the configured theme into the published page", async () => { + const config = { + ...DEFAULT_CONFIG, + dataDir: TEST_DATA, + outputDir: TEST_OUTPUT, + theme: "light", + }; + await ingestRepository( + config, + { owner: "demo-engineer", repo: "signal-router" }, + { + repo: loadFixtureRepo("signal-router"), + commits: loadFixtureCommits("signal-router"), + releases: loadFixtureReleases("signal-router"), + } + ); + + publishSite(config); + const html = readFileSync(join(TEST_OUTPUT, "index.html"), "utf-8"); + expect(html).toContain("color-scheme: light"); + expect(html).not.toContain("color-scheme: dark"); + }); + it("respects visibility when publishing", async () => { const config = { ...DEFAULT_CONFIG, dataDir: TEST_DATA, outputDir: TEST_OUTPUT }; await ingestRepository( diff --git a/tests/theme.test.ts b/tests/theme.test.ts new file mode 100644 index 0000000..ceb23cd --- /dev/null +++ b/tests/theme.test.ts @@ -0,0 +1,43 @@ +import { describe, expect, it } from "vitest"; +import { resolveTheme, listThemes, themeRootCss, THEME_KEYS } from "../src/theme/index.js"; + +describe("site themes", () => { + it("resolves the default theme by name", () => { + const theme = resolveTheme("dark"); + expect(theme.name).toBe("dark"); + expect(theme.colorScheme).toBe("dark"); + expect(theme.tokens.ink).toBe("#08111f"); + expect(theme.tokens.text).toBe("#f3f7fb"); + }); + + it("exposes distinct light and dark themes", () => { + const themes = listThemes(); + expect(themes.map((theme) => theme.name)).toEqual(["dark", "light", "paper"]); + const colorSchemes = new Set(themes.map((theme) => theme.colorScheme)); + expect(colorSchemes.has("dark")).toBe(true); + expect(colorSchemes.has("light")).toBe(true); + }); + + it("covers every token in the CSS variable output", () => { + const css = themeRootCss(resolveTheme("light")); + expect(css).toContain("color-scheme: light"); + for (const key of THEME_KEYS) { + expect(css).toContain(`--${key}:`); + } + }); + + it("keeps theme CSS deterministic", () => { + expect(themeRootCss(resolveTheme("paper"))).toBe(themeRootCss(resolveTheme("paper"))); + }); + + it("returns an independent copy of each theme", () => { + const first = resolveTheme("dark"); + const second = resolveTheme("dark"); + first.tokens.ink = "#000000"; + expect(second.tokens.ink).toBe("#08111f"); + }); + + it("rejects unknown theme names", () => { + expect(() => resolveTheme("mystery")).toThrow(/Unknown theme "mystery"/); + }); +}); diff --git a/vitest.config.mjs b/vitest.config.mjs index b699bb5..e495e59 100644 --- a/vitest.config.mjs +++ b/vitest.config.mjs @@ -4,5 +4,11 @@ export default { environment: "node", include: ["tests/**/*.test.ts"], testTimeout: 30000, + pool: "forks", + poolOptions: { + forks: { + singleFork: true, + }, + }, }, -}; \ No newline at end of file +}; diff --git a/vitest.config.ts b/vitest.config.ts index 66e7fb6..6ef0fc1 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -6,5 +6,11 @@ export default defineConfig({ environment: "node", include: ["tests/**/*.test.ts"], testTimeout: 30000, + pool: "forks", + poolOptions: { + forks: { + singleFork: true, + }, + }, }, });