From 224c39b279afccbffe7af8a83596c7f583871888 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 5 Jul 2020 20:11:16 +0200 Subject: [PATCH 1/9] Add missing dependency on `@types/node` to `@jest/types` --- CHANGELOG.md | 1 + packages/jest-types/package.json | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e88fb52389d..06c41d2cc2f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - `[jest-jasmine2]` Refine typings of `queueRunner` ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Remove usage of `Function` type ([#10216](https://github.com/facebook/jest/pull/10216)) - `[jest-resolve]` Improve types ([#10239](https://github.com/facebook/jest/pull/10239)) +- `[@jest/types]` Add missing dependency on `@types/node` ### Performance diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index 3c568f119ae4..c58a4b38c392 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -15,12 +15,10 @@ "dependencies": { "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^1.1.1", + "@types/node": "*", "@types/yargs": "^15.0.0", "chalk": "^4.0.0" }, - "devDependencies": { - "@types/node": "*" - }, "publishConfig": { "access": "public" }, From 1e50ac549ebb228040007de5651954f5760aeaec Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 5 Jul 2020 20:26:38 +0200 Subject: [PATCH 2/9] same for jest-environment --- CHANGELOG.md | 1 + packages/jest-environment/package.json | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06c41d2cc2f2..240e81fa025f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Chore & Maintenance +- `[@jest/environment]` Add missing dependency on `@types/node` - `[jest-jasmine2]` Convert `PCancelable` to TypeScript ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Refine typings of `queueRunner` ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Remove usage of `Function` type ([#10216](https://github.com/facebook/jest/pull/10216)) diff --git a/packages/jest-environment/package.json b/packages/jest-environment/package.json index 8a9d04b316ab..8d0d94817c0e 100644 --- a/packages/jest-environment/package.json +++ b/packages/jest-environment/package.json @@ -12,11 +12,9 @@ "dependencies": { "@jest/fake-timers": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "jest-mock": "^26.1.0" }, - "devDependencies": { - "@types/node": "*" - }, "engines": { "node": ">= 10.14.2" }, From 3899706ea62a1fb1e7f2ee0f058756b24993b4e1 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 5 Jul 2020 20:28:29 +0200 Subject: [PATCH 3/9] link to pr --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 240e81fa025f..8a1617dbaad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,12 +13,12 @@ ### Chore & Maintenance -- `[@jest/environment]` Add missing dependency on `@types/node` +- `[@jest/environment]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) - `[jest-jasmine2]` Convert `PCancelable` to TypeScript ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Refine typings of `queueRunner` ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Remove usage of `Function` type ([#10216](https://github.com/facebook/jest/pull/10216)) - `[jest-resolve]` Improve types ([#10239](https://github.com/facebook/jest/pull/10239)) -- `[@jest/types]` Add missing dependency on `@types/node` +- `[@jest/types]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) ### Performance From 353a012d9dcb6a43109415a3258b4975a42248a9 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 5 Jul 2020 20:52:07 +0200 Subject: [PATCH 4/9] fake timers and mock as well --- CHANGELOG.md | 2 ++ packages/jest-fake-timers/package.json | 2 +- packages/jest-mock/package.json | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a1617dbaad4..4d27c1fba6f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,11 @@ ### Chore & Maintenance - `[@jest/environment]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) +- `[@jest/fake-timers]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) - `[jest-jasmine2]` Convert `PCancelable` to TypeScript ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Refine typings of `queueRunner` ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Remove usage of `Function` type ([#10216](https://github.com/facebook/jest/pull/10216)) +- `[jest-mock]` Improve types ([#10239](https://github.com/facebook/jest/pull/10239)) - `[jest-resolve]` Improve types ([#10239](https://github.com/facebook/jest/pull/10239)) - `[@jest/types]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) diff --git a/packages/jest-fake-timers/package.json b/packages/jest-fake-timers/package.json index 8f62d5f004a7..05cfaa797abc 100644 --- a/packages/jest-fake-timers/package.json +++ b/packages/jest-fake-timers/package.json @@ -12,12 +12,12 @@ "dependencies": { "@jest/types": "^26.1.0", "@sinonjs/fake-timers": "^6.0.1", + "@types/node": "*", "jest-message-util": "^26.1.0", "jest-mock": "^26.1.0", "jest-util": "^26.1.0" }, "devDependencies": { - "@types/node": "*", "@types/sinonjs__fake-timers": "^6.0.1" }, "engines": { diff --git a/packages/jest-mock/package.json b/packages/jest-mock/package.json index 49884eb6e748..915678cedf8e 100644 --- a/packages/jest-mock/package.json +++ b/packages/jest-mock/package.json @@ -10,9 +10,7 @@ "node": ">= 10.14.2" }, "dependencies": { - "@jest/types": "^26.1.0" - }, - "devDependencies": { + "@jest/types": "^26.1.0", "@types/node": "*" }, "license": "MIT", From bed676f20faaafb0a00e3b2c685d7cde014d86a9 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 5 Jul 2020 20:52:20 +0200 Subject: [PATCH 5/9] remove unused node typing from globals package --- packages/jest-globals/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-globals/tsconfig.json b/packages/jest-globals/tsconfig.json index b6678e5f0aed..f6060ca2e675 100644 --- a/packages/jest-globals/tsconfig.json +++ b/packages/jest-globals/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { // we don't want `@types/jest` to be referenced - "types": ["node"], + "types": [], "rootDir": "src", "outDir": "build" }, From c43d2a5cc6af52b8e520aa8e2df00ae85e79382a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 5 Jul 2020 21:16:59 +0200 Subject: [PATCH 6/9] add even more missing, plus script asserting it's not missing --- CHANGELOG.md | 4 +--- package.json | 1 + packages/jest-circus/package.json | 1 + packages/jest-console/package.json | 1 + packages/jest-core/package.json | 2 +- packages/jest-environment-jsdom/package.json | 1 + packages/jest-environment-node/package.json | 1 + packages/jest-haste-map/package.json | 2 +- packages/jest-jasmine2/package.json | 1 + packages/jest-runner/package.json | 2 +- packages/jest-serializer/package.json | 4 ++-- packages/jest-util/package.json | 4 ++-- packages/jest-watcher/package.json | 4 +--- packages/jest-worker/package.json | 2 +- scripts/buildTs.js | 21 +++++++++++++++++--- yarn.lock | 5 +++++ 16 files changed, 39 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d27c1fba6f6..60e0e6d34bbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,14 +13,12 @@ ### Chore & Maintenance -- `[@jest/environment]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) -- `[@jest/fake-timers]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) +- `[*]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) - `[jest-jasmine2]` Convert `PCancelable` to TypeScript ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Refine typings of `queueRunner` ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Remove usage of `Function` type ([#10216](https://github.com/facebook/jest/pull/10216)) - `[jest-mock]` Improve types ([#10239](https://github.com/facebook/jest/pull/10239)) - `[jest-resolve]` Improve types ([#10239](https://github.com/facebook/jest/pull/10239)) -- `[@jest/types]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) ### Performance diff --git a/package.json b/package.json index 9db4cd59cc7b..633ea1aac232 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "prettier": "^2.0.1", "progress": "^2.0.0", "promise": "^8.0.2", + "read-pkg-up": "^7.0.1", "resolve": "^1.15.0", "rimraf": "^3.0.0", "semver": "^7.3.2", diff --git a/packages/jest-circus/package.json b/packages/jest-circus/package.json index a99bb128c5e1..5c618968dd2f 100644 --- a/packages/jest-circus/package.json +++ b/packages/jest-circus/package.json @@ -14,6 +14,7 @@ "@jest/environment": "^26.1.0", "@jest/test-result": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "co": "^4.6.0", "dedent": "^0.7.0", diff --git a/packages/jest-console/package.json b/packages/jest-console/package.json index 493ea4921278..44e45f7350d8 100644 --- a/packages/jest-console/package.json +++ b/packages/jest-console/package.json @@ -11,6 +11,7 @@ "types": "build/index.d.ts", "dependencies": { "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "jest-message-util": "^26.1.0", "jest-util": "^26.1.0", diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index 2cf64377f5af..862d3c54995a 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -10,6 +10,7 @@ "@jest/test-result": "^26.1.0", "@jest/transform": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", "exit": "^0.1.2", @@ -38,7 +39,6 @@ "@types/exit": "^0.1.30", "@types/graceful-fs": "^4.1.2", "@types/micromatch": "^4.0.0", - "@types/node": "*", "@types/rimraf": "^3.0.0", "jest-snapshot-serializer-raw": "^1.1.0" }, diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json index e21bd19afec1..307e03616c36 100644 --- a/packages/jest-environment-jsdom/package.json +++ b/packages/jest-environment-jsdom/package.json @@ -13,6 +13,7 @@ "@jest/environment": "^26.1.0", "@jest/fake-timers": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "jest-mock": "^26.1.0", "jest-util": "^26.1.0", "jsdom": "^16.2.2" diff --git a/packages/jest-environment-node/package.json b/packages/jest-environment-node/package.json index 4406f44fe3c0..6e822bec8151 100644 --- a/packages/jest-environment-node/package.json +++ b/packages/jest-environment-node/package.json @@ -13,6 +13,7 @@ "@jest/environment": "^26.1.0", "@jest/fake-timers": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "jest-mock": "^26.1.0", "jest-util": "^26.1.0" }, diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index adaae2e44f74..76e34ab3ea23 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -12,6 +12,7 @@ "dependencies": { "@jest/types": "^26.1.0", "@types/graceful-fs": "^4.1.2", + "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", "graceful-fs": "^4.2.4", @@ -28,7 +29,6 @@ "@types/anymatch": "^1.3.1", "@types/fb-watchman": "^2.0.0", "@types/micromatch": "^4.0.0", - "@types/node": "*", "@types/sane": "^2.0.0", "@types/which": "^1.3.2" }, diff --git a/packages/jest-jasmine2/package.json b/packages/jest-jasmine2/package.json index c9e52fb7490b..6c956b36079a 100644 --- a/packages/jest-jasmine2/package.json +++ b/packages/jest-jasmine2/package.json @@ -15,6 +15,7 @@ "@jest/source-map": "^26.1.0", "@jest/test-result": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "co": "^4.6.0", "expect": "^26.1.0", diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index 7865fcb759e6..9a1b9cf755dc 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -14,6 +14,7 @@ "@jest/environment": "^26.1.0", "@jest/test-result": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "exit": "^0.1.2", "graceful-fs": "^4.2.4", @@ -33,7 +34,6 @@ "devDependencies": { "@types/exit": "^0.1.30", "@types/graceful-fs": "^4.1.2", - "@types/node": "*", "@types/source-map-support": "^0.5.0", "jest-circus": "^26.1.0" }, diff --git a/packages/jest-serializer/package.json b/packages/jest-serializer/package.json index 8d7bd50f1493..ee85d32d0813 100644 --- a/packages/jest-serializer/package.json +++ b/packages/jest-serializer/package.json @@ -7,10 +7,10 @@ "directory": "packages/jest-serializer" }, "devDependencies": { - "@types/graceful-fs": "^4.1.3", - "@types/node": "*" + "@types/graceful-fs": "^4.1.3" }, "dependencies": { + "@types/node": "*", "graceful-fs": "^4.2.4" }, "engines": { diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index 342587f6bbf2..0d4254e9e6ce 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -11,6 +11,7 @@ "types": "build/index.d.ts", "dependencies": { "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "graceful-fs": "^4.2.4", "is-ci": "^2.0.0", @@ -19,8 +20,7 @@ "devDependencies": { "@types/graceful-fs": "^4.1.2", "@types/is-ci": "^2.0.0", - "@types/micromatch": "^4.0.0", - "@types/node": "*" + "@types/micromatch": "^4.0.0" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-watcher/package.json b/packages/jest-watcher/package.json index d1c10ea44a57..e1625cb7fc1a 100644 --- a/packages/jest-watcher/package.json +++ b/packages/jest-watcher/package.json @@ -7,14 +7,12 @@ "dependencies": { "@jest/test-result": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", "jest-util": "^26.1.0", "string-length": "^4.0.1" }, - "devDependencies": { - "@types/node": "*" - }, "repository": { "type": "git", "url": "https://github.com/facebook/jest", diff --git a/packages/jest-worker/package.json b/packages/jest-worker/package.json index a0b890832260..04d9f3c2abd7 100644 --- a/packages/jest-worker/package.json +++ b/packages/jest-worker/package.json @@ -10,12 +10,12 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { + "@types/node": "*", "merge-stream": "^2.0.0", "supports-color": "^7.0.0" }, "devDependencies": { "@types/merge-stream": "^1.1.2", - "@types/node": "*", "@types/supports-color": "^5.3.0", "get-stream": "^5.1.0", "worker-farm": "^1.6.0" diff --git a/scripts/buildTs.js b/scripts/buildTs.js index d843a9813514..51460d47282e 100644 --- a/scripts/buildTs.js +++ b/scripts/buildTs.js @@ -16,6 +16,7 @@ const util = require('util'); const chalk = require('chalk'); const execa = require('execa'); const globby = require('globby'); +const readPkgUp = require('read-pkg-up'); const throat = require('throat'); const {getPackages} = require('./buildUtils'); @@ -32,7 +33,7 @@ packagesWithTs.forEach(pkgDir => { assert.ok(pkg.types, `Package ${pkg.name} is missing \`types\` field`); - assert.equal( + assert.strictEqual( pkg.types, pkg.main.replace(/\.js$/, '.d.ts'), `\`main\` and \`types\` field of ${pkg.name} does not match`, @@ -72,8 +73,11 @@ Promise.all( globbed.map(file => Promise.all([file, readFilePromise(file, 'utf8')])), ); - const filesWithReferences = files - .filter(([, content]) => content.includes('/// + content.includes('/// [ name, content @@ -98,6 +102,17 @@ Promise.all( process.exit(1); } + + const filesWithNodeReference = filesWithTypeReferences.filter( + hit => hit.length > 0, + ).map(([filename]) => filename); + + if (filesWithNodeReference.length > 0) { + const {packageJson} = await readPkgUp({cwd: path.dirname(filesWithNodeReference[0])}) + + assert.ok(packageJson.dependencies, `Package \`${packageJson.name}\` is missing \`dependencies\``); + assert.strictEqual(packageJson.dependencies['@types/node'], '*', `Package \`${packageJson.name}\` is missing a dependency on \`@types/node\``); + } }), ), ).catch(e => { diff --git a/yarn.lock b/yarn.lock index 9a626e75e49c..bb8454203756 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11036,6 +11036,7 @@ fsevents@^1.2.7: "@types/co": ^4.6.0 "@types/dedent": ^0.7.0 "@types/graceful-fs": ^4.1.3 + "@types/node": "*" "@types/stack-utils": ^1.0.1 chalk: ^4.0.0 co: ^4.6.0 @@ -11155,6 +11156,7 @@ fsevents@^1.2.7: "@jest/fake-timers": ^26.1.0 "@jest/types": ^26.1.0 "@types/jsdom": ^16.2.1 + "@types/node": "*" jest-mock: ^26.1.0 jest-util: ^26.1.0 jsdom: ^16.2.2 @@ -11168,6 +11170,7 @@ fsevents@^1.2.7: "@jest/environment": ^26.1.0 "@jest/fake-timers": ^26.1.0 "@jest/types": ^26.1.0 + "@types/node": "*" jest-mock: ^26.1.0 jest-util: ^26.1.0 languageName: unknown @@ -11250,6 +11253,7 @@ fsevents@^1.2.7: "@jest/types": ^26.1.0 "@types/babel__traverse": ^7.0.4 "@types/co": ^4.6.2 + "@types/node": "*" chalk: ^4.0.0 co: ^4.6.0 expect: ^26.1.0 @@ -16578,6 +16582,7 @@ fsevents@^1.2.7: prettier: ^2.0.1 progress: ^2.0.0 promise: ^8.0.2 + read-pkg-up: ^7.0.1 resolve: ^1.15.0 rimraf: ^3.0.0 semver: ^7.3.2 From aac122deacbbaed676b5c7c052f285fdb3be1214 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 5 Jul 2020 21:19:31 +0200 Subject: [PATCH 7/9] remove lingering changelog entry --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60e0e6d34bbc..5e632c6e6ac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,6 @@ - `[jest-jasmine2]` Convert `PCancelable` to TypeScript ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Refine typings of `queueRunner` ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Remove usage of `Function` type ([#10216](https://github.com/facebook/jest/pull/10216)) -- `[jest-mock]` Improve types ([#10239](https://github.com/facebook/jest/pull/10239)) - `[jest-resolve]` Improve types ([#10239](https://github.com/facebook/jest/pull/10239)) ### Performance From 9194e9d59d02dd6383142c746e84cec21bbc46cc Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 5 Jul 2020 21:39:39 +0200 Subject: [PATCH 8/9] lint --- scripts/buildTs.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/scripts/buildTs.js b/scripts/buildTs.js index 51460d47282e..2c25f6db17c6 100644 --- a/scripts/buildTs.js +++ b/scripts/buildTs.js @@ -103,15 +103,24 @@ Promise.all( process.exit(1); } - const filesWithNodeReference = filesWithTypeReferences.filter( - hit => hit.length > 0, - ).map(([filename]) => filename); + const filesWithNodeReference = filesWithTypeReferences + .filter(hit => hit.length > 0) + .map(([filename]) => filename); if (filesWithNodeReference.length > 0) { - const {packageJson} = await readPkgUp({cwd: path.dirname(filesWithNodeReference[0])}) - - assert.ok(packageJson.dependencies, `Package \`${packageJson.name}\` is missing \`dependencies\``); - assert.strictEqual(packageJson.dependencies['@types/node'], '*', `Package \`${packageJson.name}\` is missing a dependency on \`@types/node\``); + const {packageJson} = await readPkgUp({ + cwd: path.dirname(filesWithNodeReference[0]), + }); + + assert.ok( + packageJson.dependencies, + `Package \`${packageJson.name}\` is missing \`dependencies\``, + ); + assert.strictEqual( + packageJson.dependencies['@types/node'], + '*', + `Package \`${packageJson.name}\` is missing a dependency on \`@types/node\``, + ); } }), ), From 69fade05611b44aa503b14a048c5132be37acbdc Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 5 Jul 2020 21:44:31 +0200 Subject: [PATCH 9/9] simplify --- package.json | 1 - scripts/buildTs.js | 25 +++++++++++-------------- yarn.lock | 1 - 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 633ea1aac232..9db4cd59cc7b 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,6 @@ "prettier": "^2.0.1", "progress": "^2.0.0", "promise": "^8.0.2", - "read-pkg-up": "^7.0.1", "resolve": "^1.15.0", "rimraf": "^3.0.0", "semver": "^7.3.2", diff --git a/scripts/buildTs.js b/scripts/buildTs.js index 2c25f6db17c6..319da312e20e 100644 --- a/scripts/buildTs.js +++ b/scripts/buildTs.js @@ -16,7 +16,6 @@ const util = require('util'); const chalk = require('chalk'); const execa = require('execa'); const globby = require('globby'); -const readPkgUp = require('read-pkg-up'); const throat = require('throat'); const {getPackages} = require('./buildUtils'); @@ -73,9 +72,9 @@ Promise.all( globbed.map(file => Promise.all([file, readFilePromise(file, 'utf8')])), ); - const filesWithTypeReferences = files.filter(([, content]) => - content.includes('/// content.includes('/// hit.length > 0); const filesWithReferences = filesWithTypeReferences .map(([name, content]) => [ @@ -103,23 +102,21 @@ Promise.all( process.exit(1); } - const filesWithNodeReference = filesWithTypeReferences - .filter(hit => hit.length > 0) - .map(([filename]) => filename); + const filesWithNodeReference = filesWithTypeReferences.map( + ([filename]) => filename, + ); if (filesWithNodeReference.length > 0) { - const {packageJson} = await readPkgUp({ - cwd: path.dirname(filesWithNodeReference[0]), - }); + const pkg = require(pkgDir + '/package.json'); assert.ok( - packageJson.dependencies, - `Package \`${packageJson.name}\` is missing \`dependencies\``, + pkg.dependencies, + `Package \`${pkg.name}\` is missing \`dependencies\``, ); assert.strictEqual( - packageJson.dependencies['@types/node'], + pkg.dependencies['@types/node'], '*', - `Package \`${packageJson.name}\` is missing a dependency on \`@types/node\``, + `Package \`${pkg.name}\` is missing a dependency on \`@types/node\``, ); } }), diff --git a/yarn.lock b/yarn.lock index bb8454203756..5f375494bdc6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16582,7 +16582,6 @@ fsevents@^1.2.7: prettier: ^2.0.1 progress: ^2.0.0 promise: ^8.0.2 - read-pkg-up: ^7.0.1 resolve: ^1.15.0 rimraf: ^3.0.0 semver: ^7.3.2