Skip to content

Commit

Permalink
Node 18 support (#206)
Browse files Browse the repository at this point in the history
* provide support for Node 18 LTS

* update min node docs

* fixup the final issues with the crypto fallbacks and warnings

* change readme min node & add to CI

* update engines rules
  • Loading branch information
versecafe authored Aug 25, 2024
1 parent 38b0392 commit a16434a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
},
"packageManager": "[email protected]",
"engines": {
"node": ">=20"
"node": ">=18"
}
}
9 changes: 8 additions & 1 deletion packages/shared/src/utils.ts
Original file line number Diff line number Diff line change
@@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion srcbook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion srcbook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"@types/express": "^4.17.21"
},
"engines": {
"node": ">=20"
"node": ">=18"
}
}

0 comments on commit a16434a

Please sign in to comment.