Skip to content

Commit

Permalink
add version info, show on options page
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 29, 2023
1 parent bcef5a1 commit 87217d2
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 3 deletions.
2 changes: 2 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ testem.log
# System files
.DS_Store
Thumbs.db

version.json
28 changes: 28 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"start": "ng serve -o --port 3699",
"setup": "ts-node scripts/setup",
"build": "ng build --configuration production",
"build:netlify": "npm run build",
"build:netlify": "npm run build && npm run generate:version",
"generate:version": "ts-node scripts/version",
"watch": "ng build --watch --configuration development",
"lint": "ng lint"
},
Expand Down Expand Up @@ -71,6 +72,7 @@
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "30.7.6",
"eslint-plugin-prefer-arrow": "1.2.2",
"fs-extra": "^11.1.1",
"ts-node": "^8.3.0",
"typescript": "~5.0.2"
}
Expand Down
15 changes: 15 additions & 0 deletions client/scripts/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require('fs-extra');
const { gitDescribeSync } = require('git-describe');

let gitRev = 'UNCOMMITTED';
try {
gitRev = gitDescribeSync({
dirtyMark: false,
dirtySemver: false,
});
} catch (e) {
console.error('No git HEAD; default gitRev set.');
}

fs.writeJson(`${__dirname}/../src/assets/version.json`, gitRev);
console.log('Wrote version information', gitRev);
1 change: 1 addition & 0 deletions client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function getAuthToken() {
JwtModule.forRoot({
config: {
tokenGetter: getAuthToken,
allowedDomains: ['localhost:3000', 'api.ateoat.com', 'ateoat.com'],
},
}),
ServiceWorkerModule.register('ngsw-worker.js', {
Expand Down
25 changes: 25 additions & 0 deletions client/src/app/pages/options/options.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@
</ion-header>

<ion-grid *ngIf="{ options: options$ | async } as data">
<ion-row>
<ion-col>
<ion-card>
<ion-card-content>
<ion-row>
<ion-col>
<strong>Client Version:</strong>
{{ version }}
</ion-col>

<ion-col>
<strong>Content Version:</strong>
{{ contentVersion }}
</ion-col>

<ion-col>
<strong>Assets Version:</strong>
{{ artVersion }}
</ion-col>
</ion-row>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>

<ion-row>
<ion-col>
<ion-card>
Expand Down
49 changes: 48 additions & 1 deletion client/src/app/pages/options/options.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,56 @@ export class OptionsPage implements OnInit {
Record<GameOption, number | string>
>;

private versionInfo: any = {
tag: '',
semverString: '',
raw: 'v.local',
hash: 'v.local',
distance: -1,
};

public get version(): string {
if (this.versionInfo.distance >= 0 && this.versionInfo.tag) {
return `${this.versionInfo.tag} (${this.versionInfo.raw})`;
}

return (
this.versionInfo.tag ||
this.versionInfo.semverString ||
this.versionInfo.raw ||
this.versionInfo.hash
);
}

public get contentVersion(): string {
return (
(localStorage.getItem('contentVersion') || '').substring(0, 8) ||
'unknown'
);
}

public get artVersion(): string {
return (
(localStorage.getItem('artVersion') || '').substring(0, 8) || 'unknown'
);
}

constructor(private store: Store) {}

ngOnInit() {}
ngOnInit() {
this.loadVersionInfo();
}

async loadVersionInfo() {
try {
const response = await fetch('/assets/version.json');
const json = await response.json();

this.versionInfo = json;
} catch {
console.error('Could not load version information');
}
}

setOption(option: string, event: any) {
this.store.dispatch(
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/services/asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class AssetService {
const manifest = await fetch(`${environment.assetsUrl}/manifest.json`);
const manifestData = await manifest.json();

localStorage.setItem('artVersion', manifestData.meta.hash);

this.maxPortraits = manifestData.assets.individualLQ.filter((x: any) =>
x.name.startsWith('portraits-'),
).length;
Expand Down
1 change: 0 additions & 1 deletion client/src/app/services/rollbar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class RollbarService {
captureUncaught: true,
captureUnhandledRejections: true,
hostBlockList: ['netlify.app'],
hostSafelist: ['ateoat.com'],
payload: {
environment: environment.rollbar.environment,
},
Expand Down

0 comments on commit 87217d2

Please sign in to comment.