kcl icon indicating copy to clipboard operation
kcl copied to clipboard

[LFX] Enhancement: KCL IDE automatically updates the dependencies through kpm

Open zong-zhe opened this issue 1 year ago β€’ 10 comments

Enhancement

When a KCL package is loaded using KCL IDE, the IDE automatically updates the dependencies of the current KCL package through the kcl mod command.

PreTest

  • https://github.com/kcl-lang/kcl/issues/1031
  • https://github.com/kcl-lang/kcl/issues/1058

zong-zhe avatar Jan 24 '24 06:01 zong-zhe

Can I some more context here? @zong-zhe @Peefy

octonawish-akcodes avatar Jan 24 '24 15:01 octonawish-akcodes

Hi @octonawish-akcodes πŸ˜„

Let me add more details to this issue.

KCL IDE is the main interface for users to write KCL, and kpm is the package management tool for KCL, used for managing KCL's third-party libraries.

KCL IDE is developed based on LSP - https://microsoft.github.io/language-server-protocol/ @He1pa 😊 can provide more details about KCL IDE.

KCL IDE uses kpm commands to manage KCL packages. The main work of this issue is to make KCL IDE automatically update the current KCL package's third-party dependencies according to the kcl.mod file in the KCL package when loading the KCL package, so that a legal KCL package will not cause errors cased by the third-party dependencies has not been updated.

The command used by kpm to update the KCL package's third-party library is kcl mod update, more details

  • https://github.com/kcl-lang/cli/blob/d05b19dca5338fb8df5298cf61a5fa46b4854178/cmd/kcl/commands/mod_update.go#L38
Sorry that there is no document about `kcl mod update` on the official website https://kcl-lang.io/docs/tools/cli/package-management/command-reference/init, which is our negligence. We have raised an issue https://github.com/kcl-lang/kcl-lang.io/issues/253 to track this issue.

We previously integrated a command kcl mod metadata to help the IDE find KCL third-party libraries during the compilation process. kcl mod updatecan be integrated with KCL IDE in a similar way

  • https://github.com/kcl-lang/kcl/blob/6147b908b52dc1674728bfef3af2002d45a7c478/kclvm/driver/src/kpm_metadata.rs#L60

If any other questions, please let me know πŸ˜„ πŸ˜„ πŸ˜„

zong-zhe avatar Jan 25 '24 02:01 zong-zhe

Just a small query, how can I test my code?

octonawish-akcodes avatar Jan 25 '24 05:01 octonawish-akcodes

/assign

d4v1d03 avatar Jan 30 '24 22:01 d4v1d03

Hey @zong-zhe, i got over the explaination you've given and have doubts regarding my conclusion, please correct me if i am wrong. So the fetch_metadata() function just gives us the output that fetch_mod_metadata() function returns after it passes the command 'kcl mod metadata'... from this, we store those third-party dependencies and iterate over each and verify if they need to be upgraded or not.

d4v1d03 avatar Feb 01 '24 04:02 d4v1d03

I can try to figure this out on my own but can you please save my time by mentioning how do i check this "version of a third-party dependency".Thank you. 😊

d4v1d03 avatar Feb 01 '24 05:02 d4v1d03

I believe you can see the versions of those third party dependencies in kcl.mod file.

octonawish-akcodes avatar Feb 01 '24 05:02 octonawish-akcodes

Hey @zong-zhe, i got over the explaination you've given and have doubts regarding my conclusion, please correct me if i am wrong. So the fetch_metadata() function just gives us the output that fetch_mod_metadata() function returns after it passes the command 'kcl mod metadata'... from this, we store those third-party dependencies and iterate over each and verify if they need to be upgraded or not.

Hi @d4v1d03 πŸ˜„ Good question ! πŸ‘ Our design is that all functionalities related to package management are handled by kpm. The KCL IDE is only responsible for sending requests to kpm and obtaining the corresponding processing results.Β Therefore, the storage and validation of third-party dependencies is done in kpm.

kpm is here ! - https://github.com/kcl-lang/kpm

zong-zhe avatar Feb 05 '24 02:02 zong-zhe

I can try to figure this out on my own but can you please save my time by mentioning how do i check this "version of a third-party dependency".Thank you. 😊

Hi @d4v1d03 , The Package Version Management is still in progress. More details here: https://github.com/kcl-lang/kpm/issues/246

zong-zhe avatar Feb 05 '24 02:02 zong-zhe

Ok @zong-zhe , thanks for the clarification. I will work on the pretest you mentioned over here. Are there any couple more to work on so i could get a good grasp of kpm.

d4v1d03 avatar Feb 06 '24 16:02 d4v1d03

Closed as 2024 LFX Phase 1 has already ended and open another one

Peefy avatar Jun 20 '24 11:06 Peefy