diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d417ce8d5..f221d8c4c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -375,6 +375,7 @@ importers: '@next/eslint-plugin-next': ^12.2.5 '@next/mdx': ^11.0.0 '@svgr/webpack': ^6.3.1 + '@swc/core': ^1.3.35 '@testing-library/dom': ^7.31.2 '@testing-library/jest-dom': ^5.16.5 '@testing-library/react': ^11.2.7 @@ -400,6 +401,7 @@ importers: lucide-react: ^0.94.0 next: '12' next-mdx-remote: ^3.0.2 + node-fetch: '2' prettier: ^2.3.2 prism-react-renderer: ^1.2.1 react: 17.0.2 @@ -437,6 +439,7 @@ importers: svgson: 5.2.1 devDependencies: '@next/eslint-plugin-next': 12.2.5 + '@swc/core': 1.3.35 '@testing-library/dom': 7.31.2 '@testing-library/jest-dom': 5.16.5 '@testing-library/react': 11.2.7_sfoxds7t5ydpegc3knd667wn6m @@ -452,9 +455,10 @@ importers: eslint: 8.22.0 eslint-config-prettier: 8.5.0_eslint@8.22.0 jest: 26.6.3_ts-node@10.9.1 + node-fetch: 2.6.7 prettier: 2.7.1 react-test-renderer: 17.0.2_react@17.0.2 - ts-node: 10.9.1_gqqbkana4qauswgj6o2wzoub7a + ts-node: 10.9.1_iuagarv54md6u2z4nbxsm6bl6u tslib: 2.4.0 typescript: 4.8.4 @@ -9112,6 +9116,113 @@ packages: - supports-color dev: false + /@swc/core-darwin-arm64/1.3.35: + resolution: {integrity: sha512-zQUFkHx4gZpu0uo2IspvPnKsz8bsdXd5bC33xwjtoAI1cpLerDyqo4v2zIahEp+FdKZjyVsLHtfJiQiA1Qka3A==} + engines: {node: '>=10'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@swc/core-darwin-x64/1.3.35: + resolution: {integrity: sha512-oOSkSGWtALovaw22lNevKD434OQTPf8X+dVPvPMrJXJpJ34dWDlFWpLntoc+arvKLNZ7LQmTuk8rR1hkrAY7cw==} + engines: {node: '>=10'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@swc/core-linux-arm-gnueabihf/1.3.35: + resolution: {integrity: sha512-Yie8k00O6O8BCATS/xeKStquV4OYSskUGRDXBQVDw1FrE23PHaSeHCgg4q6iNZjJzXCOJbaTCKnYoIDn9DMf7A==} + engines: {node: '>=10'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@swc/core-linux-arm64-gnu/1.3.35: + resolution: {integrity: sha512-Zlv3WHa/4x2p51HSvjUWXHfSe1Gl2prqImUZJc8NZOlj75BFzVuR0auhQ+LbwvIQ3gaA1LODX9lyS9wXL3yjxA==} + engines: {node: '>=10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@swc/core-linux-arm64-musl/1.3.35: + resolution: {integrity: sha512-u6tCYsrSyZ8U+4jLMA/O82veBfLy2aUpn51WxQaeH7wqZGy9TGSJXoO8vWxARQ6b72vjsnKDJHP4MD8hFwcctg==} + engines: {node: '>=10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@swc/core-linux-x64-gnu/1.3.35: + resolution: {integrity: sha512-Dtxf2IbeH7XlNhP1Qt2/MvUPkpEbn7hhGfpSRs4ot8D3Vf5QEX4S/QtC1OsFWuciiYgHAT1Ybjt4xZic9DSkmA==} + engines: {node: '>=10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@swc/core-linux-x64-musl/1.3.35: + resolution: {integrity: sha512-4XavNJ60GprjpTiESCu5daJUnmErixPAqDitJSMu4TV32LNIE8G00S9pDLXinDTW1rgcGtQdq1NLkNRmwwovtg==} + engines: {node: '>=10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@swc/core-win32-arm64-msvc/1.3.35: + resolution: {integrity: sha512-dNGfKCUSX2M4qVyaS80Lyos0FkXyHRCvrdQ2Y4Hrg3FVokiuw3yY6fLohpUfQ5ws3n2A39dh7jGDeh34+l0sGA==} + engines: {node: '>=10'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@swc/core-win32-ia32-msvc/1.3.35: + resolution: {integrity: sha512-ChuPSrDR+JBf7S7dEKPicnG8A3bM0uWPsW2vG+V2wH4iNfNxKVemESHosmYVeEZXqMpomNMvLyeHep1rjRsc0Q==} + engines: {node: '>=10'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@swc/core-win32-x64-msvc/1.3.35: + resolution: {integrity: sha512-/RvphT4WfuGfIK84Ha0dovdPrKB1bW/mc+dtdmhv2E3EGkNc5FoueNwYmXWRimxnU7X0X7IkcRhyKB4G5DeAmg==} + engines: {node: '>=10'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@swc/core/1.3.35: + resolution: {integrity: sha512-KmiBin0XSVzJhzX19zTiCqmLslZ40Cl7zqskJcTDeIrRhfgKdiAsxzYUanJgMJIRjYtl9Kcg1V/Ip2o2wL8v3w==} + engines: {node: '>=10'} + requiresBuild: true + optionalDependencies: + '@swc/core-darwin-arm64': 1.3.35 + '@swc/core-darwin-x64': 1.3.35 + '@swc/core-linux-arm-gnueabihf': 1.3.35 + '@swc/core-linux-arm64-gnu': 1.3.35 + '@swc/core-linux-arm64-musl': 1.3.35 + '@swc/core-linux-x64-gnu': 1.3.35 + '@swc/core-linux-x64-musl': 1.3.35 + '@swc/core-win32-arm64-msvc': 1.3.35 + '@swc/core-win32-ia32-msvc': 1.3.35 + '@swc/core-win32-x64-msvc': 1.3.35 + dev: true + /@swc/helpers/0.4.3: resolution: {integrity: sha512-6JrF+fdUK2zbGpJIlN7G3v966PQjyx/dPt1T9km2wj+EUBqgrxCk3uX4Kct16MIm9gGxfKRcfax2hVf5jvlTzA==} dependencies: @@ -10700,7 +10811,7 @@ packages: loader-utils: 2.0.2 make-dir: 3.1.0 schema-utils: 2.7.1 - webpack: 5.74.0 + webpack: 5.74.0_@swc+core@1.3.35 dev: true /babel-loader/8.2.5_xc6oct4hcywdrbo4ned6ytbybm: @@ -16148,7 +16259,7 @@ packages: jest-validate: 26.6.2 micromatch: 4.0.5 pretty-format: 26.6.2 - ts-node: 10.9.1_gqqbkana4qauswgj6o2wzoub7a + ts-node: 10.9.1_iuagarv54md6u2z4nbxsm6bl6u transitivePeerDependencies: - bufferutil - canvas @@ -22222,6 +22333,31 @@ packages: supports-hyperlinks: 2.2.0 dev: true + /terser-webpack-plugin/5.3.5_oogp7xv4rppobi5ktio24rc7mq: + resolution: {integrity: sha512-AOEDLDxD2zylUGf/wxHxklEkOe2/r+seuyOWujejFrIxHf11brA1/dWQNIgXa1c6/Wkxgu7zvv0JhOWfc2ELEA==} + engines: {node: '>= 10.13.0'} + peerDependencies: + '@swc/core': '*' + esbuild: '*' + uglify-js: '*' + webpack: ^5.1.0 + peerDependenciesMeta: + '@swc/core': + optional: true + esbuild: + optional: true + uglify-js: + optional: true + dependencies: + '@jridgewell/trace-mapping': 0.3.15 + '@swc/core': 1.3.35 + jest-worker: 27.5.1 + schema-utils: 3.1.1 + serialize-javascript: 6.0.0 + terser: 5.16.1 + webpack: 5.74.0_@swc+core@1.3.35 + dev: true + /terser-webpack-plugin/5.3.5_webpack@5.74.0: resolution: {integrity: sha512-AOEDLDxD2zylUGf/wxHxklEkOe2/r+seuyOWujejFrIxHf11brA1/dWQNIgXa1c6/Wkxgu7zvv0JhOWfc2ELEA==} engines: {node: '>= 10.13.0'} @@ -22483,7 +22619,7 @@ packages: '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.3 '@types/node': 18.11.4 - acorn: 8.8.0 + acorn: 8.8.1 acorn-walk: 8.2.0 arg: 4.1.3 create-require: 1.1.1 @@ -22494,7 +22630,7 @@ packages: yn: 3.1.1 dev: true - /ts-node/10.9.1_gqqbkana4qauswgj6o2wzoub7a: + /ts-node/10.9.1_iuagarv54md6u2z4nbxsm6bl6u: resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -22509,6 +22645,7 @@ packages: optional: true dependencies: '@cspotcode/source-map-support': 0.8.1 + '@swc/core': 1.3.35 '@tsconfig/node10': 1.0.9 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 @@ -23650,6 +23787,46 @@ packages: - uglify-js dev: true + /webpack/5.74.0_@swc+core@1.3.35: + resolution: {integrity: sha512-A2InDwnhhGN4LYctJj6M1JEaGL7Luj6LOmyBHjcI8529cm5p6VXiTIW2sn6ffvEAKmveLzvu4jrihwXtPojlAA==} + engines: {node: '>=10.13.0'} + hasBin: true + peerDependencies: + webpack-cli: '*' + peerDependenciesMeta: + webpack-cli: + optional: true + dependencies: + '@types/eslint-scope': 3.7.4 + '@types/estree': 0.0.51 + '@webassemblyjs/ast': 1.11.1 + '@webassemblyjs/wasm-edit': 1.11.1 + '@webassemblyjs/wasm-parser': 1.11.1 + acorn: 8.8.1 + acorn-import-assertions: 1.8.0_acorn@8.8.1 + browserslist: 4.21.4 + chrome-trace-event: 1.0.3 + enhanced-resolve: 5.10.0 + es-module-lexer: 0.9.3 + eslint-scope: 5.1.1 + events: 3.3.0 + glob-to-regexp: 0.4.1 + graceful-fs: 4.2.10 + json-parse-even-better-errors: 2.3.1 + loader-runner: 4.3.0 + mime-types: 2.1.35 + neo-async: 2.6.2 + schema-utils: 3.1.1 + tapable: 2.2.1 + terser-webpack-plugin: 5.3.5_oogp7xv4rppobi5ktio24rc7mq + watchpack: 2.4.0 + webpack-sources: 3.2.3 + transitivePeerDependencies: + - '@swc/core' + - esbuild + - uglify-js + dev: true + /websocket-driver/0.7.4: resolution: {integrity: sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg==} engines: {node: '>=0.8.0'} diff --git a/site/.gitignore b/site/.gitignore index bb0662eb8..97d946250 100644 --- a/site/.gitignore +++ b/site/.gitignore @@ -1,2 +1,4 @@ .idea public/docs/images +.vercel +.env diff --git a/site/package.json b/site/package.json index f6d538e18..09fcc9089 100644 --- a/site/package.json +++ b/site/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "next dev", "copy-assets": "mkdir -p ./public/docs/images && cp -rf ../docs/images ./public/docs", - "prebuild": "ts-node scripts/preBuild.tsx", + "prebuild": "ts-node --swc scripts/preBuild.ts", "build": "pnpm copy-assets && pnpm prebuild && next build", "export": "next export -o build", "deploy": "pnpm build && pnpm export", @@ -42,6 +42,7 @@ }, "devDependencies": { "@next/eslint-plugin-next": "^12.2.5", + "@swc/core": "^1.3.35", "@testing-library/dom": "^7.31.2", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^11.2.7", @@ -57,6 +58,7 @@ "eslint": "^8.22.0", "eslint-config-prettier": "^8.5.0", "jest": "^26.5.2", + "node-fetch": "2", "prettier": "^2.3.2", "react-test-renderer": "17.0.2", "ts-node": "~10.9.1", diff --git a/site/scripts/preBuild.tsx b/site/scripts/preBuild.ts similarity index 100% rename from site/scripts/preBuild.tsx rename to site/scripts/preBuild.ts diff --git a/site/src/lib/fetchAllContributors.ts b/site/src/lib/fetchAllContributors.ts index b74faddf2..1c003354f 100644 --- a/site/src/lib/fetchAllContributors.ts +++ b/site/src/lib/fetchAllContributors.ts @@ -2,6 +2,7 @@ import crypto from 'crypto'; import fs from 'fs'; import path from 'path'; import { Contributor } from '../types'; +import fetch, { Headers } from 'node-fetch' const IGNORE_COMMIT_MESSAGES = ['fork', 'optimize']; diff --git a/site/src/lib/nextCache.tsx b/site/src/lib/nextCache.ts similarity index 83% rename from site/src/lib/nextCache.tsx rename to site/src/lib/nextCache.ts index 6429a7fca..484c104a3 100644 --- a/site/src/lib/nextCache.tsx +++ b/site/src/lib/nextCache.ts @@ -2,11 +2,20 @@ import path from 'path'; import fs from 'fs'; const cacheDir = path.join(process.cwd(), '.next/cache'); +const nextDir = path.join(process.cwd(), '.next'); const cachePath = (cacheKey: string) => path.join(cacheDir, `${cacheKey}.json`); type AtomicCacheable = object|string|number|boolean|null; type Cacheable = AtomicCacheable|AtomicCacheable[]; +if (!fs.existsSync(nextDir)) { + fs.mkdirSync(nextDir) +} + +if (!fs.existsSync(cacheDir)) { + fs.mkdirSync(cacheDir) +} + function read(cacheKey: string): T { if (fs.existsSync(cachePath(cacheKey))) { const iconCache = fs.readFileSync(cachePath(cacheKey), "utf8") @@ -17,8 +26,10 @@ function read(cacheKey: string): T { } function write(cacheKey: string, content: T): void { - if (!fs.existsSync(cacheDir)) { - fs.mkdirSync(cacheDir) + + + if (!fs.existsSync(path.join(cacheDir, cacheKey))) { + fs.mkdirSync(path.join(cacheDir, cacheKey)) } fs.writeFileSync(cachePath(cacheKey), JSON.stringify(content), 'utf-8') diff --git a/site/tsconfig.json b/site/tsconfig.json index 27798890a..acc1b78a1 100644 --- a/site/tsconfig.json +++ b/site/tsconfig.json @@ -1,10 +1,13 @@ { "ts-node": { + "esm": true, "compilerOptions": { - "module": "commonjs" + "baseUrl": ".", + "module": "nodenext", } }, "compilerOptions": { + "baseUrl": ".", "target": "ESNext", "lib": [ "dom",