Skip to content

Commit f23e253

Browse files
authored
Merge pull request #1307 from shockey/ft/version-info
Add version global
2 parents 72df7c6 + 29cb7dd commit f23e253

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

make-webpack-config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ var webpack = require('webpack')
44
var ExtractTextPlugin = require('extract-text-webpack-plugin')
55
var deepExtend = require('deep-extend')
66
var autoprefixer = require('autoprefixer')
7+
const {gitDescribeSync} = require('git-describe')
8+
9+
var pkg = require('./package.json')
10+
const gitInfo = gitDescribeSync(__dirname)
711

812
var loadersByExtension = require('./build-tools/loadersByExtension')
913

@@ -66,6 +70,11 @@ module.exports = function(options) {
6670
NODE_ENV: specialOptions.minimize ? JSON.stringify('production') : null,
6771
WEBPACK_INLINE_STYLES: !Boolean(specialOptions.separateStylesheets)
6872
},
73+
'buildInfo': JSON.stringify({
74+
PACKAGE_VERSION: pkg.version,
75+
GIT_COMMIT: gitInfo.hash,
76+
GIT_DIRTY: gitInfo.dirty
77+
})
6978
}))
7079

7180
var cssLoader = 'css-loader!postcss-loader'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"eslint-plugin-react": "^4.3.0",
7373
"extract-text-webpack-plugin": "0.8.2",
7474
"file-loader": "0.8.4",
75+
"git-describe": "^4.0.1",
7576
"html-webpack-plugin": "^2.28.0",
7677
"http-server": "^0.9.0",
7778
"imports-loader": "0.6.5",

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import LocalStoragePlugin from "./plugins/local-storage"
88
import TopBarPlugin from "./plugins/topbar"
99
import ValidationApiPlugin from "./plugins/validation/apis"
1010

11+
// eslint-disable-next-line no-undef
12+
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
13+
14+
window.versions = window.versions || {}
15+
window.versions.swaggerEditor = `${PACKAGE_VERSION}/${GIT_COMMIT || "unknown"}${GIT_DIRTY ? "-dirty" : ""}`
16+
1117
const defaults = {
1218
dom_id: "#swagger-editor",
1319
layout: "EditorLayout",

0 commit comments

Comments
 (0)