diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 74d142cd..dc3147bf 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,6 +17,10 @@ jobs: # TURBO_TEAM: ${{ vars.TURBO_TEAM }} # TURBO_REMOTE_ONLY: true + strategy: + matrix: + node-version: ['18.x', '20.x', '22.x'] + steps: - name: Check out code uses: actions/checkout@v4 @@ -27,10 +31,10 @@ jobs: with: version: 9 - - name: Setup Node.js environment + - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: - node-version: 22 + node-version: ${{ matrix.node-version }} cache: 'pnpm' - name: Install dependencies diff --git a/README.md b/README.md index fab42f05..eba252fa 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Srcbook runs locally on your machine as a CLI application with a web interface. ### Requirements -- Node 20+, we recommend using [nvm](https://github.com/nvm-sh/nvm) to manage local node versions +- Node 18+, we recommend using [nvm](https://github.com/nvm-sh/nvm) to manage local node versions - [corepack](https://nodejs.org/api/corepack.html) to manage package manager versions ### Installing diff --git a/package.json b/package.json index e4c61c17..7ba95c46 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,6 @@ }, "packageManager": "pnpm@9.8.0", "engines": { - "node": ">=20" + "node": ">=18" } } diff --git a/packages/shared/src/utils.ts b/packages/shared/src/utils.ts index 0e7a9754..1183010e 100644 --- a/packages/shared/src/utils.ts +++ b/packages/shared/src/utils.ts @@ -1,8 +1,15 @@ import { base32hexnopad } from '@scure/base'; import type { CodeLanguageType } from './types/cells.js'; +import * as crypto from 'crypto'; + +export function isBrowser(): boolean { + return typeof window !== 'undefined'; +} export function randomid(byteSize = 16) { - const bytes = crypto.getRandomValues(new Uint8Array(byteSize)); + const bytes = isBrowser() + ? globalThis.crypto.getRandomValues(new Uint8Array(byteSize)) + : crypto.getRandomValues(new Uint8Array(byteSize)); return base32hexnopad.encode(bytes).toLowerCase(); } diff --git a/srcbook/README.md b/srcbook/README.md index ff401b65..56aa2a5a 100644 --- a/srcbook/README.md +++ b/srcbook/README.md @@ -24,7 +24,7 @@ Srcbook runs locally on your machine as a CLI application with a web interface. ### Requirements -- Node.js v20+ +- Node.js v18+ - We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage local node versions ### Installing diff --git a/srcbook/package.json b/srcbook/package.json index 9efbe9af..8c9fbaf9 100644 --- a/srcbook/package.json +++ b/srcbook/package.json @@ -34,6 +34,6 @@ "@types/express": "^4.17.21" }, "engines": { - "node": ">=20" + "node": ">=18" } }