Skip to content

Make config management developer friendly #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APP_ENV=production
UPLOAD_URL=https://api-cloud.browserstack.com/automate-frameworks/cypress/upload
RAILS_HOST=https://api.browserstack.com
DASHBOARD_URL=https://automate.browserstack.com/dashboard/v2/builds/
USAGE_REPORTING_URL=https://eds.browserstack.com:443/send_event_cy_internal
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ specs
tests.zip
package-lock.json
.nyc_output/
.env.*
!.env.production
29 changes: 18 additions & 11 deletions bin/helpers/config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
var config = {};
config.env = "prod";
var hosts = {
prod: {
uploadUrl: `https://api-cloud.browserstack.com/automate-frameworks/cypress/upload`,
rails_host: `https://api.browserstack.com`
}
};
config.uploadUrl = hosts[config.env].uploadUrl;
config.rails_host = hosts[config.env].rails_host;
config.env = process.env.NODE_ENV || "production";

if(config.env === "production") {
config.uploadUrl = 'https://api-cloud.browserstack.com/automate-frameworks/cypress/upload';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these to config.json and load that JSON on line 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

config.rails_host = 'https://api.browserstack.com';
config.dashboardUrl = 'https://automate.browserstack.com/dashboard/v2/builds/';
config.usageReportingUrl = 'https://eds.browserstack.com:443/send_event_cy_internal';
} else {

// load config based on env
require('custom-env').env(config.env);

config.uploadUrl = process.env.UPLOAD_URL;
config.rails_host = process.env.RAILS_HOST;
config.dashboardUrl = process.env.DASHBOARD_URL;
config.usageReportingUrl = process.env.USAGE_REPORTING_URL;
}

config.cypress_v1 = `${config.rails_host}/automate/cypress/v1`;
config.buildUrl = `${config.cypress_v1}/builds/`;
config.buildStopUrl = `${config.cypress_v1}/builds/stop/`;
config.dashboardUrl = `https://automate.browserstack.com/dashboard/v2/builds/`;
config.usageReportingUrl = `https://eds.browserstack.com:443/send_event_cy_internal`;
config.fileName = "tests.zip";

module.exports = config;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"devDependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"custom-env": "^2.0.1",
"mocha": "^7.1.2",
"nyc": "^15.0.1",
"proxyquire": "^2.1.3",
Expand Down