Build patch version

This commit is contained in:
Sven Heidemann 2023-04-03 07:59:30 +02:00
parent 059bd3aaf1
commit c01a6b97fe
3 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,6 @@
import { Appsettings } from "./src/app/models/config/appsettings";
import { SoftwareVersion } from "./src/app/models/config/software-version";
import fs from "fs";
const jsonFilePath = "./src/assets/config.json";
@ -33,14 +34,20 @@ async function getVersion(): Promise<SoftwareVersion> {
}
if (versions.length > 2) {
micro = versions.slice(2).toString().replace(',', '.');
micro = versions.slice(2).toString().replace(",", ".");
}
} else if (branch.startsWith("#")) {
const fs = require("fs");
const config: Appsettings = JSON.parse(fs.readFileSync(jsonFilePath, 'utf-8'))
const config: Appsettings = JSON.parse(fs.readFileSync(jsonFilePath, "utf-8"));
major = config.WebVersion.Major;
minor = config.WebVersion.Minor;
micro = `dev${branch.split("#")[1]}`;
} else {
const fs = require("fs");
const config: Appsettings = JSON.parse(fs.readFileSync(jsonFilePath, "utf-8"));
major = config.WebVersion.Major;
minor = config.WebVersion.Minor;
micro = config.WebVersion.Micro;
}
return new SoftwareVersion(major, minor, micro);
}
@ -57,13 +64,13 @@ async function setVersion(version: SoftwareVersion) {
fs.writeFile(jsonFilePath, JSON.stringify(settings, null, 4), "utf8", () => {
});
});
fs.readFile('./package.json', "utf8", (err: Error, data: string) => {
fs.readFile("./package.json", "utf8", (err: Error, data: string) => {
if (err) {
throw err;
}
const settings = JSON.parse(data);
settings.version = version.getVersionString();
fs.writeFile('./package.json', JSON.stringify(settings, null, 4), "utf8", () => {
fs.writeFile("./package.json", JSON.stringify(settings, null, 4), "utf8", () => {
});
});
}