From c01a6b97fee350c4f58a9a9fb9226415c001b8a1 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 3 Apr 2023 07:59:30 +0200 Subject: [PATCH] Build patch version --- kdb-web/package.json | 2 +- kdb-web/src/assets/config.json | 2 +- kdb-web/update-version.ts | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/kdb-web/package.json b/kdb-web/package.json index 41dd3aec..4cff7843 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -51,4 +51,4 @@ "tslib": "^2.4.1", "typescript": "~4.9.5" } -} +} \ No newline at end of file diff --git a/kdb-web/src/assets/config.json b/kdb-web/src/assets/config.json index 21c1893e..4c79ffb1 100644 --- a/kdb-web/src/assets/config.json +++ b/kdb-web/src/assets/config.json @@ -25,4 +25,4 @@ "Name": "sh-edraft-dark-theme" } ] -} +} \ No newline at end of file diff --git a/kdb-web/update-version.ts b/kdb-web/update-version.ts index e81b3376..7e3c56c8 100644 --- a/kdb-web/update-version.ts +++ b/kdb-web/update-version.ts @@ -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 { } 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", () => { }); }); }