scaffolding icon indicating copy to clipboard operation
scaffolding copied to clipboard

feat: Make scaffolding cli package manager agnostic

Open c12i opened this issue 2 months ago • 4 comments

Currently, scaffolding ~only~ implicitly supports npm as the package manager when working the hApp's workspace. If the developer has a preference for a different package manager, they would need to add support for it manually, updating scripts that run scripts and add dependencies to workspace members.

This issue suggests making the cli package manager agnostic, meaning, providing the user the option to choose which package manager they would want to use while scaffolding their hApp i.e yarn, pnpm or bun, then ensuring all references to this script manager are used elsewhere.

c12i avatar Apr 19 '24 12:04 c12i

Hum I don't actually have this experience. The custom template https://github.com/holochain-open-dev/templates uses pnpm as its package manager, and everything works just fine. What's more, pnpm is the only package I want users from my template to be able to use, as it has a unique and essential feature for my modules pattern.

I don't think the internal code from the scaffolding tool actually assumes npm at all, so the custom templates can add the one they want. Actually if they even wanted they could write their UIs with rust using something like yew, and I think this is still supported using a custom template, and not modifying anything from the source code of the scaffolding tool.

guillemcordoba avatar Apr 19 '24 16:04 guillemcordoba

I believe the scaffolding tool implicitly assumes the use of npm based on the following observations:

  1. The scaffolding instructions explicitly recommend using npm to install dependencies when setting up a web app. For reference, see this specific line in the cli code.
  2. The package.json file within the web app's root directory contains scripts that invoke npm commands that run a workspace member's scripts. For example, look at this script here. The APIs for managing workspaces vary significantly among package managers, which suggests a reliance on npm's specific features. As a result, using alternative package managers like yarn or pnpm might necessitate manual script adjustments post-scaffolding.

This issue is particularly relevant to the inbuilt templates. While custom templates can specify their preferred package/build managers, the cli should not prompt users to choose a package manager in those cases.

c12i avatar Apr 19 '24 17:04 c12i

Ah sure yeah, I'm happy to admit that the built-in templates have a total reliance on npm, but that can be totally overriden by using a custom template. The line of code in the instructions can also be overriden in a custom template, but I admit it's true that that indicates a preference towards npm.

So you're saying that only when using a built-in template the scaffolding tool should prompt to ask about which particular package manager to use? What about custom templates then? Some of them would support different package managers, some of them only one, while other won't even have any UI...

guillemcordoba avatar Apr 19 '24 19:04 guillemcordoba

So you're saying that only when using a built-in template the scaffolding tool should prompt to ask about which particular package manager to use?

Yes, only for built in templates. For custom templates, the choice would be pre-determined by the author, therefore the user would not get prompted while using one.

c12i avatar Apr 22 '24 11:04 c12i