refine icon indicating copy to clipboard operation
refine copied to clipboard

pnpm create refine-app@latest uses the npm package manger

Open crossout-db opened this issue 1 year ago • 12 comments

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

crossout-db avatar Nov 12 '23 12:11 crossout-db

Hey @crossout-db thanks for the issue. We are open to contributions from the community for this one.

BatuhanW avatar Nov 14 '23 06:11 BatuhanW

Can you assign this to me?

imtushardave avatar Nov 23 '23 07:11 imtushardave

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.

imtushardave avatar Nov 28 '23 05:11 imtushardave

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 avatar Nov 28 '23 08:11 BatuhanW

@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 avatar Nov 29 '23 06:11 imtushardave

@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 avatar Nov 29 '23 07:11 BatuhanW

@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.

imtushardave avatar Nov 29 '23 07:11 imtushardave

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 avatar Dec 04 '23 07:12 BatuhanW

@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.

imtushardave avatar Dec 07 '23 13:12 imtushardave

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?

imtushardave avatar Dec 18 '23 04:12 imtushardave

Hello @imtushardave, we can help you with testing if you stuck, or if you could create PRs, we could help with testing also.

BatuhanW avatar Dec 18 '23 07:12 BatuhanW

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.

stale[bot] avatar Feb 16 '24 07:02 stale[bot]