Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
Version info
Browse files Browse the repository at this point in the history
Add version info to footer. Generate automatically at build and pick version from package.json (though we can also pick from git or git tags or whatever.
  • Loading branch information
Martinspire committed Jun 28, 2023
1 parent 79fe55a commit 4ed1771
Show file tree
Hide file tree
Showing 6 changed files with 2,277 additions and 3,059 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ testem.log
Thumbs.db

.angular
apps/formule1/src/environments/version.ts
4 changes: 2 additions & 2 deletions apps/formule1/src/app/components/footer/footer.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<footer class="footer footer-center p-4 bg-base-300 text-base-content">
<div>
<p>
Website by Martin Spierings - 2023 - Powered by
Website by Martin Spierings - 2023 - v{{version}} - Powered by
<a href="https://ergast.com/mrd/" target="_blank">Ergast</a>&nbsp;
<button class="btn btn-outline btn-sm" (click)="showShare()">
Share
</button>
</p>
</div>
</footer>
</footer>
9 changes: 6 additions & 3 deletions apps/formule1/src/app/components/footer/footer.component.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { Component } from '@angular/core';
import { DialogService } from '@ngneat/dialog';
import { VERSION } from '../../../environments/version';

@Component({
selector: 'f1-footer',
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.scss']
})
export class FooterComponent{
export class FooterComponent {

constructor(private dialog: DialogService) {}
version = VERSION.version;

constructor(private dialog: DialogService) { }

async showShare(): Promise<void> {
const {ShareComponent} = await import(
const { ShareComponent } = await import(
'./../share/share.component'
);

Expand Down
23 changes: 23 additions & 0 deletions git-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { gitDescribeSync } = require('git-describe');
const { version } = require('./package.json');
const { resolve, relative } = require('path');
const { writeFileSync, existsSync, mkdirSync } = require('fs-extra');

const gitInfo = gitDescribeSync({
dirtyMark: false,
dirtySemver: false
});

gitInfo.version = version;

if (!existsSync(__dirname + '/apps/formule1/src/environments')) {
mkdirSync(__dirname + '/apps/formule1/src/environments');
}
const file = resolve(__dirname, 'apps', 'formule1', 'src', 'environments', 'version.ts');
writeFileSync(file,
`// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
/* eslint-disable */
export const VERSION = ${JSON.stringify(gitInfo, null, 4)};
`, { encoding: 'utf-8' });

console.log(`Wrote version info ${gitInfo.raw} to ${relative(resolve(__dirname, '..'), file)}`);
Loading

0 comments on commit 4ed1771

Please sign in to comment.