Open pdehaan opened 9 years ago
definitely would be useful for laptop testing. all the setup steps are maddening. i was thinking it might be useful to have something like an: npm start local (which fire up grok) vs. npm start which would assume you were already on an aws instance. for aws in our brave new qa jenkins world, we could have vagrant deploy the e2e test, setup the env, then call grunt to install the particulars.
Ah, good call. I forgot that ngrok is a ~13MB download, so we'd definitely want to try to optimize for AWS deployments by making it a devDependency so it doesn't get installed on a prod environment.
Also, in fxa-auth-server, I think we're using the envc module to help import a bunch of environment variables from an external file (saves you having to export a bunch of env vars manually):
# .env.dev
TWILIO_ACCOUNT_SID="YOUR TOKEN HERE"
TWILIO_AUTH_TOKEN="YOUR TOKEN HERE"
PORT=3000
// index.js
var env = require('envc')({
booleans: true,
numbers: true,
nodeenv: 'dev'
})
console.log(JSON.stringify(env, null, 2))
/*
{
"TWILIO_ACCOUNT_SID": "YOUR TOKEN HERE",
"TWILIO_AUTH_TOKEN": "YOUR TOKEN HERE",
"PORT": 3000
}
*/
console.log('SID:\t%s\nTOKEN:\t%s\nPORT:\t%d',
process.env.TWILIO_ACCOUNT_SID,
process.env.TWILIO_AUTH_TOKEN,
process.env.PORT)
/*
SID: YOUR TOKEN HERE
TOKEN: YOUR TOKEN HERE
PORT: 3000
*/
Then obviously just add that .env.dev file to the .gitignore to avoid leaking creds.
oh man, where has this been all my life. thanks, that's very helpful. i've done the stupid thing of checking some creds already this year and had to nuke a project a few times. but i've now seen the light, Peter.
OK, this is mildly neat, but your mileage may vary...
Now when you do
npm install
, it downloads ngrok into ./node_modules/. Now you can start the ngrok server via npm scripts (or calling manually via./node_modules/.bin/ngrok
or./node_modules/ngrok/bin/ngrok
).But because ./node_modules/.bin/ is added to your
$PATH
via npm, you can just callngrok
as if it was installed globally: