Skip to content

Commit be7b244

Browse files
authored
Merge pull request #3356 from owenconti/feature/3300-updated-version-info
Fixes #3300 - Updates to versions.swaggerUi information
2 parents 0ee9f95 + ff9e164 commit be7b244

File tree

2 files changed

+42
-34
lines changed

2 files changed

+42
-34
lines changed

make-webpack-config.js

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
1-
var path = require('path')
1+
var path = require("path")
22

3-
var webpack = require('webpack')
4-
var ExtractTextPlugin = require('extract-text-webpack-plugin')
5-
var deepExtend = require('deep-extend')
6-
const {gitDescribeSync} = require('git-describe');
3+
var webpack = require("webpack")
4+
var ExtractTextPlugin = require("extract-text-webpack-plugin")
5+
var deepExtend = require("deep-extend")
6+
const {gitDescribeSync} = require("git-describe")
7+
const os = require("os")
78

8-
var pkg = require('./package.json')
9+
var pkg = require("./package.json")
910

1011
let gitInfo
1112

1213
try {
1314
gitInfo = gitDescribeSync(__dirname)
1415
} catch(e) {
1516
gitInfo = {
16-
hash: 'noGit',
17+
hash: "noGit",
1718
dirty: false
1819
}
1920
}
2021

2122
var commonRules = [
2223
{ test: /\.(js(x)?)(\?.*)?$/,
2324
use: [{
24-
loader: 'babel-loader',
25+
loader: "babel-loader",
2526
options: {
2627
retainLines: true
2728
}
2829
}],
29-
include: [ path.join(__dirname, 'src') ]
30+
include: [ path.join(__dirname, "src") ]
3031
},
3132
{ test: /\.(txt|yaml)(\?.*)?$/,
32-
loader: 'raw-loader' },
33+
loader: "raw-loader" },
3334
{ test: /\.(png|jpg|jpeg|gif|svg)(\?.*)?$/,
34-
loader: 'url-loader?limit=10000' },
35+
loader: "url-loader?limit=10000" },
3536
{ test: /\.(woff|woff2)(\?.*)?$/,
36-
loader: 'url-loader?limit=100000' },
37+
loader: "url-loader?limit=100000" },
3738
{ test: /\.(ttf|eot)(\?.*)?$/,
38-
loader: 'file-loader' }
39+
loader: "file-loader" }
3940
]
4041

4142
module.exports = function(rules, options) {
@@ -54,7 +55,7 @@ module.exports = function(rules, options) {
5455

5556
if( specialOptions.separateStylesheets ) {
5657
plugins.push(new ExtractTextPlugin({
57-
filename: '[name].css' + (specialOptions.longTermCaching ? '?[contenthash]' : ''),
58+
filename: "[name].css" + (specialOptions.longTermCaching ? "?[contenthash]" : ""),
5859
allChunks: true
5960
}))
6061
}
@@ -78,61 +79,62 @@ module.exports = function(rules, options) {
7879

7980
plugins.push(
8081
new webpack.DefinePlugin({
81-
'process.env': {
82-
NODE_ENV: specialOptions.minimize ? JSON.stringify('production') : null,
83-
WEBPACK_INLINE_STYLES: !Boolean(specialOptions.separateStylesheets)
84-
82+
"process.env": {
83+
NODE_ENV: specialOptions.minimize ? JSON.stringify("production") : null,
84+
WEBPACK_INLINE_STYLES: !specialOptions.separateStylesheets
8585
},
86-
'buildInfo': JSON.stringify({
86+
"buildInfo": JSON.stringify({
8787
PACKAGE_VERSION: (pkg.version),
8888
GIT_COMMIT: gitInfo.hash,
89-
GIT_DIRTY: gitInfo.dirty
89+
GIT_DIRTY: gitInfo.dirty,
90+
HOSTNAME: os.hostname(),
91+
BUILD_TIME: new Date().toUTCString()
9092
})
9193
}))
9294

9395
delete options._special
9496

95-
var completeConfig = deepExtend({
97+
var completeConfig = deepExtend({
9698
entry: {},
9799

98100
output: {
99-
path: path.join(__dirname, 'dist'),
100-
publicPath: '/',
101-
filename: '[name].js',
102-
chunkFilename: '[name].js'
101+
path: path.join(__dirname, "dist"),
102+
publicPath: "/",
103+
filename: "[name].js",
104+
chunkFilename: "[name].js"
103105
},
104106

105-
target: 'web',
107+
target: "web",
106108

107109
// yaml-js has a reference to `fs`, this is a workaround
108110
node: {
109-
fs: 'empty'
111+
fs: "empty"
110112
},
111113

112114
module: {
113115
rules: commonRules.concat(rules),
114116
},
115117

116118
resolveLoader: {
117-
modules: [path.join(__dirname, 'node_modules')],
119+
modules: [path.join(__dirname, "node_modules")],
118120
},
119121

120122
externals: {
121-
'buffertools': true // json-react-schema/deeper depends on buffertools, which fails.
123+
"buffertools": true // json-react-schema/deeper depends on buffertools, which fails.
122124
},
123125

124126
resolve: {
125127
modules: [
126-
path.join(__dirname, './src'),
127-
'node_modules'
128+
path.join(__dirname, "./src"),
129+
"node_modules"
128130
],
129131
extensions: [".web.js", ".js", ".jsx", ".json", ".less"],
130132
alias: {
131133
base: "getbase/src/less/base",
132134
}
133135
},
134136

135-
devtool: specialOptions.sourcemaps ? 'cheap-module-source-map' : null,
137+
devtool: specialOptions.sourcemaps ? "cheap-module-source-map" : null,
136138

137139
plugins,
138140

src/core/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ const CONFIGS = [ "url", "urls", "urls.primaryName", "spec", "validatorUrl", "on
1111
"showRequestHeaders", "custom", "modelPropertyMacro", "parameterMacro", "displayOperationId" , "displayRequestDuration"]
1212

1313
// eslint-disable-next-line no-undef
14-
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
14+
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION, HOSTNAME, BUILD_TIME } = buildInfo
1515

1616
module.exports = function SwaggerUI(opts) {
1717

1818
win.versions = win.versions || {}
19-
win.versions.swaggerUi = `${PACKAGE_VERSION}/${GIT_COMMIT || "unknown"}${GIT_DIRTY ? "-dirty" : ""}`
19+
win.versions.swaggerUi = {
20+
version: PACKAGE_VERSION,
21+
gitRevision: GIT_COMMIT,
22+
gitDirty: GIT_DIRTY,
23+
buildTimestamp: BUILD_TIME,
24+
machine: HOSTNAME
25+
}
2026

2127
const defaults = {
2228
// Some general settings, that we floated to the top

0 commit comments

Comments
 (0)