1f5e333f00
* chore: Don't store revisions in `package.json` It's quite messy to have to require the `package.json` file in multiple places purely to find out what revision of a given browser we want to use. We can also achieve better type safety by placing it in an actual source file. This commit makes that change and also tidies up our reliance on `package.json` within the source code generally; we now only use it to find the location of the Puppeteer root such that we know where to install downloaded browsers to. To avoid using `package.json` to parse the name of the module, we also now explicitly have an entry point for the Puppeteer module and the Puppeter Core module. This will make it easier in the future to ship less code as part of core (e.g. core never needs to download a browser, so why ship that code?). Core can also then not have any revisions based info contained in it. The test install script has also been updated to ensure that puppeteer-core can be installed correctly too. Finally, the `install` script has been moved to TypeScript for nicer typechecking and safety. The functionality of it has not changed.
42 lines
1.3 KiB
Bash
Executable File
42 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
set -e
|
|
|
|
ROOTDIR="$(pwd)"
|
|
# Pack the module into a tarball
|
|
npm pack
|
|
tarball="$(realpath puppeteer-*.tgz)"
|
|
TMPDIR="$(mktemp -d)"
|
|
cd $TMPDIR
|
|
# Check we can install from the tarball.
|
|
# This emulates installing from npm and ensures that:
|
|
# 1. we publish the right files in the `files` list from package.json
|
|
# 2. The install script works and correctly exits without errors
|
|
# 3. Requiring Puppeteer from Node works.
|
|
npm install --loglevel silent "${tarball}"
|
|
node --eval="require('puppeteer')"
|
|
ls $TMPDIR/node_modules/puppeteer/.local-chromium/
|
|
|
|
# Again for Firefox
|
|
TMPDIR="$(mktemp -d)"
|
|
cd $TMPDIR
|
|
PUPPETEER_PRODUCT=firefox npm install --loglevel silent "${tarball}"
|
|
node --eval="require('puppeteer')"
|
|
rm "${tarball}"
|
|
ls $TMPDIR/node_modules/puppeteer/.local-firefox/linux-79.0a1/firefox/firefox
|
|
|
|
# Again for puppeteer-core
|
|
cd $ROOTDIR
|
|
node ./utils/prepare_puppeteer_core.js
|
|
npm pack
|
|
tarball="$(realpath puppeteer-core-*.tgz)"
|
|
TMPDIR="$(mktemp -d)"
|
|
cd $TMPDIR
|
|
# Check we can install from the tarball.
|
|
# This emulates installing from npm and ensures that:
|
|
# 1. we publish the right files in the `files` list from package.json
|
|
# 2. The install script works and correctly exits without errors
|
|
# 3. Requiring Puppeteer Core from Node works.
|
|
npm install --loglevel silent "${tarball}"
|
|
node --eval="require('puppeteer-core')"
|
|
|