-
Notifications
You must be signed in to change notification settings - Fork 4
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 #44 from peopledoc/typescript
Refactor to Typescript
- Loading branch information
Showing
36 changed files
with
13,116 additions
and
23,759 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 |
---|---|---|
|
@@ -53,4 +53,4 @@ module.exports = { | |
}) | ||
} | ||
] | ||
}; | ||
} |
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,5 +1,5 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
module.exports = { | ||
extends: 'recommended' | ||
}; | ||
} |
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
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
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.
This file was deleted.
Oops, something went wrong.
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,81 @@ | ||
import EmberApplication from '@ember/application' | ||
import EmberObject from '@ember/object' | ||
import { deprecate } from '@ember/application/deprecations' | ||
import { run } from '@ember/runloop' | ||
import { get } from '@ember/object' | ||
|
||
type Application = EmberApplication & EmberObject | ||
|
||
interface ObjectConfig { | ||
delegateStart: boolean, | ||
config: any | ||
} | ||
|
||
type VoidConfig = null|undefined | ||
type DeprecatedBooleanConfig = boolean | ||
|
||
type GivenConfig = VoidConfig | ||
| DeprecatedBooleanConfig | ||
| ObjectConfig | ||
|
||
function configIsVoid(config:GivenConfig): config is VoidConfig { | ||
return [null, undefined].includes(config as VoidConfig) | ||
} | ||
|
||
function configIsBoolean(config:GivenConfig): config is DeprecatedBooleanConfig { | ||
return typeof config === 'boolean' | ||
} | ||
|
||
function normalizeConfig(userConfig:GivenConfig):ObjectConfig { | ||
if (configIsVoid(userConfig)) { | ||
return { delegateStart: false, config: {} } | ||
} | ||
|
||
if (configIsBoolean(userConfig)) { | ||
let embeddedConfig = { delegateStart: userConfig, config: {} } | ||
deprecate('The `embedded` config property MUST be undefined or an an object', false, { id: 'bad-object-config', until: '1.0.0' }) | ||
return embeddedConfig | ||
} | ||
|
||
if (userConfig.delegateStart === undefined) { | ||
deprecate('The config MUST contain a `delegateStart` property. Assuming `true` for backward compatibility. The config must now be defined in a `config` property', false, { id: 'bad-object-config', until: '1.0.0' }) | ||
return { | ||
delegateStart: true, | ||
config: userConfig | ||
} | ||
} | ||
return Object.assign({ config: {} }, userConfig) | ||
} | ||
|
||
export function initialize():void { | ||
const application:Application = arguments[1] || arguments[0] | ||
const env = application.resolveRegistration('config:environment') | ||
|
||
let appConfig:GivenConfig = get(env, 'embedded') | ||
|
||
let embeddedConfig:ObjectConfig = normalizeConfig(appConfig) | ||
|
||
if (embeddedConfig.delegateStart) { | ||
// @ts-ignore | ||
application.reopen({ | ||
start: run.bind(application, function emberCliEmbeddedStart(config = {}) { | ||
const _embeddedConfig = Object.assign( | ||
{}, | ||
embeddedConfig.config, | ||
config | ||
) | ||
this.register('config:embedded', _embeddedConfig, { instantiate: false }) | ||
this.advanceReadiness() | ||
}) | ||
}) | ||
application.deferReadiness() | ||
} else { | ||
application.register('config:embedded', embeddedConfig.config) | ||
} | ||
} | ||
|
||
export default { | ||
name: 'ember-cli-embedded', | ||
after: 'export-application-global', | ||
initialize | ||
} |
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,15 +1,15 @@ | ||
import ObjectProxy from '@ember/object/proxy'; | ||
import { getOwner } from '@ember/application'; | ||
import ObjectProxy from '@ember/object/proxy' | ||
import { getOwner } from '@ember/application' | ||
|
||
let configService = ObjectProxy.extend({ | ||
init() { | ||
this.content = getOwner(this).factoryFor('config:embedded').class; | ||
this._super(...arguments); | ||
this.content = getOwner(this).factoryFor('config:embedded').class | ||
this._super(...arguments) | ||
} | ||
}); | ||
}) | ||
|
||
configService.reopenClass({ | ||
isServiceFactory: true | ||
}); | ||
}) | ||
|
||
export default configService; | ||
export default configService |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export { default, initialize } from 'ember-cli-embedded/initializers/embedded'; | ||
export { default, initialize } from 'ember-cli-embedded/initializers/embedded' |
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,10 +1,10 @@ | ||
export function initialize(appInstance) { | ||
const appConf = appInstance.resolveRegistration('config:environment').APP; | ||
const embedConf = appInstance.resolveRegistration('config:embedded'); | ||
return Object.assign(appConf, embedConf); | ||
const appConf = appInstance.resolveRegistration('config:environment').APP | ||
const embedConf = appInstance.resolveRegistration('config:embedded') | ||
return Object.assign(appConf, embedConf) | ||
} | ||
|
||
export default { | ||
name: 'embedded', | ||
initialize | ||
}; | ||
} |
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 +1 @@ | ||
export { default } from 'ember-cli-embedded/services/embedded'; | ||
export { default } from 'ember-cli-embedded/services/embedded' |
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
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,5 +1,5 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
module.exports = function(/* environment, appConfig */) { | ||
return { }; | ||
}; | ||
return { } | ||
} |
Oops, something went wrong.