Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vscode): Add codelens provider w/ generate client command #1710

Merged
merged 3 commits into from May 3, 2024

Conversation

Druue
Copy link
Contributor

@Druue Druue commented Apr 24, 2024

Added a codelens provider to our vscode extension with one codelens command to run prisma generate

This uses new config to define which script runner to use, whether you want the codelens active or not, and setting a custom path

prisma.enableCodeLens: [true, false] // default: true
prisma.scriptRunner: ["npx", "pnpm", "yarn"] // default: npx
prisma.schemaPath: 'path/to/schema' // default: undefined

This shows the following clickable text above the generator block
image

Which opens up a new output window wherein we run prisma generate using the defined script runner

Screen.Recording.2024-04-24.at.18.42.23.mov

Alternatively it is possible to run this through both

  • The command pallete (cmd + shift + p on mac)
image
  • And through keybinds (keybindings.json):
{
        "key": "shift+cmd+g shift+cmd+g",
        "command": "prisma.generate"
}

closes #1651

@Druue Druue added this to the 5.14.0 milestone Apr 24, 2024
Copy link

github-actions bot commented Apr 24, 2024

🤖 Pull request artifacts

empty string

file commit
prisma.vsix e037e3b

Copy link

github-actions bot added a commit that referenced this pull request Apr 24, 2024
@Druue Druue requested review from Jolg42 and SevInf April 24, 2024 17:00
@Jolg42
Copy link
Member

Jolg42 commented Apr 25, 2024

I just tried it out, and it only works for the first generator block, which might not be Prisma Client's generator.
Screenshot 2024-04-25 at 15 06 18

Also, it looks like it only runs "... prisma generate", which breaks if the Prisma schema filename is custom like cockroachdb.prisma with

prisma:warn We could not find your Prisma schema at `prisma/schema.prisma`.
If you have a Prisma schema file in a custom path, you will need to run
`prisma generate --schema=./path/to/your/schema.prisma` to generate Prisma Client.
If you do not have a Prisma schema file yet, you can ignore this message.

see screenshot from GitPod (using the comment above)
Screenshot 2024-04-25 at 15 08 12

Also, it looks like it gets stuck if Prisma CLI is not installed, but maybe this instance of GitPod is broken because "npm -v" gets stuck too in the terminal 😓 :
Screenshot 2024-04-25 at 15 13 51

@Druue
Copy link
Contributor Author

Druue commented Apr 29, 2024

Hmm, I didn't have the same problem with npm in codespaces @Jolg42

Screen.Recording.2024-04-29.at.17.17.44.mov

@Jolg42
Copy link
Member

Jolg42 commented Apr 30, 2024

@Druue Nice, then that's probably my instance that was broken, I'll try again later.
Do you think you can make the current state better to add the codelens to all generator blocks? And make the name generic for all, or generic for all except prisma-client-js?

github-actions bot added a commit that referenced this pull request May 1, 2024
@Druue
Copy link
Contributor Author

Druue commented May 1, 2024

I'm not keen on adding further regex to check if the generator is prisma-client-js just to add a slightly different title. I'd rather just have the one selfsame lens for all generators

Screen.Recording.2024-05-01.at.11.13.14.mov

Copy link
Member

@Jolg42 Jolg42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR!
I'm curious to see people noticing this ✨

github-actions bot added a commit that referenced this pull request May 3, 2024
@CLAassistant
Copy link

CLAassistant commented May 3, 2024

CLA assistant check
All committers have signed the CLA.

github-actions bot added a commit that referenced this pull request May 3, 2024
Druue and others added 3 commits May 3, 2024 14:27
Add script runner config setting
Register prisma generate client codelens
Add event tracking to update script runner for codelens
Use script runner as arg for gen client command
- this lets users set a custom schema path for codelenses

Removed scriptRunner as prop on codelens provider
- see comment for more info
- now directly accessingthe config from within `generateClient()`

Allow for generate lens to appear over all generators in the file, not just the first
@Druue Druue force-pushed the feat/codelens-generate_client branch from ec0624b to e037e3b Compare May 3, 2024 12:27
github-actions bot added a commit that referenced this pull request May 3, 2024
@Jolg42 Jolg42 merged commit 611874c into main May 3, 2024
7 checks passed
@Jolg42 Jolg42 deleted the feat/codelens-generate_client branch May 3, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make superior: model generate
3 participants