loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

Missing whitespace in lb4 repository command last line output when selecting multiple models

Open Charly6596 opened this issue 7 years ago • 5 comments

Description/Steps to reproduce

1- Create a new project and enable repositories

lb4
? Project description: loopback
? Project root directory: loopback
? Application class name: LoopbackApplication
? Select features to enable in the project Enable repositories

2- Move to the proyect folder and add two models (with any name and default values would do)

cd loopback
lb4 model
? Model class name: Animal
? Please select the model base class Entity (A persisted model with an ID)
? Allow additional (free-form) properties? No

lb4 model
? Model class name: Pet
? Please select the model base class Entity (A persisted model with an ID)
? Allow additional (free-form) properties? No

3- Add any datasource with default values

lb4 datasource
? Datasource name: db
? Select the connector for db: In-memory db (supported by StrongLoop)
? window.localStorage key to use for persistence (browser only): 
? Full path to file for persistence (server only): 

4- Add a repository for both entities

lb4 repository
? Please select the datasource DbDatasource
? Select the model(s) you want to generate a repository Animal, Pet
? Please select the repository base class DefaultCrudRepository (Legacy juggler bridge)
? Please enter the name of the ID property for Animal: id
? Please enter the name of the ID property for Pet: id
   create src/repositories/animal.repository.ts
   create src/repositories/pet.repository.ts
   update src/repositories/index.ts
   update src/repositories/index.ts

Repositories AnimalRepositoryPetRepository was created in src/repositories/

Link to reproduction sandbox

The issue is before launching the app

Expected result

Last line should be something like the following:

Repositories AnimalRepository PetRepository created in src/repositories/

instead of

Repositories AnimalRepositoryPetRepository was created in src/repositories/

Additional information

node -e 'console.log(process.platform, process.arch, process.versions.node)'
linux x64 11.15.0```
```cmd
npm ls --prod --depth 0 | grep loopback
[email protected] /home/charly/repos/loopback/loopback
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
└── @loopback/[email protected]

Charly6596 avatar Jul 12 '19 11:07 Charly6596

Transferred to loopback-next repo since it's related to LB4. @Charly6596, thanks for reporting the problem. Would you be interested in submitting a patch? The code for LB4 CLI is in here: https://github.com/strongloop/loopback-next/tree/master/packages/cli.

In case you're new to submitting PR in LB4, here is the step by step instruction: https://loopback.io/doc/en/lb4/submitting_a_pr.html. Thanks!

dhmlau avatar Jul 12 '19 19:07 dhmlau

@Charly6596 The fix should be very simple. On line https://github.com/strongloop/loopback-next/blob/master/packages/cli/generators/repository/index.js#L553, use:

? this.artifactInfo.modelNameList.join(',')

raymondfeng avatar Jul 12 '19 20:07 raymondfeng

@dhmlau @raymondfeng thanks, yes, I'd like to do that after reading the instructions :+1:

Charly6596 avatar Jul 13 '19 12:07 Charly6596

hi @Charly6596 , i see you are not assigne to this issue , so do you plan to do it or can i take it ?

godartm avatar Jul 25 '19 15:07 godartm

hi @Charly6596 , i see you are not assigne to this issue , so do you plan to do it or can i take it ?

Hey, I actually fixed it, it was a bit more than adding a , but it isn't passing the tests (formatting test i believe) so if you want to take a look at that here is my commit in my forked repo, I will create a work in progress pull request and I won't be able to complete it anytime soon, so feel free to contribute!

Charly6596 avatar Jul 25 '19 23:07 Charly6596