Bug: create plugin "update" script modifies (prettyfies) all files in plugin's directory
Which package(s) does this bug affect?
- [x] Create Plugin
- [ ] Sign Plugin
- [ ] Plugin E2E
- [ ] Plugin Meta Extractor
Package versions
5.3.10
What happened?
When running npx @grafana/create-plugin@latest update command it seems it prettifies all files in the plugin directory.
This creates a lot of changes which complicates the review.
What you expected to happen
Only files inside .config directory should be prettified.
How to reproduce it (as minimally and precisely as possible)
- Pick any plugin that doesn't have the latest config.
- Plugin should have some files that are not prettified (e.g. test
*.jsoncfiles,*.mdetc.). - Run
npx @grafana/create-plugin@latest update - Observe how files outside
.configfolder got modified (prettified).
Environment
System: OS: macOS 15.0 CPU: (10) arm64 Apple M1 Pro Memory: 863.66 MB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node Yarn: 1.22.22 - /opt/homebrew/bin/yarn npm: 10.7.0 - ~/.nvm/versions/node/v20.15.0/bin/npm Watchman: 2024.09.09.00 - /opt/homebrew/bin/watchman Browsers: Brave Browser: 128.1.69.168 Chrome: 129.0.6668.59 Safari: 18.0
Additional context
No response
Thanks for writing this up @cletter7 however I'm struggling to reproduce it in my plugin. I created a markdown file in the root of the plugin directory that prettier will act on. I ran npx -y @grafana/create-plugin@latest update from the root. It didn't run prettier over the md file. I then run npx prettier --write *.md and it formats it.
Do you have a reproduction case I can take a look at?
@jackw this happens to me all the time in our plugin monorepos. Haven't actually tried this in single repo plugins. Could you try in monorepo?
@jackw this happens to me all the time in our plugin monorepos. Haven't actually tried this in single repo plugins. Could you try in monorepo?
Is that this repo?
@jackw yes.
Ok, I think I've narrowed it down to how create plugin sets the cwd then executes prettier however prettier doesn't resolve the . correctly and I think it's somehow resolving the workspace root (maybe by finding the first package.json) then running against the entire project.
~/dev/grafana/plugins-private/plugins/grafana-dynatrace-datasource/.config $ yarn prettier . --list-different
yarn run v1.22.22
$ /Users/jackwestbrook/dev/grafana/plugins-private/node_modules/.bin/prettier . --list-different
cypress/e2e/grafana-dynatrace-datasource.cy.ts
src/dashboards/overview.json
src/datasource.test.ts
error Command failed with exit code 1.
If I give it a specific directory from the workspace I believe it works as intended.
~/dev/grafana/plugins-private/plugins/grafana-dynatrace-datasource $ yarn prettier "./.config" --list-different
yarn run v1.22.22
$ /Users/jackwestbrook/dev/grafana/plugins-private/node_modules/.bin/prettier ./.config --list-different
✨ Done in 0.52s.
I'll get a fix in place shortly once I've done a bit more testing. 👍
:rocket: Issue was released in @grafana/[email protected] :rocket: