Skip to content

Commit

Permalink
Add diff-tarball script and more explicit files property in package.j…
Browse files Browse the repository at this point in the history
…son (#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'
  • Loading branch information
karimnaaji authored Apr 15, 2020
1 parent 7312e58 commit 1deb457
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 32 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
18 changes: 18 additions & 0 deletions build/diff-tarball.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const packlist = require('npm-packlist')
const npmContent = require('list-npm-contents');

npmContent('mapbox-gl').then(function(last_version_files) {
packlist({ path: '.' }).then(function(new_version_files) {
new_version_files = new_version_files.map(file => file.replace(/\/\/+/g, '/'));
let diff_new = new_version_files.filter(x => !last_version_files.includes(x));
let diff_last = last_version_files.filter(x => !new_version_files.includes(x));
console.log(`${diff_new.length} files are about to be added in the new tarball`)
diff_new.forEach(file => {
console.log('+', file);
});
console.log(`${diff_last.length} files are about to be deleted in the new tarball`)
diff_last.forEach(file => {
console.log('-', file);
});
});
});
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@
"jsdom": "^13.0.0",
"json-stringify-pretty-compact": "^2.0.0",
"jsonwebtoken": "^8.3.0",
"list-npm-contents": "^1.0.2",
"lodash.template": "^4.5.0",
"mapbox-gl-styles": "^2.0.2",
"mock-geolocation": "^1.0.11",
"node-notifier": "^5.4.3",
"npm-font-open-sans": "^1.1.0",
"npm-packlist": "^2.1.1",
"npm-run-all": "^4.1.5",
"nyc": "^13.3.0",
"pirates": "^4.0.1",
Expand Down Expand Up @@ -138,6 +140,7 @@
"start-tests": "run-p build-token watch-css watch-query start-server",
"start-bench": "run-p build-token watch-benchmarks start-server",
"start-release": "run-s build-token build-prod-min build-css print-release-url start-server",
"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",
"lint": "eslint --cache --ignore-path .gitignore src test bench debug/*.html",
"lint-docs": "documentation lint src/index.js",
"lint-css": "stylelint 'src/css/mapbox-gl.css'",
Expand All @@ -154,14 +157,15 @@
"test-expressions": "build/run-node test/expression.test.js",
"test-flow": "build/run-node build/generate-flow-typed-style-spec && flow .",
"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",
"prepublishOnly": "run-s build-flow-types build-dev build-prod-min build-prod build-csp build-css build-style-spec test-build",
"prepublishOnly": "run-s build-flow-types build-dev build-prod-min build-prod build-csp build-css build-style-spec test-build diff-tarball",
"print-release-url": "node build/print-release-url.js",
"codegen": "build/run-node build/generate-style-code.js && build/run-node build/generate-struct-arrays.js"
},
"files": [
"build/",
"dist/",
"flow-typed/",
"dist/mapbox-gl*",
"dist/style-spec/",
"flow-typed/*.js",
"src/",
".flowconfig"
]
Expand Down
Loading

0 comments on commit 1deb457

Please sign in to comment.