Skip to content

Support custom ENVs - #1520

Closed
dschmidt wants to merge 11 commits into
ember-cli:masterfrom
dschmidt:customenvs
Closed

Support custom ENVs#1520
dschmidt wants to merge 11 commits into
ember-cli:masterfrom
dschmidt:customenvs

Conversation

@dschmidt

Copy link
Copy Markdown
Contributor

Hey,

so I started trying to implement the proposal from https://gist.github.com/rwjblue/51f1df4b21a23466ae47
To make sure I understood it right and to show up my problems I'm submitting this in a really early hacky stage.

Instead of adding methods to the EmberApp object I created a config model that is passed to the respective configuration module.

See the corresponding config files here: https://github.com/dschmidt/ember-cli-sass-demo/tree/customenvs/config

Going to add my questions as comments to the code below

Best regards,
Dominik

Comment thread lib/broccoli/ember-app.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we support ember's path support? get('hinting.js.app')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had the same thought when writing that line! 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^ get('hinting.js.app') would be great, but we can add it in a follow up PR

@stefanpenner

Copy link
Copy Markdown
Contributor

Scheint gut Bruder.
I like that you have separated the config object out

@dschmidt

Copy link
Copy Markdown
Contributor Author

My most important question before I proceed:
If I don't cache the config object where/how am I supposed to set/add defaults like for jshintrc above?

@dschmidt

Copy link
Copy Markdown
Contributor Author

ping @stefanpenner

@stefanpenner

Copy link
Copy Markdown
Contributor

@dschmidt thanks for the reminder I have been traveling. Will review this evening.

@stefanpenner

Copy link
Copy Markdown
Contributor

@dschmidt this looks fantastic, only tiny feedbacks^

I think for the first pass we can ignore the caching stuff, subsequent work and introduce this.

@rwjblue

rwjblue commented Aug 13, 2014

Copy link
Copy Markdown
Member

Looks good. Happy to defer the caching issue for now.

@stefanpenner

Copy link
Copy Markdown
Contributor

can I provide any help/feedback here (sorry I have been out of town with little time to provide feedback here)

@dschmidt

Copy link
Copy Markdown
Contributor Author

Yup, you can. I am pretty clueless about what's up with tests ... they are hanging for me and having odd issues that I really don't know how to debug.

So if you could walk me through debugging it, that would be rad. Currently I am still at the ownCloud sprint, but could work on it early next week.

@dschmidt

Copy link
Copy Markdown
Contributor Author

I'm still aware of this PR, just been travelling a lot last month and haven't got around to it. Will get back to it soon hopefully, sorry.

@stefanpenner

Copy link
Copy Markdown
Contributor

No worries im in the same boat

@stefanpenner

Copy link
Copy Markdown
Contributor

cc @lukemelia

@rwjblue

rwjblue commented Oct 2, 2014

Copy link
Copy Markdown
Member

Submitted #2164 to make adding additional environments (as either production or development styles) really simple.

@stefanpenner

Copy link
Copy Markdown
Contributor

I will attempt some time this Saturday to help get this to completion.

@joshsmith

Copy link
Copy Markdown

Thanks a lot @stefanpenner. While I know there's probably not much I can do, let me know if I can do anything to help.

@joshsmith

Copy link
Copy Markdown

And thanks for attempt at temporary fix @rwjblue.

@stefanpenner

Copy link
Copy Markdown
Contributor

@joshsmith if u can get that PR over the finish line that would be handy.

@soulcutter

Copy link
Copy Markdown

What still needs to be done? I was able to make the tests pass with a fairly trivial change from config/environment -> config/development in project-test, but it's a little hard for me to follow what might still need attention.

@jakecraige

Copy link
Copy Markdown
Member

I'm a bit late chiming in here but it's better late than never.

First, since we're in ember-land I think we should make this very ember like and pretty much clone Ember.get, Ember.set, Ember.setProperties API.

This also means config.get,config.set and config.isEnabled should use the . syntax to get/set properties. This allows for arbitrary nesting or properties which currently isn't allowed. It's fixed 2 levels deep right now. A real example of this that wouldn't work: config.isEnabled('ENV.EmberENV.FEATURES.query-params)`

My idea is the API look like:

config.set(keyPath, value);
config.get(keyPath);
config.isEnabled(keyPath);
config.setProperties(keyPath, hash);

Thoughts?

@stefanpenner

Copy link
Copy Markdown
Contributor

we still intend to solve this, but master has diverged pretty far. I am going to close this, but we will sort this out.

@raido

raido commented Sep 6, 2015

Copy link
Copy Markdown
Contributor

What's the status of this?

@e00dan

e00dan commented Dec 11, 2015

Copy link
Copy Markdown

Status?

@trcarden

Copy link
Copy Markdown

@stefanpenner is there any update on this feature? We are trying to put our app up but we need staging environment support

@stefanpenner

Copy link
Copy Markdown
Contributor

Please use the existing 3 env. And configure those further with environment variables

@trcarden

Copy link
Copy Markdown

Ah, thats pretty obvious in retrospect. For others that come across this i found a decent SO post here to help: http://stackoverflow.com/questions/26403334/how-to-pass-api-keys-in-environment-variables-to-ember-cli-using-process-env @stefanpenner thank you!

@JoannaFalkowska

JoannaFalkowska commented Nov 16, 2016

Copy link
Copy Markdown

Two years later - is support for staging never going to be done? Documentation implies otherwise.

Honestly I just encountered this issue today and can't understand why isn't it added? Am I really supposed to pass variables from bash if I need them for staging, like the @trcarden post above suggests? I'm really lost. There was an issue opened to document it (#5400) but documentation was never done.

@nathanhammond

Copy link
Copy Markdown
Contributor

@zackthehuman can you paste in the snippet that you wrote?

@zackthehuman

Copy link
Copy Markdown

@nathanhammond I think this is what you're referring to.

I sometimes build my addon's dummy app in order to use it like a demo/api documentation. For certain reasons I am unable to use the production build, so I want to use the development build, but I need to override some settings when I'm building the "apidoc" mode.

// environment.js

if(process.argv.indexOf('--apidoc') !== -1) {
    console.log('This is an apidoc build so the environment settings will be adjusted.');
    ENV.locationType = 'hash';

    // We want to force the country code to be "us".
    ENV.i18n.requestIpCountryCode = 'us';
}

@meliborn

meliborn commented Nov 25, 2016

Copy link
Copy Markdown

Is there a better way how to add staging environment like production and development? I need to set API_HOST for each environment in my app, but I can't wait another 2 year for support this feature.

@nathanhammond

Copy link
Copy Markdown
Contributor

@meliborn See the comment above yours. That represents a semi-official recommendation for how to toggle different information on a per-build basis. You'd use that code and something like:

ember build -prod --api-host=asdfasdfasdf

@meliborn

Copy link
Copy Markdown

@nathanhammond wrong link?

@wayne-o

wayne-o commented Nov 25, 2016 via email

Copy link
Copy Markdown

@meliborn

Copy link
Copy Markdown

@wayne-o could you throw me an example please? Can't imagine how to use it without if-env block

@nathanhammond

Copy link
Copy Markdown
Contributor

@meliborn Corrected link. Literally the comment above yours provides a workaround you can use, and my comment demonstrates how you could use it.

@nathanhammond

Copy link
Copy Markdown
Contributor

Also, @meliborn

but I can't wait another 2 year for support this feature

This type of communication is not constructive in an open source community. This implies a demand. Our work on Ember is a labor of love. Very few of us are paid to work directly on Ember projects, and if we are those efforts are strongly directed by those who are paying. We're real human beings with hobbies and pastimes and friends and things we do other than this. We strive to be friendly and helpful in spite of this, but I wanted to provide a bit of feedback so you understand that it's frustrating and hurtful to read comments like that. We'd love infinite time to address all things. I assure you. But we must prioritize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.