SamagraX-Stencil / stencil-cli

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

[cli] gitignore is over-written #2

Closed sooraj1002 closed 6 months ago

sooraj1002 commented 9 months ago

Description

When we setup prisma, the default gitignore is over-written to just have node_modules and .env

This happens because we are running npx prisma init for the default setup of prisma models

Screenshots for reference

Current .gitignore image

Expected .gitignore image

Savio629 commented 6 months ago

@sooraj1002 If we do something like this when prisma is selected?

cp .gitignore temp_gitignore

npx prisma init

cp temp_gitignore .gitignore

rm temp_gitignore
Savio629 commented 6 months ago

// @sooraj1002 @techsavvyash

techsavvyash commented 6 months ago

how will this merge the changes made by npx prisma init in the .env?

Savio629 commented 6 months ago

We can do the same process for .env right?

techsavvyash commented 6 months ago

oh sorry, nevermind, I confused between .gitignore and .env. Yes for .gitignore this seems to be the right approach

Savio629 commented 6 months ago

Prisma version installed by stencil cli prisma : 5.11.0 @prisma/client : 5.11.0

This issue is fixed by prisma way back in the version 3.2.0 Ref: https://github.com/prisma/prisma/pull/8946

Any idea what's causing the issue here then?

sooraj1002 commented 6 months ago

There is an issue in the wording of the ticket. What happens is the npx prisma init command runs before our cli is creating the gitignore and the implementation from schematics does not overwrite the created gitignore

Savio629 commented 6 months ago

An alternative which worked is shown below

image

Savio629 commented 6 months ago

Right now when repo is initialized, there is no .gitignore so prisma treats it like no .gitignore so I'll add one Ref: https://github.com/prisma/prisma/pull/8946 Do not create .gitignore file if already present

So after prisma creates a .gitignore we check if there exists .gitignore, if yes then return as shown in above code If we don't select prisma this condition is false and we can see .gitignore file

techsavvyash commented 6 months ago

This approach looks good @Savio629