Skip to content

Commit a0777eb

Browse files
authored
chore: npm release should only include production assets (#1794)
* chore: Excluded non-production assets from released npm package * test: Use npm-pack for running functional test on npm package installed as in production mode
1 parent e3aa788 commit a0777eb

File tree

4 files changed

+15
-25
lines changed

4 files changed

+15
-25
lines changed

.npmignore

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
# OSX
2-
.DS_Store
3-
4-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
5-
.grunt
6-
.cache
7-
8-
# Build artifacts.
9-
npm-debug.log
10-
dist/tests.js*
11-
artifacts/*
12-
coverage/*
1+
# The files to be included in the npm package are listed in the package.json file,
2+
# in the `files` property (See https://docs.npmjs.com/files/package.json#files).

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"version": "3.2.0",
44
"description": "A command line tool to help build, run, and test web extensions",
55
"main": "dist/web-ext.js",
6+
"files": [
7+
"CODE_OF_CONDUCT.md",
8+
"dist/*.js",
9+
"src/**"
10+
],
611
"engines": {
712
"node": ">=10.0.0",
813
"npm": ">=5.6.0"

scripts/lib/config.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
module.exports = {
22
clean: ['dist/*'],
3-
copy: {
4-
productionModeAssets: {
5-
src: [
6-
'package.json',
7-
'package-lock.json',
8-
'dist/**',
9-
'bin/**',
10-
],
11-
},
12-
},
133
watch: {
144
files: [
155
'package.json',

scripts/test-functional

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ const path = require('path');
55
const shell = require('shelljs');
66
const tmp = require('tmp');
77

8-
const config = require('./lib/config');
8+
const pkg = require('../package.json');
99
const {mochaFunctional} = require('./lib/mocha');
1010

1111
shell.set('-e');
1212

13+
const packageFileName = `${pkg.name}-${pkg.version}.tgz`;
1314
const testProductionMode = process.env.TEST_PRODUCTION_MODE === '1';
1415
const testLegacyBundling = process.env.TEST_LEGACY_BUNDLING === '1';
1516

@@ -23,6 +24,7 @@ shell.exec('npm run build', testProductionMode ? {
2324
} : {});
2425

2526
if (testProductionMode) {
27+
const srcDir = process.cwd();
2628
const destDir = tmp.tmpNameSync();
2729
const packageDir = tmp.tmpNameSync();
2830
const npmInstallOptions = ['--production'];
@@ -42,9 +44,12 @@ if (testProductionMode) {
4244
shell.echo('\nPreparing web-ext production mode environment...\n');
4345
shell.rm('-rf', destDir, packageDir);
4446
shell.mkdir('-p', destDir, packageDir);
45-
shell.cp('-rf', config.copy.productionModeAssets.src, packageDir);
47+
shell.pushd(packageDir);
48+
shell.exec(`npm pack ${srcDir}`);
49+
shell.popd();
4650
shell.pushd(destDir);
47-
shell.exec(`npm install ${npmInstallOptions.join(' ')} ${packageDir}`);
51+
const pkgPath = path.join(packageDir, packageFileName);
52+
shell.exec(`npm install ${npmInstallOptions.join(' ')} ${pkgPath}`);
4853
shell.popd();
4954
shell.echo('\nProduction mode environment successfully created.\n');
5055
}

0 commit comments

Comments
 (0)