Skip to content

Extend FastBoot.config to read other provided config as well.#164

Merged
rwjblue merged 1 commit intomasterfrom
config-tree
Sep 20, 2017
Merged

Extend FastBoot.config to read other provided config as well.#164
rwjblue merged 1 commit intomasterfrom
config-tree

Conversation

@kratiahuja
Copy link
Contributor

@kratiahuja kratiahuja commented Aug 27, 2017

Fixes #163 . This will unblock engines support in FastBoot.

Motivation

Today by default FastBoot provides the ability to read config based info in Node for host applications only. Other infrastructure like Ember Engines may provide their own configuration per bundle. In order to support this, we want to extend FastBoot.config to have a key as an input which determines which config to return a JSON blob.

Things done in this PR

  • Bumped the supported manifest version of fastboot to 3 since the format has changed
  • App config by default will be read from `app-name/config/environment
  • Backward compatibility for older schema versions
  • Added relevant tests

FastBoot addon

Corresponding FastBoot addon PR: ember-fastboot/ember-cli-fastboot#515

cc: @rwjblue

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

Overall, looks very good! Left a few inline notes/questions...

let appConfigKey = `${this.appName}/config/environment`;
if (!appConfig.hasOwnProperty(appConfigKey)) {
this.config[appConfigKey] = appConfig;
}
Copy link
Member

Choose a reason for hiding this comment

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

We should probably create another environment variable to allow the entire config to be replaced, thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the use case for that?

Copy link
Member

Choose a reason for hiding this comment

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

Well, the same as the use case for process.env.APP_CONFIG in the first place. To allow customizing the configuration without requiring a recompile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oho yes, I agree. Will add that.

src/ember-app.js Outdated
const config = this.config;
const appName = this.appName;
function fastbootConfig(key) {
if (!key && config) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this guard is needed, defaulting the key here when not provided to appname/config/environment (regardless if config is available) seems totally fine, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I might have forgotten to clean this up..

src/ember-app.js Outdated
if (process.env.APP_CONFIG) {
this.appConfig = JSON.parse(process.env.APP_CONFIG);
let appConfig = JSON.parse(process.env.APP_CONFIG);
let appConfigKey = `${this.appName}/config/environment`;
Copy link
Member

Choose a reason for hiding this comment

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

Should the keys be ${appName}/config/environment or just appName? I'd generally prefer the config keys to be "opaque" (so either is fine), but I'd lean towards making the key in this object just appName here (though I don't feel super strongly).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am fine with anything. The reason I went with appName/config/environment since it is easier to map to the AMD module name.

'base': 1, // first schema version supported by fastboot library
'manifestFileArrays': 2 // schema version when app and vendor in manifest supported an array of files
'manifestFileArrays': 2, // schema version when app and vendor in manifest supported an array of files
'configExtension': 3 // schema version when FastBoot.config can read artibitary indexed config
Copy link
Member

Choose a reason for hiding this comment

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

typo here, artibitary -> arbitrary

@rwjblue
Copy link
Member

rwjblue commented Sep 5, 2017

@kratiahuja - Ping?

@kratiahuja
Copy link
Contributor Author

@rwjblue updated per feedback. Super sorry for the delay here!

@rwjblue rwjblue merged commit fadd166 into master Sep 20, 2017
@rwjblue rwjblue deleted the config-tree branch September 20, 2017 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants