@grafana/create-plugin 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v0.6.3 (Mon Nov 28 2022)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Create Plugin: Fix incorrect templates being used for scaffolding [#158](https://github.com/grafana/plugin-tools/pull/158) ([@jackw](https://github.com/jackw))
6
+
7
+ #### Authors: 1
8
+
9
+ - Jack Westbrook ([@jackw](https://github.com/jackw))
10
+
11
+ ---
12
+
1
13
  # v0.6.2 (Thu Nov 24 2022)
2
14
 
3
15
  #### 🐛 Bug Fix
@@ -105,6 +105,14 @@ function default_1(plop) {
105
105
  var backendActions = hasBackend
106
106
  ? getActionsForTemplateFolder({ folderPath: backendFolderPath, exportPath: exportPath })
107
107
  : [];
108
+ var pluginActions = __spreadArray(__spreadArray(__spreadArray([], backendActions, true), pluginTypeSpecificActions, true), commonActions, true).reduce(function (acc, file) {
109
+ var actionExists = acc.find(function (f) { return f.path === file.path; });
110
+ if (actionExists && actionExists.type === 'add' && file.type === 'add') {
111
+ return acc;
112
+ }
113
+ acc.push(file);
114
+ return acc;
115
+ }, []);
108
116
  var ciWorkflowActions = hasGithubWorkflows
109
117
  ? getActionsForTemplateFolder({ folderPath: constants_1.TEMPLATE_PATHS.ciWorkflows, exportPath: exportPath })
110
118
  : [];
@@ -112,7 +120,7 @@ function default_1(plop) {
112
120
  ? getActionsForTemplateFolder({ folderPath: constants_1.TEMPLATE_PATHS.isCompatibleWorkflow, exportPath: exportPath })
113
121
  : [];
114
122
  var readmeActions = getActionsForReadme({ exportPath: exportPath });
115
- return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], commonActions, true), pluginTypeSpecificActions, true), backendActions, true), ciWorkflowActions, true), readmeActions, true), isCompatibleWorkflowActions, true);
123
+ return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], pluginActions, true), ciWorkflowActions, true), readmeActions, true), isCompatibleWorkflowActions, true);
116
124
  }
117
125
  });
118
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "directory": "packages/create-plugin",
@@ -60,5 +60,5 @@
60
60
  "engines": {
61
61
  "node": ">=16"
62
62
  },
63
- "gitHead": "3095dcb3b735c93b0c4fa64d9d5f8590b0030293"
63
+ "gitHead": "f1dc565ab40f62006c023bc3eda23e8ebeed6ae7"
64
64
  }
@@ -101,7 +101,7 @@ export default function (plop: NodePlopAPI) {
101
101
  templateData: { pluginId },
102
102
  });
103
103
 
104
- // Copy over files from the plugin type specific folder, e.g. "tempaltes/app" for "app" plugins ("app" | "panel" | "datasource").
104
+ // Copy over files from the plugin type specific folder, e.g. "templates/app" for "app" plugins ("app" | "panel" | "datasource").
105
105
  const pluginTypeSpecificActions = getActionsForTemplateFolder({
106
106
  folderPath: TEMPLATE_PATHS[pluginType],
107
107
  exportPath,
@@ -113,6 +113,20 @@ export default function (plop: NodePlopAPI) {
113
113
  ? getActionsForTemplateFolder({ folderPath: backendFolderPath, exportPath })
114
114
  : [];
115
115
 
116
+ // Common, pluginType and backend actions can contain different templates for the same destination.
117
+ // This filtering removes the duplicate file additions to prevent plop erroring and makes sure the
118
+ // correct template is scaffolded.
119
+ // Note that the order is reversed so backend > pluginType > common
120
+ const pluginActions = [...backendActions, ...pluginTypeSpecificActions, ...commonActions].reduce((acc, file) => {
121
+ const actionExists = acc.find((f) => f.path === file.path);
122
+ // return early to prevent multiple add type actions being added to the array
123
+ if (actionExists && actionExists.type === 'add' && file.type === 'add') {
124
+ return acc;
125
+ }
126
+ acc.push(file);
127
+ return acc;
128
+ }, []);
129
+
116
130
  // Copy over Github workflow files (if selected)
117
131
  const ciWorkflowActions = hasGithubWorkflows
118
132
  ? getActionsForTemplateFolder({ folderPath: TEMPLATE_PATHS.ciWorkflows, exportPath })
@@ -125,14 +139,7 @@ export default function (plop: NodePlopAPI) {
125
139
  // Replace conditional bits in the Readme files
126
140
  const readmeActions = getActionsForReadme({ exportPath });
127
141
 
128
- return [
129
- ...commonActions,
130
- ...pluginTypeSpecificActions,
131
- ...backendActions,
132
- ...ciWorkflowActions,
133
- ...readmeActions,
134
- ...isCompatibleWorkflowActions,
135
- ];
142
+ return [...pluginActions, ...ciWorkflowActions, ...readmeActions, ...isCompatibleWorkflowActions];
136
143
  },
137
144
  });
138
145
  }
@@ -196,7 +203,7 @@ function getActionsForTemplateFolder({
196
203
  templateFile: f,
197
204
  // The target path where the compiled template is saved to
198
205
  path: path.join(exportPath, getExportPath(f), getExportFileName(f)),
199
- // We would like to override generated files in development mode
206
+ // Support overriding files in development for overriding "generated" plugins.
200
207
  force: IS_DEV,
201
208
  // We would still like to scaffold as many files as possible even if one fails
202
209
  abortOnFail: false,