File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,6 +86,22 @@ module.exports = class AppGenerator extends ProjectGenerator {
8686 return super . promptOptions ( ) ;
8787 }
8888
89+ buildAppClassMixins ( ) {
90+ if ( this . shouldExit ( ) ) return false ;
91+ const { enableRepository, enableServices} = this . projectInfo || { } ;
92+ if ( ! enableRepository && ! enableServices ) return ;
93+
94+ let appClassWithMixins = 'RestApplication' ;
95+ if ( enableRepository ) {
96+ appClassWithMixins = `RepositoryMixin(${ appClassWithMixins } )` ;
97+ }
98+ if ( enableServices ) {
99+ appClassWithMixins = `ServiceMixin(${ appClassWithMixins } )` ;
100+ }
101+
102+ this . projectInfo . appClassWithMixins = appClassWithMixins ;
103+ }
104+
89105 scaffold ( ) {
90106 return super . scaffold ( ) ;
91107 }
Original file line number Diff line number Diff line change @@ -9,17 +9,9 @@ import {ServiceMixin} from '@loopback/service-proxy';
99< % } - %>
1010import {MySequence} from './sequence';
1111
12- <% if (project .enableRepository || project .enableServices ) {
13- let classWithOptionalMixins = ' RestApplication' ;
14- if (project .enableRepository ) {
15- classWithOptionalMixins = ` RepositoryMixin(${ classWithOptionalMixins} )` ;
16- }
17- if (project .enableServices ) {
18- classWithOptionalMixins = ` ServiceMixin(${ classWithOptionalMixins} )` ;
19- }
20- -% >
12+ <% if (project .appClassWithMixins ) { -% >
2113export class < %= project .applicationName % > extends BootMixin (
22- < %= classWithOptionalMixins % > ,
14+ < %= project . appClassWithMixins % > ,
2315) {
2416< %
2517} else { // no optional mixins
Original file line number Diff line number Diff line change 7878 " @loopback/core" : " <%= project.dependencies['@loopback/core'] -%>" ,
7979 " @loopback/dist-util" : " <%= project.dependencies['@loopback/dist-util'] -%>" ,
8080 " @loopback/openapi-v3" : " <%= project.dependencies['@loopback/openapi-v3'] -%>" ,
81+ < % if (project .enableRepository ) { -% >
8182 " @loopback/repository" : " <%= project.dependencies['@loopback/repository'] -%>" ,
83+ < % } -% >
84+ < % if (project .enableServices ) { -% >
8285 " @loopback/rest" : " <%= project.dependencies['@loopback/rest'] -%>" ,
8386 " @loopback/service-proxy" : " <%= project.dependencies['@loopback/service-proxy'] -%>"
8487< % } else { -% >
88+ " @loopback/rest" : " <%= project.dependencies['@loopback/rest'] -%>"
89+ < % } -% >
90+ < % } else { /* NOT AN APPLICATION */ -% >
8591 " @loopback/core" : " <%= project.dependencies['@loopback/core'] -%>" ,
8692 " @loopback/dist-util" : " <%= project.dependencies['@loopback/dist-util'] -%>"
8793< % } - %>
You can’t perform that action at this time.
0 commit comments