1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-05-21 22:33:32 +02:00

adding git commit hash and built time to release package.json and showing it at admin

This commit is contained in:
Patrik J. Braun 2019-12-24 00:25:39 +01:00
parent 97c8f41fa3
commit d38d0f01bf
5 changed files with 32 additions and 4 deletions

View File

@ -117,7 +117,9 @@ gulp.task('copy-package', function () {
devDependencies: { [key: string]: string }, devDependencies: { [key: string]: string },
scripts: { [key: string]: string }, scripts: { [key: string]: string },
dependencies: { [key: string]: string }, dependencies: { [key: string]: string },
optionalDependencies: { [key: string]: string } optionalDependencies: { [key: string]: string },
buildTime: string,
buildCommitHash: string
}) => { }) => {
delete json.devDependencies; delete json.devDependencies;
json.scripts = {start: 'node ./src/backend/index.js'}; json.scripts = {start: 'node ./src/backend/index.js'};
@ -139,6 +141,13 @@ gulp.task('copy-package', function () {
} }
delete json.optionalDependencies; delete json.optionalDependencies;
} }
json.buildTime = (new Date()).toISOString();
try {
json.buildCommitHash = require('child_process').execSync('git rev-parse HEAD');
} catch (e) {
}
return json; return json;
})) }))
.pipe(gulp.dest('./release')); .pipe(gulp.dest('./release'));

View File

@ -41,6 +41,8 @@ export class Server {
await ConfigDiagnostics.runDiagnostics(); await ConfigDiagnostics.runDiagnostics();
Logger.verbose(LOG_TAG, 'using config:'); Logger.verbose(LOG_TAG, 'using config:');
Config.Client.appVersion = require('../../package.json').version; Config.Client.appVersion = require('../../package.json').version;
Config.Client.buildTime = require('../../package.json').buildTime;
Config.Client.buildCommitHash = require('../../package.json').buildCommitHash;
Logger.verbose(LOG_TAG, JSON.stringify(Config, null, '\t')); Logger.verbose(LOG_TAG, JSON.stringify(Config, null, '\t'));
this.app = _express(); this.app = _express();

View File

@ -92,6 +92,8 @@ export module ClientConfig {
export interface Config { export interface Config {
appVersion: string; appVersion: string;
buildTime: string;
buildCommitHash: string;
applicationTitle: string; applicationTitle: string;
publicUrl: string; publicUrl: string;
urlBase: string; urlBase: string;
@ -118,6 +120,8 @@ export class PublicConfigClass {
public Client: ClientConfig.Config = { public Client: ClientConfig.Config = {
applicationTitle: 'PiGallery 2', applicationTitle: 'PiGallery 2',
appVersion: '', appVersion: '',
buildCommitHash: '',
buildTime: '',
Media: { Media: {
Video: { Video: {
enabled: true enabled: true

View File

@ -22,7 +22,7 @@
</div> </div>
<div class="form-horizontal"> <div class="form-horizontal">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<a class="version" href="https://github.com/bpatrik/pigallery2/releases"> <a title="{{versionExtra}}" class="version" href="https://github.com/bpatrik/pigallery2/releases">
<span i18n>App version:</span>&nbsp;v<span>{{appVersion}}</span> <span i18n>App version:</span>&nbsp;v<span>{{appVersion}}</span>
</a> </a>
<div class="form-group"> <div class="form-group">
@ -55,7 +55,8 @@
(click)="scrollTo(i)" (click)="scrollTo(i)"
[hidden]="!s.HasAvailableSettings"> [hidden]="!s.HasAvailableSettings">
{{s.Name}}<!-- {{s.Name}}<!--
--><ng-container *ngIf="s.Changed">*</ng-container> -->
<ng-container *ngIf="s.Changed">*</ng-container>
</button> </button>
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
import {AfterViewInit, Component, ElementRef, OnInit, QueryList, ViewChildren} from '@angular/core'; import {AfterViewInit, Component, ElementRef, Inject, LOCALE_ID, OnInit, QueryList, ViewChildren} from '@angular/core';
import {AuthenticationService} from '../../model/network/authentication.service'; import {AuthenticationService} from '../../model/network/authentication.service';
import {UserRoles} from '../../../../common/entities/UserDTO'; import {UserRoles} from '../../../../common/entities/UserDTO';
import {NotificationService} from '../../model/notification.service'; import {NotificationService} from '../../model/notification.service';
@ -8,6 +8,7 @@ import {I18n} from '@ngx-translate/i18n-polyfill';
import {Config} from '../../../../common/config/public/Config'; import {Config} from '../../../../common/config/public/Config';
import {ISettingsComponent} from '../settings/_abstract/ISettingsComponent'; import {ISettingsComponent} from '../settings/_abstract/ISettingsComponent';
import {PageHelper} from '../../model/page.helper'; import {PageHelper} from '../../model/page.helper';
import {formatDate} from '@angular/common';
@Component({ @Component({
selector: 'app-admin', selector: 'app-admin',
@ -21,6 +22,9 @@ export class AdminComponent implements OnInit, AfterViewInit {
Simplified: 'Simplified' Simplified: 'Simplified'
}; };
appVersion = Config.Client.appVersion; appVersion = Config.Client.appVersion;
versionExtra = '';
buildTime = Config.Client.buildTime;
buildCommitHash = Config.Client.buildCommitHash;
@ViewChildren('setting') settingsComponents: QueryList<ISettingsComponent>; @ViewChildren('setting') settingsComponents: QueryList<ISettingsComponent>;
@ViewChildren('setting', {read: ElementRef}) settingsComponents2: QueryList<ElementRef>; @ViewChildren('setting', {read: ElementRef}) settingsComponents2: QueryList<ElementRef>;
contents: ISettingsComponent[] = []; contents: ISettingsComponent[] = [];
@ -28,9 +32,17 @@ export class AdminComponent implements OnInit, AfterViewInit {
constructor(private _authService: AuthenticationService, constructor(private _authService: AuthenticationService,
private _navigation: NavigationService, private _navigation: NavigationService,
public notificationService: NotificationService, public notificationService: NotificationService,
@Inject(LOCALE_ID) private locale: string,
public i18n: I18n) { public i18n: I18n) {
this.text.Advanced = i18n('Advanced'); this.text.Advanced = i18n('Advanced');
this.text.Simplified = i18n('Simplified'); this.text.Simplified = i18n('Simplified');
if (Config.Client.buildTime) {
this.versionExtra = i18n('Built at') + ': ' + formatDate(Config.Client.buildTime, 'medium', locale);
}
if (Config.Client.buildCommitHash) {
this.versionExtra += ', ' + i18n('git hash') + ': ' + Config.Client.buildCommitHash;
}
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {