Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lb4 relation doesn't find models #9653

Open
danysz opened this issue Jun 13, 2023 · 5 comments
Open

lb4 relation doesn't find models #9653

danysz opened this issue Jun 13, 2023 · 5 comments
Labels

Comments

@danysz
Copy link

danysz commented Jun 13, 2023

Describe the bug

I have a project with a lot of models. I organized the models in "sub directories" inside "models" directory.
The "export" is working properly and all the project is working.
What is not working is the possibility to add repositories, relations or anything else
"lb4 relation" stops with an error "Generation is aborted: Error: No models found in ".../src/models"."
I expect the script to be capable to look for models also inside according to what is available in "index.ts" from "models" directory.

Logs

No response

Additional information

No response

Reproduction

https://github.com/danysz/demo-lb4-cli-model-not-found

@danysz danysz added the bug label Jun 13, 2023
@benjaminrae
Copy link
Contributor

This is the error that the CLI gives:

$ lb4 relation
? Please select the relation type belongsTo

No change to package.json was detected. No package manager install will be executed.
Generation is aborted: Error: No models found in C:\Users\Ben\Documents\dev\sandbox\demo-lb4-cli-model-not-found\src\models.
        Please visit https://loopback.io/doc/en/lb4/Model-generator.html for information on how models are discovered      

Visiting the page provided doesn't actually give any information about how models are discovered.

@danysz
Copy link
Author

danysz commented Jun 15, 2023

This is the error that the CLI gives:

$ lb4 relation
? Please select the relation type belongsTo

No change to package.json was detected. No package manager install will be executed.
Generation is aborted: Error: No models found in C:\Users\Ben\Documents\dev\sandbox\demo-lb4-cli-model-not-found\src\models.
        Please visit https://loopback.io/doc/en/lb4/Model-generator.html for information on how models are discovered      

Visiting the page provided doesn't actually give any information about how models are discovered.

Exactly and even more there Is no way I can make it to look in the subdirectories. Which means that if I am using 100 models for different purposes all of them should be in the same directory.

@benjaminrae
Copy link
Contributor

@loopback/boot is able to find artifacts in nested folders. I wonder if same type of artifact discovery could be used for @loopback/cli to find models/repositories in nested folders.

@arnaud16571542
Copy link

I confirm lb4 is not able to find models in subdirectory. Not really a bug, but a nice to have feature.

@benjaminrae
Copy link
Contributor

I confirm lb4 is not able to find models in subdirectory. Not really a bug, but a nice to have feature.

It could definitely make organization a lot easier as a service grows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants