Closed Oliverq755 closed 4 years ago
create a repository for your existing datasource
How is your datasource configured? Do you have src/datasources/update.datasource.config.json
present in your project? Maybe you have src/datasources/update.datasource.json
instead?
We have recently changed the file names of datasource JSON files to accommodate breaking changes introduced by TypeScript version 3.7.
@raymondfeng Do we have any migration guide showing our users how to deal with this change?
Here is the pull request that introduced the change: https://github.com/strongloop/loopback-next/pull/4060
@bajtos Yes, this is causing because of the latest changes to accommodate breaking changes introduced by TypeScript version 3.7. I uninstalled the current version and installed 1.21.3 version and it worked. I will try the migration later. Is there any migration steps included?
@Oliverq755 I don't think there's an official migration documented yet, but renaming all instances of *.datasource.json
to *.datasource.config.json
and renaming references to the files will fix the issue when using typescript@~3.7.0
.
Updating the @loopback/cli
to the latest version will fix the issue for future generated datasources.
Similar: #4173, #4119
@Oliverq755 I don't think there's an official migration documented yet, but renaming all instances of
*.datasource.json
to*.datasource.config.json
and renaming references to the files will fix the issue when usingtypescript@~3.7.0
.Updating the
@loopback/cli
to the latest version will fix the issue for future generated datasources.Similar: #4173, #4119
@achrinza Thanks for the reply, I downgraded my loopback version @1.21.3 which fixes the issue. However, the latest @loopback/cli
version fixes the future generation of data sources, but what if we are using the old version generated applications. I don't think it's a proper way (renaming all instances of *.datasource.json
to *.datasource.config.json
and renaming references to the files) to fix this issue. There should be auto migration which could be done when user do npm install
.
I don't think it's a proper way (renaming all instances of
*.datasource.json
to*.datasource.config.json
and renaming references to the files) to fix this issue. There should be auto migration which could be done when user donpm install
.
Might not be proper but it seems to work. For those with plentiful datasources though, I think that you can open the project in a tool like VsCode with import path correction enabled ("typescript.updateImportsOnFileMove.enabled": "always",) and bulk rename the files using a script or shareware tool. Doesn't warrant addition to install script for a one time change. Maybe the change should be considered breaking if it is causing the error.
There should be auto migration which could be done when user do
npm install
.
I agree that a migration tool would be great. I am don't think it can be invoked by npm install
, but that's an implementation detail.
The bigger problem is that we don't have enough bandwidth to implement such tool. It requires a non-trivial amount of work with little pay-off, because most users will run it only once.
Personally, I would start with improving the way how we are communicating breaking changes and make the migration guides easier to find.
In https://github.com/strongloop/loopback-next/pull/4080, we introduced lb4 update
command, it think it provides a good place where to educate users about changes they need to make after upgrading to newer version of LB4 dependencies. It can implement proper auto-migration too, but as I said, that may require more work than we are willing to invest.
@dougal83 would you be interested in implementing & contributing such feature yourself?
Opened an issue https://github.com/strongloop/loopback-next/issues/4864 for improving the breaking change message announcement. Closing the issue as the content might be misleading. Feel free to join discussion there.
Steps to reproduce
npm install
lb4 model
lb4 repository
I downloaded the zip folder of my project and extracted to my location. I installed all the required nodemodules and started the project. It got successfully run. Now I tried to create a new model for my project using the code
lb4 model
which was also successful. Now I have already datasource setup and want new repository for that datasource. I started to create new repository usinglb4 repository
but it thows errorevents.js:187 throw er; // Unhandled 'error' event ^ Error: Cannot load /home/ecas0002/Repos/demo-backendcode/src/datasources/update.datasource.config.json: ENOENT: no such file or directory, open '/home/ecas0002/Repos/demo-backendcode/src/datasources/update.datasource.config.json'
Current Behavior
events.js:187 throw er; // Unhandled 'error' event ^ Error: Cannot load /home/ecas0002/Repos/demo-backendcode/src/datasources/update.datasource.config.json: ENOENT: no such file or directory, open '/home/ecas0002/Repos/demo-backendcode/src/datasources/update.datasource.config.json'
Expected Behavior
It should normally create and repository by allowing me to choose datasource and model.
Additional information
events.js:187 throw er; // Unhandled 'error' event ^ Error: Cannot load /home/ecas0002/Repos/demo-backendcode/src/datasources/update.datasource.config.json: ENOENT: no such file or directory, open '/home/ecas0002/Repos/demo-backendcode/src/datasources/update.datasource.config.json'
See Reporting Issues for more tips on writing good issues