Skip to content

Commit 1deb457

Browse files
authored
Add diff-tarball script and more explicit files property in package.json (#9550)
* More explicit files property in package.json To prevent potential upload error when publishing to npm Refer https://docs.npmjs.com/files/package.json\#files * Add a way to diff the new tarball content with previously published version This is intended to be used as part of our release process before publishing to NPM --dry-run is a useful step, but can be fairly noisy, yarn run v1.21.1 to go along the fake deploy and more clearly shows what would be added and deleted * Run the diff as part of prepublishOnly * Prompt to ensure user check before going further with publishing when running 'npm publish'
1 parent 7312e58 commit 1deb457

File tree

4 files changed

+376
-32
lines changed

4 files changed

+376
-32
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

build/diff-tarball.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const packlist = require('npm-packlist')
2+
const npmContent = require('list-npm-contents');
3+
4+
npmContent('mapbox-gl').then(function(last_version_files) {
5+
packlist({ path: '.' }).then(function(new_version_files) {
6+
new_version_files = new_version_files.map(file => file.replace(/\/\/+/g, '/'));
7+
let diff_new = new_version_files.filter(x => !last_version_files.includes(x));
8+
let diff_last = last_version_files.filter(x => !new_version_files.includes(x));
9+
console.log(`${diff_new.length} files are about to be added in the new tarball`)
10+
diff_new.forEach(file => {
11+
console.log('+', file);
12+
});
13+
console.log(`${diff_last.length} files are about to be deleted in the new tarball`)
14+
diff_last.forEach(file => {
15+
console.log('-', file);
16+
});
17+
});
18+
});

package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@
7373
"jsdom": "^13.0.0",
7474
"json-stringify-pretty-compact": "^2.0.0",
7575
"jsonwebtoken": "^8.3.0",
76+
"list-npm-contents": "^1.0.2",
7677
"lodash.template": "^4.5.0",
7778
"mapbox-gl-styles": "^2.0.2",
7879
"mock-geolocation": "^1.0.11",
7980
"node-notifier": "^5.4.3",
8081
"npm-font-open-sans": "^1.1.0",
82+
"npm-packlist": "^2.1.1",
8183
"npm-run-all": "^4.1.5",
8284
"nyc": "^13.3.0",
8385
"pirates": "^4.0.1",
@@ -138,6 +140,7 @@
138140
"start-tests": "run-p build-token watch-css watch-query start-server",
139141
"start-bench": "run-p build-token watch-benchmarks start-server",
140142
"start-release": "run-s build-token build-prod-min build-css print-release-url start-server",
143+
"diff-tarball": "build/run-node build/diff-tarball && echo \"Please confirm the above is correct [y/n]? \"; read answer; if [ \"$answer\" = \"${answer#[Yy]}\" ]; then false; fi",
141144
"lint": "eslint --cache --ignore-path .gitignore src test bench debug/*.html",
142145
"lint-docs": "documentation lint src/index.js",
143146
"lint-css": "stylelint 'src/css/mapbox-gl.css'",
@@ -154,14 +157,15 @@
154157
"test-expressions": "build/run-node test/expression.test.js",
155158
"test-flow": "build/run-node build/generate-flow-typed-style-spec && flow .",
156159
"test-cov": "nyc --require=@mapbox/flow-remove-types/register --reporter=text-summary --reporter=lcov --cache run-s test-unit test-expressions test-query test-render",
157-
"prepublishOnly": "run-s build-flow-types build-dev build-prod-min build-prod build-csp build-css build-style-spec test-build",
160+
"prepublishOnly": "run-s build-flow-types build-dev build-prod-min build-prod build-csp build-css build-style-spec test-build diff-tarball",
158161
"print-release-url": "node build/print-release-url.js",
159162
"codegen": "build/run-node build/generate-style-code.js && build/run-node build/generate-struct-arrays.js"
160163
},
161164
"files": [
162165
"build/",
163-
"dist/",
164-
"flow-typed/",
166+
"dist/mapbox-gl*",
167+
"dist/style-spec/",
168+
"flow-typed/*.js",
165169
"src/",
166170
".flowconfig"
167171
]

0 commit comments

Comments
 (0)