Skip to content

Commit

Permalink
chore!: drop Node.js 16.x support and remove obsolete code (#25609)
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln authored Nov 15, 2024
1 parent b336467 commit db69914
Show file tree
Hide file tree
Showing 65 changed files with 8,241 additions and 7,045 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/scripts/setup-mysql.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#!/usr/bin/env bash

set -ex

Expand All @@ -7,7 +7,14 @@ if [ "$RUNNER_OS" = "Windows" ]; then
fi

if [ "$RUNNER_OS" = "macOS" ]; then
brew install mysql || true
brew install mysql

cat <<EOF > /opt/homebrew/etc/my.cnf
[mysqld]
bind-address = ::1
mysqlx-bind-address = ::1
EOF

brew services run mysql
fi

Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
matrix:
shard: ['1/5', '2/5', '3/5', '4/5', '5/5']
queryEngine: ${{ fromJson(inputs.queryEngine) }}
node: [16, 18, 20]
node: [18, 20, 22]
previewFeatures: ['', 'relationJoins']
env:
NODE_OPTIONS: '--max-old-space-size=8096'
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
fail-fast: false
matrix:
shard: ['1/6', '2/6', '3/6', '4/6', '5/6', '6/6']
node: [16, 18, 20]
node: [18, 20, 22]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -243,7 +243,7 @@ jobs:
clientRuntime: ['node', 'wasm']
flavor: ['js_pg', 'js_neon', 'js_libsql', 'js_planetscale', 'js_d1']
shard: ['1/6', '2/6', '3/6', '4/6', '5/6', '6/6']
node: [20] #[16, 18, 20]
node: [20]
previewFeatures: ['driverAdapters', 'driverAdapters,relationJoins']
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -299,7 +299,7 @@ jobs:
fail-fast: false
matrix:
queryEngine: ['library'] # TODO: binary engine is leaking at the moment
node: [16, 18, 20]
node: [18, 20, 22]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -439,7 +439,7 @@ jobs:
matrix:
relationMode: ['', 'foreignKeys', 'prisma']
os: [ubuntu-latest]
node: [16]
node: [18]
env:
NODE_OPTIONS: '--max-old-space-size=8096'
JEST_JUNIT_SUITE_NAME: 'client/functional'
Expand Down Expand Up @@ -514,7 +514,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [16]
node: [18]
steps:
- uses: actions/checkout@v4

Expand All @@ -540,7 +540,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [16]
node: [18]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -568,7 +568,7 @@ jobs:
fail-fast: false
matrix:
queryEngine: ${{ fromJson(inputs.queryEngine) }}
node: [16]
node: [18]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -614,7 +614,7 @@ jobs:
matrix:
queryEngine: ${{ fromJson(inputs.queryEngine) }}
os: [ubuntu-latest]
node: [16, 18, 20]
node: [18, 20, 22]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -660,7 +660,7 @@ jobs:
matrix:
queryEngine: ${{ fromJson(inputs.queryEngine) }}
os: [ubuntu-latest]
node: [16, 18, 20]
node: [18, 20, 22]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -706,7 +706,7 @@ jobs:
matrix:
queryEngine: ${{ fromJson(inputs.queryEngine) }}
os: [ubuntu-latest]
node: [16, 18, 20]
node: [18, 20, 22]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -751,12 +751,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [16, 18, 20]
node: [18, 20, 22]
include:
- os: windows-latest
version: 16
version: 18
- os: macos-latest
version: 16
version: 18
steps:
- uses: actions/checkout@v4

Expand All @@ -783,7 +783,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [16, 18, 20]
node: [18, 20, 22]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -854,7 +854,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-14, windows-latest]
node: [16]
node: [18]
queryEngine: ${{ fromJson(inputs.queryEngine) }}
shard: ['1/2', '2/2']
if: |
Expand Down Expand Up @@ -925,7 +925,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-14, windows-latest]
node: [16]
node: [18]
queryEngine: ${{ fromJson(inputs.queryEngine) }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-engines-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version: '16'
node-version: '18'

# This step uses `@prisma/ensure-npm-release` (abbv. `enr`) https://github.com/prisma/ensure-npm-release
- name: Check if version of @prisma/engines-version is available on npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-studio-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version: '16'
node-version: '18'

# This step uses `@prisma/ensure-npm-release` (abbv. `enr`) https://github.com/prisma/ensure-npm-release
- name: Check if version is available on npm
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"triggerEmptyDevReleaseByIncrementingThisNumber": 0,
"license": "Apache-2.0",
"engines": {
"node": ">=16.13",
"node": ">=18.18",
"pnpm": ">=8.6.7 <9"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"bugs": "https://github.com/prisma/prisma/issues",
"license": "Apache-2.0",
"engines": {
"node": ">=16.13"
"node": ">=18.18"
},
"prisma": {
"prismaCommit": "placeholder-for-commit-hash-replaced-during-publishing-in-publish-ts"
Expand Down
17 changes: 9 additions & 8 deletions packages/cli/scripts/preinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ import process from 'node:process'

import { drawBox } from '@prisma/internals'

type MajorMinor = `${number}.${number}`
type MajorMinorPatch = `${MajorMinor}.${number}`

export function main() {
printMessageAndExitIfUnsupportedNodeVersion(process.version)
printMessageAndExitIfUnsupportedNodeVersion(process.versions.node as MajorMinorPatch)
}

function extractSemanticVersionParts(version) {
function extractSemanticVersionParts(version: MajorMinor | MajorMinorPatch) {
return version
.split('.')
.slice(0, 2) // only major and minor version
.map((v) => parseInt(v, 10))
.map((v) => parseInt(v, 10)) as [number, number]
}

/**
* Given a Node.js version (e.g. `v16.13.0`), prints an error and exits the process
* if the Node.js version is not supported by Prisma.
*/
export function printMessageAndExitIfUnsupportedNodeVersion(nodeVersion) {
// Node.js version, without the `v` prefix (e.g. `16.13.0`)
const semanticNodeVersion = nodeVersion.slice(1)
const [nodeMajorVersion, nodeMinorVersion] = extractSemanticVersionParts(semanticNodeVersion)
export function printMessageAndExitIfUnsupportedNodeVersion(nodeVersion: MajorMinorPatch) {
const [nodeMajorVersion, nodeMinorVersion] = extractSemanticVersionParts(nodeVersion)

// Minimum Node.js version supported by Prisma
const MIN_NODE_VERSION = '16.13'
const MIN_NODE_VERSION = '18.18'
const [MIN_NODE_MAJOR_VERSION, MIN_NODE_MINOR_VERSION] = extractSemanticVersionParts(MIN_NODE_VERSION)

if (
Expand Down
20 changes: 10 additions & 10 deletions packages/cli/src/__tests__/preinstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { printMessageAndExitIfUnsupportedNodeVersion } from '../../scripts/prein

const ctx = jestContext.new().add(jestConsoleContext()).assemble()

it('should exit 1 and print a message when Node.js version is lower than minimum - 16.0', () => {
it('should exit 1 and print a message when Node.js minor version is lower than minimum - 18.0', () => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation()

printMessageAndExitIfUnsupportedNodeVersion('v16.0.0')
printMessageAndExitIfUnsupportedNodeVersion('18.0.0')

expect(ctx.mocked['console.error'].mock.calls.join('\n')).toMatchInlineSnapshot(`
"┌──────────────────────────────────────────────┐
│ Prisma only supports Node.js >= 16.13. │
│ Prisma only supports Node.js >= 18.18. │
│ Please upgrade your Node.js version. │
└──────────────────────────────────────────────┘"
`)
Expand All @@ -20,14 +20,14 @@ it('should exit 1 and print a message when Node.js version is lower than minimum
mockExit.mockRestore()
})

it('should exit 1 and print a message when Node.js version is lower than minimum - 14.13', () => {
it('should exit 1 and print a message when Node.js major version is lower than minimum - 16.18', () => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation()

printMessageAndExitIfUnsupportedNodeVersion('v14.13.0')
printMessageAndExitIfUnsupportedNodeVersion('16.18.0')

expect(ctx.mocked['console.error'].mock.calls.join('\n')).toMatchInlineSnapshot(`
"┌──────────────────────────────────────────────┐
│ Prisma only supports Node.js >= 16.13. │
│ Prisma only supports Node.js >= 18.18. │
│ Please upgrade your Node.js version. │
└──────────────────────────────────────────────┘"
`)
Expand All @@ -36,20 +36,20 @@ it('should exit 1 and print a message when Node.js version is lower than minimum
mockExit.mockRestore()
})

it('should do nothing when Node.js version is supported - 16.13', () => {
printMessageAndExitIfUnsupportedNodeVersion('v16.13.0')
it('should do nothing when Node.js version is supported - 18.18', () => {
printMessageAndExitIfUnsupportedNodeVersion('18.18.0')

expect(ctx.mocked['console.error'].mock.calls.join('\n')).toMatchInlineSnapshot(`""`)
})

it('should do nothing when Node.js version is supported - current', () => {
printMessageAndExitIfUnsupportedNodeVersion(process.version)
printMessageAndExitIfUnsupportedNodeVersion(process.versions.node as `${number}.${number}.${number}`)

expect(ctx.mocked['console.error'].mock.calls.join('\n')).toMatchInlineSnapshot(`""`)
})

it('should do nothing when Node.js version is supported - 20.0', () => {
printMessageAndExitIfUnsupportedNodeVersion('v20.0.0')
printMessageAndExitIfUnsupportedNodeVersion('20.0.0')

expect(ctx.mocked['console.error'].mock.calls.join('\n')).toMatchInlineSnapshot(`""`)
})
24 changes: 14 additions & 10 deletions packages/client/helpers/functional-test/JestCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,28 @@ import path from 'path'
const packageRoot = path.resolve(__dirname, '..', '..')

export class JestCli {
private args: string[]
private env: Record<string, string>

constructor(args: string[] = [], env: Record<string, string> = {}) {
this.args = args
this.env = env
}
constructor(
private args: string[] = [],
private env: Record<string, string> = {},
private path = 'node_modules/.bin/jest',
) {}

withArgs(args: string[]): JestCli {
return new JestCli([...this.args, ...args], this.env)
return new JestCli([...this.args, ...args], this.env, this.path)
}

withEnv(env: Record<string, string>): JestCli {
return new JestCli(this.args, { ...this.env, ...env })
return new JestCli(this.args, { ...this.env, ...env }, this.path)
}

withDebugger(): JestCli {
const args = ['--inspect-brk', 'node_modules/jest/bin/jest.js', ...this.args]
const cli = new JestCli(args, this.env, 'node')
return cli
}

run(): void {
execa.sync('node_modules/.bin/jest', this.args, {
execa.sync(this.path, this.args, {
env: this.env,
stdio: 'inherit',
cwd: packageRoot,
Expand Down
6 changes: 6 additions & 0 deletions packages/client/helpers/functional-test/run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ const args = arg(
'--engine-type': String,
// Forces any given test to be run with an *added* set of preview features, comma-separated
'--preview-features': String,
// Enable Node.js debugger
'--inspect-brk': Boolean,

//
// Jest params
Expand All @@ -134,6 +136,10 @@ async function main(): Promise<number | void> {
}
}

if (args['--inspect-brk']) {
jestCli = jestCli.withDebugger()
}

if (args['--preview-features']) {
jestCli = jestCli.withEnv({ TEST_PREVIEW_FEATURES: args['--preview-features'] })
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
},
"license": "Apache-2.0",
"engines": {
"node": ">=16.13"
"node": ">=18.18"
},
"homepage": "https://www.prisma.io",
"repository": {
Expand Down
Loading

0 comments on commit db69914

Please sign in to comment.