Skip to content

Commit

Permalink
refactor: drop support for Node.js 10 (#7573)
Browse files Browse the repository at this point in the history
  • Loading branch information
millsp committed Jun 10, 2021
1 parent c960ec1 commit 2680a44
Show file tree
Hide file tree
Showing 11 changed files with 4,379 additions and 3,761 deletions.
1,491 changes: 804 additions & 687 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/packages/cli/README.md
Expand Up @@ -8,7 +8,7 @@ Check out the [**Getting Started Quickstart**](https://www.prisma.io/docs/gettin

## Installation

The Prisma CLI currently requires Node.js 10.4 (or higher).
The Prisma CLI currently requires Node.js 12.2 (or higher).
We recommend using [the latest Node.js LTS ("long-term support") release.](https://nodejs.org/en/about/releases/)

### npm
Expand Down
6 changes: 3 additions & 3 deletions src/packages/cli/helpers/build.js
Expand Up @@ -23,7 +23,7 @@ async function main() {
esbuild.build({
platform: 'node',
bundle: true,
target: 'node10',
target: 'node12',
outfile: 'build/index.js',
entryPoints: ['src/bin.ts'],
external: ['@prisma/engines', '_http_common'],
Expand All @@ -32,15 +32,15 @@ async function main() {
platform: 'node',
bundle: true,
minify: true,
target: ['node10'],
target: ['node12'],
outfile: 'preinstall/index.js',
entryPoints: ['scripts/preinstall.js'],
}),
esbuild.build({
platform: 'node',
bundle: true,
minify: true,
target: ['node10'],
target: ['node12'],
outfile: 'install/index.js',
entryPoints: ['scripts/install.js'],
}),
Expand Down
2 changes: 1 addition & 1 deletion src/packages/cli/package.json
Expand Up @@ -29,7 +29,7 @@
"bugs": "https://github.com/prisma/prisma/issues",
"license": "Apache-2.0",
"engines": {
"node": ">=10.4"
"node": ">=12.2"
},
"prisma": {
"prismaCommit": "placeholder-for-commit-hash-replaced-during-publishing-in-publish-ts"
Expand Down
5 changes: 3 additions & 2 deletions src/packages/cli/scripts/preinstall.js
Expand Up @@ -118,10 +118,11 @@ export function main() {

const nodeVersions = process.version.split('.')
const nodeMajorVersion = parseInt(nodeVersions[0].slice(1))
if (nodeMajorVersion < 10) {
const nodeMinorVersion = parseInt(nodeVersions[1])
if (nodeMajorVersion < 12 || (nodeMajorVersion === 12 && nodeMinorVersion < 2)) {
console.error(
drawBox({
str: `Prisma only supports Node.js >= 10`,
str: `Prisma only supports Node.js >= 12.2`,
verticalPadding: 1,
horizontalPadding: 3,
}),
Expand Down
4 changes: 2 additions & 2 deletions src/packages/client/helpers/build.js
Expand Up @@ -28,7 +28,7 @@ async function main() {
esbuild.build({
platform: 'node',
bundle: true,
target: 'node10',
target: 'node12',
outfile: 'generator-build/index.js',
entryPoints: ['src/generator.ts'],
external: ['_http_common']
Expand All @@ -39,7 +39,7 @@ async function main() {
esbuild.build({
platform: 'node',
bundle: true,
target: 'node10',
target: 'node12',
outdir: 'runtime',
entryPoints: ['src/runtime/index.ts'],
external: ['_http_common']
Expand Down
2 changes: 1 addition & 1 deletion src/packages/client/package.json
Expand Up @@ -24,7 +24,7 @@
"types": "index.d.ts",
"license": "Apache-2.0",
"engines": {
"node": ">=10.16"
"node": ">=12.2"
},
"homepage": "https://www.prisma.io",
"repository": "git@github.com:prisma/prisma.git",
Expand Down
Binary file not shown.
Binary file not shown.
14 changes: 1 addition & 13 deletions src/packages/client/src/runtime/query.ts
Expand Up @@ -1472,19 +1472,7 @@ function valueToArg(key: string, value: any, arg: DMMF.SchemaArg): Arg | null {
}
})

// because Node 10's sort has a different order for sorting than Node 11+
let scoresEqual = true
const currentScore = argsWithScores[0].score
for (const { score } of argsWithScores) {
if (score !== currentScore) {
scoresEqual = false
break
}
}

if (!scoresEqual) {
argsWithScores.sort((a, b) => (a.score < b.score ? -1 : 1))
}
argsWithScores.sort((a, b) => (a.score < b.score ? -1 : 1))

return argsWithScores[0].arg
}
Expand Down

0 comments on commit 2680a44

Please sign in to comment.