mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: use jobs for artifact generation (#8864)
This commit is contained in:
parent
292216652b
commit
eb6cea4f57
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@ -68,10 +68,15 @@ jobs:
|
|||||||
run: npm run docs
|
run: npm run docs
|
||||||
- name: Check if autogenerated docs differ
|
- name: Check if autogenerated docs differ
|
||||||
run: |
|
run: |
|
||||||
if [[ $(git diff) ]]; then
|
diff_file=$(mktemp doc_diff_XXXXXX)
|
||||||
echo "Please update the documentation by running 'npm run docs'"
|
git diff --color > $diff_file
|
||||||
|
if [[ -s $diff_file ]]; then
|
||||||
|
echo "Please update the documentation by running 'npm run docs'. The following was the diff"
|
||||||
|
cat $diff_file
|
||||||
|
rm $diff_file
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
rm $diff_file
|
||||||
- name: Check if docs need to be deployed
|
- name: Check if docs need to be deployed
|
||||||
id: needs_deploying
|
id: needs_deploying
|
||||||
run: |
|
run: |
|
||||||
@ -165,7 +170,7 @@ jobs:
|
|||||||
if: ${{ matrix.spec.name == 'Linux' }}
|
if: ${{ matrix.spec.name == 'Linux' }}
|
||||||
run: sudo apt-get install xvfb
|
run: sudo apt-get install xvfb
|
||||||
- name: Build
|
- name: Build
|
||||||
run: npm run build
|
run: npm run build:ci
|
||||||
- name: Test types
|
- name: Test types
|
||||||
run: npm run test:types
|
run: npm run test:types
|
||||||
# On Linux we run all Chrome tests without retries and Firefox tests with retries.
|
# On Linux we run all Chrome tests without retries and Firefox tests with retries.
|
||||||
@ -215,7 +220,7 @@ jobs:
|
|||||||
ls .local-chromium
|
ls .local-chromium
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
npm run build
|
npm run build:ci
|
||||||
docker/pack.sh
|
docker/pack.sh
|
||||||
- name: Build docker image
|
- name: Build docker image
|
||||||
working-directory: ./docker
|
working-directory: ./docker
|
||||||
|
216
package-lock.json
generated
216
package-lock.json
generated
@ -30,6 +30,7 @@
|
|||||||
"@microsoft/api-extractor-model": "7.23.0",
|
"@microsoft/api-extractor-model": "7.23.0",
|
||||||
"@types/debug": "4.1.7",
|
"@types/debug": "4.1.7",
|
||||||
"@types/diff": "5.0.2",
|
"@types/diff": "5.0.2",
|
||||||
|
"@types/glob": "7.2.0",
|
||||||
"@types/mime": "3.0.1",
|
"@types/mime": "3.0.1",
|
||||||
"@types/mocha": "9.1.1",
|
"@types/mocha": "9.1.1",
|
||||||
"@types/node": "18.7.1",
|
"@types/node": "18.7.1",
|
||||||
@ -61,6 +62,7 @@
|
|||||||
"eslint-plugin-unused-imports": "2.0.0",
|
"eslint-plugin-unused-imports": "2.0.0",
|
||||||
"esprima": "4.0.1",
|
"esprima": "4.0.1",
|
||||||
"expect": "25.2.7",
|
"expect": "25.2.7",
|
||||||
|
"glob": "8.0.3",
|
||||||
"gts": "4.0.0",
|
"gts": "4.0.0",
|
||||||
"husky": "8.0.1",
|
"husky": "8.0.1",
|
||||||
"jpeg-js": "0.4.4",
|
"jpeg-js": "0.4.4",
|
||||||
@ -4088,19 +4090,19 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/glob": {
|
"node_modules/glob": {
|
||||||
"version": "7.2.0",
|
"version": "8.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
|
||||||
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
"integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
|
||||||
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs.realpath": "^1.0.0",
|
"fs.realpath": "^1.0.0",
|
||||||
"inflight": "^1.0.4",
|
"inflight": "^1.0.4",
|
||||||
"inherits": "2",
|
"inherits": "2",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^5.0.1",
|
||||||
"once": "^1.3.0",
|
"once": "^1.3.0"
|
||||||
"path-is-absolute": "^1.0.0"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "*"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
@ -4118,6 +4120,27 @@
|
|||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/glob/node_modules/brace-expansion": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"balanced-match": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/glob/node_modules/minimatch": {
|
||||||
|
"version": "5.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
|
||||||
|
"integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/global-dirs": {
|
"node_modules/global-dirs": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz",
|
||||||
@ -5474,6 +5497,48 @@
|
|||||||
"node": ">=0.3.1"
|
"node": ">=0.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/mocha/node_modules/glob": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"fs.realpath": "^1.0.0",
|
||||||
|
"inflight": "^1.0.4",
|
||||||
|
"inherits": "2",
|
||||||
|
"minimatch": "^3.0.4",
|
||||||
|
"once": "^1.3.0",
|
||||||
|
"path-is-absolute": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "*"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mocha/node_modules/glob/node_modules/brace-expansion": {
|
||||||
|
"version": "1.1.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||||
|
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"balanced-match": "^1.0.0",
|
||||||
|
"concat-map": "0.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mocha/node_modules/glob/node_modules/minimatch": {
|
||||||
|
"version": "3.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": "^1.1.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mocha/node_modules/js-yaml": {
|
"node_modules/mocha/node_modules/js-yaml": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||||
@ -6614,6 +6679,25 @@
|
|||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/rimraf/node_modules/glob": {
|
||||||
|
"version": "7.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||||
|
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
||||||
|
"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/run-async": {
|
"node_modules/run-async": {
|
||||||
"version": "2.4.1",
|
"version": "2.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz",
|
||||||
@ -7087,6 +7171,26 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/test-exclude/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/text-diff": {
|
"node_modules/text-diff": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/text-diff/-/text-diff-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/text-diff/-/text-diff-1.0.1.tgz",
|
||||||
@ -10655,16 +10759,36 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"glob": {
|
"glob": {
|
||||||
"version": "7.2.0",
|
"version": "8.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
|
||||||
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
"integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"fs.realpath": "^1.0.0",
|
"fs.realpath": "^1.0.0",
|
||||||
"inflight": "^1.0.4",
|
"inflight": "^1.0.4",
|
||||||
"inherits": "2",
|
"inherits": "2",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^5.0.1",
|
||||||
"once": "^1.3.0",
|
"once": "^1.3.0"
|
||||||
"path-is-absolute": "^1.0.0"
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"balanced-match": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimatch": {
|
||||||
|
"version": "5.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
|
||||||
|
"integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"brace-expansion": "^2.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"glob-parent": {
|
"glob-parent": {
|
||||||
@ -11670,6 +11794,41 @@
|
|||||||
"integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
|
"integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"glob": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"fs.realpath": "^1.0.0",
|
||||||
|
"inflight": "^1.0.4",
|
||||||
|
"inherits": "2",
|
||||||
|
"minimatch": "^3.0.4",
|
||||||
|
"once": "^1.3.0",
|
||||||
|
"path-is-absolute": "^1.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": {
|
||||||
|
"version": "1.1.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||||
|
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"balanced-match": "^1.0.0",
|
||||||
|
"concat-map": "0.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimatch": {
|
||||||
|
"version": "3.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"brace-expansion": "^1.1.7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"js-yaml": {
|
"js-yaml": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||||
@ -12501,6 +12660,21 @@
|
|||||||
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
|
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"glob": "^7.1.3"
|
"glob": "^7.1.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"glob": {
|
||||||
|
"version": "7.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||||
|
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"run-async": {
|
"run-async": {
|
||||||
@ -12859,6 +13033,22 @@
|
|||||||
"@istanbuljs/schema": "^0.1.2",
|
"@istanbuljs/schema": "^0.1.2",
|
||||||
"glob": "^7.1.4",
|
"glob": "^7.1.4",
|
||||||
"minimatch": "^3.0.4"
|
"minimatch": "^3.0.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"text-diff": {
|
"text-diff": {
|
||||||
|
20
package.json
20
package.json
@ -42,24 +42,24 @@
|
|||||||
"lint:eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet -f codeframe . || eslint --ext js --ext ts .)",
|
"lint:eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet -f codeframe . || eslint --ext js --ext ts .)",
|
||||||
"install": "node install.js",
|
"install": "node install.js",
|
||||||
"generate:sources": "tsx utils/generate_sources.ts",
|
"generate:sources": "tsx utils/generate_sources.ts",
|
||||||
"generate:types": "node utils/export_all.js && api-extractor run --local --verbose && eslint --ext ts --no-ignore --no-eslintrc -c .eslintrc.types.cjs --fix lib/types.d.ts",
|
"generate:artifacts": "tsx utils/generate_artifacts.ts",
|
||||||
"generate:markdown": "tsx utils/generate_docs.ts && prettier --ignore-path none --write docs",
|
"generate:markdown": "tsx utils/generate_docs.ts",
|
||||||
"generate:esm-package-json": "echo '{\"type\": \"module\"}' > lib/esm/package.json",
|
|
||||||
"format": "run-s format:*",
|
"format": "run-s format:*",
|
||||||
"format:prettier": "prettier --write .",
|
"format:prettier": "prettier --write .",
|
||||||
"format:eslint": "eslint --ext js --ext ts --fix .",
|
"format:eslint": "eslint --ext js --ext ts --fix .",
|
||||||
"docs": "run-s build generate:markdown",
|
"docs": "run-s build generate:markdown",
|
||||||
"debug": "npm run build && mocha --inspect-brk",
|
"debug": "npm run build:test && mocha --inspect-brk",
|
||||||
"commitlint": "commitlint --from=HEAD~1",
|
"commitlint": "commitlint --from=HEAD~1",
|
||||||
"clean": "rimraf lib && rimraf test/build",
|
"clean": "rimraf lib && rimraf test/build",
|
||||||
"check": "run-p check:*",
|
"check": "run-p check:*",
|
||||||
"check:protocol-revision": "tsx scripts/ensure-correct-devtools-protocol-package",
|
"check:protocol-revision": "tsx scripts/ensure-correct-devtools-protocol-package",
|
||||||
"check:pinned-deps": "tsx scripts/ensure-pinned-deps",
|
"check:pinned-deps": "tsx scripts/ensure-pinned-deps",
|
||||||
"build": "run-s generate:sources build:tsc generate:types generate:esm-package-json",
|
"build": "npm run build:lib",
|
||||||
"build:tsc": "tsc --version && run-p build:tsc:*",
|
"build:test": "run-s generate:sources build:tsc:test",
|
||||||
"build:tsc:esm": "tsc -b src/tsconfig.esm.json",
|
"build:ci": "run-s build:test generate:artifacts",
|
||||||
"build:tsc:cjs": "tsc -b src/tsconfig.cjs.json",
|
"build:lib": "run-s generate:sources build:tsc:lib generate:artifacts",
|
||||||
"build:tsc:test": "tsc -b test"
|
"build:tsc:test": "tsc -b test",
|
||||||
|
"build:tsc:lib": "tsc -b tsconfig.lib.json"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib",
|
"lib",
|
||||||
@ -90,6 +90,7 @@
|
|||||||
"@microsoft/api-extractor-model": "7.23.0",
|
"@microsoft/api-extractor-model": "7.23.0",
|
||||||
"@types/debug": "4.1.7",
|
"@types/debug": "4.1.7",
|
||||||
"@types/diff": "5.0.2",
|
"@types/diff": "5.0.2",
|
||||||
|
"@types/glob": "7.2.0",
|
||||||
"@types/mime": "3.0.1",
|
"@types/mime": "3.0.1",
|
||||||
"@types/mocha": "9.1.1",
|
"@types/mocha": "9.1.1",
|
||||||
"@types/node": "18.7.1",
|
"@types/node": "18.7.1",
|
||||||
@ -121,6 +122,7 @@
|
|||||||
"eslint-plugin-unused-imports": "2.0.0",
|
"eslint-plugin-unused-imports": "2.0.0",
|
||||||
"esprima": "4.0.1",
|
"esprima": "4.0.1",
|
||||||
"expect": "25.2.7",
|
"expect": "25.2.7",
|
||||||
|
"glob": "8.0.3",
|
||||||
"gts": "4.0.0",
|
"gts": "4.0.0",
|
||||||
"husky": "8.0.1",
|
"husky": "8.0.1",
|
||||||
"jpeg-js": "0.4.4",
|
"jpeg-js": "0.4.4",
|
||||||
|
@ -8,5 +8,6 @@
|
|||||||
"references": [
|
"references": [
|
||||||
{"path": "../vendor/tsconfig.cjs.json"},
|
{"path": "../vendor/tsconfig.cjs.json"},
|
||||||
{"path": "../compat/cjs/tsconfig.json"}
|
{"path": "../compat/cjs/tsconfig.json"}
|
||||||
]
|
],
|
||||||
|
"exclude": ["injected/injected.ts"]
|
||||||
}
|
}
|
||||||
|
38
src/types.ts
38
src/types.ts
@ -1,13 +1,5 @@
|
|||||||
// AUTOGENERATED - Use `utils/export_all.js` to regenerate.
|
// AUTOGENERATED - Use `npm run generate:sources` to regenerate.
|
||||||
|
|
||||||
export * from './compat.d.js';
|
|
||||||
export * from './constants.js';
|
|
||||||
export * from './environment.js';
|
|
||||||
export * from './initializePuppeteer.js';
|
|
||||||
export * from './puppeteer.js';
|
|
||||||
export * from './revisions.js';
|
|
||||||
|
|
||||||
// Exports from `common`
|
|
||||||
export * from './common/Accessibility.js';
|
export * from './common/Accessibility.js';
|
||||||
export * from './common/AriaQueryHandler.js';
|
export * from './common/AriaQueryHandler.js';
|
||||||
export * from './common/Browser.js';
|
export * from './common/Browser.js';
|
||||||
@ -26,6 +18,7 @@ export * from './common/EmulationManager.js';
|
|||||||
export * from './common/Errors.js';
|
export * from './common/Errors.js';
|
||||||
export * from './common/EventEmitter.js';
|
export * from './common/EventEmitter.js';
|
||||||
export * from './common/ExecutionContext.js';
|
export * from './common/ExecutionContext.js';
|
||||||
|
export * from './common/fetch.js';
|
||||||
export * from './common/FileChooser.js';
|
export * from './common/FileChooser.js';
|
||||||
export * from './common/FirefoxTargetManager.js';
|
export * from './common/FirefoxTargetManager.js';
|
||||||
export * from './common/Frame.js';
|
export * from './common/Frame.js';
|
||||||
@ -39,8 +32,8 @@ export * from './common/LifecycleWatcher.js';
|
|||||||
export * from './common/NetworkConditions.js';
|
export * from './common/NetworkConditions.js';
|
||||||
export * from './common/NetworkEventManager.js';
|
export * from './common/NetworkEventManager.js';
|
||||||
export * from './common/NetworkManager.js';
|
export * from './common/NetworkManager.js';
|
||||||
export * from './common/PDFOptions.js';
|
|
||||||
export * from './common/Page.js';
|
export * from './common/Page.js';
|
||||||
|
export * from './common/PDFOptions.js';
|
||||||
export * from './common/Product.js';
|
export * from './common/Product.js';
|
||||||
export * from './common/Puppeteer.js';
|
export * from './common/Puppeteer.js';
|
||||||
export * from './common/PuppeteerViewport.js';
|
export * from './common/PuppeteerViewport.js';
|
||||||
@ -51,25 +44,30 @@ export * from './common/TargetManager.js';
|
|||||||
export * from './common/TaskQueue.js';
|
export * from './common/TaskQueue.js';
|
||||||
export * from './common/TimeoutSettings.js';
|
export * from './common/TimeoutSettings.js';
|
||||||
export * from './common/Tracing.js';
|
export * from './common/Tracing.js';
|
||||||
export * from './common/USKeyboardLayout.js';
|
|
||||||
export * from './common/WebWorker.js';
|
|
||||||
export * from './common/fetch.js';
|
|
||||||
export * from './common/types.js';
|
export * from './common/types.js';
|
||||||
|
export * from './common/USKeyboardLayout.js';
|
||||||
export * from './common/util.js';
|
export * from './common/util.js';
|
||||||
|
export * from './common/WebWorker.js';
|
||||||
// Exports from `node`
|
export * from './compat.d.js';
|
||||||
|
export * from './constants.js';
|
||||||
|
export * from './environment.js';
|
||||||
|
export * from './generated/injected.js';
|
||||||
|
export * from './generated/version.js';
|
||||||
|
export * from './initializePuppeteer.js';
|
||||||
export * from './node/BrowserFetcher.js';
|
export * from './node/BrowserFetcher.js';
|
||||||
export * from './node/BrowserRunner.js';
|
export * from './node/BrowserRunner.js';
|
||||||
export * from './node/ChromeLauncher.js';
|
export * from './node/ChromeLauncher.js';
|
||||||
export * from './node/FirefoxLauncher.js';
|
export * from './node/FirefoxLauncher.js';
|
||||||
|
export * from './node/install.js';
|
||||||
export * from './node/LaunchOptions.js';
|
export * from './node/LaunchOptions.js';
|
||||||
export * from './node/NodeWebSocketTransport.js';
|
export * from './node/NodeWebSocketTransport.js';
|
||||||
export * from './node/PipeTransport.js';
|
export * from './node/PipeTransport.js';
|
||||||
export * from './node/ProductLauncher.js';
|
export * from './node/ProductLauncher.js';
|
||||||
export * from './node/Puppeteer.js';
|
export * from './node/Puppeteer.js';
|
||||||
export * from './node/install.js';
|
|
||||||
export * from './node/util.js';
|
export * from './node/util.js';
|
||||||
|
export * from './puppeteer.js';
|
||||||
// Exports from `generated`
|
export * from './revisions.js';
|
||||||
export * from './generated/injected.js';
|
export * from './util/assert.js';
|
||||||
export * from './generated/version.js';
|
export * from './util/DeferredPromise.js';
|
||||||
|
export * from './util/ErrorLike.js';
|
||||||
|
export * from './util/getPackageDirectory.js';
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import {existsSync} from 'fs';
|
import {existsSync} from 'fs';
|
||||||
import {dirname, join, parse} from 'path';
|
import {dirname, join, parse} from 'path';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
export const getPackageDirectory = (from: string): string => {
|
export const getPackageDirectory = (from: string): string => {
|
||||||
let found = existsSync(join(from, 'package.json'));
|
let found = existsSync(join(from, 'package.json'));
|
||||||
const root = parse(from).root;
|
const root = parse(from).root;
|
||||||
|
16
tsconfig.lib.json
Normal file
16
tsconfig.lib.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* This configuration only exists for the API Extractor tool and for VSCode to use. It is NOT the tsconfig used for compilation.
|
||||||
|
* For CJS builds, `tsconfig.cjs.json` is used, and for ESM, it's `tsconfig.esm.json`.
|
||||||
|
* See the details in CONTRIBUTING.md that describes our TypeScript setup.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
"extends": "./tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true
|
||||||
|
},
|
||||||
|
"references": [
|
||||||
|
{"path": "src/tsconfig.esm.json"},
|
||||||
|
{"path": "src/tsconfig.cjs.json"}
|
||||||
|
],
|
||||||
|
"exclude": ["**/*"]
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
const {readdirSync, writeFileSync} = require('fs');
|
|
||||||
const {join, basename} = require('path');
|
|
||||||
|
|
||||||
const EXCLUDE_FILES = ['puppeteer-core.ts'];
|
|
||||||
|
|
||||||
let typesTs = '// AUTOGENERATED - Use `utils/export_all.js` to regenerate.\n';
|
|
||||||
|
|
||||||
typesTs += `\n`;
|
|
||||||
for (const file of readdirSync(join(__dirname, `../src`)).filter(filename => {
|
|
||||||
return (
|
|
||||||
filename.endsWith('ts') &&
|
|
||||||
!filename.startsWith('types') &&
|
|
||||||
!EXCLUDE_FILES.includes(filename)
|
|
||||||
);
|
|
||||||
})) {
|
|
||||||
typesTs += `export * from './${basename(file, '.ts')}.js';\n`;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const folder of ['common', 'node', 'generated']) {
|
|
||||||
typesTs += `\n// Exports from \`${folder}\`\n`;
|
|
||||||
for (const file of readdirSync(join(__dirname, `../src/${folder}`)).filter(
|
|
||||||
filename => {
|
|
||||||
return filename.endsWith('ts') && !EXCLUDE_FILES.includes(filename);
|
|
||||||
}
|
|
||||||
)) {
|
|
||||||
typesTs += `export * from './${folder}/${basename(file, '.ts')}.js';\n`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writeFileSync(join(__dirname, '../src/types.ts'), typesTs);
|
|
28
utils/generate_artifacts.ts
Normal file
28
utils/generate_artifacts.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import {writeFile} from 'fs/promises';
|
||||||
|
import {job} from './internal/job.js';
|
||||||
|
import {spawnAndLog} from './internal/util.js';
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
job('', async ({outputs}) => {
|
||||||
|
await writeFile(outputs[0]!, '{"type": "module"}');
|
||||||
|
})
|
||||||
|
.outputs(['lib/esm/package.json'])
|
||||||
|
.build();
|
||||||
|
|
||||||
|
job('', async ({outputs}) => {
|
||||||
|
spawnAndLog('api-extractor', 'run', '--local');
|
||||||
|
spawnAndLog(
|
||||||
|
'eslint',
|
||||||
|
'--ext=ts',
|
||||||
|
'--no-ignore',
|
||||||
|
'--no-eslintrc',
|
||||||
|
'-c=.eslintrc.types.cjs',
|
||||||
|
'--fix',
|
||||||
|
outputs[0]!
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.inputs(['lib/esm/puppeteer/types.d.ts'])
|
||||||
|
.outputs(['lib/types.d.ts', 'puppeteer.api.json'])
|
||||||
|
.build();
|
||||||
|
})();
|
@ -14,11 +14,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {readFile, writeFile} from 'fs/promises';
|
import {readFile, rm, writeFile} from 'fs/promises';
|
||||||
import rimraf from 'rimraf';
|
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import {generateDocs} from './internal/custom_markdown_action.js';
|
import {generateDocs} from './internal/custom_markdown_action.js';
|
||||||
import {job} from './internal/job.js';
|
import {job} from './internal/job.js';
|
||||||
|
import {spawnAndLog} from './internal/util.js';
|
||||||
|
|
||||||
function getOffsetAndLimit(
|
function getOffsetAndLimit(
|
||||||
sectionName: string,
|
sectionName: string,
|
||||||
@ -46,7 +46,7 @@ function spliceIntoSection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
job('', async ({inputs, outputs}) => {
|
const job1 = job('', async ({inputs, outputs}) => {
|
||||||
const content = await readFile(inputs[0]!, 'utf-8');
|
const content = await readFile(inputs[0]!, 'utf-8');
|
||||||
const sectionContent = `
|
const sectionContent = `
|
||||||
---
|
---
|
||||||
@ -60,8 +60,8 @@ sidebar_position: 1
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Chrome Versions
|
// Chrome Versions
|
||||||
job('', async ({inputs, outputs}) => {
|
const job2 = job('', async ({inputs, outputs}) => {
|
||||||
let content = await readFile(outputs[0]!, {encoding: 'utf8'});
|
let content = await readFile(inputs[2]!, {encoding: 'utf8'});
|
||||||
const {versionsPerRelease} = await import(inputs[0]!);
|
const {versionsPerRelease} = await import(inputs[0]!);
|
||||||
const versionsArchived = JSON.parse(await readFile(inputs[1]!, 'utf8'));
|
const versionsArchived = JSON.parse(await readFile(inputs[1]!, 'utf8'));
|
||||||
|
|
||||||
@ -95,14 +95,21 @@ sidebar_position: 1
|
|||||||
|
|
||||||
await writeFile(outputs[0]!, content);
|
await writeFile(outputs[0]!, content);
|
||||||
})
|
})
|
||||||
.inputs(['versions.js', 'website/versionsArchived.json'])
|
.inputs([
|
||||||
|
'versions.js',
|
||||||
|
'website/versionsArchived.json',
|
||||||
|
'docs/chromium-support.md',
|
||||||
|
])
|
||||||
.outputs(['docs/chromium-support.md'])
|
.outputs(['docs/chromium-support.md'])
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
await Promise.all([job1, job2]);
|
||||||
|
|
||||||
// Generate documentation
|
// Generate documentation
|
||||||
job('', async ({inputs, outputs}) => {
|
job('', async ({inputs, outputs}) => {
|
||||||
rimraf.sync(outputs[0]!);
|
await rm(outputs[0]!, {recursive: true, force: true});
|
||||||
generateDocs(inputs[0]!, outputs[0]!);
|
generateDocs(inputs[0]!, outputs[0]!);
|
||||||
|
spawnAndLog('prettier', '--ignore-path', 'none', '--write', 'docs');
|
||||||
})
|
})
|
||||||
.inputs(['docs/puppeteer.api.json'])
|
.inputs(['docs/puppeteer.api.json'])
|
||||||
.outputs(['docs/api'])
|
.outputs(['docs/api'])
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
import {createHash} from 'crypto';
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import {mkdir, mkdtemp, readFile, writeFile} from 'fs/promises';
|
import {mkdir, mkdtemp, readFile, rm, writeFile} from 'fs/promises';
|
||||||
|
import {sync as glob} from 'glob';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import rimraf from 'rimraf';
|
|
||||||
import {job} from './internal/job.js';
|
import {job} from './internal/job.js';
|
||||||
|
|
||||||
|
const INCLUDED_FOLDERS = ['common', 'node', 'generated', 'util'];
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await job('', async ({outputs}) => {
|
await job('', async ({outputs}) => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
@ -45,12 +48,35 @@ import {job} from './internal/job.js';
|
|||||||
JSON.stringify(content)
|
JSON.stringify(content)
|
||||||
);
|
);
|
||||||
await writeFile(outputs[0]!, scriptContent);
|
await writeFile(outputs[0]!, scriptContent);
|
||||||
rimraf.sync(tmp);
|
await rm(tmp, {recursive: true, force: true});
|
||||||
})
|
})
|
||||||
.inputs(['src/templates/injected.ts.tmpl', 'src/injected/**.ts'])
|
.inputs(['src/templates/injected.ts.tmpl', 'src/injected/**/*.ts'])
|
||||||
.outputs(['src/generated/injected.ts'])
|
.outputs(['src/generated/injected.ts'])
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
const sources = glob(
|
||||||
|
`src/{@(${INCLUDED_FOLDERS.join('|')})/*.ts,!(types|puppeteer-core).ts}`
|
||||||
|
);
|
||||||
|
await job('', async ({outputs}) => {
|
||||||
|
let types =
|
||||||
|
'// AUTOGENERATED - Use `npm run generate:sources` to regenerate.\n\n';
|
||||||
|
for (const input of sources.map(source => {
|
||||||
|
return `.${source.slice(3)}`;
|
||||||
|
})) {
|
||||||
|
types += `export * from '${input.replace('.ts', '.js')}';\n`;
|
||||||
|
}
|
||||||
|
await writeFile(outputs[0]!, types);
|
||||||
|
})
|
||||||
|
.value(
|
||||||
|
sources
|
||||||
|
.reduce((hmac, value) => {
|
||||||
|
return hmac.update(value);
|
||||||
|
}, createHash('sha256'))
|
||||||
|
.digest('hex')
|
||||||
|
)
|
||||||
|
.outputs(['src/types.ts'])
|
||||||
|
.build();
|
||||||
|
|
||||||
job('', async ({inputs, outputs}) => {
|
job('', async ({inputs, outputs}) => {
|
||||||
const version = JSON.parse(await readFile(inputs[0]!, 'utf8')).version;
|
const version = JSON.parse(await readFile(inputs[0]!, 'utf8')).version;
|
||||||
await writeFile(
|
await writeFile(
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import {Stats} from 'fs';
|
import {createHash} from 'crypto';
|
||||||
import {stat} from 'fs/promises';
|
import {existsSync, Stats} from 'fs';
|
||||||
|
import {mkdir, readFile, stat, writeFile} from 'fs/promises';
|
||||||
import {glob} from 'glob';
|
import {glob} from 'glob';
|
||||||
import path from 'path';
|
import {tmpdir} from 'os';
|
||||||
|
import {dirname, join, resolve} from 'path';
|
||||||
|
import {chdir} from 'process';
|
||||||
|
|
||||||
|
const packageRoot = resolve(join(__dirname, '..', '..'));
|
||||||
|
chdir(packageRoot);
|
||||||
|
|
||||||
interface JobContext {
|
interface JobContext {
|
||||||
name: string;
|
name: string;
|
||||||
@ -14,61 +20,120 @@ class JobBuilder {
|
|||||||
#outputs: string[] = [];
|
#outputs: string[] = [];
|
||||||
#callback: (ctx: JobContext) => Promise<void>;
|
#callback: (ctx: JobContext) => Promise<void>;
|
||||||
#name: string;
|
#name: string;
|
||||||
|
#value = '';
|
||||||
|
#force = false;
|
||||||
|
|
||||||
constructor(name: string, callback: (ctx: JobContext) => Promise<void>) {
|
constructor(name: string, callback: (ctx: JobContext) => Promise<void>) {
|
||||||
this.#name = name;
|
this.#name = name;
|
||||||
this.#callback = callback;
|
this.#callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get jobHash(): string {
|
||||||
|
return createHash('sha256').update(this.#name).digest('hex');
|
||||||
|
}
|
||||||
|
|
||||||
|
force() {
|
||||||
|
this.#force = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
value(value: string) {
|
||||||
|
this.#value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
inputs(inputs: string[]): JobBuilder {
|
inputs(inputs: string[]): JobBuilder {
|
||||||
this.#inputs = inputs.flatMap(value => {
|
this.#inputs = inputs.flatMap(value => {
|
||||||
value = path.resolve(__dirname, '..', '..', value);
|
if (glob.hasMagic(value)) {
|
||||||
const paths = glob.sync(value);
|
return glob.sync(value).map(value => {
|
||||||
return paths.length ? paths : [value];
|
// Glob doesn't support `\` on Windows, so we join here.
|
||||||
|
return join(packageRoot, value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return join(packageRoot, value);
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputs(outputs: string[]): JobBuilder {
|
outputs(outputs: string[]): JobBuilder {
|
||||||
if (!this.#name) {
|
if (!this.#name) {
|
||||||
this.#name = outputs[0]!;
|
this.#name = outputs.join(' and ');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#outputs = outputs.map(value => {
|
this.#outputs = outputs.map(value => {
|
||||||
return path.resolve(__dirname, '..', '..', value);
|
return join(packageRoot, value);
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
async build(): Promise<void> {
|
async build(): Promise<void> {
|
||||||
console.log(`Running job ${this.#name}...`);
|
console.log(`Running job ${this.#name}...`);
|
||||||
|
// For debugging.
|
||||||
|
if (this.#force) {
|
||||||
|
return this.#run();
|
||||||
|
}
|
||||||
|
// In case we deleted an output file on purpose.
|
||||||
|
if (!this.getOutputStats()) {
|
||||||
|
return this.#run();
|
||||||
|
}
|
||||||
|
// Run if the job has a value, but it changes.
|
||||||
|
if (this.#value) {
|
||||||
|
if (!(await this.isValueDifferent())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.#run();
|
||||||
|
}
|
||||||
|
// Always run when there is no output.
|
||||||
|
if (!this.#outputs.length) {
|
||||||
|
return this.#run();
|
||||||
|
}
|
||||||
|
// Make-like comparator.
|
||||||
|
if (!(await this.areInputsNewer())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.#run();
|
||||||
|
}
|
||||||
|
|
||||||
let shouldRun = true;
|
async isValueDifferent(): Promise<boolean> {
|
||||||
|
const file = join(tmpdir(), `puppeteer/${this.jobHash}.txt`);
|
||||||
|
await mkdir(dirname(file), {recursive: true});
|
||||||
|
if (!existsSync(file)) {
|
||||||
|
await writeFile(file, this.#value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return this.#value !== (await readFile(file, 'utf8'));
|
||||||
|
}
|
||||||
|
|
||||||
|
#outputStats?: Stats[];
|
||||||
|
async getOutputStats(): Promise<Stats[] | undefined> {
|
||||||
|
if (this.#outputStats) {
|
||||||
|
return this.#outputStats;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.#outputStats = await Promise.all(
|
||||||
|
this.#outputs.map(output => {
|
||||||
|
return stat(output);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} catch {}
|
||||||
|
return this.#outputStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
async areInputsNewer(): Promise<boolean> {
|
||||||
const inputStats = await Promise.all(
|
const inputStats = await Promise.all(
|
||||||
this.#inputs.map(input => {
|
this.#inputs.map(input => {
|
||||||
return stat(input);
|
return stat(input);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
let outputStats: Stats[];
|
const outputStats = await this.getOutputStats();
|
||||||
try {
|
if (
|
||||||
outputStats = await Promise.all(
|
outputStats &&
|
||||||
this.#outputs.map(output => {
|
outputStats.reduce(reduceMinTime, Infinity) >
|
||||||
return stat(output);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
outputStats.reduce(reduceMinTime, Infinity) >
|
|
||||||
inputStats.reduce(reduceMaxTime, 0)
|
inputStats.reduce(reduceMaxTime, 0)
|
||||||
) {
|
) {
|
||||||
shouldRun = false;
|
return false;
|
||||||
}
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
if (shouldRun) {
|
|
||||||
this.#run();
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#run(): Promise<void> {
|
#run(): Promise<void> {
|
||||||
|
14
utils/internal/util.ts
Normal file
14
utils/internal/util.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import {spawnSync} from 'child_process';
|
||||||
|
|
||||||
|
export const spawnAndLog = (...args: string[]): void => {
|
||||||
|
const {stdout, stderr} = spawnSync(args[0]!, args.slice(1), {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
shell: true,
|
||||||
|
});
|
||||||
|
if (stdout) {
|
||||||
|
console.log(stdout);
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
console.error(stderr);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user