diff --git a/.gitignore b/.gitignore index 70629f3..12abf87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Auto generated after a successful npm install +web/src/environments/version.ts + release/ node_modules/ web/npm-debug.log diff --git a/web/package-lock.json b/web/package-lock.json index 7a51e6a..ed89c36 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -7266,6 +7266,25 @@ "assert-plus": "^1.0.0" } }, + "git-describe": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/git-describe/-/git-describe-4.0.4.tgz", + "integrity": "sha512-L1X9OO1e4MusB4PzG9LXeXCQifRvyuoHTpuuZ521Qyxn/B0kWHWEOtsT4LsSfSNacZz0h4ZdYDsDG7f+SrA3hg==", + "dev": true, + "requires": { + "lodash": "^4.17.11", + "semver": "^5.6.0" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "optional": true + } + } + }, "glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", diff --git a/web/package.json b/web/package.json index 8207ddb..184f247 100644 --- a/web/package.json +++ b/web/package.json @@ -16,7 +16,8 @@ "start:electron": "tsc main.ts && ng build && electron .", "pack": "electron-builder --dir", "dist": "electron-builder", - "electron-postinstall": "electron-builder install-app-deps && ngcc" + "electron-postinstall": "electron-builder install-app-deps && ngcc", + "postinstall": "node scripts/version.js" }, "dependencies": { "@angular/animations": "~9.1.11", @@ -52,6 +53,7 @@ "codelyzer": "^5.1.2", "electron": "^9.3.1", "electron-builder": "^22.7.0", + "git-describe": "^4.0.4", "husky": "^4.2.5", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~4.2.1", diff --git a/web/scripts/version.js b/web/scripts/version.js new file mode 100644 index 0000000..b6c6fd0 --- /dev/null +++ b/web/scripts/version.js @@ -0,0 +1,21 @@ +const { gitDescribeSync } = require('git-describe'); +const { version } = require('../package.json'); +const { resolve, relative } = require('path'); +const { writeFileSync } = require('fs-extra'); + +const gitInfo = gitDescribeSync({ + dirtyMark: false, + dirtySemver: false +}); + +gitInfo.version = version; + +const file = resolve(__dirname, '..', 'src', 'environments', 'version.ts'); +writeFileSync(file, + `// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN! +/* tslint:disable */ +export const VERSION = ${JSON.stringify(gitInfo, null, 4)}; +/* tslint:enable */ +`, { encoding: 'utf-8' }); + +console.log(`Wrote version info ${gitInfo.raw} to ${relative(resolve(__dirname, '..'), file)}`); diff --git a/web/src/app/pages/dialog-template.html b/web/src/app/pages/dialog-template.html index beefd29..b556fc2 100644 --- a/web/src/app/pages/dialog-template.html +++ b/web/src/app/pages/dialog-template.html @@ -1,4 +1,16 @@
+ Dapr version: {{ data.version }} +
+ ++ Dapr Dashboard: {{ version.version }} ({{ version.hash }}) +
+ +