@grafana/create-plugin 0.6.1 → 0.6.2-canary.158.e2fc550.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.
- package/README.md +2 -1
- package/dist/commands/generate.plopfile.js +10 -1
- package/package.json +2 -2
- package/src/commands/generate.plopfile.ts +18 -10
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Create Grafana plugins with ease.
|
|
|
8
8
|
- [Create a new plugin](#create-a-new-plugin)
|
|
9
9
|
- [Quick overview](#quick-overview)
|
|
10
10
|
- [`yarn` (1.x)](#yarn-1x)
|
|
11
|
-
- [`yarn` (
|
|
11
|
+
- [`yarn` (\> 2.x)](#yarn--2x)
|
|
12
12
|
- [`npx`](#npx)
|
|
13
13
|
- [`npm`](#npm)
|
|
14
14
|
- [Migrate your existing plugin](#migrate-your-existing-plugin)
|
|
@@ -61,6 +61,7 @@ npm init @grafana/plugin
|
|
|
61
61
|
---
|
|
62
62
|
|
|
63
63
|
## Migrate your existing plugin
|
|
64
|
+
:warning: We [do not support](https://grafana.com/docs/grafana/latest/developers/angular_deprecation/) plugins written in `angular`
|
|
64
65
|
|
|
65
66
|
In case you have an existing plugin previously created using the `@grafana/toolkit` you can use the
|
|
66
67
|
following command to migrate it to the new build tooling:
|
|
@@ -105,6 +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') {
|
|
111
|
+
return acc;
|
|
112
|
+
}
|
|
113
|
+
acc.push(file);
|
|
114
|
+
return acc;
|
|
115
|
+
}, [])
|
|
116
|
+
.reverse();
|
|
108
117
|
var ciWorkflowActions = hasGithubWorkflows
|
|
109
118
|
? getActionsForTemplateFolder({ folderPath: constants_1.TEMPLATE_PATHS.ciWorkflows, exportPath: exportPath })
|
|
110
119
|
: [];
|
|
@@ -112,7 +121,7 @@ function default_1(plop) {
|
|
|
112
121
|
? getActionsForTemplateFolder({ folderPath: constants_1.TEMPLATE_PATHS.isCompatibleWorkflow, exportPath: exportPath })
|
|
113
122
|
: [];
|
|
114
123
|
var readmeActions = getActionsForReadme({ exportPath: exportPath });
|
|
115
|
-
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(
|
|
124
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], pluginActions, true), ciWorkflowActions, true), readmeActions, true), isCompatibleWorkflowActions, true);
|
|
116
125
|
}
|
|
117
126
|
});
|
|
118
127
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2-canary.158.e2fc550.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": "
|
|
63
|
+
"gitHead": "e2fc5503dc5eb38c10ff0db191f57c0eda0d5fcd"
|
|
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. "
|
|
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,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);
|
|
127
|
+
return acc;
|
|
128
|
+
}, [])
|
|
129
|
+
.reverse();
|
|
130
|
+
|
|
116
131
|
// Copy over Github workflow files (if selected)
|
|
117
132
|
const ciWorkflowActions = hasGithubWorkflows
|
|
118
133
|
? getActionsForTemplateFolder({ folderPath: TEMPLATE_PATHS.ciWorkflows, exportPath })
|
|
@@ -125,14 +140,7 @@ export default function (plop: NodePlopAPI) {
|
|
|
125
140
|
// Replace conditional bits in the Readme files
|
|
126
141
|
const readmeActions = getActionsForReadme({ exportPath });
|
|
127
142
|
|
|
128
|
-
return [
|
|
129
|
-
...commonActions,
|
|
130
|
-
...pluginTypeSpecificActions,
|
|
131
|
-
...backendActions,
|
|
132
|
-
...ciWorkflowActions,
|
|
133
|
-
...readmeActions,
|
|
134
|
-
...isCompatibleWorkflowActions,
|
|
135
|
-
];
|
|
143
|
+
return [...pluginActions, ...ciWorkflowActions, ...readmeActions, ...isCompatibleWorkflowActions];
|
|
136
144
|
},
|
|
137
145
|
});
|
|
138
146
|
}
|
|
@@ -196,7 +204,7 @@ function getActionsForTemplateFolder({
|
|
|
196
204
|
templateFile: f,
|
|
197
205
|
// The target path where the compiled template is saved to
|
|
198
206
|
path: path.join(exportPath, getExportPath(f), getExportFileName(f)),
|
|
199
|
-
//
|
|
207
|
+
// Support overriding files in development for overriding "generated" plugins.
|
|
200
208
|
force: IS_DEV,
|
|
201
209
|
// We would still like to scaffold as many files as possible even if one fails
|
|
202
210
|
abortOnFail: false,
|