SamagraX-Stencil / stencil-cli

NestJS CLI on steroids for stencil 🍹
https://stencil.samagra.io/cli/introduction
Other
3 stars 9 forks source link

[cli] Install packages as well when using `generate` command #8

Open sooraj1002 opened 6 months ago

sooraj1002 commented 6 months ago

Description

Presently, the cli while setting up a service using the generate command instead of setting it up during the bootstrapping phase does not install the external/extra dependencies if any. This should not be the case, those should be added alongside the service setup.

Potential fix

  1. Detect the lock file in the package root, if the package root contains only yarn.lock or pnpm.lock use yarn or pnpm respectively, incase there is no lock file of multiple lock files default to npm.
  2. Read, parse and update the package.json to add the dependency with the particular version that is required and print a message for the user to install the new dependencies using a package manager of their choice.

Objective

The goal of this issue is to update the package.json when user runs the generate command and prompt user on which package manager he needs to install the packages or use the registry generated here https://github.com/SamagraX-Stencil/stencil-cli/pull/20 to know which package manager the user has chosen while bootstraping the project.

Goals

Before generate command After generate command

Complexity : Medium

Product Name

Stencil-Cli

Organisation Name

SamagraX

Domain

Command Line Interface

Tech Skills Needed

TypeScript, Cli

Savio629 commented 2 months ago

@sooraj1002 So instead of installing it directly, we will have to store it in dependencies and then prompt user for package manager of his choice to install the dependencies? Can't we just install it when the specific module is being generated?

sooraj1002 commented 2 months ago

@techsavvyash can you also confirm this once?

techsavvyash commented 2 months ago

Yes, this is the correct approach, incase a direct install fails, it will not update the package.json making it very difficult for the end user to figure out what all dependencies are required giving a very bad UX, we must first update the package.json manually, which should be easy work, then we should check for the existence of lock files, incase of conflict, just prompt the user for the package manager and use that. Additionally the registry feature that @Savio629 added can be used to store the package manager of user's choice as well removing the need to check for package manager over and over again.

Savio629 commented 1 month ago

Description

Presently, the cli while setting up a service using the generate command instead of setting it up during the bootstrapping phase does not install the external/extra dependencies if any. This should not be the case, those should be added alongside the service setup.

Objective

The goal of this issue is to update the package.json when user runs the generate command and prompt user on which package manager he needs to install the packages or use the registry generated here https://github.com/SamagraX-Stencil/stencil-cli/pull/20 to know which package manager the user has chosen while bootstraping the project.

Goals

Before generate command After generate command

Complexity : Medium

Product Name

Stencil-Cli

Organisation Name

SamagraX

Domain

Command Line Interface

Tech Skills Needed

TypeScript, Cli

shivankurchavan commented 2 weeks ago

please assign me : )