Script was mentioning an update to shrinkwrap that we no longer use. Also it was calling `yarn run doctoc` that had been remove in an old commit, and re-added.
39 lines
1,017 B
JavaScript
39 lines
1,017 B
JavaScript
/* eslint no-console:0 max-len:0 */
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
import mversion from 'mversion';
|
|
|
|
import semver from 'semver';
|
|
import currentVersion from '../src/lib/version.js';
|
|
|
|
if (!process.env.VERSION) {
|
|
throw new Error(
|
|
'bump: Usage is VERSION=MAJOR.MINOR.PATCH scripts/bump-package-version.js'
|
|
);
|
|
}
|
|
const newVersion = process.env.VERSION;
|
|
|
|
if (!semver.valid(newVersion)) {
|
|
throw new Error(
|
|
`bump: Provided new version (${newVersion}) is not a valid version per semver`
|
|
);
|
|
}
|
|
|
|
if (semver.gte(currentVersion, newVersion)) {
|
|
throw new Error(
|
|
`bump: Provided new version is not higher than current version (${newVersion} <= ${currentVersion})`
|
|
);
|
|
}
|
|
|
|
console.log(`Bumping ${newVersion}`);
|
|
|
|
console.log('..Updating src/lib/version.js');
|
|
|
|
const versionFile = path.join(__dirname, '../src/lib/version.js');
|
|
const newContent = `export default '${newVersion}';\n`;
|
|
fs.writeFileSync(versionFile, newContent);
|
|
|
|
console.log('..Updating package.json');
|
|
|
|
mversion.update(newVersion);
|