mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-07-23 00:14:09 +00:00
Improve integrity generation for releases (#8459)
This commit is contained in:

committed by
Jon Koops

parent
f45c06a13f
commit
0c995a9c4a
@ -15,9 +15,8 @@
|
||||
- [ ] Make a new branch for the update
|
||||
- [ ] Write a blog post about the new release and put it in `/docs/_posts`
|
||||
- [ ] If necessary to preserve previous version's docs, rename `docs/reference.html` to `docs/reference-X.Y.Z.html` and add it to the list in `docs/reference-versions.html`
|
||||
- [ ] Run `npm run docs` to generate the new `docs/reference.html`
|
||||
- [ ] Run `npm run docs` to generate the new `docs/reference.html` and update integrity hashes in `docs/_config.yml`
|
||||
- [ ] Add the version number to the first paragraph in `docs/reference.html`
|
||||
- [ ] Run `npm run integrity` and make sure `docs/_config.yml` is updated with new hashes
|
||||
- [ ] Update link to latest release in `docs/download.md`
|
||||
- [ ] Update the announcement section in `docs/index.html`
|
||||
- [ ] Commit all the changes and submit a PR for someone to review
|
||||
|
@ -1,28 +1,34 @@
|
||||
// This script calculates the integrity hashes of the files in dist/ , and
|
||||
// **overwrites** the values in the documentation.
|
||||
|
||||
var ssri = require('ssri');
|
||||
var fs = require('fs');
|
||||
var version = require('../package.json').version;
|
||||
const ssri = require('ssri');
|
||||
const fs = require('fs');
|
||||
const https = require('https');
|
||||
const version = require('../package.json').version;
|
||||
|
||||
const integritySrc = ssri.fromData(fs.readFileSync('dist/leaflet-src.js'));
|
||||
const integrityUglified = ssri.fromData(fs.readFileSync('dist/leaflet.js'));
|
||||
const integrityCss = ssri.fromData(fs.readFileSync('dist/leaflet.css'));
|
||||
const getIntegrity = async (path) => new Promise((resolve) => {
|
||||
https.get(`https://unpkg.com/leaflet@${version}/dist/${path}`, (res) => {
|
||||
ssri.fromStream(res, {algorithms: ['sha256']}).then(integrity => resolve(integrity.toString()));
|
||||
});
|
||||
});
|
||||
|
||||
(async () => {
|
||||
const integrityUglified = await getIntegrity('leaflet.js');
|
||||
const integritySrc = await getIntegrity('leaflet-src.js');
|
||||
const integrityCss = await getIntegrity('leaflet.css');
|
||||
|
||||
console.log('Integrity hashes for ', version, ':');
|
||||
console.log('dist/leaflet-src.js: ', integritySrc.toString());
|
||||
console.log('dist/leaflet.js: ', integrityUglified.toString());
|
||||
console.log('dist/leaflet.css: ', integrityCss.toString());
|
||||
console.log(`Integrity hashes for ${version}:`);
|
||||
console.log(`dist/leaflet.js: ${integrityUglified}`);
|
||||
console.log(`dist/leaflet-src.js: ${integritySrc}`);
|
||||
console.log(`dist/leaflet.css: ${integrityCss}`);
|
||||
|
||||
var docConfig = fs.readFileSync('docs/_config.yml').toString();
|
||||
let docConfig = fs.readFileSync('docs/_config.yml', 'utf8');
|
||||
|
||||
docConfig = docConfig
|
||||
.replace(/latest_leaflet_version:.*/, 'latest_leaflet_version: ' + version)
|
||||
.replace(/integrity_hash_source:.*/, 'integrity_hash_source: "' + integritySrc.toString() + '"')
|
||||
.replace(/integrity_hash_uglified:.*/, 'integrity_hash_uglified: "' + integrityUglified.toString() + '"')
|
||||
.replace(/integrity_hash_css:.*/, 'integrity_hash_css: "' + integrityCss.toString() + '"');
|
||||
docConfig = docConfig
|
||||
.replace(/latest_leaflet_version:.*/, 'latest_leaflet_version: ' + version)
|
||||
.replace(/integrity_hash_source:.*/, 'integrity_hash_source: "' + integritySrc + '"')
|
||||
.replace(/integrity_hash_uglified:.*/, 'integrity_hash_uglified: "' + integrityUglified + '"')
|
||||
.replace(/integrity_hash_css:.*/, 'integrity_hash_css: "' + integrityCss + '"');
|
||||
|
||||
// console.log('New jekyll docs config: \n', docConfig);
|
||||
|
||||
fs.writeFileSync('docs/_config.yml', docConfig);
|
||||
fs.writeFileSync('docs/_config.yml', docConfig);
|
||||
})();
|
||||
|
@ -42,7 +42,7 @@
|
||||
"CHANGELOG.md"
|
||||
],
|
||||
"scripts": {
|
||||
"docs": "node ./build/docs.js",
|
||||
"docs": "node ./build/docs.js && node ./build/integrity.js",
|
||||
"test": "karma start ./spec/karma.conf.js",
|
||||
"build": "npm run rollup && npm run uglify",
|
||||
"lint": "eslint .",
|
||||
@ -50,7 +50,6 @@
|
||||
"rollup": "rollup -c build/rollup-config.js",
|
||||
"watch": "rollup -w -c build/rollup-config.js",
|
||||
"uglify": "uglifyjs dist/leaflet-src.js -c -m -o dist/leaflet.js --source-map filename=dist/leaflet.js.map --source-map content=dist/leaflet-src.js.map --source-map url=leaflet.js.map --comments",
|
||||
"integrity": "NODE_ENV=release npm run build && node ./build/integrity.js",
|
||||
"bundlemon": "bundlemon --subProject js --defaultCompression none && bundlemon --subProject js-gzip --defaultCompression gzip",
|
||||
"serve": "cd docs && bundle exec jekyll serve",
|
||||
"prepare": "husky install"
|
||||
@ -65,7 +64,8 @@
|
||||
"docs/examples/map-panes/eu-countries.js",
|
||||
"docs/examples/extending/extending-2-layers.md",
|
||||
"docs/_posts/2012*",
|
||||
"docs/_site"
|
||||
"docs/_site",
|
||||
"build/integrity.js"
|
||||
],
|
||||
"root": true,
|
||||
"globals": {
|
||||
|
Reference in New Issue
Block a user