Skip to content

Commit

Permalink
chore: apply feedback
Browse files Browse the repository at this point in the history
Apply feedback

Signed-off-by: Yaapa Hage <[email protected]>
  • Loading branch information
Yaapa Hage committed Aug 24, 2020
1 parent 3157719 commit 6c8bc9b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions packages/cli/generators/extension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ module.exports = class ExtensionGenerator extends ProjectGenerator {

promptOptions() {
if (this.shouldExit()) return;
const titleCase =
this.projectInfo.name.charAt(0).toUpperCase() +
this.projectInfo.name.slice(1);
this.projectInfo.optionsInterface = `${titleCase}Options`;
this.projectInfo.bindingsNamespace = `${titleCase}Bindings`;
this.projectInfo.defaultOptions = `DEFAULT_${this.projectInfo.name.toUpperCase()}_OPTIONS`;
return super.promptOptions();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {Component, ProviderMap} from '@loopback/core';
import {<%= project.name.charAt(0).toUpperCase() + project.name.slice(1) %>Bindings} from './keys'
import {<%= project.name.toUpperCase() %>_OPTIONS} from './types';
import {<%= project.bindingsNamespace %>} from './keys'
import {<%= project.defaultOptions %>, <%= project.optionsInterface %>} from './types';

@bind({tags: {[ContextTags.KEY]: {<%= project.name.charAt(0).toUpperCase() + project.name.slice(1) %>Bindings.COMPONENT}})
@bind({tags: {[ContextTags.KEY]: {<%= project.bindingsNamespace %>.COMPONENT}})
export class <%= project.componentName %> implements Component {
constructor(
@inject(CoreBindings.APPLICATION_INSTANCE)
private application: Application,
@config()
options: Options = <%= project.name.toUpperCase() %>_OPTIONS,
options: <%= project.optionsInterface %> = <%= project.defaultOptions %>,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {<%= project.componentName %>} from './component';
/**
* Binding keys used by this component.
*/
export namespace <%= project.name.charAt(0).toUpperCase() + project.name.slice(1) %>Bindings {
export namespace <%= project.bindingsNamespace %> {
export const COMPONENT = BindingKey.create<<%= project.componentName %>>(
`${CoreBindings.COMPONENTS}.<%= project.componentName %>`,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/generators/extension/templates/src/types.ts.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface <%= project.name.charAt(0).toUpperCase() + project.name.slice(1) %>Options {
export interface <%= project.optionsInterface %> {

}

export const <%= project.name.toUpperCase() %>_OPTIONS: <%= project.name.charAt(0).toUpperCase() + project.name.slice(1) %>Options = {
export const <%= project.defaultOptions %>: <%= project.optionsInterface %> = {

};

0 comments on commit 6c8bc9b

Please sign in to comment.