@grafana/create-plugin 0.6.2-canary.158.e2fc550.0 → 0.6.2-canary.158.fc9b4e5.0

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.
@@ -105,15 +105,15 @@ function default_1(plop) {
105
105
  var backendActions = hasBackend
106
106
  ? getActionsForTemplateFolder({ folderPath: backendFolderPath, exportPath: exportPath })
107
107
  : [];
108
- var pluginActions = __spreadArray(__spreadArray(__spreadArray([], commonActions, true), pluginTypeSpecificActions, true), backendActions, true).reduceRight(function (acc, file) {
109
- var exists = acc.some(function (f) { return f.path === file.path; });
110
- if (exists && file.type !== 'modify') {
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
111
  return acc;
112
112
  }
113
113
  acc.push(file);
114
114
  return acc;
115
- }, [])
116
- .reverse();
115
+ }, []);
116
+ console.log(__spreadArray(__spreadArray(__spreadArray([], backendActions, true), pluginTypeSpecificActions, true), commonActions, true).length, pluginActions.length);
117
117
  var ciWorkflowActions = hasGithubWorkflows
118
118
  ? getActionsForTemplateFolder({ folderPath: constants_1.TEMPLATE_PATHS.ciWorkflows, exportPath: exportPath })
119
119
  : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "0.6.2-canary.158.e2fc550.0",
3
+ "version": "0.6.2-canary.158.fc9b4e5.0",
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": "e2fc5503dc5eb38c10ff0db191f57c0eda0d5fcd"
63
+ "gitHead": "fc9b4e51d5ea2ae865f253553b571ba5710cf2b2"
64
64
  }
@@ -113,20 +113,21 @@ export default function (plop: NodePlopAPI) {
113
113
  ? getActionsForTemplateFolder({ folderPath: backendFolderPath, exportPath })
114
114
  : [];
115
115
 
116
- // Common, pluginType and backend actions can contain the same destination filenames.
117
- // This filtering allows overriding templates by removing the duplication destinations
118
- const pluginActions = [...commonActions, ...pluginTypeSpecificActions, ...backendActions]
119
- .reduceRight((acc, file) => {
120
- const exists = acc.some((f) => f.path === file.path);
121
- // if the file.path already exists and isn't a modification exclude it.
122
- if (exists && file.type !== 'modify') {
123
- return acc;
124
- }
125
-
126
- acc.push(file);
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') {
127
124
  return acc;
128
- }, [])
129
- .reverse();
125
+ }
126
+ acc.push(file);
127
+ return acc;
128
+ }, []);
129
+
130
+ console.log([...backendActions, ...pluginTypeSpecificActions, ...commonActions].length, pluginActions.length);
130
131
 
131
132
  // Copy over Github workflow files (if selected)
132
133
  const ciWorkflowActions = hasGithubWorkflows