-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,109 @@ | ||
coverage | ||
# Created by https://www.gitignore.io/api/webstorm | ||
|
||
### WebStorm ### | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
### WebStorm Patch ### | ||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 | ||
|
||
# *.iml | ||
# modules.xml | ||
# .idea/misc.xml | ||
# *.ipr | ||
|
||
# Sonarlint plugin | ||
.idea/sonarlint | ||
|
||
|
||
# End of https://www.gitignore.io/api/webstorm | ||
|
||
######################### CUSTOM/MANUAL ############################# | ||
|
||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# IDE plugins | ||
.idea/markdown-navigator*/** | ||
|
||
# package directories | ||
node_modules | ||
*.log | ||
jspm_packages | ||
|
||
# Serverless directories | ||
.serverless | ||
.webpack | ||
.next | ||
dist | ||
|
||
.DS_Store | ||
.sls-simulate-registry | ||
|
||
# Builds | ||
build | ||
.firebase | ||
coverage/ | ||
|
||
# Sensitive values, do not share (staging is fine, development is for personal use) | ||
.env.production | ||
!.env | ||
|
||
# Epsagon generated files | ||
epsagon_handlers/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
'use strict' | ||
'use strict'; | ||
|
||
const fs = require('fs') | ||
const mkdirp = require('mkdirp') | ||
const path = require('path') | ||
const fs = require('fs'); | ||
const mkdirp = require('mkdirp'); | ||
const path = require('path'); | ||
|
||
const collectFunctionEnvVariables = require('./lib/collectFunctionEnvVariables.js') | ||
const collectOfflineEnvVariables = require('./lib/collectOfflineEnvVariables.js') | ||
const transformEnvVarsToString = require('./lib/transformEnvVarsToString.js') | ||
const collectFunctionEnvVariables = require('./lib/collectFunctionEnvVariables.js'); | ||
const collectOfflineEnvVariables = require('./lib/collectOfflineEnvVariables.js'); | ||
const transformEnvVarsToString = require('./lib/transformEnvVarsToString.js'); | ||
|
||
class ServerlessDotenvPlugin { | ||
constructor (serverless, options) { | ||
this.serverless = serverless | ||
this.options = options | ||
constructor(serverless, options) { | ||
this.serverless = serverless; | ||
this.options = options; | ||
|
||
this.commands = { | ||
dotenv: { | ||
usage: 'Create .env file with serverless environment variables', | ||
lifecycleEvents: [ | ||
'dotenvHandler' | ||
] | ||
} | ||
} | ||
'dotenvHandler', | ||
], | ||
}, | ||
}; | ||
|
||
this.hooks = { | ||
'before:offline:start:init': this.initOfflineHook.bind(this), | ||
'before:offline:start': this.initOfflineHook.bind(this), | ||
'dotenv:dotenvHandler': this.dotenvHandler.bind(this) | ||
} | ||
'dotenv:dotenvHandler': this.dotenvHandler.bind(this), | ||
}; | ||
|
||
this.environmentVariables = {} | ||
this.environmentVariables = {}; | ||
} | ||
|
||
initOfflineHook () { | ||
this.IS_HOOKED = true | ||
initOfflineHook() { | ||
this.IS_HOOKED = true; | ||
|
||
this.serverless.pluginManager.run(['dotenv']) | ||
this.serverless.pluginManager.run(['dotenv']); | ||
} | ||
|
||
dotenvHandler () { | ||
this.serverless.cli.log('Creating .env file...') | ||
dotenvHandler() { | ||
this.serverless.cli.log('Creating .env file...'); | ||
|
||
// collect global environment variables | ||
const globalEnvironment = this.serverless.service.provider.environment | ||
this.environmentVariables = Object.assign(this.environmentVariables, globalEnvironment) | ||
const globalEnvironment = this.serverless.service.provider.environment; | ||
this.environmentVariables = Object.assign(this.environmentVariables, globalEnvironment); | ||
|
||
// collect environment variables of functions | ||
const functionEnvironment = collectFunctionEnvVariables(this.serverless) | ||
this.environmentVariables = Object.assign(this.environmentVariables, functionEnvironment) | ||
const functionEnvironment = collectFunctionEnvVariables(this.serverless); | ||
this.environmentVariables = Object.assign(this.environmentVariables, functionEnvironment); | ||
|
||
// collect environment variables for serverless offline | ||
if (this.IS_HOOKED) { | ||
const offlineEnvVars = collectOfflineEnvVariables(this.serverless, this.options) | ||
this.environmentVariables = Object.assign(this.environmentVariables, offlineEnvVars) | ||
const offlineEnvVars = collectOfflineEnvVariables(this.serverless, this.options); | ||
this.environmentVariables = Object.assign(this.environmentVariables, offlineEnvVars); | ||
} | ||
|
||
// write .env file | ||
const dotEnvPath = path.join(this.serverless.config.servicePath, '.serverless') | ||
const dotEnvFile = path.join(this.serverless.config.servicePath, '.serverless/.env') | ||
const dotEnvDocument = transformEnvVarsToString(this.environmentVariables) | ||
const dotEnvPath = path.join(this.serverless.config.servicePath, '.serverless'); | ||
const dotEnvFile = path.join(this.serverless.config.servicePath, '.serverless/.env'); | ||
const dotEnvDocument = transformEnvVarsToString(this.environmentVariables); | ||
|
||
mkdirp.sync(dotEnvPath) | ||
fs.writeFileSync(dotEnvFile, dotEnvDocument) | ||
mkdirp.sync(dotEnvPath); | ||
fs.writeFileSync(dotEnvFile, dotEnvDocument); | ||
} | ||
} | ||
|
||
module.exports = ServerlessDotenvPlugin | ||
module.exports = ServerlessDotenvPlugin; |