@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.
@@ -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. Restart this command after each time you run mage to run your new backend code.',
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
- return newOrgName.toLowerCase() + '-' + newPluginName.toLowerCase() + `-${type}`;
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": "{{ normalize_id pluginName orgName 'app' }}",
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.5",
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": "83b004bd75c21c6de1b04a8f7e4eb14e887aa116"
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. Restart this command after each time you run mage to run your new backend code.',
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
- return newOrgName.toLowerCase() + '-' + newPluginName.toLowerCase() + `-${type}`;
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.
@@ -1,7 +1,7 @@
1
1
  apiVersion: 1
2
2
 
3
3
  apps:
4
- - type: '{{ normalize_id pluginName orgName 'app' }}'
4
+ - type: '{{ pluginId }}'
5
5
  org_id: 1
6
6
  org_name: '{{ orgName }}'
7
7
  disabled: false
@@ -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": "{{ normalize_id pluginName orgName 'app' }}",{{#if hasBackend}}
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("{{ normalize_id pluginName orgName pluginType }}", plugin.NewDatasource, datasource.ManageOpts{}); err != nil {
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("{{ normalize_id pluginName orgName pluginType }}", plugin.NewApp, app.ManageOpts{}); err != nil {
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 @@ apiVersion: 1
2
2
 
3
3
  datasources:
4
4
  - name: '{{ pluginName }}'
5
- type: '{{ normalize_id pluginName orgName 'datasource' }}'
5
+ type: '{{ pluginId }}'
6
6
  access: proxy
7
7
  isDefault: false
8
8
  orgId: 1
@@ -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": "{{ normalize_id pluginName orgName 'datasource' }}",
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": "{{ normalize_id pluginName orgName 'panel' }}",
5
+ "id": "{{ pluginId }}",
6
6
  "info": {
7
7
  "keywords": ["panel"],
8
8
  "description": "{{ sentenceCase pluginDescription }}",
@@ -1,7 +1,7 @@
1
1
  apiVersion: 1
2
2
 
3
3
  apps:
4
- - type: '{{ normalize_id pluginName orgName 'app' }}'
4
+ - type: '{{ pluginId }}'
5
5
  org_id: 1
6
6
  org_name: '{{ orgName }}'
7
7
  disabled: false
@@ -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": "{{ normalize_id pluginName orgName 'app' }}",{{#if hasBackend}}
5
+ "id": "{{ pluginId }}",{{#if hasBackend}}
6
6
  "backend": true,
7
7
  "executable": "gpx_{{ snakeCase pluginName }}",{{/if}}
8
8
  "info": {