2019-12-30 02:41:09 -05:00
|
|
|
#!/usr/bin/env node
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {readFileSync, writeFileSync} = require("fs");
|
2020-01-01 05:01:55 -05:00
|
|
|
const {spawnSync} = require("child_process");
|
2019-12-30 02:41:09 -05:00
|
|
|
|
|
|
|
const NEW_VERSION = process.argv[2];
|
|
|
|
|
2020-01-01 05:01:55 -05:00
|
|
|
const cmd = (command, ...args) => {
|
|
|
|
const {status, signal, error} = spawnSync(command, args.map(String), {stdio: ['ignore', 'inherit', 'inherit']});
|
|
|
|
if (error) {
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
if (status !== 0) {
|
|
|
|
throw new Error(`Command exited with ${status ? `status ${status}` : `signal ${signal}`}: ${command} ${args.join(' ')}`);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-30 02:41:09 -05:00
|
|
|
const replaceInFile = (path, pattern, replacement) => writeFileSync(path, readFileSync(path, "utf8").replace(pattern, replacement));
|
|
|
|
|
|
|
|
for (const f of ["Cargo.toml", "nodejs/native/Cargo.toml"]) {
|
2020-01-01 05:01:55 -05:00
|
|
|
replaceInFile(f, /^version = "\d+\.\d+\.\d+"\s*$/m, `version = "${NEW_VERSION}"`);
|
2019-12-30 02:41:09 -05:00
|
|
|
}
|
|
|
|
|
2019-12-30 03:20:33 -05:00
|
|
|
for (const f of ["README.md", "nodejs/native/Cargo.toml"]) {
|
2020-01-01 05:01:55 -05:00
|
|
|
replaceInFile(f, /^hyperbuild = "\d+\.\d+\.\d+"\s*$/m, `hyperbuild = "${NEW_VERSION}"`);
|
2019-12-30 02:41:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for (const f of ["nodejs/package.json"]) {
|
2020-01-01 05:01:55 -05:00
|
|
|
replaceInFile(f, /^(\s*)"version": "\d+\.\d+\.\d+",\s*$/m, `$1"version": "${NEW_VERSION}",`);
|
2019-12-30 02:41:09 -05:00
|
|
|
}
|
2020-01-01 04:47:49 -05:00
|
|
|
|
|
|
|
for (const f of ["README.md"]) {
|
2020-01-01 05:01:55 -05:00
|
|
|
replaceInFile(f, /(wilsonl\.in\/hyperbuild\/bin\/)\d+\.\d+\.\d+/g, `$1${NEW_VERSION}`);
|
2020-01-01 04:47:49 -05:00
|
|
|
}
|
2020-01-01 05:01:55 -05:00
|
|
|
|
|
|
|
cmd('cargo', 'generate-lockfile');
|