Skip to content

Commit

Permalink
misc: bump-versions.js release script (GoogleChrome#9998)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Nov 21, 2019
1 parent 18e3a55 commit 83d9d9c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/recipes/custom-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"private": true,
"scripts": {},
"devDependencies": {
"lighthouse": "^3.x"
"lighthouse": "^5.6.0"
}
}
2 changes: 1 addition & 1 deletion docs/recipes/gulp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"devDependencies": {
"gulp": "^3.9.1",
"gulp-connect": "^5.0.0",
"lighthouse": "^2.x"
"lighthouse": "^5.6.0"
}
}
33 changes: 33 additions & 0 deletions lighthouse-core/scripts/release/bump-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @license Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

const fs = require('fs');
const path = require('path');
const glob = require('glob');

const NEW_VERSION = process.argv[2];
if (!/^\d+\.\d+\.\d+$/.test(NEW_VERSION)) throw new Error('Usage: node bump-versions.json x.x.x');
const ignore = [
'**/node_modules/**',
'docs/recipes/auth/package.json',
'changelog.md',
];

for (const file of glob.sync('**/{package.json,*.md}', {ignore})) {
let text;
if (file === 'package.json') {
const pkg = require(path.resolve(file));
pkg.version = NEW_VERSION;
text = JSON.stringify(pkg, null, 2) + '\n';
} else {
// Replace `package.json`-like examples in markdown files.
text = fs.readFileSync(file, 'utf-8');
text = text.replace(/"lighthouse": ".*?"/g, `"lighthouse": "^${NEW_VERSION}"`);
}

fs.writeFileSync(file, text);
}
7 changes: 2 additions & 5 deletions lighthouse-core/scripts/release/prepare-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ git checkout -b "$BRANCH_NAME"
# Install the dependencies.
yarn install

# Bump the version in package.json
NEEDLE="^ \"version\": \"$SEMVER_PATTERN\""
REPLACEMENT=" \"version\": \"$NEW_VERSION\""

sed -i '' "s/$NEEDLE/$REPLACEMENT/g" package.json
# Bump the version in package.json and others.
node lighthouse-core/scripts/release/bump-versions.js $NEW_VERSION

# Update the fixtures with the new version
yarn update:sample-json
Expand Down

0 comments on commit 83d9d9c

Please sign in to comment.