@@ -47,7 +47,7 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator {
4747 let fileContent = '' ;
4848 let modelFile = path . join (
4949 this . artifactInfo . modelDir ,
50- ` ${ utils . kebabCase ( modelName ) } .model.ts` ,
50+ utils . toModelFileName ( modelName ) ,
5151 ) ;
5252 try {
5353 fileContent = this . fs . read ( modelFile , { } ) ;
@@ -141,20 +141,20 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator {
141141 _setupGenerator ( ) {
142142 this . artifactInfo = {
143143 type : 'repository ' ,
144- rootDir : 'src' ,
144+ rootDir : utils . sourceRootDir ,
145145 } ;
146146
147147 this . artifactInfo . outDir = path . resolve (
148148 this . artifactInfo . rootDir ,
149- 'repositories' ,
149+ utils . repositoriesDir ,
150150 ) ;
151151 this . artifactInfo . datasourcesDir = path . resolve (
152152 this . artifactInfo . rootDir ,
153- 'datasources' ,
153+ utils . datasourcesDir ,
154154 ) ;
155155 this . artifactInfo . modelDir = path . resolve (
156156 this . artifactInfo . rootDir ,
157- 'models' ,
157+ utils . modelsDir ,
158158 ) ;
159159
160160 this . artifactInfo . defaultTemplate = REPOSITORY_CRUD_TEMPLATE ;
@@ -230,7 +230,11 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator {
230230 'datasource' ,
231231 true ,
232232 ) ;
233- debug ( `datasourcesList from src/datasources : ${ datasourcesList } ` ) ;
233+ debug (
234+ `datasourcesList from ${ utils . sourceRootDir } /${
235+ utils . datasourcesDir
236+ } : ${ datasourcesList } `,
237+ ) ;
234238 } catch ( err ) {
235239 return this . exit ( err ) ;
236240 }
@@ -310,7 +314,11 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator {
310314
311315 this . options . model = utils . toClassName ( this . options . model ) ;
312316 // assign the model name from the command line only if it is valid
313- if ( modelList . length > 0 && modelList . includes ( this . options . model ) ) {
317+ if (
318+ modelList &&
319+ modelList . length > 0 &&
320+ modelList . includes ( this . options . model )
321+ ) {
314322 Object . assign ( this . artifactInfo , { modelNameList : [ this . options . model ] } ) ;
315323 } else {
316324 modelList = [ ] ;
@@ -399,25 +407,29 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator {
399407
400408 if ( this . options . name ) {
401409 this . artifactInfo . className = utils . toClassName ( this . options . name ) ;
402- this . artifactInfo . outFile =
403- utils . kebabCase ( this . options . name ) + '.repository.ts' ;
410+ this . artifactInfo . outFile = utils . toRepositoryFileName ( this . options . name ) ;
404411
405412 // make sure the name supplied from cmd line is only used once
406413 delete this . options . name ;
407414 } else {
408415 this . artifactInfo . className = utils . toClassName (
409416 this . artifactInfo . modelName ,
410417 ) ;
411- this . artifactInfo . outFile =
412- utils . kebabCase ( this . artifactInfo . modelName ) + '.repository.ts' ;
418+ this . artifactInfo . outFile = utils . toRepositoryFileName (
419+ this . artifactInfo . modelName ,
420+ ) ;
413421 }
414422
415423 if ( debug . enabled ) {
416424 debug ( `Artifact output filename set to: ${ this . artifactInfo . outFile } ` ) ;
417425 }
418426
419427 const source = this . templatePath (
420- path . join ( 'src' , 'repositories' , this . artifactInfo . defaultTemplate ) ,
428+ path . join (
429+ utils . sourceRootDir ,
430+ utils . repositoriesDir ,
431+ this . artifactInfo . defaultTemplate ,
432+ ) ,
421433 ) ;
422434
423435 if ( debug . enabled ) {
0 commit comments