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

@ -51,4 +51,4 @@
"tslib": "^2.4.1", "tslib": "^2.4.1",
"typescript": "~4.9.5" "typescript": "~4.9.5"
} }
} }

View File

@ -25,4 +25,4 @@
"Name": "sh-edraft-dark-theme" "Name": "sh-edraft-dark-theme"
} }
] ]
} }

View File

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