diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 8bcef07..7df7a23 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -17,7 +17,6 @@ module.exports = { }, ], '@typescript-eslint/no-unused-vars': ['warn', { varsIgnorePatter: '^_' }], - 'no-unused-vars': ['warn', { varsIgnorePatter: '^_' }], 'testing-library/no-await-sync-events': 'off', 'jest-dom/prefer-in-document': 'off', '@typescript-eslint/no-duplicate-imports': 'warn', diff --git a/.gitignore b/.gitignore index cadc4a4..7d6eb17 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ node_modules -/build -/public/build -/public/images -/public/pdf -/server-build +/docs-build +/docs-public/build +/docs-public/images +/docs-public/pdf +/docs-server-build .env *.local.* @@ -14,4 +14,4 @@ node_modules documentation /scripts/crd-builder/specs -/public/documentation \ No newline at end of file +/docs-public/documentation \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 163340e..3532933 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,9 +2,9 @@ node_modules /content/**/*.mdx -/build -/public/build -/server-build +/docs-build +/docs-public/build +/docs-server-build .env /test-results/ diff --git a/app/utils/timing.server.ts b/app/utils/timing.server.ts deleted file mode 100644 index a122308..0000000 --- a/app/utils/timing.server.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { type CreateReporter } from 'cachified' - -export type Timings = Record< - string, - Array<{ desc?: string; type: string; time: number }> -> - -function createTimer(type: string, desc?: string) { - const start = performance.now() - return { - end(timings: Timings) { - let timingType = timings[type] - - if (!timingType) { - // eslint-disable-next-line no-multi-assign - timingType = timings[type] = [] - } - timingType.push({ desc, type, time: performance.now() - start }) - }, - } -} - -export async function time( - fn: Promise | (() => ReturnType | Promise), - { - type, - desc, - timings, - }: { - type: string - desc?: string - timings?: Timings - }, -): Promise { - const timer = createTimer(type, desc) - const promise = typeof fn === 'function' ? fn() : fn - if (!timings) return promise - - const result = await promise - - timer.end(timings) - return result -} - -export function getServerTimeHeader(timings: Timings) { - return Object.entries(timings) - .map(([key, timingInfos]) => { - const dur = timingInfos - .reduce((acc, timingInfo) => acc + timingInfo.time, 0) - .toFixed(1) - const desc = timingInfos - .map(t => t.desc) - .filter(Boolean) - .join(' & ') - return [ - key.replaceAll(/(:| |@|=|;|,)/g, '_'), - desc ? `desc=${JSON.stringify(desc)}` : null, - `dur=${dur}`, - ] - .filter(Boolean) - .join(';') - }) - .join(',') -} - -export function cachifiedTimingReporter( - timings?: Timings, -): undefined | CreateReporter { - if (!timings) return - - return ({ key }) => { - const cacheRetrievalTimer = createTimer( - `cache:${key}`, - `${key} cache retrieval`, - ) - let getFreshValueTimer: ReturnType | undefined - return event => { - switch (event.name) { - case 'getFreshValueStart': - getFreshValueTimer = createTimer( - `getFreshValue:${key}`, - `request forced to wait for a fresh ${key} value`, - ) - break - case 'getFreshValueSuccess': - getFreshValueTimer?.end(timings) - break - case 'done': - cacheRetrievalTimer.end(timings) - break - } - } - } -} diff --git a/index.js b/docs-index.js similarity index 71% rename from index.js rename to docs-index.js index 703c33c..686269b 100644 --- a/index.js +++ b/docs-index.js @@ -1,7 +1,7 @@ import 'dotenv/config' if (process.env.NODE_ENV === 'production') { - await import('./server-build/index.js') + await import('./docs-server-build/index.js') } else { await import('./server/index.ts') } diff --git a/public/favicon.ico b/docs-public/favicon.ico similarity index 100% rename from public/favicon.ico rename to docs-public/favicon.ico diff --git a/public/favicons/android-icon-144x144.png b/docs-public/favicons/android-icon-144x144.png similarity index 100% rename from public/favicons/android-icon-144x144.png rename to docs-public/favicons/android-icon-144x144.png diff --git a/public/favicons/android-icon-192x192.png b/docs-public/favicons/android-icon-192x192.png similarity index 100% rename from public/favicons/android-icon-192x192.png rename to docs-public/favicons/android-icon-192x192.png diff --git a/public/favicons/android-icon-36x36.png b/docs-public/favicons/android-icon-36x36.png similarity index 100% rename from public/favicons/android-icon-36x36.png rename to docs-public/favicons/android-icon-36x36.png diff --git a/public/favicons/android-icon-48x48.png b/docs-public/favicons/android-icon-48x48.png similarity index 100% rename from public/favicons/android-icon-48x48.png rename to docs-public/favicons/android-icon-48x48.png diff --git a/public/favicons/android-icon-72x72.png b/docs-public/favicons/android-icon-72x72.png similarity index 100% rename from public/favicons/android-icon-72x72.png rename to docs-public/favicons/android-icon-72x72.png diff --git a/public/favicons/android-icon-96x96.png b/docs-public/favicons/android-icon-96x96.png similarity index 100% rename from public/favicons/android-icon-96x96.png rename to docs-public/favicons/android-icon-96x96.png diff --git a/public/favicons/apple-icon-114x114.png b/docs-public/favicons/apple-icon-114x114.png similarity index 100% rename from public/favicons/apple-icon-114x114.png rename to docs-public/favicons/apple-icon-114x114.png diff --git a/public/favicons/apple-icon-120x120.png b/docs-public/favicons/apple-icon-120x120.png similarity index 100% rename from public/favicons/apple-icon-120x120.png rename to docs-public/favicons/apple-icon-120x120.png diff --git a/public/favicons/apple-icon-144x144.png b/docs-public/favicons/apple-icon-144x144.png similarity index 100% rename from public/favicons/apple-icon-144x144.png rename to docs-public/favicons/apple-icon-144x144.png diff --git a/public/favicons/apple-icon-152x152.png b/docs-public/favicons/apple-icon-152x152.png similarity index 100% rename from public/favicons/apple-icon-152x152.png rename to docs-public/favicons/apple-icon-152x152.png diff --git a/public/favicons/apple-icon-180x180.png b/docs-public/favicons/apple-icon-180x180.png similarity index 100% rename from public/favicons/apple-icon-180x180.png rename to docs-public/favicons/apple-icon-180x180.png diff --git a/public/favicons/apple-icon-57x57.png b/docs-public/favicons/apple-icon-57x57.png similarity index 100% rename from public/favicons/apple-icon-57x57.png rename to docs-public/favicons/apple-icon-57x57.png diff --git a/public/favicons/apple-icon-60x60.png b/docs-public/favicons/apple-icon-60x60.png similarity index 100% rename from public/favicons/apple-icon-60x60.png rename to docs-public/favicons/apple-icon-60x60.png diff --git a/public/favicons/apple-icon-72x72.png b/docs-public/favicons/apple-icon-72x72.png similarity index 100% rename from public/favicons/apple-icon-72x72.png rename to docs-public/favicons/apple-icon-72x72.png diff --git a/public/favicons/apple-icon-76x76.png b/docs-public/favicons/apple-icon-76x76.png similarity index 100% rename from public/favicons/apple-icon-76x76.png rename to docs-public/favicons/apple-icon-76x76.png diff --git a/public/favicons/apple-icon-precomposed.png b/docs-public/favicons/apple-icon-precomposed.png similarity index 100% rename from public/favicons/apple-icon-precomposed.png rename to docs-public/favicons/apple-icon-precomposed.png diff --git a/public/favicons/apple-icon.png b/docs-public/favicons/apple-icon.png similarity index 100% rename from public/favicons/apple-icon.png rename to docs-public/favicons/apple-icon.png diff --git a/public/favicons/favicon-16x16.png b/docs-public/favicons/favicon-16x16.png similarity index 100% rename from public/favicons/favicon-16x16.png rename to docs-public/favicons/favicon-16x16.png diff --git a/public/favicons/favicon-32x32.png b/docs-public/favicons/favicon-32x32.png similarity index 100% rename from public/favicons/favicon-32x32.png rename to docs-public/favicons/favicon-32x32.png diff --git a/public/favicons/favicon-96x96.png b/docs-public/favicons/favicon-96x96.png similarity index 100% rename from public/favicons/favicon-96x96.png rename to docs-public/favicons/favicon-96x96.png diff --git a/public/favicons/manifest.json b/docs-public/favicons/manifest.json similarity index 100% rename from public/favicons/manifest.json rename to docs-public/favicons/manifest.json diff --git a/public/favicons/ms-icon-144x144.png b/docs-public/favicons/ms-icon-144x144.png similarity index 100% rename from public/favicons/ms-icon-144x144.png rename to docs-public/favicons/ms-icon-144x144.png diff --git a/public/favicons/ms-icon-150x150.png b/docs-public/favicons/ms-icon-150x150.png similarity index 100% rename from public/favicons/ms-icon-150x150.png rename to docs-public/favicons/ms-icon-150x150.png diff --git a/public/favicons/ms-icon-310x310.png b/docs-public/favicons/ms-icon-310x310.png similarity index 100% rename from public/favicons/ms-icon-310x310.png rename to docs-public/favicons/ms-icon-310x310.png diff --git a/public/favicons/ms-icon-70x70.png b/docs-public/favicons/ms-icon-70x70.png similarity index 100% rename from public/favicons/ms-icon-70x70.png rename to docs-public/favicons/ms-icon-70x70.png diff --git a/public/logos/TRADEMARKS.md b/docs-public/logos/TRADEMARKS.md similarity index 100% rename from public/logos/TRADEMARKS.md rename to docs-public/logos/TRADEMARKS.md diff --git a/public/logos/pgo.png b/docs-public/logos/pgo.png similarity index 100% rename from public/logos/pgo.png rename to docs-public/logos/pgo.png diff --git a/public/logos/pgo.svg b/docs-public/logos/pgo.svg similarity index 100% rename from public/logos/pgo.svg rename to docs-public/logos/pgo.svg diff --git a/public/robots.txt b/docs-public/robots.txt similarity index 100% rename from public/robots.txt rename to docs-public/robots.txt diff --git a/public/sso.webm b/docs-public/sso.webm similarity index 100% rename from public/sso.webm rename to docs-public/sso.webm diff --git a/public/upgrade.webm b/docs-public/upgrade.webm similarity index 100% rename from public/upgrade.webm rename to docs-public/upgrade.webm diff --git a/package.json b/package.json index a774af9..0382f21 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ "build:server": "tsx ./scripts/build-server.ts", "dev": "run-p dev:*", "dev:remix": "remix dev -c \"npm run dev-server\" --no-restart", - "dev-server": "cross-env MOCKS=true tsx watch --clear-screen=false --ignore \"app/**\" --ignore \"build/**\" --ignore \"node_modules/**\" ./index.js", + "dev-server": "cross-env MOCKS=true tsx watch --clear-screen=false --ignore \"app/**\" --ignore \"docs-build/**\" --ignore \"node_modules/**\" ./index.js", "format": "prettier --write .", "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .", "lint:files": "ts-node --esm scripts/lint-file-case.ts", - "start": "cross-env NODE_ENV=production node .", + "start": "cross-env NODE_ENV=production node docs-index.js", "test": "vitest", "typecheck": "tsc", "validate": "run-p lint typecheck test", @@ -28,10 +28,10 @@ }, "eslintIgnore": [ "/node_modules", - "/build", - "/public/build", + "/docs-build", + "/docs-public/build", "/playwright-report", - "/server-build" + "/docs-server-build" ], "dependencies": { "@headlessui/react": "^1.7.14", diff --git a/remix.config.js b/remix.config.js index 0194a59..107cb21 100644 --- a/remix.config.js +++ b/remix.config.js @@ -3,6 +3,9 @@ */ export default { cacheDirectory: './node_modules/.cache/remix', + assetsBuildDirectory: 'docs-public/build', + serverBuildPath: 'docs-build/index.js', + publicPath: '/docs-public/build/', ignoredRouteFiles: ['**/.*', '**/.test.{js,jsx,ts,tsx}'], serverModuleFormat: 'esm', serverPlatform: 'node', diff --git a/scripts/build-server.ts b/scripts/build-server.ts index ea74c41..bf33ccb 100644 --- a/scripts/build-server.ts +++ b/scripts/build-server.ts @@ -19,7 +19,7 @@ for (const file of allFiles) { if (/\.(ts|js|tsx|jsx)$/.test(file)) { entries.push(file) } else { - const dest = file.replace(here('../server'), here('../server-build')) + const dest = file.replace(here('../server'), here('../docs-server-build')) fsExtra.ensureDirSync(path.parse(dest).dir) fsExtra.copySync(file, dest) console.log(`copied: ${file.replace(`${here('../server')}/`, '')}`) @@ -32,7 +32,7 @@ console.log('building...') esbuild .build({ entryPoints: glob.sync(globsafe(here('../server/**/*.+(ts|js|tsx|jsx)'))), - outdir: here('../server-build'), + outdir: here('../docs-server-build'), target: [`node${pkg.engines.node}`], platform: 'node', format: 'esm', diff --git a/server/index.ts b/server/index.ts index 06e74c3..0655e55 100644 --- a/server/index.ts +++ b/server/index.ts @@ -21,7 +21,7 @@ import { } from 'path-to-regexp' import { fileURLToPath, pathToFileURL } from 'url' -const BUILD_DIR = path.join(process.cwd(), 'build', 'index.js') +const BUILD_DIR = path.join(process.cwd(), 'docs-build', 'index.js') const BUILD_DIR_FILE_URL = pathToFileURL(BUILD_DIR).href const __dirname = path.dirname(fileURLToPath(import.meta.url)) @@ -38,13 +38,13 @@ app.disable('x-powered-by') // Remix fingerprints its assets so we can cache forever. app.use( - '/build', - express.static('public/build', { immutable: true, maxAge: '1y' }), + '/docs-public/build', + express.static('docs-public/build', { immutable: true, maxAge: '1y' }), ) // Everything else (like favicon.ico) is cached for an hour. You may want to be // more aggressive with this caching. -app.use(express.static('public', { maxAge: '1h' })) +app.use(express.static('docs-public', { maxAge: '1h' })) morgan.token('url', (req, res) => decodeURIComponent(req.url ?? '')) app.use(morgan('tiny'))