Skip to content

Commit

Permalink
add startup message with version number
Browse files Browse the repository at this point in the history
  • Loading branch information
artlowel authored and samuelcambien committed Sep 13, 2022
1 parent 59f9534 commit c94e5d0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dspace-angular",
"version": "0.0.0",
"version": "7.4.0-next.0",
"scripts": {
"ng": "ng",
"config:watch": "nodemon",
Expand Down
3 changes: 3 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { ServerAppModule } from './src/main.server';
import { buildAppConfig } from './src/config/config.server';
import { APP_CONFIG, AppConfig } from './src/config/app-config.interface';
import { extendEnvironmentWithAppConfig } from './src/config/config.util';
import { logStartupMessage } from './startup-message';

/*
* Set path for the browser application's dist folder
Expand Down Expand Up @@ -281,6 +282,8 @@ function run() {
}

function start() {
logStartupMessage(environment);

/*
* If SSL is enabled
* - Read credentials from configuration files
Expand Down
4 changes: 0 additions & 4 deletions src/app/init.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ export abstract class InitService {
if (environment.debug) {
console.info(environment);
}

const env: string = environment.production ? 'Production' : 'Development';
const color: string = environment.production ? 'red' : 'green';
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/modules/app/browser-init.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { StoreAction, StoreActionTypes } from '../../app/store.actions';
import { coreSelector } from '../../app/core/core.selectors';
import { find, map } from 'rxjs/operators';
import { isNotEmpty } from '../../app/shared/empty.util';
import { logStartupMessage } from '../../../startup-message';

/**
* Performs client-side initialization.
Expand Down Expand Up @@ -79,6 +80,7 @@ export class BrowserInitService extends InitService {
this.initCorrelationId();

this.checkEnvironment();
logStartupMessage(environment);

this.initI18n();
this.initAngulartics();
Expand Down
19 changes: 19 additions & 0 deletions startup-message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import PACKAGE_JSON from './package.json';
import { BuildConfig } from './src/config/build-config.interface';

/**
* Log a message at the start of the application containing the version number and the environment.
*
* @param environment the environment configuration
*/
export const logStartupMessage = (environment: Partial<BuildConfig>) => {
const env: string = environment.production ? 'Production' : 'Development';
const color: string = environment.production ? 'red' : 'green';

console.info('');
console.info(`%cdspace-angular`, `font-weight: bold;`);
console.info(`Version: %c${PACKAGE_JSON.version}`, `font-weight: bold;`);
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
console.info('');

}

0 comments on commit c94e5d0

Please sign in to comment.