From 2b87d20290084a4bc547a0bfa1222e2152037988 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Thu, 29 Nov 2018 09:55:30 -0800 Subject: Set .env in builds, and update profile to use 0xproject --- packages/instant/.dogfood.discharge.json | 4 ++-- packages/instant/.production.discharge.json | 4 ++-- packages/instant/.staging.discharge.json | 4 ++-- packages/instant/package.json | 7 ++----- 4 files changed, 8 insertions(+), 11 deletions(-) (limited to 'packages') diff --git a/packages/instant/.dogfood.discharge.json b/packages/instant/.dogfood.discharge.json index ca36b3861..6e669ebaa 100644 --- a/packages/instant/.dogfood.discharge.json +++ b/packages/instant/.dogfood.discharge.json @@ -1,12 +1,12 @@ { "domain": "0x-instant-dogfood", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:umd:prod", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.dogfood", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", "trailing_slashes": true, "cache": 3600, - "aws_profile": "default", + "aws_profile": "0xproject", "aws_region": "us-east-1", "cdn": false, "dns_configured": true diff --git a/packages/instant/.production.discharge.json b/packages/instant/.production.discharge.json index 447fa1756..b2369d43e 100644 --- a/packages/instant/.production.discharge.json +++ b/packages/instant/.production.discharge.json @@ -1,12 +1,12 @@ { "domain": "instant.0xproject.com", - "build_command": "yarn build", + "build_command": "yarn build --env.production_cdn", "upload_directory": "umd", "index_key": "instant.js", "error_key": "404.html", "trailing_slashes": true, "cache": 3600, - "aws_profile": "default", + "aws_profile": "0xproject", "aws_region": "us-east-1", "cdn": true, "dns_configured": true diff --git a/packages/instant/.staging.discharge.json b/packages/instant/.staging.discharge.json index c917a650b..6df436f73 100644 --- a/packages/instant/.staging.discharge.json +++ b/packages/instant/.staging.discharge.json @@ -1,12 +1,12 @@ { "domain": "0x-instant-staging", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:umd:prod", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:prod --env.staging", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", "trailing_slashes": true, "cache": 3600, - "aws_profile": "default", + "aws_profile": "0xproject", "aws_region": "us-east-1", "cdn": false, "dns_configured": true diff --git a/packages/instant/package.json b/packages/instant/package.json index 427d5984e..bc46aa732 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -8,7 +8,7 @@ "main": "umd/instant.js", "private": true, "scripts": { - "build": "webpack --mode production", + "build": "webpack --mode production --env.production_standalone", "build:ci": "yarn build", "watch_without_deps": "tsc -w", "dev": "webpack-dev-server --mode development", @@ -25,10 +25,7 @@ }, "config": { "postpublish": { - "assets": [ - "packages/instant/umd/instant.js", - "packages/instant/umd/instant.js.map" - ] + "assets": ["packages/instant/umd/instant.js", "packages/instant/umd/instant.js.map"] } }, "repository": { -- cgit v1.2.3 From bd03df8af02169ef88207eb14051bc79231927aa Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Thu, 29 Nov 2018 12:05:20 -0800 Subject: feat(instant): Cleaner config-specific setup --- packages/instant/.dogfood.discharge.json | 2 +- packages/instant/.production.discharge.json | 2 +- packages/instant/.staging.discharge.json | 2 +- packages/instant/package.json | 7 +-- packages/instant/src/constants.ts | 6 +++ packages/instant/webpack.config.js | 73 ++++++++++++++++++++++------- 6 files changed, 69 insertions(+), 23 deletions(-) (limited to 'packages') diff --git a/packages/instant/.dogfood.discharge.json b/packages/instant/.dogfood.discharge.json index 6e669ebaa..5a11f8a1d 100644 --- a/packages/instant/.dogfood.discharge.json +++ b/packages/instant/.dogfood.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-dogfood", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.dogfood", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:prod --env.dogfood", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/.production.discharge.json b/packages/instant/.production.discharge.json index b2369d43e..ecd3a12d4 100644 --- a/packages/instant/.production.discharge.json +++ b/packages/instant/.production.discharge.json @@ -1,6 +1,6 @@ { "domain": "instant.0xproject.com", - "build_command": "yarn build --env.production_cdn", + "build_command": "yarn build:prod --env.production_cdn", "upload_directory": "umd", "index_key": "instant.js", "error_key": "404.html", diff --git a/packages/instant/.staging.discharge.json b/packages/instant/.staging.discharge.json index 6df436f73..ba2ca5f99 100644 --- a/packages/instant/.staging.discharge.json +++ b/packages/instant/.staging.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-staging", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:prod --env.staging", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:prod:prod --env.staging", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/package.json b/packages/instant/package.json index bc46aa732..964e5c9b3 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -8,10 +8,11 @@ "main": "umd/instant.js", "private": true, "scripts": { - "build": "webpack --mode production --env.production_standalone", - "build:ci": "yarn build", + "build": "yarn build:prod --env.production_standalone", + "build:prod": "webpack --mode production", + "build:ci": "build", "watch_without_deps": "tsc -w", - "dev": "webpack-dev-server --mode development", + "dev": "webpack-dev-server --mode development --env.development", "lint": "tslint --format stylish --project .", "test": "jest", "test:coverage": "jest --coverage", diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts index be6077ca9..e70b3f1d8 100644 --- a/packages/instant/src/constants.ts +++ b/packages/instant/src/constants.ts @@ -20,6 +20,12 @@ export const HEAP_ANALYTICS_ID = process.env.HEAP_ANALYTICS_ID; export const COINBASE_API_BASE_URL = 'https://api.coinbase.com/v2'; export const PROGRESS_STALL_AT_WIDTH = '95%'; export const PROGRESS_FINISH_ANIMATION_TIME_MS = 200; +export const INSTANT_ENVIRONMENT = process.env.INSTANT_ENVIRONMENT as + | 'dogfood' + | 'staging' + | 'development' + | 'production_cdn' + | 'production_standalone'; export const COINBASE_WALLET_IOS_APP_STORE_URL = 'https://itunes.apple.com/us/app/coinbase-wallet/id1278383455?mt=8'; export const COINBASE_WALLET_ANDROID_APP_STORE_URL = 'https://play.google.com/store/apps/details?id=org.toshi&hl=en'; export const COINBASE_WALLET_SITE_URL = 'https://wallet.coinbase.com/'; diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js index 41276809c..284276c1a 100644 --- a/packages/instant/webpack.config.js +++ b/packages/instant/webpack.config.js @@ -6,27 +6,64 @@ const webpack = require('webpack'); // The common js bundle (not this one) is built using tsc. // The umd bundle (this one) has a different entrypoint. +const ACCEPTABLE_ENV_NAMES = ['production_standalone', 'production_cdn', 'staging', 'dogfood', 'development']; +const getEnvironmentName = env => { + if (!env) { + throw new Error('Please specify env via --env to webpack'); + } + const foundName = ACCEPTABLE_ENV_NAMES.find(e => (env[e] ? e : false)); + if (!foundName) { + throw new Error( + `Couldn't find env name, please specify via one of the following CLI arguments: ${acceptableEnvNames.map( + i => `--env.${i}`, + )}`, + ); + } + return foundName; +}; + +const getConfigForEnv = environmentName => { + switch (environmentName) { + case 'production_standalone': + case 'production_cdn': + return { + heapAnalyticsIdEnvName: 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION', + heapAnalyticsIdRequired: environmentName !== 'production_standalone', + }; + case 'staging': + case 'dogfood': + case 'development': + return { + heapAnalyticsIdEnvName: 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT', + heapAnalyticsIdRequired: environmentName !== 'development', + }; + } +}; + const GIT_SHA = childProcess .execSync('git rev-parse HEAD') .toString() .trim(); +const generateConfig = (environmentName, configOptions) => { + const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd'; -const HEAP_PRODUCTION_ENV_VAR_NAME = 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION'; -const HEAP_DEVELOPMENT_ENV_VAR_NAME = 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT'; -const getHeapAnalyticsId = modeName => { - if (modeName === 'production') { - return process.env[HEAP_PRODUCTION_ENV_VAR_NAME]; + const { heapAnalyticsIdEnvName, heapAnalyticsIdRequired } = configOptions; + const heapAnalyticsId = process.env[heapAnalyticsIdEnvName]; + if (heapAnalyticsIdRequired && !heapAnalyticsId) { + throw new Error( + `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${environmentName}`, + ); } - if (modeName === 'development') { - return process.env[HEAP_DEVELOPMENT_ENV_VAR_NAME]; + const envVars = { + GIT_SHA: JSON.stringify(GIT_SHA), + INSTANT_ENVIRONMENT: JSON.stringify(environmentName), + NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version), + }; + if (heapAnalyticsId) { + envVars.HEAP_ANALYTICS_ID = JSON.stringify(heapAnalyticsId); } - return undefined; -}; - -module.exports = (env, argv) => { - const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd'; const config = { entry: { instant: './src/index.umd.ts', @@ -39,11 +76,7 @@ module.exports = (env, argv) => { }, plugins: [ new webpack.DefinePlugin({ - 'process.env': { - GIT_SHA: JSON.stringify(GIT_SHA), - HEAP_ANALYTICS_ID: getHeapAnalyticsId(argv.mode), - NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version), - }, + 'process.env': envVars, }), ], devtool: 'source-map', @@ -79,3 +112,9 @@ module.exports = (env, argv) => { }; return config; }; + +module.exports = (env, _argv) => { + const environmentName = getEnvironmentName(env); + const configOptions = getConfigForEnv(environmentName); + return generateConfig(environmentName, configOptions); +}; -- cgit v1.2.3 From 4616c51e199b3e5c37f8b5f23788645632f2faf6 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Thu, 29 Nov 2018 14:36:05 -0800 Subject: Fix build command --- packages/instant/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/instant/package.json b/packages/instant/package.json index 964e5c9b3..068900b48 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -10,7 +10,7 @@ "scripts": { "build": "yarn build:prod --env.production_standalone", "build:prod": "webpack --mode production", - "build:ci": "build", + "build:ci": "yarn build", "watch_without_deps": "tsc -w", "dev": "webpack-dev-server --mode development --env.development", "lint": "tslint --format stylish --project .", -- cgit v1.2.3 From d99bdcf036eebc6613274fecfdd19187eaf4aa1a Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Thu, 29 Nov 2018 15:13:55 -0800 Subject: cdn approach to identifyign environments --- packages/instant/.dogfood.discharge.json | 2 +- packages/instant/.production.discharge.json | 2 +- packages/instant/.staging.discharge.json | 2 +- packages/instant/package.json | 3 +- packages/instant/src/constants.ts | 7 +--- packages/instant/webpack.config.js | 53 ++++++++--------------------- 6 files changed, 20 insertions(+), 49 deletions(-) (limited to 'packages') diff --git a/packages/instant/.dogfood.discharge.json b/packages/instant/.dogfood.discharge.json index 5a11f8a1d..f9b96ac95 100644 --- a/packages/instant/.dogfood.discharge.json +++ b/packages/instant/.dogfood.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-dogfood", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:prod --env.dogfood", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:prod --env.cdn=staging", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/.production.discharge.json b/packages/instant/.production.discharge.json index ecd3a12d4..70dd4e04c 100644 --- a/packages/instant/.production.discharge.json +++ b/packages/instant/.production.discharge.json @@ -1,6 +1,6 @@ { "domain": "instant.0xproject.com", - "build_command": "yarn build:prod --env.production_cdn", + "build_command": "yarn build --env.cdn=production", "upload_directory": "umd", "index_key": "instant.js", "error_key": "404.html", diff --git a/packages/instant/.staging.discharge.json b/packages/instant/.staging.discharge.json index ba2ca5f99..44fc3abc8 100644 --- a/packages/instant/.staging.discharge.json +++ b/packages/instant/.staging.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-staging", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:prod:prod --env.staging", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.cdn=staging", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/package.json b/packages/instant/package.json index 068900b48..381d78c88 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -8,8 +8,7 @@ "main": "umd/instant.js", "private": true, "scripts": { - "build": "yarn build:prod --env.production_standalone", - "build:prod": "webpack --mode production", + "build": "webpack --mode production", "build:ci": "yarn build", "watch_without_deps": "tsc -w", "dev": "webpack-dev-server --mode development --env.development", diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts index e70b3f1d8..3370af094 100644 --- a/packages/instant/src/constants.ts +++ b/packages/instant/src/constants.ts @@ -20,12 +20,7 @@ export const HEAP_ANALYTICS_ID = process.env.HEAP_ANALYTICS_ID; export const COINBASE_API_BASE_URL = 'https://api.coinbase.com/v2'; export const PROGRESS_STALL_AT_WIDTH = '95%'; export const PROGRESS_FINISH_ANIMATION_TIME_MS = 200; -export const INSTANT_ENVIRONMENT = process.env.INSTANT_ENVIRONMENT as - | 'dogfood' - | 'staging' - | 'development' - | 'production_cdn' - | 'production_standalone'; +export const INSTANT_CDN = process.env.INSTANT_CDN as 'production' | 'dogfood' | 'staging' | undefined; export const COINBASE_WALLET_IOS_APP_STORE_URL = 'https://itunes.apple.com/us/app/coinbase-wallet/id1278383455?mt=8'; export const COINBASE_WALLET_ANDROID_APP_STORE_URL = 'https://play.google.com/store/apps/details?id=org.toshi&hl=en'; export const COINBASE_WALLET_SITE_URL = 'https://wallet.coinbase.com/'; diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js index 284276c1a..020fab506 100644 --- a/packages/instant/webpack.config.js +++ b/packages/instant/webpack.config.js @@ -6,60 +6,37 @@ const webpack = require('webpack'); // The common js bundle (not this one) is built using tsc. // The umd bundle (this one) has a different entrypoint. -const ACCEPTABLE_ENV_NAMES = ['production_standalone', 'production_cdn', 'staging', 'dogfood', 'development']; -const getEnvironmentName = env => { - if (!env) { - throw new Error('Please specify env via --env to webpack'); - } - const foundName = ACCEPTABLE_ENV_NAMES.find(e => (env[e] ? e : false)); - if (!foundName) { - throw new Error( - `Couldn't find env name, please specify via one of the following CLI arguments: ${acceptableEnvNames.map( - i => `--env.${i}`, - )}`, - ); - } - return foundName; -}; - -const getConfigForEnv = environmentName => { - switch (environmentName) { - case 'production_standalone': - case 'production_cdn': - return { - heapAnalyticsIdEnvName: 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION', - heapAnalyticsIdRequired: environmentName !== 'production_standalone', - }; - case 'staging': - case 'dogfood': - case 'development': - return { - heapAnalyticsIdEnvName: 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT', - heapAnalyticsIdRequired: environmentName !== 'development', - }; - } +const CDNS_THAT_REQUIRE_HEAP = ['production', 'staging', 'dogfood']; +const getConfigForCdn = cdnName => { + return { + heapAnalyticsIdEnvName: + cdnName === 'production' ? 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION' : 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT', + heapAnalyticsIdRequired: CDNS_THAT_REQUIRE_HEAP.includes(cdnName), + }; }; const GIT_SHA = childProcess .execSync('git rev-parse HEAD') .toString() .trim(); -const generateConfig = (environmentName, configOptions) => { +const generateConfig = (cdnName, configOptions) => { const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd'; const { heapAnalyticsIdEnvName, heapAnalyticsIdRequired } = configOptions; const heapAnalyticsId = process.env[heapAnalyticsIdEnvName]; if (heapAnalyticsIdRequired && !heapAnalyticsId) { throw new Error( - `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${environmentName}`, + `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${cdnName}`, ); } const envVars = { GIT_SHA: JSON.stringify(GIT_SHA), - INSTANT_ENVIRONMENT: JSON.stringify(environmentName), NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version), }; + if (cdnName) { + envVars.INSTANT_CDN = JSON.stringify(cdnName); + } if (heapAnalyticsId) { envVars.HEAP_ANALYTICS_ID = JSON.stringify(heapAnalyticsId); } @@ -114,7 +91,7 @@ const generateConfig = (environmentName, configOptions) => { }; module.exports = (env, _argv) => { - const environmentName = getEnvironmentName(env); - const configOptions = getConfigForEnv(environmentName); - return generateConfig(environmentName, configOptions); + const cdnName = env ? env.cdn : undefined; + const configOptions = getConfigForCdn(cdnName); + return generateConfig(cdnName, configOptions); }; -- cgit v1.2.3 From e59d47eac82d2db85b301b24aad4c1e41246daa8 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Thu, 29 Nov 2018 15:32:05 -0800 Subject: Take out old --env --- packages/instant/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/instant/package.json b/packages/instant/package.json index 381d78c88..511edff3d 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -11,7 +11,7 @@ "build": "webpack --mode production", "build:ci": "yarn build", "watch_without_deps": "tsc -w", - "dev": "webpack-dev-server --mode development --env.development", + "dev": "webpack-dev-server --mode development", "lint": "tslint --format stylish --project .", "test": "jest", "test:coverage": "jest --coverage", -- cgit v1.2.3 From ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Fri, 30 Nov 2018 12:42:40 -0800 Subject: cdn -> dischargeTarget, and report to heap --- packages/instant/.dogfood.discharge.json | 2 +- packages/instant/.production.discharge.json | 2 +- packages/instant/.staging.discharge.json | 2 +- .../src/components/zero_ex_instant_provider.tsx | 7 +++++- packages/instant/src/constants.ts | 6 +++++- packages/instant/src/util/analytics.ts | 1 + packages/instant/webpack.config.js | 25 ++++++++++++---------- 7 files changed, 29 insertions(+), 16 deletions(-) (limited to 'packages') diff --git a/packages/instant/.dogfood.discharge.json b/packages/instant/.dogfood.discharge.json index f9b96ac95..b0e4edaff 100644 --- a/packages/instant/.dogfood.discharge.json +++ b/packages/instant/.dogfood.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-dogfood", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build:prod --env.cdn=staging", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.discharge_target=dogfood", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/.production.discharge.json b/packages/instant/.production.discharge.json index 70dd4e04c..4aa5337ba 100644 --- a/packages/instant/.production.discharge.json +++ b/packages/instant/.production.discharge.json @@ -1,6 +1,6 @@ { "domain": "instant.0xproject.com", - "build_command": "yarn build --env.cdn=production", + "build_command": "yarn build --env.discharge_target=production", "upload_directory": "umd", "index_key": "instant.js", "error_key": "404.html", diff --git a/packages/instant/.staging.discharge.json b/packages/instant/.staging.discharge.json index 44fc3abc8..56ffee4e9 100644 --- a/packages/instant/.staging.discharge.json +++ b/packages/instant/.staging.discharge.json @@ -1,6 +1,6 @@ { "domain": "0x-instant-staging", - "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.cdn=staging", + "build_command": "WEBPACK_OUTPUT_PATH=public yarn build --env.discharge_target=staging", "upload_directory": "public", "index_key": "index.html", "error_key": "index.html", diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx index 9814aabf8..dc57513d1 100644 --- a/packages/instant/src/components/zero_ex_instant_provider.tsx +++ b/packages/instant/src/components/zero_ex_instant_provider.tsx @@ -5,7 +5,11 @@ import * as _ from 'lodash'; import * as React from 'react'; import { Provider as ReduxProvider } from 'react-redux'; -import { ACCOUNT_UPDATE_INTERVAL_TIME_MS, BUY_QUOTE_UPDATE_INTERVAL_TIME_MS } from '../constants'; +import { + ACCOUNT_UPDATE_INTERVAL_TIME_MS, + BUY_QUOTE_UPDATE_INTERVAL_TIME_MS, + INSTANT_DISCHARGE_TARGET, +} from '../constants'; import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider'; import { asyncData } from '../redux/async_data'; import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer'; @@ -132,6 +136,7 @@ export class ZeroExInstantProvider extends React.Component { +const DISCHARGE_TARGETS_THAT_REQUIRED_HEAP = ['production', 'staging', 'dogfood']; +const getConfigForDischargeTarget = dischargeTarget => { return { heapAnalyticsIdEnvName: - cdnName === 'production' ? 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION' : 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT', - heapAnalyticsIdRequired: CDNS_THAT_REQUIRE_HEAP.includes(cdnName), + dischargeTarget === 'production' + ? 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION' + : 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT', + heapAnalyticsIdRequired: DISCHARGE_TARGETS_THAT_REQUIRED_HEAP.includes(dischargeTarget), }; }; @@ -19,14 +21,14 @@ const GIT_SHA = childProcess .execSync('git rev-parse HEAD') .toString() .trim(); -const generateConfig = (cdnName, configOptions) => { +const generateConfig = (dischargeTarget, configOptions) => { const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd'; const { heapAnalyticsIdEnvName, heapAnalyticsIdRequired } = configOptions; const heapAnalyticsId = process.env[heapAnalyticsIdEnvName]; if (heapAnalyticsIdRequired && !heapAnalyticsId) { throw new Error( - `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${cdnName}`, + `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${dischargeTarget}`, ); } @@ -34,12 +36,13 @@ const generateConfig = (cdnName, configOptions) => { GIT_SHA: JSON.stringify(GIT_SHA), NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version), }; - if (cdnName) { - envVars.INSTANT_CDN = JSON.stringify(cdnName); + if (dischargeTarget) { + envVars.INSTANT_DISCHARGE_TARGET = JSON.stringify(dischargeTarget); } if (heapAnalyticsId) { envVars.HEAP_ANALYTICS_ID = JSON.stringify(heapAnalyticsId); } + console.log(envVars); const config = { entry: { @@ -91,7 +94,7 @@ const generateConfig = (cdnName, configOptions) => { }; module.exports = (env, _argv) => { - const cdnName = env ? env.cdn : undefined; - const configOptions = getConfigForCdn(cdnName); - return generateConfig(cdnName, configOptions); + const dischargeTarget = env ? env.discharge_target : undefined; + const configOptions = getConfigForDischargeTarget(dischargeTarget); + return generateConfig(dischargeTarget, configOptions); }; -- cgit v1.2.3 From de8dcf9a72283711d41617fc2c0e849a4a8c7461 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Fri, 30 Nov 2018 12:47:16 -0800 Subject: takeout console.log --- packages/instant/webpack.config.js | 1 - 1 file changed, 1 deletion(-) (limited to 'packages') diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js index 917e84ff0..803240e76 100644 --- a/packages/instant/webpack.config.js +++ b/packages/instant/webpack.config.js @@ -39,7 +39,6 @@ const generateConfig = (dischargeTarget, configOptions) => { if (heapAnalyticsId) { envVars.HEAP_ANALYTICS_ID = JSON.stringify(heapAnalyticsId); } - console.log(envVars); const config = { entry: { -- cgit v1.2.3 From d77efb611ebbeaf54aea6388f3e417ed326ccc62 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Fri, 30 Nov 2018 12:49:07 -0800 Subject: Remove env var check for INSTANT_HEAP_ANALYTICS_ID_PRODUCTION since this is only needed on discharge --- packages/monorepo-scripts/src/prepublish_checks.ts | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'packages') diff --git a/packages/monorepo-scripts/src/prepublish_checks.ts b/packages/monorepo-scripts/src/prepublish_checks.ts index 60cdccf1d..36e61714b 100644 --- a/packages/monorepo-scripts/src/prepublish_checks.ts +++ b/packages/monorepo-scripts/src/prepublish_checks.ts @@ -17,7 +17,6 @@ async function prepublishChecksAsync(): Promise { await checkChangelogFormatAsync(updatedPublicPackages); await checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicPackages); await checkPublishRequiredSetupAsync(); - checkRequiredEnvVariables(); } async function checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicPackages: Package[]): Promise { @@ -184,16 +183,6 @@ async function checkPublishRequiredSetupAsync(): Promise { } } -const checkRequiredEnvVariables = () => { - utils.log('Checking required environment variables...'); - const requiredEnvVars = ['INSTANT_HEAP_ANALYTICS_ID_PRODUCTION']; - requiredEnvVars.forEach(requiredEnvVarName => { - if (_.isUndefined(process.env[requiredEnvVarName])) { - throw new Error(`Must have ${requiredEnvVarName} set`); - } - }); -}; - prepublishChecksAsync().catch(err => { utils.log(err); process.exit(1); -- cgit v1.2.3 From 34b2f4736e30b50f94a3110c313131b56e35bc02 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Fri, 30 Nov 2018 12:58:42 -0800 Subject: removing unused references --- packages/instant/src/components/standard_sliding_panel.tsx | 2 +- packages/instant/src/redux/analytics_middleware.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/instant/src/components/standard_sliding_panel.tsx b/packages/instant/src/components/standard_sliding_panel.tsx index f587ff79a..9f517d273 100644 --- a/packages/instant/src/components/standard_sliding_panel.tsx +++ b/packages/instant/src/components/standard_sliding_panel.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { SlideAnimationState, StandardSlidingPanelContent, StandardSlidingPanelSettings } from '../types'; +import { StandardSlidingPanelContent, StandardSlidingPanelSettings } from '../types'; import { InstallWalletPanelContent } from './install_wallet_panel_content'; import { SlidingPanel } from './sliding_panel'; diff --git a/packages/instant/src/redux/analytics_middleware.ts b/packages/instant/src/redux/analytics_middleware.ts index 3dc5fe924..47876ca2d 100644 --- a/packages/instant/src/redux/analytics_middleware.ts +++ b/packages/instant/src/redux/analytics_middleware.ts @@ -3,7 +3,7 @@ import * as _ from 'lodash'; import { Middleware } from 'redux'; import { ETH_DECIMALS } from '../constants'; -import { Account, AccountState, StandardSlidingPanelContent } from '../types'; +import { AccountState, StandardSlidingPanelContent } from '../types'; import { analytics } from '../util/analytics'; import { Action, ActionTypes } from './actions'; -- cgit v1.2.3