-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from jasonmit/u/jasonmit/2.0.0
Initial commit for ember-cli 2.15.0 support
- Loading branch information
Showing
10 changed files
with
5,268 additions
and
90 deletions.
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.