From 405d863913c88a78e62b5e88ad6ef3744993bd6b Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Fri, 8 Nov 2019 17:01:39 +0800 Subject: [PATCH] build: sanitize build scope, pass version through env --- package.json | 4 ++-- src/analytics.ts | 5 ++--- src/components/SettingsBar.tsx | 5 ++--- src/env.ts | 2 ++ webpack.config.js | 15 ++++++--------- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 2f45dc2..b5d5721 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/analytics.ts b/src/analytics.ts index 492c2f2..0fdf838 100644 --- a/src/analytics.ts +++ b/src/analytics.ts @@ -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 diff --git a/src/components/SettingsBar.tsx b/src/components/SettingsBar.tsx index 1aa686d..71ff569 100644 --- a/src/components/SettingsBar.tsx +++ b/src/components/SettingsBar.tsx @@ -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 { target={'_blank'} title={'Check out new features!'} > - v{version} + {VERSION} {activated ? (