@grafana/create-plugin 7.10.1 → 7.11.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 (36) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/codemods/additions/additions.js +5 -0
  3. package/dist/codemods/additions/scripts/experimental-app-sdk.js +275 -0
  4. package/dist/codemods/context.js +13 -1
  5. package/dist/codemods/runner.js +2 -1
  6. package/dist/codemods/utils.goMod.js +45 -0
  7. package/dist/codemods/utils.js +25 -1
  8. package/dist/commands/add.command.js +9 -4
  9. package/dist/commands/generate/print-success-message.js +1 -1
  10. package/package.json +3 -3
  11. package/src/codemods/additions/additions.ts +5 -0
  12. package/src/codemods/additions/scripts/experimental-app-sdk.test.ts +655 -0
  13. package/src/codemods/additions/scripts/experimental-app-sdk.ts +431 -0
  14. package/src/codemods/context.test.ts +7 -1
  15. package/src/codemods/context.ts +23 -1
  16. package/src/codemods/runner.ts +3 -1
  17. package/src/codemods/utils.goMod.test.ts +86 -0
  18. package/src/codemods/utils.goMod.ts +70 -0
  19. package/src/codemods/utils.test.ts +49 -0
  20. package/src/codemods/utils.ts +39 -0
  21. package/src/commands/add.command.ts +10 -5
  22. package/src/commands/generate/print-success-message.ts +1 -1
  23. package/templates/app-sdk/.config/AGENTS/app-sdk.md +87 -0
  24. package/templates/app-sdk/.config/app-sdk/README.md +60 -0
  25. package/templates/app-sdk/.config/app-sdk/generate-kinds.mjs +138 -0
  26. package/templates/app-sdk/.github/workflows/generate-kinds-drift.yml +84 -0
  27. package/templates/app-sdk/kinds/README.md +3 -0
  28. package/templates/app-sdk/kinds/config.cue +39 -0
  29. package/templates/app-sdk/kinds/cue.mod/module.cue +4 -0
  30. package/templates/app-sdk/kinds/example.cue +29 -0
  31. package/templates/app-sdk/kinds/manifest.cue +29 -0
  32. package/templates/app-sdk/pkg/generated/example/v1alpha1/doc.go +11 -0
  33. package/templates/app-sdk/pkg/generated/manifestdata/doc.go +12 -0
  34. package/templates/app-sdk/pkg/provider/provider.go +30 -0
  35. package/templates/common/_package.json +1 -1
  36. package/vitest.setup.ts +2 -2
@@ -0,0 +1,30 @@
1
+ package provider
2
+
3
+ import (
4
+ "github.com/grafana/grafana-app-sdk/app"
5
+ "github.com/grafana/grafana-app-sdk/simple"
6
+
7
+ examplev1alpha1 "github.com/{{ kebabCase orgName }}/{{ kebabCase pluginName }}/pkg/generated/example/v1alpha1"
8
+ "github.com/{{ kebabCase orgName }}/{{ kebabCase pluginName }}/pkg/generated/manifestdata"
9
+ )
10
+
11
+ // New returns the app.Provider, the single entry point to this package. main.go uses it to read the
12
+ // manifest and instantiate the app.App.
13
+ func New() app.Provider {
14
+ return simple.NewAppProvider(manifestdata.LocalManifest(), nil, newApp)
15
+ }
16
+
17
+ // newApp is the factory passed to simple.NewAppProvider; it builds the app.App from the resolved
18
+ // config. Attach a Validator, Mutator, or Reconciler per kind as you need one — see
19
+ // simple.AppManagedKind and ./.config/AGENTS/app-sdk.md.
20
+ func newApp(cfg app.Config) (app.App, error) {
21
+ return simple.NewApp(simple.AppConfig{
22
+ Name: "{{ pluginId }}",
23
+ KubeConfig: cfg.KubeConfig,
24
+ ManagedKinds: []simple.AppManagedKind{
25
+ {
26
+ Kind: examplev1alpha1.Kind(),
27
+ },
28
+ },
29
+ })
30
+ }
@@ -17,7 +17,7 @@
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
19
  "@grafana/eslint-config": "^9.0.0",
20
- "@grafana/plugin-e2e": "^3.11.0",
20
+ "@grafana/plugin-e2e": "^3.12.0",
21
21
  "@grafana/sign-plugin": "^3.3.3",
22
22
  "@grafana/tsconfig": "^2.2.0",
23
23
  "@playwright/test": "^1.62.1",{{#if useExperimentalRspack}}
package/vitest.setup.ts CHANGED
@@ -28,10 +28,10 @@ const parseContent = (content?: string) => (content ? JSON.parse(content) : '');
28
28
  expect.extend({
29
29
  async toBeIdempotent(migrate: (context: Context) => Promise<Context>, context: Context) {
30
30
  const firstRun = await migrate(context);
31
- const firstRunDeepCopy = structuredClone(firstRun) as unknown as ClonedContext;
31
+ const firstRunDeepCopy = { files: structuredClone(firstRun.listChanges()) } as unknown as ClonedContext;
32
32
 
33
33
  const secondRun = await migrate(firstRun);
34
- const secondRunDeepCopy = structuredClone(secondRun) as unknown as ClonedContext;
34
+ const secondRunDeepCopy = { files: structuredClone(secondRun.listChanges()) } as unknown as ClonedContext;
35
35
 
36
36
  const result = await compareContexts(firstRunDeepCopy, secondRunDeepCopy);
37
37