Automatically embed the application version in the UI.pull/263/head
parent
5dbfad68ad
commit
d93d24b52d
@ -0,0 +1,25 @@
|
|||||||
|
import { writeFileSync } from 'fs';
|
||||||
|
import { dedent } from 'tslint/lib/utils';
|
||||||
|
import { promisify } from 'util';
|
||||||
|
import * as child from 'child_process';
|
||||||
|
const exec = promisify(child.exec);
|
||||||
|
|
||||||
|
async function createVersionsFile(filename: string) {
|
||||||
|
const tag = (await exec('git describe --tags')).stdout.toString().trim();
|
||||||
|
const revision = (await exec('git rev-parse --short HEAD')).stdout.toString().trim();
|
||||||
|
const branch = (await exec('git rev-parse --abbrev-ref HEAD')).stdout.toString().trim();
|
||||||
|
|
||||||
|
console.log(`version: '${process.env.npm_package_version}', revision: '${revision}', branch: '${branch}'`);
|
||||||
|
|
||||||
|
const content = dedent`
|
||||||
|
// this file is automatically generated by git.version.ts script
|
||||||
|
export const versions = {
|
||||||
|
version: '${tag}',
|
||||||
|
revision: '${revision}',
|
||||||
|
branch: '${branch}'
|
||||||
|
};`;
|
||||||
|
|
||||||
|
writeFileSync(filename, content, {encoding: 'utf8'});
|
||||||
|
}
|
||||||
|
|
||||||
|
createVersionsFile('src/environments/versions.ts');
|
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
// this file is automatically generated by git.version.ts script
|
||||||
|
export const versions = {
|
||||||
|
version: 'v0.0.0',
|
||||||
|
revision: 'abcdef123',
|
||||||
|
branch: 'master'
|
||||||
|
};
|
Loading…
Reference in new issue