Skip to content

Commit b3f336a

Browse files
committed
added support for .env.development -- gitignored -- to allow dynamic environment variables depending on node environment
1 parent 43d6d1e commit b3f336a

File tree

6 files changed

+22
-24
lines changed

6 files changed

+22
-24
lines changed

.env.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#DO NOT DELETE THIS FILE, and follow instructions:
22
# Required for Slack Oauth features
3-
# Create a file named .env in this directory, and give it the following variables
4-
# Any variable you create in .env, you MUST create an example for here in .env.example
3+
# Create TWO files, one named ".env" and the second named ".env.development" in this directory, and give them the following variables
4+
# Any environment variables you create MUST also be created here in .env.example
5+
56
SLACK_CLIENT_SECRET = "ENTER_CLIENT_SECRET_HERE"
67
SLACK_CLIENT_ID = "ENTER_CLIENT_ID_HERE"
78
SLACK_WEBHOOK_URL = "ENTER WEBHOOK URL HERE"
9+
SLACK_REDIRECT_URI = "REDIRECT URL HERE"
810

911
# https://www.npmjs.com/package/dotenv
1012
# https://www.npmjs.com/package/quasar-dotenv

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#secret Api keys, Webhook URLs etc
22
slackApiStuff.js
33
.env
4+
.env.development
45
#
56
.quasar
67
.DS_Store

quasar.conf.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
// https://quasar.dev/quasar-cli/quasar-conf-js
33

44
module.exports = function(ctx) {
5-
const env = require("quasar-dotenv").config();
5+
const env = ctx.dev
6+
? require("quasar-dotenv").config({ path: '.env.development' })
7+
: require("quasar-dotenv").config()
8+
9+
// console.log('ctx: ', ctx)
610
return {
711
// app boot file (/src/boot)
812
// --> boot files are part of "main.js"
@@ -89,7 +93,7 @@ module.exports = function(ctx) {
8993
// }
9094
// })
9195
},
92-
env: env
96+
env: env,
9397
},
9498

9599
devServer: {

src-electron/main-process/electron-main.dev.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,8 @@
55
* environment.
66
*/
77

8-
// NOTE Aug 2021 - VUEJS DevTools not loading, need to debug why is does not in Dev mode
9-
108
// Install `electron-debug` with `devtron`
119
require('electron-debug')({ showDevTools: true })
1210

13-
// Install `vue-devtools`
14-
// require('electron').app.on('ready', () => {
15-
// let installExtension = require('electron-devtools-installer')
16-
// installExtension.default(installExtension.VUEJS_DEVTOOLS)
17-
// .then(() => {})
18-
// .catch(err => {
19-
// console.log('Unable to install `vue-devtools`: \n', err)
20-
// })
21-
// })
22-
2311
// Require `main` process to boot app
2412
require('./electron-main')

src-electron/main-process/electron-main.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ if (process.env.PROD) {
1313
.replace(/\\/g, "\\\\");
1414
}
1515

16-
let mainWindow;
17-
let authCode;
18-
const protocol = isDev ? "overvuedev" : "overvue";
19-
20-
// Used to console log for main process in production mode
2116
function logEverywhere(toBeLogged) {
2217
if (isDev) {
2318
console.log(toBeLogged);
@@ -31,13 +26,19 @@ function logEverywhere(toBeLogged) {
3126
}
3227
}
3328

29+
let mainWindow;
30+
let authCode;
31+
const protocol = isDev ? "overvuedev" : "overvue";
32+
33+
// Used to console log for main process in production mode
34+
3435
const deeplink = new Deeplink({
3536
app,
3637
mainWindow,
3738
protocol,
3839
isDev,
3940
debugLogging: true,
40-
// electronPath: '../../node_modules/electron/dist/electron.app'
41+
electronPath: '/node_modules/electron/dist/electron.exe'
4142
});
4243
// logEverywhere(`electron path: ${require('path').join(__dirname, '../../node_modules/electron/dist/electron.exe')}`);
4344
// Sends request to Slack for User's information,
@@ -49,7 +50,7 @@ function sendTokenRequest() {
4950
client_id: process.env.SLACK_CLIENT_ID,
5051
client_secret: process.env.SLACK_CLIENT_SECRET,
5152
code: authCode,
52-
redirect_uri: isDev ? "overvuedev://test" : "overvue://slack"
53+
redirect_uri: process.env.SLACK_REDIRECT_URI
5354
};
5455
logEverywhere(authData.code);
5556

@@ -127,6 +128,7 @@ function createWindow() {
127128
});
128129

129130
logEverywhere(`Current deeplink Protocol: ${deeplink.getProtocol()}`);
131+
logEverywhere(`process.execPath: ${process.execPath}`);
130132
mainWindow.loadURL(process.env.APP_URL);
131133

132134
mainWindow.on("closed", () => {

src/components/slack_login/SlackLoginWindow.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ export default {
5252
ipcRenderer.on('tokenReceived', (event, data) => {
5353
console.log('data in SlackLoginWindow: ', data)
5454
})
55+
console.log(`process.env: ${process.env}`)
5556
},
5657
methods: {
5758
slackOauth: function () {
5859
const slackBaseUrl = 'https://slack.com/openid/connect/authorize'
5960
const responseType = 'code'
6061
const scope = 'openid profile'
6162
const clientId = process.env.SLACK_CLIENT_ID
62-
const redirectUri = process.env.DEV ? 'overvuedev://test' : 'overvue://slack'
63+
const redirectUri = process.env.SLACK_REDIRECT_URI
6364
6465
this.isAuthenticating = true;
6566

0 commit comments

Comments
 (0)