Add better version info

This commit is contained in:
rubikscraft 2022-03-21 19:43:31 +01:00
parent 581be5921b
commit 6931d03ae8
No known key found for this signature in database
GPG key ID: 1463EBE9200A5CD4
12 changed files with 61 additions and 10 deletions

View file

@ -1,7 +1,7 @@
{
"name": "picsur-backend",
"private": false,
"version": "0.0.0",
"version": "3.0.0",
"description": "Backend for Picsur",
"license": "GPL-3.0",
"repository": "https://github.com/rubikscraft/Picsur",

View file

@ -43,4 +43,12 @@ export class HostConfigService {
);
return enabled;
}
public getVersion() {
const version = this.configService.get<string>(
`npm_package_version`,
'0.0.0',
);
return version;
}
}

View file

@ -13,6 +13,7 @@ export class InfoController {
return {
demo: this.hostConfig.isDemo(),
production: this.hostConfig.isProduction(),
version: this.hostConfig.getVersion(),
};
}
}

View file

@ -1,7 +1,7 @@
{
"private": false,
"name": "picsur-frontend",
"version": "0.0.0",
"version": "3.0.0",
"description": "Frontend for Picsur",
"license": "GPL-3.0",
"repository": "https://github.com/rubikscraft/Picsur",

View file

@ -4,10 +4,12 @@
<a class="link-unstyled" href="https://rubikscraft.nl" target="_blank"
>Rubikscraft</a
>
{{ isDemo ? " - Demo Version" : "" }}
-
{{ version }}
-
<a class="link-unstyled" href="https://github.com/rubikscraft/picsur"
>Source Code</a
>
{{ isDemo ? " - Demo Version" : "" }}
</p>
</footer>

View file

@ -11,6 +11,7 @@ export class FooterComponent implements OnInit {
constructor(private infoService: InfoService) {}
isDemo: boolean = false;
version: string = 'V0.0.0';
ngOnInit(): void {
this.subscribeInfo();
@ -20,6 +21,7 @@ export class FooterComponent implements OnInit {
subscribeInfo() {
return this.infoService.live.subscribe((info) => {
this.isDemo = info.demo;
this.version = 'V' + info.version;
});
}
}

View file

@ -1,4 +1,5 @@
export class ServerInfo {
production: boolean = false;
demo: boolean = false;
version: string = '0.0.0';
}

View file

@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import { plainToClass } from 'class-transformer';
import { InfoResponse } from 'picsur-shared/dist/dto/api/info.dto';
import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types';
import { BehaviorSubject } from 'rxjs';
@ -25,9 +26,7 @@ export class InfoService {
const response = await this.api.get(InfoResponse, '/api/info');
if (HasFailed(response)) return response;
const info = new ServerInfo();
info.production = response.production;
info.demo = response.demo;
const info = plainToClass(ServerInfo, response);
this.infoSubject.next(info);
return info;

View file

@ -1,6 +1,6 @@
{
"private": true,
"version": "0.2.0",
"version": "3.0.0",
"workspaces": [
"shared",
"backend",
@ -9,6 +9,7 @@
"scripts": {
"devdb:start": "podman-compose -f ./dev/docker-compose.yml up -d",
"devdb:stop": "podman-compose -f ./dev/docker-compose.yml down",
"build": "./support/build.sh"
"build": "./support/build.sh",
"setversion": "./support/setversion.sh"
}
}

View file

@ -1,7 +1,7 @@
{
"private": false,
"name": "picsur-shared",
"version": "0.0.0",
"version": "3.0.0",
"description": "Shared libraries for Picsur",
"license": "GPL-3.0",
"repository": "https://github.com/rubikscraft/Picsur",

View file

@ -1,4 +1,4 @@
import { IsBoolean, IsDefined } from 'class-validator';
import { IsBoolean, IsDefined, IsSemVer, IsString } from 'class-validator';
export class InfoResponse {
@IsBoolean()
@ -8,4 +8,9 @@ export class InfoResponse {
@IsBoolean()
@IsDefined()
demo: boolean;
@IsDefined()
@IsString()
@IsSemVer()
version: string;
}

32
support/setversion.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
# First param
VERSION=$1
# Check not null
if [ -z "$VERSION" ]; then
echo "Please specify a version"
exit 1
fi
SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
UPDATE_VERSION="yarn version --no-commit-hooks --no-git-tag-version --new-version"
cd $SCRIPT_PATH/..
$UPDATE_VERSION $VERSION
(
cd backend
$UPDATE_VERSION $VERSION
)
(
cd frontend
$UPDATE_VERSION $VERSION
)
(
cd shared
$UPDATE_VERSION $VERSION
)