mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-11 02:09:26 +00:00
.devcontainer
.github
.vscode
.yarn
build-scripts
cast
demo
docs
gallery
hassio
public
script
bootstrap
build_frontend
core
develop
release
setup
size_stats
translations_download
translations_upload_base
version_bump.js
src
test
translations
.eslintrc.json
.gitattributes
.gitignore
.gitmodules
.nvmrc
.prettierignore
.yarnrc.yml
CLA.md
CODE_OF_CONDUCT.md
LICENSE.md
MANIFEST.in
README.md
gulpfile.js
lint-staged.config.js
netlify.toml
package.json
pyproject.toml
rollup.config.js
setup.cfg
tsconfig.json
web-dev-server.config.js
webpack.config.js
yarn.lock
73 lines
1.5 KiB
JavaScript
Executable File
73 lines
1.5 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
const fs = require("fs");
|
|
const util = require("util");
|
|
const exec = util.promisify(require("child_process").exec);
|
|
|
|
function patch(version) {
|
|
const parts = version.split(".");
|
|
return `${parts[0]}.${Number(parts[1]) + 1}`;
|
|
}
|
|
|
|
function today() {
|
|
const now = new Date();
|
|
return `${now.getUTCFullYear()}${String(now.getUTCMonth() + 1).padStart(
|
|
2,
|
|
"0"
|
|
)}${String(now.getUTCDate()).padStart(2, "0")}.0`;
|
|
}
|
|
|
|
function auto(version) {
|
|
const todayVersion = today();
|
|
if (todayVersion !== version) {
|
|
return todayVersion;
|
|
}
|
|
return patch(version);
|
|
}
|
|
|
|
const methods = {
|
|
patch,
|
|
today,
|
|
auto,
|
|
};
|
|
|
|
async function main(args) {
|
|
let method;
|
|
let commit;
|
|
|
|
if (args.length === 0) {
|
|
method = methods.auto;
|
|
commit = true;
|
|
} else {
|
|
method = args.length > 0 && methods[args[0]];
|
|
commit = args.length > 1 && args[1] == "--commit";
|
|
}
|
|
|
|
if (!method) {
|
|
console.error(
|
|
"Missing required method. Choose from",
|
|
Object.keys(methods).join(", ")
|
|
);
|
|
return;
|
|
}
|
|
|
|
const setup = fs.readFileSync("pyproject.toml", "utf8");
|
|
const version = setup.match(/version\W+=\W"(\d{8}\.\d)"/)[1];
|
|
const newVersion = method(version);
|
|
|
|
console.log("Current version:", version);
|
|
console.log("New version:", newVersion);
|
|
|
|
fs.writeFileSync("pyproject.toml", setup.replace(version, newVersion), "utf-8");
|
|
|
|
if (!commit) {
|
|
return;
|
|
}
|
|
|
|
const { stdout } = await exec(
|
|
`git commit -am "Bumped version to ${newVersion}"`
|
|
);
|
|
console.log(stdout);
|
|
}
|
|
|
|
main(process.argv.slice(2)).catch(console.error);
|