chore: fix npm scripts (#9646)

This commit is contained in:
jrandolf 2023-02-10 09:57:17 -08:00 committed by GitHub
parent 54885be1de
commit 558a8e2999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 318 additions and 57 deletions

224
package-lock.json generated
View File

@ -70,6 +70,7 @@
"prettier": "2.8.1",
"puppeteer": "file:packages/puppeteer",
"rollup": "3.12.1",
"rollup-plugin-copy": "3.4.0",
"semver": "7.3.8",
"sinon": "15.0.1",
"source-map-support": "0.5.21",
@ -1730,6 +1731,15 @@
"integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==",
"dev": true
},
"node_modules/@types/fs-extra": {
"version": "8.1.2",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.1.2.tgz",
"integrity": "sha512-SvSrYXfWSc7R4eqnOzbQF4TZmfpNSM9FrSWLU3EUnWBuyZqNBOrv1B1JA3byUDPUl9z4Ab3jeZG2eDdySlgNMg==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/glob": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.0.0.tgz",
@ -2736,6 +2746,12 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/colorette": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.4.0.tgz",
"integrity": "sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==",
"dev": true
},
"node_modules/colors": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz",
@ -5275,6 +5291,15 @@
"node": ">=0.10.0"
}
},
"node_modules/is-plain-object": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-3.0.1.tgz",
"integrity": "sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-reference": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
@ -7362,6 +7387,103 @@
"fsevents": "~2.3.2"
}
},
"node_modules/rollup-plugin-copy": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-copy/-/rollup-plugin-copy-3.4.0.tgz",
"integrity": "sha512-rGUmYYsYsceRJRqLVlE9FivJMxJ7X6jDlP79fmFkL8sJs7VVMSVyA2yfyL+PGyO/vJs4A87hwhgVfz61njI+uQ==",
"dev": true,
"dependencies": {
"@types/fs-extra": "^8.0.1",
"colorette": "^1.1.0",
"fs-extra": "^8.1.0",
"globby": "10.0.1",
"is-plain-object": "^3.0.0"
},
"engines": {
"node": ">=8.3"
}
},
"node_modules/rollup-plugin-copy/node_modules/@types/glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==",
"dev": true,
"dependencies": {
"@types/minimatch": "*",
"@types/node": "*"
}
},
"node_modules/rollup-plugin-copy/node_modules/fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"dev": true,
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
},
"engines": {
"node": ">=6 <7 || >=8"
}
},
"node_modules/rollup-plugin-copy/node_modules/glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
"dev": true,
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.1.1",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
},
"engines": {
"node": "*"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/rollup-plugin-copy/node_modules/globby": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/globby/-/globby-10.0.1.tgz",
"integrity": "sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==",
"dev": true,
"dependencies": {
"@types/glob": "^7.1.1",
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.0.3",
"glob": "^7.1.3",
"ignore": "^5.1.1",
"merge2": "^1.2.3",
"slash": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/rollup-plugin-copy/node_modules/jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==",
"dev": true,
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/rollup-plugin-copy/node_modules/universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true,
"engines": {
"node": ">= 4.0.0"
}
},
"node_modules/run-async": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz",
@ -10242,6 +10364,15 @@
"integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==",
"dev": true
},
"@types/fs-extra": {
"version": "8.1.2",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.1.2.tgz",
"integrity": "sha512-SvSrYXfWSc7R4eqnOzbQF4TZmfpNSM9FrSWLU3EUnWBuyZqNBOrv1B1JA3byUDPUl9z4Ab3jeZG2eDdySlgNMg==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/glob": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.0.0.tgz",
@ -10983,6 +11114,12 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"colorette": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.4.0.tgz",
"integrity": "sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==",
"dev": true
},
"colors": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz",
@ -12741,6 +12878,12 @@
"integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==",
"dev": true
},
"is-plain-object": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-3.0.1.tgz",
"integrity": "sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==",
"dev": true
},
"is-reference": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
@ -14363,6 +14506,87 @@
"fsevents": "~2.3.2"
}
},
"rollup-plugin-copy": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-copy/-/rollup-plugin-copy-3.4.0.tgz",
"integrity": "sha512-rGUmYYsYsceRJRqLVlE9FivJMxJ7X6jDlP79fmFkL8sJs7VVMSVyA2yfyL+PGyO/vJs4A87hwhgVfz61njI+uQ==",
"dev": true,
"requires": {
"@types/fs-extra": "^8.0.1",
"colorette": "^1.1.0",
"fs-extra": "^8.1.0",
"globby": "10.0.1",
"is-plain-object": "^3.0.0"
},
"dependencies": {
"@types/glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==",
"dev": true,
"requires": {
"@types/minimatch": "*",
"@types/node": "*"
}
},
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"dev": true,
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.1.1",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"globby": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/globby/-/globby-10.0.1.tgz",
"integrity": "sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==",
"dev": true,
"requires": {
"@types/glob": "^7.1.1",
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.0.3",
"glob": "^7.1.3",
"ignore": "^5.1.1",
"merge2": "^1.2.3",
"slash": "^3.0.0"
}
},
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6"
}
},
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true
}
}
},
"run-async": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz",

View File

@ -11,7 +11,7 @@
"build:docs": "npm run build:docs --workspace puppeteer --if-present",
"check:pinned-deps": "tsx tools/ensure-pinned-deps",
"check": "npm run check --workspaces --if-present && run-p check:*",
"clean": "npm run clean --workspaces --if-present && rimraf **/.wireit",
"clean": "rimraf **/.wireit && npm run clean --workspaces --if-present",
"commitlint": "commitlint --from=HEAD~1",
"debug": "mocha --inspect-brk",
"docs": "run-s build:docs generate:markdown",
@ -96,6 +96,7 @@
"prettier": "2.8.1",
"puppeteer": "file:packages/puppeteer",
"rollup": "3.12.1",
"rollup-plugin-copy": "3.4.0",
"semver": "7.3.8",
"sinon": "15.0.1",
"source-map-support": "0.5.21",

View File

@ -3,18 +3,16 @@
"version": "0.1.0",
"description": "Puppeteer Angular schematics",
"scripts": {
"dev": "npm run build --watch",
"dev:test": "npm run test --watch",
"copy": "wireit",
"build:tsc": "wireit",
"build": "wireit",
"clean": "tsc --build --clean && rimraf lib",
"clean:test": "rimraf test/build",
"clean": "tsc -b --clean && rimraf lib && rimraf test/build",
"dev:test": "npm run test --watch",
"dev": "npm run build --watch",
"test": "wireit"
},
"wireit": {
"copy": {
"clean": "if-file-deleted",
"command": "node copySchemaFiles.js",
"build": {
"command": "node tools/copySchemaFiles.js",
"files": [
"src/**/files/**",
"src/**/*.json"
@ -24,29 +22,25 @@
"lib/**/*.json"
],
"dependencies": [
"clean"
"build:tsc"
]
},
"build": {
"build:tsc": {
"command": "tsc -b",
"clean": "if-file-deleted",
"files": [
"src/**/*.ts",
"!src/**/files",
"!src/**/*.json"
"**/tsconfig.*.json",
"**/tsconfig.json",
"src/**/*.ts"
],
"output": [
"lib/**",
"!lib/**/files",
"!lib/**/*.json"
],
"dependencies": [
"copy"
"lib/**/*.{ts,js}",
"lib/**/*.{ts,js}.map"
]
},
"test": {
"command": "mocha",
"dependencies": [
"clean:test",
"build"
]
}

View File

@ -15,7 +15,9 @@
*/
const fs = require('fs/promises');
const {join} = require('path');
const path = require('path');
/**
*
* @param {String} directory
@ -42,8 +44,8 @@ async function findSchemaFiles(directory, files = []) {
}
async function copySchemaFiles() {
const srcDir = './src';
const outputDir = './lib';
const srcDir = join(__dirname, '..', 'src');
const outputDir = join(__dirname, '..', 'lib');
const files = await findSchemaFiles(srcDir);
const moves = files.map(file => {

View File

@ -44,8 +44,7 @@
"generate:package-json": "wireit",
"generate:sources": "wireit",
"prepack": "wireit",
"clean": "tsc -b --clean && rimraf lib src/generated",
"clean:third_party": "wireit"
"clean": "tsc -b --clean && rimraf lib src/generated"
},
"wireit": {
"prepack": {
@ -67,25 +66,25 @@
},
"generate:sources": {
"command": "tsx tools/generate_sources.ts",
"clean": "if-file-deleted",
"files": [
"tools/generate_sources.ts",
"src/templates/**"
"../../versions.js",
"src/injected/**",
"src/templates/**",
"tools/generate_sources.ts"
],
"output": [
"src/generated/**"
"src/generated/*.ts"
]
},
"clean:third_party": {
"command": "rimraf lib/esm/third_party lib/cjs/third_party"
},
"build:third_party": {
"command": "rollup --config rollup.third_party.config.mjs",
"dependencies": [
"build:tsc"
],
"clean": false,
"files": [
"third_party/**"
".wireit/third_party/**",
"rollup.third_party.config.mjs"
],
"output": [
"lib/esm/third_party/**",
@ -94,20 +93,18 @@
},
"generate:package-json": {
"command": "tsx ../../tools/generate_module_package_json.ts lib/esm/package.json",
"clean": "if-file-deleted",
"dependencies": [
"build:tsc"
],
"files": [
"../../tools/generate_module_package_json.ts"
],
"output": [
"lib/esm/package.json"
]
},
"build:types": {
"command": "api-extractor run --local",
"dependencies": [
"build:tsc",
"build:third_party"
],
"files": [
"tsconfig.json",
"api-extractor.json",
@ -115,10 +112,19 @@
],
"output": [
"lib/types.d.ts"
],
"dependencies": [
"build:tsc",
"build:third_party"
]
},
"build:docs": {
"command": "api-extractor run --local --config \"./api-extractor.docs.json\"",
"files": [
"tsconfig.json",
"api-extractor.docs.json",
"lib/esm/puppeteer/puppeteer-core.d.ts"
],
"dependencies": [
"build:tsc"
]
@ -141,18 +147,21 @@
"command": "tsc -b",
"clean": "if-file-deleted",
"dependencies": [
"clean:third_party",
"generate:sources"
],
"files": [
"src/**",
"compat/**",
"third_party/**",
"**/tsconfig.*.json"
"**/tsconfig.*.json",
"**/tsconfig.json",
"compat/**/*.ts",
"src/**/*.ts",
"third_party/**/*.ts"
],
"output": [
"lib/esm/**",
"lib/cjs/**"
".wireit/third_party/**/*.{ts,js}",
"lib/{cjs,esm}/**/*.{ts,js}",
".wireit/third_party/**/*.{ts,js}.map",
"lib/{cjs,esm}/**/*.{ts,js}.map",
"!lib/{cjs,esm}/third_party"
]
}
},

View File

@ -16,17 +16,46 @@
import glob from 'glob';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import {dirname, join, relative} from 'path';
export default ['cjs', 'esm'].flatMap(outputType => {
const configs = [];
// Note we don't use path.join here. We cannot since `glob` does not support
// the backslash path separator.
const thirdPartyPath = `lib/${outputType}/third_party`;
for (const jsFile of glob.sync(`${thirdPartyPath}/**/*.js`)) {
const sourcePath = `.wireit/third_party/${outputType}/`;
for (const file of glob.sync(`${sourcePath}**/*.js`)) {
const typesFile = `${file.slice(0, -3)}.d.ts`;
configs.push({
input: jsFile,
output: {file: jsFile, format: outputType, dynamicImportInCjs: false},
plugins: [commonjs(), nodeResolve()],
input: file,
output: {
file: join(
'lib',
outputType,
'third_party',
relative(sourcePath, file)
),
format: outputType,
},
plugins: [
commonjs(),
nodeResolve(),
copy({
targets: [
{
src: typesFile,
dest: dirname(
join(
'lib',
outputType,
'third_party',
relative(sourcePath, typesFile)
)
),
},
],
}),
],
});
}
return configs;

View File

@ -2,4 +2,4 @@
This folder contains code that is injected into every Puppeteer execution context. Each file is transpiled using esbuild into a script in `src/generated` which is then imported into server code.
See `tools/generate_injected.ts` for more information.
See `tools/generate_sources.ts` for more information.

View File

@ -2,7 +2,7 @@
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"declarationMap": false,
"outDir": "../lib/cjs/third_party",
"outDir": "../.wireit/third_party/cjs",
"sourceMap": false
}
}

View File

@ -2,7 +2,7 @@
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"declarationMap": false,
"outDir": "../lib/esm/third_party",
"outDir": "../.wireit/third_party/esm",
"sourceMap": false
}
}

View File

@ -63,10 +63,12 @@
},
"generate:package-json": {
"command": "tsx ../../tools/generate_module_package_json.ts lib/esm/package.json",
"clean": "if-file-deleted",
"dependencies": [
"build:tsc"
],
"files": [
"../../tools/generate_module_package_json.ts"
],
"output": [
"lib/esm/package.json"
]
@ -112,9 +114,9 @@
"../puppeteer-core:build"
],
"files": [
"src/**",
"compat/**",
"**/tsconfig.*.json"
"**/tsconfig.*.json",
"**/tsconfig.json",
"src/**"
],
"output": [
"lib/**"