2023-11-06 14:40:20 -07:00
|
|
|
const { join } = require("node:path");
|
|
|
|
const fs = require("node:fs");
|
|
|
|
const exec = require("execa");
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
const file = join(__dirname, "../package.json");
|
|
|
|
const json = require(file);
|
|
|
|
|
|
|
|
const match = json['version'].match(/^[\d.]*(?:-pre\d+|)?/);
|
|
|
|
const version = match ? `${match[0]}-dev` : "dev";
|
2023-11-06 14:52:53 -07:00
|
|
|
const revision = process.argv.length > 2
|
|
|
|
? process.argv[2]
|
|
|
|
: (await exec("git", ["rev-parse", "--short", "HEAD"])).stdout;
|
2023-11-06 14:40:20 -07:00
|
|
|
|
|
|
|
json['version'] = `${version}-${revision}`;
|
2023-11-06 15:06:24 -07:00
|
|
|
console.log(`Package version was updated to ${json['version']}`);
|
2023-11-06 14:40:20 -07:00
|
|
|
fs.writeFileSync(file, JSON.stringify(json, null, '\t'));
|
|
|
|
})();
|