From 5e7cdc8783b663208d41f4ba06c089d3cb09bdb0 Mon Sep 17 00:00:00 2001 From: ajianaz Date: Thu, 16 Jul 2026 18:33:24 +0700 Subject: [PATCH 1/3] ci: add validation workflow (files, exports, CSS, JSON, TS) --- .github/workflows/ci.yml | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..85feea7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,73 @@ +name: CI + +on: + pull_request: + branches: [main] + push: + branches: [main] + +permissions: + contents: read + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + +jobs: + validate: + name: Validate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Check package.json exports + run: | + node -e " + const pkg = require('./package.json'); + const errors = []; + const files = pkg.files || []; + for (const f of files) { + if (!require('fs').existsSync(f)) errors.push('Missing file: ' + f); + } + if (errors.length) { console.error(errors.join('\n')); process.exit(1); } + console.log('Files check passed:', files.join(', ')); + " + + - name: Validate JSON (Shiki theme) + run: node -e "require('./catppuccin-mocha.json'); console.log('catppuccin-mocha.json: valid')" + + - name: Check CSS syntax + run: | + # Basic CSS validation — ensure no broken @import or obvious syntax errors + if grep -q '@import' tokens.css; then + echo "ERROR: tokens.css should not have @import (consumed directly)" + exit 1 + fi + echo "tokens.css: syntax OK" + + - name: Validate exports map + run: | + node -e " + const pkg = require('./package.json'); + const exp = pkg.exports || {}; + const fs = require('fs'); + for (const [key, val] of Object.entries(exp)) { + if (typeof val === 'string') { + if (!fs.existsSync(val)) { + console.error('Export ' + key + ' points to missing: ' + val); + process.exit(1); + } + } + } + console.log('Exports map valid, ' + Object.keys(exp).length + ' entries'); + " + + - name: TypeScript check (VitePress adapter) + run: | + npm install --save-dev typescript vitepress + npx tsc --noEmit --skipLibCheck vitepress/config.ts vitepress/index.ts 2>&1 || true + # Non-blocking: just report, don't fail (TS strictness varies by consumer) + echo "TypeScript check complete" From 99ba5594f81127ec33c386c86d80571c4acb085f Mon Sep 17 00:00:00 2001 From: ajianaz Date: Thu, 16 Jul 2026 19:07:51 +0700 Subject: [PATCH 2/3] fix: add compiled config.mjs for Node 24 type-stripping compat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Node 24 native type stripping does not support files under node_modules. The .ts config file has TypeScript annotations (interface, type, etc.) that fail at runtime. This .mjs file is the compiled JS equivalent — same logic, no type annotations. - Export ./vitepress/config → config.mjs (runtime) - Keep ./vitepress/config.ts for editors/type checking - No consumer changes needed — import path stays the same --- package.json | 3 +- vitepress/config.mjs | 67 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 vitepress/config.mjs diff --git a/package.json b/package.json index 36f3198..b8c428e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "./tokens.css": "./tokens.css", "./vitepress": "./vitepress/index.ts", "./vitepress/style.css": "./vitepress/style.css", - "./vitepress/config": "./vitepress/config.ts", + "./vitepress/config": "./vitepress/config.mjs", + "./vitepress/config.ts": "./vitepress/config.ts", "./shiki": "./catppuccin-mocha.json", "./catppuccin-mocha.json": "./catppuccin-mocha.json" }, diff --git a/vitepress/config.mjs b/vitepress/config.mjs new file mode 100644 index 0000000..ebc3ea7 --- /dev/null +++ b/vitepress/config.mjs @@ -0,0 +1,67 @@ +/** + * CodeCora VitePress config helper (compiled JS). + * + * Identical logic to config.ts but without TypeScript annotations, + * so Node.js 24 can import it from node_modules without type-stripping errors. + */ +import { defineConfig } from 'vitepress' +import mochaShiki from '../catppuccin-mocha.json' + +const ACCENT_VAR = { + green: 'var(--cc-green)', + mauve: 'var(--cc-mauve)', + blue: 'var(--cc-blue)', + red: 'var(--cc-red)', + peach: 'var(--cc-peach)', + teal: 'var(--cc-teal)', + yellow: 'var(--cc-yellow)', + lavender: 'var(--cc-lavender)', +} + +export function createConfig(opts) { + const repo = opts.repo ?? opts.product + const accent = opts.accent ?? 'green' + + return defineConfig({ + title: opts.title, + description: opts.description, + lang: 'en', + cleanUrls: true, + base: `/${opts.product}/docs/`, + head: [ + ['link', { rel: 'preconnect', href: 'https://fonts.googleapis.com' }], + ['link', { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: '' }], + [ + 'link', + { + rel: 'stylesheet', + href: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap' + } + ], + ['meta', { name: 'theme-color', content: '#1e1e2e' }], + [ + 'style', + {}, + `:root{--cc-accent:${ACCENT_VAR[accent]};}` + ] + ], + markdown: { + theme: { light: 'github-light', dark: mochaShiki }, + defaultHighlightOptions: { decodeNamedCharacterReference: true }, + lineNumbers: true + }, + themeConfig: { + logo: { src: '/logo.png', width: 24, height: 24, alt: 'CodeCora' }, + siteTitle: opts.title, + nav: opts.nav ?? [ + { text: 'codecora.dev', link: 'https://codecora.dev' }, + { text: 'GitHub', link: `https://github.com/codecoradev/${repo}` } + ], + sidebar: opts.sidebar, + socialLinks: [{ icon: 'github', link: `https://github.com/codecoradev/${repo}` }], + ...(opts.search === false ? {} : { search: { provider: 'local' } }) + } + }) +} + +export { ACCENT_VAR } From bbde4c21afd92f7410a21d4a4d8f45f70daddb03 Mon Sep 17 00:00:00 2001 From: ajianaz Date: Thu, 16 Jul 2026 19:17:55 +0700 Subject: [PATCH 3/3] fix: add JSON import assertion for Node 24 compat Node 24 requires for JSON imports in ESM. --- vitepress/config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vitepress/config.mjs b/vitepress/config.mjs index ebc3ea7..342991f 100644 --- a/vitepress/config.mjs +++ b/vitepress/config.mjs @@ -5,7 +5,7 @@ * so Node.js 24 can import it from node_modules without type-stripping errors. */ import { defineConfig } from 'vitepress' -import mochaShiki from '../catppuccin-mocha.json' +import mochaShiki from '../catppuccin-mocha.json' with { type: 'json' } const ACCENT_VAR = { green: 'var(--cc-green)',