Create Plugin: Fix incorrect templates being used for scaffolding #158
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andtemplates/backend/src/datasource.ts
and they should both be scaffolded tosrc/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