Version bump and sync git hash

This commit is contained in:
Nicholas Zuber 2018-11-10 23:29:53 -05:00
parent 7ad93df2bd
commit b27c4bc962
4 changed files with 27 additions and 11 deletions

View File

@ -2,6 +2,7 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const {execSync} = require('child_process');
const PnpWebpackPlugin = require('pnp-webpack-plugin'); const PnpWebpackPlugin = require('pnp-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
@ -14,6 +15,7 @@ const paths = require('./paths');
const ManifestPlugin = require('webpack-manifest-plugin'); const ManifestPlugin = require('webpack-manifest-plugin');
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
const gitHash = execSync('git rev-parse --short HEAD').toString().trim();
// Webpack uses `publicPath` to determine where the app is being served from. // Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier. // In development, we always serve from the root. This makes config easier.
@ -177,7 +179,7 @@ module.exports = {
options: { options: {
formatter: require.resolve('react-dev-utils/eslintFormatter'), formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'), eslintPath: require.resolve('eslint'),
}, },
loader: require.resolve('eslint-loader'), loader: require.resolve('eslint-loader'),
}, },
@ -210,7 +212,7 @@ module.exports = {
customize: require.resolve( customize: require.resolve(
'babel-preset-react-app/webpack-overrides' 'babel-preset-react-app/webpack-overrides'
), ),
plugins: [ plugins: [
[ [
require.resolve('babel-plugin-named-asset-import'), require.resolve('babel-plugin-named-asset-import'),
@ -250,7 +252,7 @@ module.exports = {
cacheDirectory: true, cacheDirectory: true,
// Don't waste time on Gzipping the cache // Don't waste time on Gzipping the cache
cacheCompression: false, cacheCompression: false,
// If an error happens in a package, it's possible to be // If an error happens in a package, it's possible to be
// because it was compiled. Thus, we don't want the browser // because it was compiled. Thus, we don't want the browser
// debugger to show the original code. Instead, the code // debugger to show the original code. Instead, the code
@ -327,6 +329,11 @@ module.exports = {
], ],
}, },
plugins: [ plugins: [
new webpack.DefinePlugin({
'process.env': {
'GIT_HASH': JSON.stringify(gitHash)
}
}),
// Generates an `index.html` file with the <script> injected. // Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
inject: true, inject: true,

View File

@ -2,6 +2,7 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const {execSync} = require('child_process');
const PnpWebpackPlugin = require('pnp-webpack-plugin'); const PnpWebpackPlugin = require('pnp-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin'); const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
@ -18,6 +19,8 @@ const paths = require('./paths');
const getClientEnvironment = require('./env'); const getClientEnvironment = require('./env');
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
const gitHash = execSync('git rev-parse --short HEAD').toString().trim();
// Webpack uses `publicPath` to determine where the app is being served from. // Webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path. // It requires a trailing slash, or the file assets will get an incorrect path.
@ -251,7 +254,7 @@ module.exports = {
options: { options: {
formatter: require.resolve('react-dev-utils/eslintFormatter'), formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'), eslintPath: require.resolve('eslint'),
}, },
loader: require.resolve('eslint-loader'), loader: require.resolve('eslint-loader'),
}, },
@ -284,7 +287,7 @@ module.exports = {
customize: require.resolve( customize: require.resolve(
'babel-preset-react-app/webpack-overrides' 'babel-preset-react-app/webpack-overrides'
), ),
plugins: [ plugins: [
[ [
require.resolve('babel-plugin-named-asset-import'), require.resolve('babel-plugin-named-asset-import'),
@ -322,7 +325,7 @@ module.exports = {
cacheDirectory: true, cacheDirectory: true,
// Save disk space when time isn't as important // Save disk space when time isn't as important
cacheCompression: true, cacheCompression: true,
// If an error happens in a package, it's possible to be // If an error happens in a package, it's possible to be
// because it was compiled. Thus, we don't want the browser // because it was compiled. Thus, we don't want the browser
// debugger to show the original code. Instead, the code // debugger to show the original code. Instead, the code
@ -416,6 +419,11 @@ module.exports = {
], ],
}, },
plugins: [ plugins: [
new webpack.DefinePlugin({
'process.env': {
'GIT_HASH': JSON.stringify(gitHash)
}
}),
// Generates an `index.html` file with the <script> injected. // Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
inject: true, inject: true,

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "meteorite", "name": "meteorite",
"version": "0.1.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -8,7 +8,8 @@ import Logo from '../../components/Logo';
import screenshot from '../../images/screenshot.png'; import screenshot from '../../images/screenshot.png';
import '../../styles/gradient.css'; import '../../styles/gradient.css';
const version = require('../../../package.json').version; const hash = process.env.GIT_HASH ? `#${process.env.GIT_HASH}` : '';
const version = require('../../../package.json').version + hash;
function createImagePlaceholder (highlight) { function createImagePlaceholder (highlight) {
return ( return (
@ -749,9 +750,9 @@ export default function Scene ({loggedIn, onLogout, ...props}) {
</SmallText> </SmallText>
</Item> </Item>
<Item style={{textAlign: 'right'}} className="footer-links"> <Item style={{textAlign: 'right'}} className="footer-links">
<SmallLink style={{marginLeft: 28}}>Source code</SmallLink> <SmallLink target="_blank" href="https://github.com/nickzuber/meteorite/" style={{marginLeft: 28}}>Source code</SmallLink>
<SmallLink style={{marginLeft: 28}}>Bug reports</SmallLink> <SmallLink target="_blank" href="https://github.com/nickzuber/meteorite/issues" style={{marginLeft: 28}}>Bug reports</SmallLink>
<SmallLink style={{marginLeft: 28}}>Submit feedback</SmallLink> <SmallLink target="_blank" href="https://github.com/nickzuber/meteorite/issues" style={{marginLeft: 28}}>Submit feedback</SmallLink>
<SmallText style={{marginLeft: 28, opacity: .25}}>v{version}</SmallText> <SmallText style={{marginLeft: 28, opacity: .25}}>v{version}</SmallText>
</Item> </Item>
<Item style={{flex: '0 0 2.5%', padding: 0}} /> <Item style={{flex: '0 0 2.5%', padding: 0}} />