@grafana/create-plugin 7.12.3 → 7.14.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/codemods/additions/additions.js +20 -7
  3. package/dist/codemods/additions/prompts/docs-content.md +119 -0
  4. package/dist/codemods/additions/prompts/example-prompt.md +56 -0
  5. package/dist/codemods/additions/scripts/docs-content.js +30 -0
  6. package/dist/codemods/additions/scripts/docs.js +250 -0
  7. package/dist/codemods/additions/scripts/experimental-app-sdk.js +39 -33
  8. package/dist/codemods/agentic/definitions.js +31 -0
  9. package/dist/codemods/agentic/detect.js +57 -0
  10. package/dist/codemods/agentic/handoff.js +35 -0
  11. package/dist/codemods/agentic/index.js +143 -0
  12. package/dist/codemods/agentic/prompts.js +115 -0
  13. package/dist/codemods/agentic/resolve.js +120 -0
  14. package/dist/codemods/agentic/runner.js +79 -0
  15. package/dist/codemods/agentic/verify.js +55 -0
  16. package/dist/codemods/migrations/migrations.js +12 -0
  17. package/dist/codemods/migrations/scripts/017-jest-30.js +32 -0
  18. package/dist/codemods/migrations/scripts/018-replace-eslint-webpack-plugin.js +115 -0
  19. package/dist/codemods/utils.agents.js +64 -0
  20. package/dist/codemods/utils.js +51 -8
  21. package/dist/codemods/utils.workflows.js +94 -0
  22. package/dist/commands/add.command.js +74 -12
  23. package/dist/utils/utils.cli.js +7 -2
  24. package/dist/utils/utils.console.js +10 -1
  25. package/dist/utils/utils.git.js +10 -1
  26. package/dist/utils/utils.handlebars.js +9 -2
  27. package/dist/utils/utils.packageManager.js +2 -2
  28. package/dist/utils/utils.templates.js +38 -24
  29. package/package.json +1 -1
  30. package/src/codemods/AGENTS.md +25 -0
  31. package/src/codemods/additions/additions.test.ts +69 -4
  32. package/src/codemods/additions/additions.ts +50 -8
  33. package/src/codemods/additions/prompts/docs-content.md +119 -0
  34. package/src/codemods/additions/prompts/example-prompt.md +56 -0
  35. package/src/codemods/additions/scripts/docs-content.test.ts +94 -0
  36. package/src/codemods/additions/scripts/docs-content.ts +32 -0
  37. package/src/codemods/additions/scripts/docs.test.ts +1037 -0
  38. package/src/codemods/additions/scripts/docs.ts +353 -0
  39. package/src/codemods/additions/scripts/experimental-app-sdk.test.ts +40 -80
  40. package/src/codemods/additions/scripts/experimental-app-sdk.ts +42 -34
  41. package/src/codemods/agentic/definitions.test.ts +67 -0
  42. package/src/codemods/agentic/definitions.ts +33 -0
  43. package/src/codemods/agentic/detect.test.ts +136 -0
  44. package/src/codemods/agentic/detect.ts +75 -0
  45. package/src/codemods/agentic/handoff.test.ts +102 -0
  46. package/src/codemods/agentic/handoff.ts +45 -0
  47. package/src/codemods/agentic/index.test.ts +342 -0
  48. package/src/codemods/agentic/index.ts +221 -0
  49. package/src/codemods/agentic/prompts.test.ts +233 -0
  50. package/src/codemods/agentic/prompts.ts +166 -0
  51. package/src/codemods/agentic/resolve.test.ts +220 -0
  52. package/src/codemods/agentic/resolve.ts +165 -0
  53. package/src/codemods/agentic/runner.test.ts +146 -0
  54. package/src/codemods/agentic/runner.ts +103 -0
  55. package/src/codemods/agentic/types.ts +50 -0
  56. package/src/codemods/agentic/verify.test.ts +106 -0
  57. package/src/codemods/agentic/verify.ts +93 -0
  58. package/src/codemods/migrations/migrations.ts +14 -0
  59. package/src/codemods/migrations/scripts/004-eslint9-flat-config.ts +1 -3
  60. package/src/codemods/migrations/scripts/017-jest-30.test.ts +72 -0
  61. package/src/codemods/migrations/scripts/017-jest-30.ts +39 -0
  62. package/src/codemods/migrations/scripts/018-replace-eslint-webpack-plugin.test.ts +174 -0
  63. package/src/codemods/migrations/scripts/018-replace-eslint-webpack-plugin.ts +141 -0
  64. package/src/codemods/utils.agents.test.ts +140 -0
  65. package/src/codemods/utils.agents.ts +81 -0
  66. package/src/codemods/utils.test.ts +131 -1
  67. package/src/codemods/utils.ts +79 -8
  68. package/src/codemods/utils.workflows.test.ts +153 -0
  69. package/src/codemods/utils.workflows.ts +140 -0
  70. package/src/commands/add.command.ts +92 -9
  71. package/src/utils/utils.cli.ts +5 -0
  72. package/src/utils/utils.git.test.ts +57 -0
  73. package/src/utils/utils.git.ts +25 -0
  74. package/src/utils/utils.handlebars.ts +9 -0
  75. package/src/utils/utils.packageManager.test.ts +23 -0
  76. package/src/utils/utils.packageManager.ts +3 -2
  77. package/src/utils/utils.templates.ts +50 -25
  78. package/templates/app-sdk/.config/app-sdk/generate-kinds.mjs +1 -1
  79. package/templates/common/.config/webpack/webpack.config.ts +4 -5
  80. package/templates/common/_package.json +9 -8
  81. package/templates/docs/common/workflows/validate-docs.yml +52 -0
  82. package/templates/docs/panel/docs/AGENTS.md +107 -0
  83. package/templates/docs/panel/docs/CLAUDE.md +1 -0
  84. package/templates/docs/panel/docs/README.md +20 -0
  85. package/templates/docs/panel/docs/data-formats.md +27 -0
  86. package/templates/docs/panel/docs/examples.md +35 -0
  87. package/templates/docs/panel/docs/index.md +26 -0
  88. package/templates/docs/panel/docs/options.md +53 -0
  89. package/templates/docs/panel/docs/troubleshooting.md +35 -0
  90. package/templates/github/workflows/bundle-stats.yml +1 -1
  91. package/templates/github/workflows/ci.yml +7 -7
  92. package/templates/github/workflows/is-compatible.yml +3 -3
  93. package/templates/github/workflows/release.yml +1 -1
@@ -0,0 +1,20 @@
1
+ # {{{pluginName}}} documentation
2
+
3
+ This folder is the documentation for **{{{pluginName}}}**. It's published on the Documentation tab of
4
+ `grafana.com/grafana/plugins/{{pluginId}}/` with each plugin release. This README isn't published.
5
+
6
+ To learn how plugin docs work and how to write them, read the
7
+ [Add documentation to your plugin](https://grafana.com/developers/plugin-tools/how-to-guides/plugin-docs) guide.
8
+
9
+ ## Next steps
10
+
11
+ 1. Write the pages. Each section has a note that says what belongs there. **Or** let an AI agent draft them from your source code and README: commit your changes, then run `{{createPluginCmd}} add docs-content`. Review its work either way.
12
+ 2. Add screenshots, videos and figures where they help readers. Save them inside this folder, for example in `img/`, and link to them with a relative path. `docs:validate` checks their formats and sizes.
13
+ 3. Run `{{packageManagerName}} run docs:serve` to preview the docs. It also lists every section left to fill.
14
+
15
+ ## Commands
16
+
17
+ ```bash
18
+ {{packageManagerName}} run docs:serve # local preview at http://localhost:3001
19
+ {{packageManagerName}} run docs:validate # check your docs, including sections left to fill
20
+ ```
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: Data formats
3
+ description: "Learn what data formats the {{{yamlEscape pluginName}}} panel accepts."
4
+ sidebar_position: 2
5
+ ---
6
+
7
+ This document explains the data the {{{pluginName}}} panel needs from a query, so you can build a matching query or check your test data.
8
+
9
+ ## Supported data shape
10
+
11
+ <!-- section-brief
12
+ Fill this in: Describe the data frame shape {{{pluginName}}} expects: time series with N numeric fields, table with specific columns, single numeric value, geographic coordinates, log lines, etc. Be specific about field types and structure, because this is the contract dashboard authors rely on when building queries for the panel. Name the required field types (time, number, string, boolean) and any minimum/maximum field counts. After each shape, add a `#### Example` table whose headers are the field names the panel reads, with 3-5 rows of realistic values, so a reader can build a matching query or test data.
13
+ -->
14
+
15
+ ## Field mapping
16
+
17
+ <!-- section-brief
18
+ Fill this in: Explain which incoming field plays which role in the visualization - for example "the first time-typed field is the x-axis, all numeric fields become series". If {{{pluginName}}} lets users explicitly pick field roles in the editor, document those controls here. Remove the section if mapping is fully automatic and not user-configurable.
19
+ -->
20
+
21
+ ## Check what your query returns
22
+
23
+ To see the data the panel receives, open the panel editor, click **Query inspector** and select the **Data** tab. You can also turn on **Table view** at the top of the panel editor to see the data as a table.
24
+
25
+ ## Reshape data that doesn't match
26
+
27
+ If a query returns data in a different shape, you can reshape it without changing the query. Select the **Transform data** tab in the panel editor and add a transformation. For more information, refer to [Transform data](https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/).
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: Examples
3
+ description: "Worked examples of the {{{yamlEscape pluginName}}} panel."
4
+ sidebar_position: 4
5
+ ---
6
+
7
+ To use an example, open your dashboard and go to **Dashboard settings** > **JSON Model**. Paste the excerpt into the `panels` array and click **Save changes**.
8
+
9
+ <!-- section-brief
10
+ Fill this in: Show concrete examples of {{{pluginName}}} configured for real use cases. When the repo has panels of this plugin's type in `provisioning/dashboards/*.json`, take the examples from those before inventing any. Express each example as a `dashboard.json` panel excerpt: `type` and `options`, plus `fieldConfig` and `targets` when the example depends on them. Leave out `id`, `gridPos`, `pluginVersion`, datasource UIDs and timestamps - they are specific to one dashboard and hide the settings that matter. Pair each example with a screenshot of the rendered visualization.
11
+
12
+ If the repo ships a complete dashboard, for example under `provisioning/dashboards/`, link to it for readers who want the full JSON. Use the file's `https://` URL in your repository - relative links can't point outside the docs folder.
13
+ -->
14
+
15
+ ## Basic example
16
+
17
+ A panel excerpt in dashboard JSON has this shape:
18
+
19
+ ```json
20
+ {
21
+ "type": "{{pluginId}}",
22
+ "options": {},
23
+ "targets": []
24
+ }
25
+ ```
26
+
27
+ <!-- section-brief
28
+ Fill this in: Complete the excerpt above as the minimum viable {{{pluginName}}} configuration: the smallest `panels[]` entry that produces a meaningful visualization. Include only the settings it needs, plus a sample query in `targets` if the panel reads data. If the panel doesn't read data, remove `targets` from the excerpt. Pair with a screenshot of the result.
29
+ -->
30
+
31
+ ## Common variations
32
+
33
+ <!-- section-brief
34
+ Fill this in: Show 1-3 alternate configurations that cover the most common ways dashboard authors use {{{pluginName}}} - different data shapes, option combinations, or display modes. Each variation is an excerpt showing only the settings that differ from the basic example, plus a screenshot. Explain in one line what each variation demonstrates.
35
+ -->
@@ -0,0 +1,26 @@
1
+ ---
2
+ title: Introduction
3
+ description: "Where to start and what to read next in the {{{yamlEscape pluginName}}} docs."
4
+ sidebar_position: 1
5
+ ---
6
+
7
+ <!-- section-brief
8
+ Fill this in: Write a short orientation for someone who already has {{{pluginName}}} installed and landed here from the Documentation tab. One or two sentences on what this section covers and how it's organized. Do not restate what the plugin does, its feature list, or its requirements - that's the README's job on the Overview tab, and this reader has already seen it there. Do not list every page in this folder either - the sidebar already does that; use prose to say what to read first and why.
9
+ -->
10
+
11
+ ## Recommended path
12
+
13
+ <!-- section-brief
14
+ Fill this in: Give a short, ordered reading path for someone new to {{{pluginName}}} - two or three sentences, not a repeat of the sidebar. Point out the one or two pages most people need first and why, e.g. "Start with **Data formats** to shape your query results, then **Options** to configure the panel."
15
+ -->
16
+
17
+ ## Common tasks
18
+
19
+ - [Shape your query results for {{{pluginName}}}](./data-formats.md)
20
+ - [Configure panel and field options](./options.md)
21
+ - [See worked dashboard.json examples](./examples.md)
22
+ - [Fix a panel that isn't rendering correctly](./troubleshooting.md)
23
+
24
+ <!-- section-brief
25
+ Fill this in: Keep the list above and adapt it to {{{pluginName}}}'s actual entry points - add, remove or reword tasks so each one matches a real job a user comes here to do. If you remove a page, remove its task too. This is a curated set of jobs, not a mechanical list of every file in this folder.
26
+ -->
@@ -0,0 +1,53 @@
1
+ ---
2
+ title: Options
3
+ description: "Reference for {{{yamlEscape pluginName}}} panel options."
4
+ sidebar_position: 3
5
+ ---
6
+
7
+ To change these options, edit the panel and use the options pane.
8
+
9
+ <!-- section-brief
10
+ Fill this in: Reference the options {{{pluginName}}} exposes in the panel editor. Cover both the custom options the panel adds (via `setPanelOptions` in source) and the standard field options it enables (via `useFieldConfig`). Skip the sections below that don't apply to this panel - if there's no Standard field options block, no Tooltip and legend section etc., remove those headings entirely rather than leaving an empty brief.
11
+
12
+ Do not redocument the framework-level standard options themselves (Min, Max, Unit, etc.) - Grafana's own docs cover those. The Standard field options section lists which ones are enabled, nothing more.
13
+ -->
14
+
15
+ ## Panel options
16
+
17
+ <!-- section-brief
18
+ Fill this in: Emit a markdown table with these columns - one row per option registered through `setPanelOptions` in `src/module.ts`. Match the Grafana built-in panel docs style: https://grafana.com/docs/grafana/latest/visualizations/panels-visualizations/visualizations/logs/#logs-options
19
+
20
+ | Option | Type | Default | Description |
21
+ | ------ | ---- | ------- | ----------- |
22
+
23
+ - _Option_: the `name` value from the `setPanelOptions` `.add*({...})` call, verbatim.
24
+ - _Type_: a short label for the editor the option uses, derived from the builder method (`addBooleanSwitch` → Toggle, `addSelect` → Select, `addNumberInput` → Number, `addFieldNamePicker` → Field picker). For a custom editor, name what it is, such as Color picker, rather than writing Custom.
25
+ - _Default_: the value a reader sees in the panel editor, rendered as inline code. Resolve enum members, constants and translation calls to that value - `ClockMode.time` becomes `Time`. Keep the source expression only when it can't be resolved. When there is no default but the code falls back to a value while the option is unset, give that fallback value. Leave the cell empty only when there is neither.
26
+ - _Description_: the `description` value, verbatim. If the verbatim text causes a `docs:validate` warning, reword it as little as possible and keep its meaning. When source has none, write one short sentence describing what the option does, based on how the panel code uses it. Don't guess beyond what the code shows.
27
+
28
+ If the panel does not call `setPanelOptions`, remove this section entirely.
29
+ -->
30
+
31
+ ## Standard field options
32
+
33
+ For what each standard option does, refer to [Configure standard options](https://grafana.com/docs/grafana/latest/panels-visualizations/configure-standard-options/).
34
+
35
+ <!-- section-brief
36
+ Fill this in: A bulleted list of the standard field options this panel enables - the entries from `useFieldConfig({ standardOptions: [...] })` in `src/module.ts`. If the panel calls `useFieldConfig()` or `useFieldConfig({})` without a `standardOptions` key, document this as "all standard options are enabled" and list the standard set.
37
+
38
+ If the panel does not call `useFieldConfig` at all, remove this section entirely, including the link above.
39
+ -->
40
+
41
+ ## Custom field options
42
+
43
+ <!-- section-brief
44
+ Fill this in: A table with the same shape as Panel options (Option / Type / Default / Description) but for the per-field overrides registered via `useFieldConfig({ useCustomConfig: builder => ... })`. These appear under the Overrides picker in the panel editor.
45
+
46
+ If the panel does not register custom field options, remove this section entirely.
47
+ -->
48
+
49
+ ## Tooltip and legend options
50
+
51
+ <!-- section-brief
52
+ Fill this in: Describe the tooltip and legend options {{{pluginName}}} exposes: hover behavior, the fields the tooltip shows and its formatting, and legend placement, values and calculations. Most of these already appear in the Panel options table above when they're registered via `setPanelOptions` with `category: ['Tooltip']` or `category: ['Legend']`, so use this section only for narrative context that doesn't fit in a table row. Remove this section if there is nothing extra to say beyond the table.
53
+ -->
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: Troubleshooting
3
+ description: "Troubleshoot the {{{yamlEscape pluginName}}} panel."
4
+ sidebar_position: 5
5
+ ---
6
+
7
+ This page explains how to fix common issues when you use the {{{pluginName}}} panel. For the data the panel expects, refer to [Data formats](./data-formats.md).
8
+
9
+ <!-- section-brief
10
+ Fill this in: Replace this brief with one H2 per real failure mode, such as "Panel shows no data", "Wrong field selected" or "Rendering errors". Open each H2 with the symptom users see, then give the most likely cause and the steps to resolve it. Remove this brief and add nothing if there are no real failures to report.
11
+ -->
12
+
13
+ ## Get more detail about an error
14
+
15
+ To see the data the panel receives, open the panel editor, click **Query inspector** and select the **Data** tab.
16
+
17
+ For errors in the panel itself, open the developer tools in your browser and check the console.
18
+
19
+ ## Get additional help
20
+
21
+ If this page doesn't solve your problem:
22
+
23
+ - Search the [Grafana community forums](https://community.grafana.com/).
24
+ - If your Grafana Cloud or Grafana Enterprise plan includes support, contact Grafana Support.
25
+
26
+ <!-- section-brief
27
+ Fill this in: Add links to the plugin's issue tracker to the list above.
28
+ -->
29
+
30
+ When you report an issue, include:
31
+
32
+ - The Grafana and plugin versions.
33
+ - The error message, with sensitive information removed.
34
+ - The steps to reproduce the issue.
35
+ - The panel options and a sample of the data it shows, with sensitive information removed.
@@ -20,7 +20,7 @@ jobs:
20
20
 
21
21
  steps:
22
22
  - name: Checkout repository
23
- uses: actions/checkout@v6
23
+ uses: actions/checkout@v7
24
24
  with:
25
25
  persist-credentials: false
26
26
 
@@ -26,7 +26,7 @@ jobs:
26
26
  env:
27
27
  GRAFANA_ACCESS_POLICY_TOKEN: $\{{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}
28
28
  steps:
29
- - uses: actions/checkout@v6
29
+ - uses: actions/checkout@v7
30
30
  with:
31
31
  persist-credentials: false
32
32
  {{#if_eq packageManagerName "pnpm"}}
@@ -35,7 +35,7 @@ jobs:
35
35
  - uses: pnpm/action-setup@v6
36
36
  {{/if_eq}}
37
37
  - name: Setup Node.js environment
38
- uses: actions/setup-node@v6
38
+ uses: actions/setup-node@v7
39
39
  with:
40
40
  node-version: '22'
41
41
  cache: '{{ packageManagerName }}'
@@ -62,13 +62,13 @@ jobs:
62
62
 
63
63
  - name: Setup Go environment
64
64
  if: steps.check-for-backend.outputs.has-backend == 'true'
65
- uses: actions/setup-go@v6
65
+ uses: actions/setup-go@v7
66
66
  with:
67
67
  go-version-file: go.mod
68
68
 
69
69
  - name: Lint backend
70
70
  if: steps.check-for-backend.outputs.has-backend == 'true'
71
- uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1
71
+ uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
72
72
  with:
73
73
  version: latest
74
74
  args: ./...
@@ -146,7 +146,7 @@ jobs:
146
146
  matrix: $\{{ steps.resolve-versions.outputs.matrix }}
147
147
  steps:
148
148
  - name: Checkout
149
- uses: actions/checkout@v6
149
+ uses: actions/checkout@v7
150
150
  with:
151
151
  persist-credentials: false
152
152
 
@@ -164,7 +164,7 @@ jobs:
164
164
  name: e2e test $\{{ matrix.GRAFANA_IMAGE.name }}@$\{{ matrix.GRAFANA_IMAGE.VERSION }}
165
165
  runs-on: ubuntu-latest
166
166
  steps:
167
- - uses: actions/checkout@v6
167
+ - uses: actions/checkout@v7
168
168
  with:
169
169
  persist-credentials: false
170
170
 
@@ -185,7 +185,7 @@ jobs:
185
185
  - uses: pnpm/action-setup@v6
186
186
  {{/if_eq}}
187
187
  - name: Setup Node.js environment
188
- uses: actions/setup-node@v6
188
+ uses: actions/setup-node@v7
189
189
  with:
190
190
  node-version: '22'
191
191
  cache: '{{ packageManagerName }}'
@@ -7,18 +7,18 @@ jobs:
7
7
  permissions:
8
8
  contents: read
9
9
  steps:
10
- - uses: actions/checkout@v6
10
+ - uses: actions/checkout@v7
11
11
  with:
12
12
  persist-credentials: false
13
13
 
14
14
  {{#if_eq packageManagerName "pnpm"}}
15
15
  # pnpm action uses the packageManager field in package.json to
16
16
  # understand which version to install.
17
- - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
17
+ - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
18
18
  {{/if_eq}}
19
19
 
20
20
  - name: Setup Node.js environment
21
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
21
+ uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
22
22
  with:
23
23
  node-version: '22'
24
24
  cache: '{{ packageManagerName }}'
@@ -16,7 +16,7 @@ jobs:
16
16
  contents: write
17
17
  runs-on: ubuntu-latest
18
18
  steps:
19
- - uses: actions/checkout@v6
19
+ - uses: actions/checkout@v7
20
20
  with:
21
21
  persist-credentials: false
22
22