@grafana/create-plugin 4.2.5 → 4.2.6-canary.834.ce6962b.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/dist/commands/generate/print-success-message.js +2 -1
- package/dist/utils/utils.handlebars.js +3 -2
- package/fixtures/test-template/src/plugin.json +1 -1
- package/package.json +2 -2
- package/src/commands/generate/print-success-message.ts +2 -1
- package/src/utils/utils.handlebars.ts +3 -1
- package/templates/app/provisioning/plugins/apps.yaml +1 -1
- package/templates/app/src/plugin.json +1 -1
- package/templates/backend/pkg/main.go +2 -2
- package/templates/backend-app/pkg/main.go +1 -1
- package/templates/datasource/provisioning/datasources/datasources.yml +1 -1
- package/templates/datasource/src/plugin.json +1 -1
- package/templates/panel/src/plugin.json +1 -1
- package/templates/scenes-app/provisioning/plugins/app.yaml +1 -1
- package/templates/scenes-app/src/plugin.json +1 -1
|
@@ -13,7 +13,8 @@ export function printGenerateSuccessMessage(answers) {
|
|
|
13
13
|
'- `mage -v build:linux` to build the plugin backend code. Rerun this command every time you edit your backend files.',
|
|
14
14
|
]
|
|
15
15
|
: []),
|
|
16
|
-
'- `docker-compose up` to start a grafana development server.
|
|
16
|
+
'- `docker-compose up` to start a grafana development server. ' +
|
|
17
|
+
(answers.hasBackend ? 'Restart this command after each time you run mage to run your new backend code.' : ''),
|
|
17
18
|
'- Open http://localhost:3000 in your browser to create a dashboard to begin developing your plugin.',
|
|
18
19
|
];
|
|
19
20
|
const msg = `\n# Congratulations on scaffolding a Grafana ${answers.pluginType} plugin! 🚀
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Handlebars from 'handlebars';
|
|
2
2
|
import { camelCase, snakeCase, dotCase, pathCase, sentenceCase, constantCase, kebabCase, pascalCase, } from 'change-case';
|
|
3
3
|
import { titleCase } from 'title-case';
|
|
4
|
-
import { PARTIALS_DIR } from '../constants.js';
|
|
4
|
+
import { PARTIALS_DIR, PLUGIN_TYPES } from '../constants.js';
|
|
5
5
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
6
6
|
import { basename, join } from 'node:path';
|
|
7
7
|
export const ifEq = (a, b, options) => {
|
|
@@ -12,7 +12,8 @@ export const normalizeId = (pluginName, orgName, type) => {
|
|
|
12
12
|
const nameRegex = new RegExp('[^0-9a-zA-Z]', 'g');
|
|
13
13
|
const newPluginName = pluginName.replace(re, '').replace(nameRegex, '');
|
|
14
14
|
const newOrgName = orgName.replace(nameRegex, '');
|
|
15
|
-
|
|
15
|
+
const newType = type === PLUGIN_TYPES.scenes ? PLUGIN_TYPES.app : type;
|
|
16
|
+
return newOrgName.toLowerCase() + '-' + newPluginName.toLowerCase() + `-${newType}`;
|
|
16
17
|
};
|
|
17
18
|
registerHandlebarsHelpers();
|
|
18
19
|
registerHandlebarsPartials();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "app",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
|
-
"id": "{{
|
|
5
|
+
"id": "{{ pluginId }}",
|
|
6
6
|
"backend": true,
|
|
7
7
|
"executable": "gpx_{{ snakeCase pluginName }}",
|
|
8
8
|
"info": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.6-canary.834.ce6962b.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"directory": "packages/create-plugin",
|
|
6
6
|
"url": "https://github.com/grafana/plugin-tools"
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"engines": {
|
|
88
88
|
"node": ">=20"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "ce6962b220c6effebbd8bc163c1b1de050bbea49"
|
|
91
91
|
}
|
|
@@ -15,7 +15,8 @@ export function printGenerateSuccessMessage(answers: CliArgs) {
|
|
|
15
15
|
'- `mage -v build:linux` to build the plugin backend code. Rerun this command every time you edit your backend files.',
|
|
16
16
|
]
|
|
17
17
|
: []),
|
|
18
|
-
'- `docker-compose up` to start a grafana development server.
|
|
18
|
+
'- `docker-compose up` to start a grafana development server. ' +
|
|
19
|
+
(answers.hasBackend ? 'Restart this command after each time you run mage to run your new backend code.' : ''),
|
|
19
20
|
'- Open http://localhost:3000 in your browser to create a dashboard to begin developing your plugin.',
|
|
20
21
|
];
|
|
21
22
|
|
|
@@ -25,7 +25,9 @@ export const normalizeId = (pluginName: string, orgName: string, type: PLUGIN_TY
|
|
|
25
25
|
|
|
26
26
|
const newPluginName = pluginName.replace(re, '').replace(nameRegex, '');
|
|
27
27
|
const newOrgName = orgName.replace(nameRegex, '');
|
|
28
|
-
|
|
28
|
+
const newType = type === PLUGIN_TYPES.scenes ? PLUGIN_TYPES.app : type;
|
|
29
|
+
|
|
30
|
+
return newOrgName.toLowerCase() + '-' + newPluginName.toLowerCase() + `-${newType}`;
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
// Register our helpers and partials with handlebars.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "app",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
|
-
"id": "{{
|
|
5
|
+
"id": "{{ pluginId }}",{{#if hasBackend}}
|
|
6
6
|
"backend": true,
|
|
7
7
|
"executable": "gpx_{{ snakeCase pluginName }}",{{/if}}
|
|
8
8
|
"info": {
|
|
@@ -17,8 +17,8 @@ func main() {
|
|
|
17
17
|
// from Grafana to create different instances of SampleDatasource (per datasource
|
|
18
18
|
// ID). When datasource configuration changed Dispose method will be called and
|
|
19
19
|
// new datasource instance created using NewSampleDatasource factory.
|
|
20
|
-
if err := datasource.Manage("{{
|
|
20
|
+
if err := datasource.Manage("{{ pluginId }}", plugin.NewDatasource, datasource.ManageOpts{}); err != nil {
|
|
21
21
|
log.DefaultLogger.Error(err.Error())
|
|
22
22
|
os.Exit(1)
|
|
23
23
|
}
|
|
24
|
-
}
|
|
24
|
+
}
|
|
@@ -16,7 +16,7 @@ func main() {
|
|
|
16
16
|
// argument. This factory will be automatically called on incoming request
|
|
17
17
|
// from Grafana to create different instances of `App` (per plugin
|
|
18
18
|
// ID).
|
|
19
|
-
if err := app.Manage("{{
|
|
19
|
+
if err := app.Manage("{{ pluginId }}", plugin.NewApp, app.ManageOpts{}); err != nil {
|
|
20
20
|
log.DefaultLogger.Error(err.Error())
|
|
21
21
|
os.Exit(1)
|
|
22
22
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "datasource",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
|
-
"id": "{{
|
|
5
|
+
"id": "{{ pluginId }}",
|
|
6
6
|
"metrics": true,{{#if hasBackend}}
|
|
7
7
|
"backend": true,
|
|
8
8
|
"executable": "gpx_{{ snakeCase pluginName }}",{{/if}}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "panel",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
|
-
"id": "{{
|
|
5
|
+
"id": "{{ pluginId }}",
|
|
6
6
|
"info": {
|
|
7
7
|
"keywords": ["panel"],
|
|
8
8
|
"description": "{{ sentenceCase pluginDescription }}",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "app",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
|
-
"id": "{{
|
|
5
|
+
"id": "{{ pluginId }}",{{#if hasBackend}}
|
|
6
6
|
"backend": true,
|
|
7
7
|
"executable": "gpx_{{ snakeCase pluginName }}",{{/if}}
|
|
8
8
|
"info": {
|