-
Notifications
You must be signed in to change notification settings - Fork 32
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
Initial commit for ember-cli 2.15.0 support #33
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
language: node_js | ||
node_js: | ||
- "0.12" | ||
- "4.5.0" | ||
|
||
sudo: false | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* eslint-env node */ | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
module.exports = function(/* env */) { | ||
return { | ||
clientAllowedKeys: ['DROPBOX_KEY'], | ||
path: path.join(__dirname, '.env') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
description: 'Setup ember-cli-dotenv', | ||
normalizeEntityName() {} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
/* jshint node: true */ | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const dotenv = require('dotenv'); | ||
const parseArgs = require('minimist'); | ||
const existsSync = require('exists-sync'); | ||
|
||
module.exports = { | ||
name: 'ember-cli-dotenv', | ||
config: function(environment){ | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var dotenv = require('dotenv'); | ||
var existsSync = require('exists-sync'); | ||
var project = this.project; | ||
var loadedConfig; | ||
var config = {}; | ||
var hasOwn = Object.prototype.hasOwnProperty; | ||
|
||
var configFilePath, | ||
dotEnvPath = this.app && this.app.options.dotEnv && this.app.options.dotEnv.path; | ||
|
||
if (dotEnvPath) { | ||
// path is defined | ||
if (typeof dotEnvPath === 'string') { | ||
configFilePath = dotEnvPath; | ||
} else { | ||
if (dotEnvPath[environment]) { | ||
configFilePath = dotEnvPath[environment]; | ||
} | ||
} | ||
} | ||
|
||
if (!configFilePath) { | ||
configFilePath = path.join(project.root, '.env'); | ||
/** | ||
* NOTE: dotenv needs to be invoked before the app config is materialized | ||
* so that the process.env's are set appropriately. Previously this was done | ||
* within the `config` hook. As of 2.15.x, that is too late in the process | ||
* and needed to be moved into `init`. | ||
*/ | ||
init() { | ||
this._super.init && this._super.init.apply(this, arguments); | ||
let root = this.project.root; | ||
let configFactory = path.join(root, 'dotenv.js'); | ||
let options = { | ||
path: path.join(root, '.env'), | ||
clientAllowedKeys: [] | ||
}; | ||
|
||
if (existsSync(configFactory)) { | ||
Object.assign(options, require(configFactory)(this._resolveEnvironment())); | ||
} | ||
|
||
if (existsSync(configFilePath) && dotenv.config({path: configFilePath})) { | ||
loadedConfig = dotenv.parse(fs.readFileSync(configFilePath)); | ||
} else { | ||
loadedConfig = {}; | ||
} | ||
if (existsSync(options.path) && dotenv.config({ path: options.path })) { | ||
let loadedConfig = dotenv.parse(fs.readFileSync(options.path)); | ||
let allowedKeys = options.clientAllowedKeys || []; | ||
|
||
var app = this.app; | ||
if (!this.app) { | ||
return; | ||
this._config = allowedKeys.reduce((accumulator, key) => { | ||
accumulator[key] = loadedConfig[key]; | ||
|
||
return accumulator; | ||
}, {}); | ||
} | ||
if (app.options.dotEnv && hasOwn.call(app.options.dotEnv, 'allow')){ | ||
console.warn("[EMBER-CLI-DOTENV] app.options.allow has been deprecated. Please use clientAllowedKeys instead. Support will be removed in the next major version"); | ||
}, | ||
|
||
_resolveEnvironment() { | ||
if (process.env.EMBER_ENV) { | ||
return process.env.EMBER_ENV; | ||
} | ||
var allowedKeys = (app.options.dotEnv && (app.options.dotEnv.clientAllowedKeys || app.options.dotEnv.allow) || []); | ||
|
||
allowedKeys.forEach(function(key){ | ||
config[key] = loadedConfig[key]; | ||
}); | ||
let args = parseArgs(process.argv); | ||
let env = args.e || args.env || args.environment; | ||
|
||
return config; | ||
return env || 'development'; | ||
}, | ||
included: function(app){ | ||
this.app = app; | ||
this._super.included.apply(this, arguments); | ||
|
||
config() { | ||
return this._config; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure how we want to deal with this, are you planning to land your fastboot work soon or should I defer the README changes until after we version? @SergeAstapov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do actually have a branch with FastBoot support, but it appeared there is a small issue in ember-cli-fastboot that blocks this addon to have FastBoot support, see ember-fastboot/ember-cli-fastboot#543
To not block people from using this addon I think we can
What about such plan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasonmit I'll take care of ember-cli upgrade (need to resolve conflict) and failing tests so we would be able to release version 2.0 shortly