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

Create Plugin: Fix incorrect templates being used for scaffolding #158

Merged
merged 5 commits into from
Nov 28, 2022

Conversation

jackw
Copy link
Collaborator

@jackw jackw commented Nov 23, 2022

What this PR does / why we need it:

Right now when we scaffold the different types of plugins in DEV we use the force property on plop actions so we can regenerate the plugin without needing to delete the plugin directory first. However for production cases we don't want to trash a developers plugin if they accidentally run the command.

This behaviour difference has a bug in production which prevents a pluginType or backend template (that should be used as an override) from being written to the same location. E.g If a user scaffolds a backend datasource there is templates/datasource/src/datasource.ts and templates/backend/src/datasource.ts and they should both be scaffolded to src/datasource.ts. Currently the first template found will be written and the second will fail causing the scaffolded plugin to have incorrect source code.

This PR attempts to address this by filtering through the destination paths of the combined "common", "pluginType" and "backend" templates to only keep the last entry for a given destination path.

Which issue(s) this PR fixes:

Fixes #157

Special notes for your reviewer:

📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @grafana/create-plugin@0.6.3-canary.158.10dc5db.0
# or 
yarn add @grafana/create-plugin@0.6.3-canary.158.10dc5db.0

@jackw jackw added bug create-plugin related to the create-plugin tool patch Increment the patch version when merged release Create a release when this pr is merged labels Nov 23, 2022
@jackw jackw added this to the v1.0.0 milestone Nov 23, 2022
@jackw jackw self-assigned this Nov 23, 2022
@jackw jackw marked this pull request as ready for review November 24, 2022 12:01
@jackw jackw force-pushed the jackw/fix-datasource-with-backend branch from 3b33530 to 10dc5db Compare November 24, 2022 13:54
@jackw jackw merged commit a14500f into main Nov 28, 2022
@jackw jackw deleted the jackw/fix-datasource-with-backend branch November 28, 2022 16:15
@grafanabot
Copy link
Contributor

🚀 PR was released in @grafana/create-plugin@0.6.3 🚀

@grafanabot grafanabot added the released This issue/pull request has been released. label Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-plugin related to the create-plugin tool patch Increment the patch version when merged release Create a release when this pr is merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Scaffolding a datasource with backend doesn't use DataSourceWithBackend
4 participants