build: sanitize build scope, pass version through env

This commit is contained in:
EnixCoda 2019-11-08 17:01:39 +08:00
parent 0fc3b26337
commit 405d863913
No known key found for this signature in database
GPG key ID: FE06F5DFC1C9B8E4
5 changed files with 14 additions and 17 deletions

View file

@ -7,10 +7,10 @@
"license": "MIT",
"private": true,
"scripts": {
"start": "webpack --watch",
"start": "VERSION=dev-v$(node scripts/get-version.js) webpack --watch",
"debug-firefox": "web-ext run -s dist",
"analyse-bundle": "ANALYSE= NODE_ENV=production webpack",
"build": "NODE_ENV=production webpack",
"build": "VERSION=v$(node scripts/get-version.js) NODE_ENV=production webpack",
"postversion": "node scripts/version.js",
"roll": "make release"
},

View file

@ -1,14 +1,13 @@
import * as Sentry from '@sentry/browser'
import { Middleware } from 'driver/connect.js'
import { IN_PRODUCTION_MODE } from 'env'
import { version } from '../package.json'
import { IN_PRODUCTION_MODE, VERSION } from 'env'
const PUBLIC_KEY = 'd22ec5c9cc874539a51c78388c12e3b0'
const PROJECT_ID = '1406497'
const sentryOptions: Sentry.BrowserOptions = {
dsn: `https://${PUBLIC_KEY}@sentry.io/${PROJECT_ID}`,
release: `v${version}`,
release: VERSION,
environment: IN_PRODUCTION_MODE ? 'production' : 'development',
// Not safe to activate all integrations in non-Chrome environments where Gitako may not run in top context
// https://docs.sentry.io/platforms/javascript/#sdk-integrations

View file

@ -1,11 +1,10 @@
import { raiseError } from 'analytics'
import Icon from 'components/Icon'
import { oauth } from 'env'
import { oauth, VERSION } from 'env'
import * as React from 'react'
import configHelper, { Config, configKeys } from 'utils/configHelper'
import { friendlyFormatShortcut, JSONRequest, parseURLSearch } from 'utils/general'
import keyHelper from 'utils/keyHelper'
import { version } from '../../package.json'
const WIKI_HOME_LINK = 'https://github.com/EnixCoda/Gitako/wiki'
const wikiLinks = {
@ -348,7 +347,7 @@ export default class SettingsBar extends React.PureComponent<Props, State> {
target={'_blank'}
title={'Check out new features!'}
>
v{version}
{VERSION}
</a>
{activated ? (
<Icon

View file

@ -9,3 +9,5 @@ export const oauth = {
clientId: process.env.GITHUB_OAUTH_CLIENT_ID,
clientSecret: process.env.GITHUB_OAUTH_CLIENT_SECRET,
}
export const VERSION = process.env.VERSION

View file

@ -38,15 +38,12 @@ if (analyse) {
}
const IN_PRODUCTION_MODE = process.env.NODE_ENV === 'production'
if (IN_PRODUCTION_MODE) {
plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
)
}
plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.VERSION': JSON.stringify(process.env.VERSION),
}),
)
module.exports = {
entry: {