From 819e977ae3185cd4bcaea05bfa51266a44d3adab Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Fri, 21 Oct 2016 12:01:29 -0400 Subject: [PATCH] feature(externalServices): apply external services configuration via environment variable --no-verify --- README.md | 10 ++++++++++ app-template/apply.js | 11 ++++++++--- .../{package.json => package-template.json} | 3 +-- package.json | 15 ++++++++------- 4 files changed, 27 insertions(+), 12 deletions(-) rename app-template/{package.json => package-template.json} (95%) diff --git a/README.md b/README.md index 2183d7209..2fe2e65da 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,16 @@ npm run final:desktop On success, the Chrome extension will be located at: `browser-extensions/chrome/copay-chrome-extension`. To install it go to `chrome://extensions/` in your browser and ensure you have the 'developer mode' option enabled in the settings. Then click on "Load unpacked chrome extension" and choose the directory mentioned above. +## Configuration + +### Enable External Services + +To enable external services, set the `COPAY_EXTERNAL_SERVICES_CONFIG_LOCATION` environment variable to the location of your configuration before running the `apply` task. + +```sh +export COPAY_EXTERNAL_SERVICES_CONFIG_LOCATION="~/.copay/externalServices.json" +``` + ## About Copay ### General diff --git a/app-template/apply.js b/app-template/apply.js index 191f2b571..106bfc998 100755 --- a/app-template/apply.js +++ b/app-template/apply.js @@ -5,7 +5,7 @@ // var templates = { - 'package.json': '/', + 'package-template.json': '/', 'index.html': 'www/', 'Makefile': 'cordova/', 'ProjectMakefile': 'cordova/', @@ -64,6 +64,8 @@ Object.keys(templates).forEach(function(k) { if(k === 'config-template.xml'){ k = 'config.xml'; + } else if (k === 'package-template.json') { + k = 'package.json'; } if (!fs.existsSync('../' + targetDir)){ @@ -80,8 +82,11 @@ fs.writeFileSync('../appConfig.json', configBlob, 'utf8'); //////////////// var externalServices; try { - console.log('Copying ' + configDir + '/externalServices.json' + ' to root'); - externalServices = fs.readFileSync(configDir + '/externalServices.json', 'utf8'); + if(typeof process.env.COPAY_EXTERNAL_SERVICES_CONFIG_LOCATION !== 'undefined') { + var location = process.env.COPAY_EXTERNAL_SERVICES_CONFIG_LOCATION; + console.log('Copying ' + location + ' to root'); + externalServices = fs.readFileSync(location, 'utf8'); + } } catch(err) { externalServices = '{}'; console.log('External services not configured'); diff --git a/app-template/package.json b/app-template/package-template.json similarity index 95% rename from app-template/package.json rename to app-template/package-template.json index 1a56073d7..6fb7b14f4 100644 --- a/app-template/package.json +++ b/app-template/package-template.json @@ -79,8 +79,7 @@ "shelljs": "^0.3.0" }, "scripts": { - "postinstall": "bower install && npm run postapply", - "postapply": "echo && echo \"To finish, choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.\" && echo", + "postinstall": "bower install", "start": "npm run build:www && ionic serve --nolivereload --nogulp -s", "start:ios": "npm run build:www && npm run build:ios && npm run open:ios", "start:android": "npm run build:www && npm run build:android && npm run run:android", diff --git a/package.json b/package.json index 9e43644ba..b2434908a 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,21 @@ { + "changes": "changes to this file can be commited with the --no-verify option", "name": "distribution-not-selected", "description": "Choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.", "primary-package-json": "See the tempate in app-template/package.json", "scripts": { - "postinstall": "npm run apply:copay", + "postinstall": "npm run apply:copay && echo && echo \"Repo configured for standard Copay distribution. To switch to the BitPay distribution, run 'npm run apply:bitpay'.\" && echo", "start": "echo && echo \"Choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.\" && echo", - "preapply": "npm i fs-extra", - "apply:copay": "npm run preapply && cd app-template && node apply.js copay && cd .. && npm i && npm run postapply", - "apply:bitpay": "npm run preapply && cd app-template && node apply.js bitpay && cd .. && npm i && npm run postapply", + "apply:copay": "cd app-template && node apply.js copay && cd .. && npm i && npm run postapply", + "apply:bitpay": "cd app-template && node apply.js bitpay && cd .. && npm i && npm run postapply", "clean-all": "git clean -dfx" }, + "dependencies": { + "fs-extra": "^0.30.0" + }, "license": "MIT", "repository": { - "url": "git://github.com/bitpay/copay.git", "url": "git://github.com/bitpay/bitpay-wallet.git", "type": "git" - }, - "changes": "changes to this file can be commited with the --no-verify option" + } }