@grafana/create-plugin 4.10.4 → 4.10.5-canary.920.733d88e.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.
@@ -1,3 +1,4 @@
1
+ import { lt as semverLt } from 'semver';
1
2
  import { glob } from 'glob';
2
3
  import path from 'node:path';
3
4
  import fs from 'node:fs';
@@ -57,15 +58,17 @@ export function renderTemplateFromFile(templateFile, data) {
57
58
  export function getTemplateData(cliArgs) {
58
59
  const { features } = getConfig();
59
60
  const currentVersion = getVersion();
61
+ const grafanaVersion = EXTRA_TEMPLATE_VARIABLES.grafanaVersion;
60
62
  const usePlaywright = features.usePlaywright === true || isFile(path.join(process.cwd(), 'playwright.config.ts'));
63
+ const useCypress = !usePlaywright && semverLt(grafanaVersion, '11.0.0') && fs.existsSync(path.join(process.cwd(), 'cypress'));
61
64
  const bundleGrafanaUI = features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI;
62
65
  const shouldUseReactRouterV6 = (pluginType) => features.useReactRouterV6 === true && pluginType === PLUGIN_TYPES.app;
63
66
  const getReactRouterVersion = (pluginType) => (shouldUseReactRouterV6(pluginType) ? '6.22.0' : '5.2.0');
64
67
  const isAppType = (pluginType) => pluginType === PLUGIN_TYPES.app || pluginType === PLUGIN_TYPES.scenes;
65
68
  const isNPM = (packageManagerName) => packageManagerName === 'npm';
66
- const getE2eTestCmd = (packageManagerName) => usePlaywright
67
- ? 'playwright test'
68
- : `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run`;
69
+ const getE2eTestCmd = (packageManagerName) => useCypress
70
+ ? `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run`
71
+ : 'playwright test';
69
72
  let templateData;
70
73
  if (cliArgs) {
71
74
  const { packageManagerName, packageManagerVersion } = getPackageManagerFromUserAgent();
@@ -87,6 +90,7 @@ export function getTemplateData(cliArgs) {
87
90
  useReactRouterV6: shouldUseReactRouterV6(cliArgs.pluginType),
88
91
  reactRouterVersion: getReactRouterVersion(cliArgs.pluginType),
89
92
  usePlaywright,
93
+ useCypress,
90
94
  e2eTestCmd: getE2eTestCmd(packageManagerName),
91
95
  hasGithubWorkflows: cliArgs.hasGithubWorkflows,
92
96
  hasGithubLevitateWorkflow: cliArgs.hasGithubLevitateWorkflow,
@@ -114,6 +118,7 @@ export function getTemplateData(cliArgs) {
114
118
  useReactRouterV6: shouldUseReactRouterV6(pluginJson.type),
115
119
  reactRouterVersion: getReactRouterVersion(pluginJson.type),
116
120
  usePlaywright,
121
+ useCypress,
117
122
  e2eTestCmd: getE2eTestCmd(packageManagerName),
118
123
  hasGithubWorkflows: isFile(path.join(githubFolder, 'ci.yml')),
119
124
  hasGithubLevitateWorkflow: isFile(path.join(githubFolder, 'is-compatible.yml')),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "4.10.4",
3
+ "version": "4.10.5-canary.920.733d88e.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": "b917ec2d6470f7778be7b2f0832d22a676685ba1"
90
+ "gitHead": "733d88e6222088a9a34f7d142475f14e95038556"
91
91
  }
package/src/types.ts CHANGED
@@ -29,6 +29,7 @@ export type TemplateData = {
29
29
  useReactRouterV6: boolean;
30
30
  reactRouterVersion: string;
31
31
  usePlaywright: boolean;
32
+ useCypress: boolean;
32
33
  e2eTestCmd: string;
33
34
  hasGithubWorkflows: boolean;
34
35
  hasGithubLevitateWorkflow: boolean;
@@ -1,3 +1,4 @@
1
+ import { lt as semverLt } from 'semver';
1
2
  import { glob } from 'glob';
2
3
  import path from 'node:path';
3
4
  import fs from 'node:fs';
@@ -95,7 +96,11 @@ export function renderTemplateFromFile(templateFile: string, data?: any) {
95
96
  export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
96
97
  const { features } = getConfig();
97
98
  const currentVersion = getVersion();
99
+ const grafanaVersion = EXTRA_TEMPLATE_VARIABLES.grafanaVersion;
98
100
  const usePlaywright = features.usePlaywright === true || isFile(path.join(process.cwd(), 'playwright.config.ts'));
101
+ //@grafana/e2e was deprecated in Grafana 11
102
+ const useCypress =
103
+ !usePlaywright && semverLt(grafanaVersion, '11.0.0') && fs.existsSync(path.join(process.cwd(), 'cypress'));
99
104
  const bundleGrafanaUI = features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI;
100
105
  const shouldUseReactRouterV6 = (pluginType: string) =>
101
106
  features.useReactRouterV6 === true && pluginType === PLUGIN_TYPES.app;
@@ -103,9 +108,9 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
103
108
  const isAppType = (pluginType: string) => pluginType === PLUGIN_TYPES.app || pluginType === PLUGIN_TYPES.scenes;
104
109
  const isNPM = (packageManagerName: string) => packageManagerName === 'npm';
105
110
  const getE2eTestCmd = (packageManagerName: string) =>
106
- usePlaywright
107
- ? 'playwright test'
108
- : `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run`;
111
+ useCypress
112
+ ? `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run`
113
+ : 'playwright test';
109
114
 
110
115
  let templateData: TemplateData;
111
116
 
@@ -131,6 +136,7 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
131
136
  useReactRouterV6: shouldUseReactRouterV6(cliArgs.pluginType),
132
137
  reactRouterVersion: getReactRouterVersion(cliArgs.pluginType),
133
138
  usePlaywright,
139
+ useCypress,
134
140
  e2eTestCmd: getE2eTestCmd(packageManagerName),
135
141
  hasGithubWorkflows: cliArgs.hasGithubWorkflows,
136
142
  hasGithubLevitateWorkflow: cliArgs.hasGithubLevitateWorkflow,
@@ -160,6 +166,7 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
160
166
  useReactRouterV6: shouldUseReactRouterV6(pluginJson.type),
161
167
  reactRouterVersion: getReactRouterVersion(pluginJson.type),
162
168
  usePlaywright,
169
+ useCypress,
163
170
  e2eTestCmd: getE2eTestCmd(packageManagerName),
164
171
  hasGithubWorkflows: isFile(path.join(githubFolder, 'ci.yml')),
165
172
  hasGithubLevitateWorkflow: isFile(path.join(githubFolder, 'is-compatible.yml')),
@@ -9,20 +9,21 @@
9
9
  "test:ci": "jest --passWithNoTests --maxWorkers 4",
10
10
  "typecheck": "tsc --noEmit",
11
11
  "lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
12
- "lint:fix": "{{ packageManagerName }} run lint{{#if isNPM}} --{{/if}} --fix",
13
- "e2e": "{{{ e2eTestCmd }}}",{{#unless usePlaywright}}
14
- "e2e:update": "{{ packageManagerName }} exec cypress install && {{ packageManagerName }} exec grafana-e2e run --update-screenshots",{{/unless}}
12
+ "lint:fix": "{{ packageManagerName }} run lint{{#if isNPM}} --{{/if}} --fix",{{#if usePlaywright}}
13
+ "e2e": "playwright test",{{/if}}{{#if useCypress}}
14
+ "e2e": "{{ packageManagerName }} exec cypress install && {{ packageManagerName }} exec grafana-e2e run",
15
+ "e2e:update": "{{ packageManagerName }} exec cypress install && {{ packageManagerName }} exec grafana-e2e run --update-screenshots",{{/if}}
15
16
  "server": "docker-compose up --build",
16
17
  "sign": "npx --yes @grafana/sign-plugin@latest"
17
18
  },
18
19
  "author": "{{ sentenceCase orgName }}",
19
20
  "license": "Apache-2.0",
20
21
  "devDependencies": {
21
- "@babel/core": "^7.21.4",{{#unless usePlaywright}}
22
+ "@babel/core": "^7.21.4",{{#if useCypress}}
22
23
  "@grafana/e2e": "{{ grafanaVersion }}",
23
- "@grafana/e2e-selectors": "{{ grafanaVersion }}",{{/unless}}
24
+ "@grafana/e2e-selectors": "{{ grafanaVersion }}",{{/if}}
24
25
  "@grafana/eslint-config": "^7.0.0",{{#if usePlaywright}}
25
- "@grafana/plugin-e2e": "^1.0.1",{{/if}}
26
+ "@grafana/plugin-e2e": "^1.2.0",{{/if}}
26
27
  "@grafana/tsconfig": "^1.2.0-rc1",
27
28
  "@grafana/plugin-meta-extractor": "^0.0.2",{{#if usePlaywright}}
28
29
  "@playwright/test": "^1.41.2",{{/if}}