forked from sh-edraft.de/sh_discord_bot
Improved set version for frontend #70
This commit is contained in:
parent
0fcf2c7b45
commit
47f294a982
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kdb-web",
|
"name": "kdb-web",
|
||||||
"version": "0.3.0",
|
"version": "0.3.dev70",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"update-version": "ts-node -O '{\"module\": \"commonjs\"}' update-version.ts",
|
"update-version": "ts-node -O '{\"module\": \"commonjs\"}' update-version.ts",
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
"ApiURL": "http://localhost:5000",
|
"ApiURL": "http://localhost:5000",
|
||||||
"WebVersion": {
|
"WebVersion": {
|
||||||
"Major": "0",
|
"Major": "0",
|
||||||
"Minor": "0",
|
"Minor": "3",
|
||||||
"Micro": "0"
|
"Micro": "dev70"
|
||||||
},
|
},
|
||||||
"Themes": [
|
"Themes": [
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
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";
|
||||||
|
|
||||||
const jsonFilePath = './src/assets/config.json';
|
const jsonFilePath = "./src/assets/config.json";
|
||||||
|
|
||||||
function Main(): void {
|
function Main(): void {
|
||||||
getVersion()
|
getVersion()
|
||||||
@ -14,16 +14,16 @@ function Main(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getVersion(): Promise<SoftwareVersion> {
|
async function getVersion(): Promise<SoftwareVersion> {
|
||||||
const util = require('util');
|
const util = require("util");
|
||||||
const exec = util.promisify(require('child_process').exec);
|
const exec = util.promisify(require("child_process").exec);
|
||||||
|
|
||||||
let major = '0';
|
let major = "0";
|
||||||
let minor = '0';
|
let minor = "0";
|
||||||
let micro = '0';
|
let micro = "0";
|
||||||
|
|
||||||
const branch: string = (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim();
|
const branch: string = (await exec("git rev-parse --abbrev-ref HEAD")).stdout.toString().trim();
|
||||||
if (branch.includes('.')) {
|
if (branch.includes(".")) {
|
||||||
const versions = branch.split('.');
|
const versions = branch.split(".");
|
||||||
if (versions.length > 0) {
|
if (versions.length > 0) {
|
||||||
major = versions[0];
|
major = versions[0];
|
||||||
}
|
}
|
||||||
@ -35,19 +35,27 @@ async function getVersion(): Promise<SoftwareVersion> {
|
|||||||
if (versions.length > 2) {
|
if (versions.length > 2) {
|
||||||
micro = versions[2];
|
micro = versions[2];
|
||||||
}
|
}
|
||||||
|
} else if (branch.startsWith("#")) {
|
||||||
|
const fs = require("fs");
|
||||||
|
const config: Appsettings = JSON.parse(fs.readFileSync(jsonFilePath, 'utf-8'))
|
||||||
|
major = config.WebVersion.Major;
|
||||||
|
minor = config.WebVersion.Minor;
|
||||||
|
micro = `dev${branch.split("#")[1]}`;
|
||||||
}
|
}
|
||||||
return new SoftwareVersion(major, minor, micro);
|
return new SoftwareVersion(major, minor, micro);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function setVersion(version: SoftwareVersion) {
|
async function setVersion(version: SoftwareVersion) {
|
||||||
var fs = require('fs');
|
const fs = require("fs");
|
||||||
fs.readFile(jsonFilePath, 'utf8', (err: Error, data: string) => {
|
fs.readFile(jsonFilePath, "utf8", (err: Error, data: string) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
const settings: Appsettings = JSON.parse(data);
|
const settings: Appsettings = JSON.parse(data);
|
||||||
settings.WebVersion = version;
|
settings.WebVersion = version;
|
||||||
fs.writeFile(jsonFilePath, JSON.stringify(settings, null, 4), 'utf8', () => {});
|
fs.writeFile(jsonFilePath, JSON.stringify(settings, null, 4), "utf8", () => {
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user