Commit 1307e466 authored by Robert Knight's avatar Robert Knight

Update deploy-to-s3.js script for npm-packlist v7

Update the code for listing the files that would go into the npm package.
npm-packlist v7 removed the internal logic for using Arborist and instead
requires the caller to do this instead. The new code follows the current example
in the npm-packlist README [1].

This unfortunately means adding an extra dependency. An alternative approach
would be to invoke `npm package` to generate a tarball, then unpack that tarball
somewhere and read its contents using file system APIs.

[1] https://github.com/npm/npm-packlist#npm-packlist
parent 8afc17ce
......@@ -13,6 +13,7 @@
"@babel/preset-typescript": "^7.16.7",
"@hypothesis/frontend-build": "1.2.0",
"@hypothesis/frontend-shared": "5.4.2",
"@npmcli/arborist": "^5.6.2",
"@octokit/rest": "^19.0.3",
"@rollup/plugin-babel": "^6.0.0",
"@rollup/plugin-commonjs": "^23.0.0",
......
......@@ -6,6 +6,7 @@ const fs = require('fs');
const { extname } = require('path');
const commander = require('commander');
const Arborist = require('@npmcli/arborist');
const packlist = require('npm-packlist');
const AWS = require('aws-sdk');
......@@ -99,7 +100,9 @@ class S3Uploader {
async function uploadPackageToS3(bucket, options) {
// Get list of files that are distributed with the package, respecting
// the `files` field in `package.json`, `.npmignore` etc.
const files = await packlist({ path: '.' });
const arb = new Arborist({ path: '.' });
const tree = await arb.loadActual();
const files = await packlist(tree);
// Get name, version and main module of the package.
const packageJson = require(`${process.cwd()}/package.json`);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment