refine
                                
                                 refine copied to clipboard
                                
                                    refine copied to clipboard
                            
                            
                            
                        pnpm create refine-app@latest uses the npm package manger
Describe the bug
When executing pnpm create refine-app@latest -- -o refine-chakra-ui tutorial it used the npm package manager to install packages.
Steps To Reproduce
pnpm create refine-app@latest -- -o refine-chakra-ui tutorial
Expected behavior
Use pnpm to install packages
Screenshot
https://i.imgur.com/A1ptSKD.png
Desktop
No response
Mobile
No response
Additional Context
No response
Hey @crossout-db thanks for the issue. We are open to contributions from the community for this one.
Can you assign this to me?
I looked into this issue, here are my observations -
When we run the command pnpm create refine-app@latest -- -o refine-chakra-ui tutorial, it triggers the superplate-cli command.
Upon looking superplate-cli source, I got to know that it is taking answers for the cli prompt as configured in preset.js in superplate-core-plugins for given preset.
preset.js also does not explicitly define the package manager to be used so I guess superplate is by default picking npm as package manager to install dependencies.
I have 2 quick fix ideas, either we need to prompt for package manager selection regardless of preset answers in interactive cli or we can create new argument in superplate-cli command for preferred package manager, and that can be configured in our codebase.
@BatuhanW @omeraplak , Can we discuss around how do we want to solve this? Do correct me if I am wrong somewhere or missed anything.
Hello, @imtushardave, great investigation!
While we can go with both of your solutions, like explicitly prompting regardless or having a configuration, people want us to use pnpm if they ran pnpm create refine-app command.
I think we can check process.env.npm_execpath and process.env.npm_config_user_agent ENV variables to understand which package manager triggered the command and we can use the package manager to install dependencies by default, without prompting. I think that would be better DX.
Some pseudo-code:
const isPnpm = process.env?.npm_execpath?.includes('pnpm') || process.env?.npm_config_user_agent?.includes('pnpm')
We could do this for npm and yarn too.
WDYT about this approach?
@BatuhanW At first glance, your approach looks good to me as no intervention is required from the user at all. can you just confirm if there are any use cases where the user would want to choose a different package manager? if that is not the case then I feel your approach is the way to go.
Just confirm once and I will start the implementation of the solution discussed.
@imtushardave, I think we can have both. We could give users an option to explicitly set the desired package manager, but we can fallback to package manager from env variables.
@BatuhanW Should we use the command line argument or throw a prompt regardless for taking user input? default selection we can get from the env variables.
Also, since these changes are related to superplate-cli, will need to do change in Superplate repository as well apart from changes in Refine repo.
Let's finalize the approach first and I will start doing the changes.
Hello @imtushardave, it seems I forgot to post my reply last week.
Let's use ENV as a default option, unless user explicitly passes --package-manager.
@BatuhanW Just so that you know, I've been busy at the office for the last couple of days. I will try to close this by Sunday Evening.
Hey @BatuhanW, I am stuck in testing the changes of superplate-cli in local. I am sorry for the delay but be assured that I will close this within this week or else I will let you know.
Also, do you have some references which can help for testing superplate-cli?
Hello @imtushardave, we can help you with testing if you stuck, or if you could create PRs, we could help with testing also.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.