@grafana/create-plugin 4.10.4 → 4.10.5-canary.920.b2d6ce6.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.b2d6ce6.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": "b2d6ce6b2d06aa3e7564601cabbcd967cd219b96"
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,10 @@ 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
+ const useCypress =
102
+ !usePlaywright && semverLt(grafanaVersion, '11.0.0') && fs.existsSync(path.join(process.cwd(), 'cypress'));
99
103
  const bundleGrafanaUI = features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI;
100
104
  const shouldUseReactRouterV6 = (pluginType: string) =>
101
105
  features.useReactRouterV6 === true && pluginType === PLUGIN_TYPES.app;
@@ -103,9 +107,9 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
103
107
  const isAppType = (pluginType: string) => pluginType === PLUGIN_TYPES.app || pluginType === PLUGIN_TYPES.scenes;
104
108
  const isNPM = (packageManagerName: string) => packageManagerName === 'npm';
105
109
  const getE2eTestCmd = (packageManagerName: string) =>
106
- usePlaywright
107
- ? 'playwright test'
108
- : `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run`;
110
+ useCypress
111
+ ? `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run`
112
+ : 'playwright test';
109
113
 
110
114
  let templateData: TemplateData;
111
115
 
@@ -131,6 +135,7 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
131
135
  useReactRouterV6: shouldUseReactRouterV6(cliArgs.pluginType),
132
136
  reactRouterVersion: getReactRouterVersion(cliArgs.pluginType),
133
137
  usePlaywright,
138
+ useCypress,
134
139
  e2eTestCmd: getE2eTestCmd(packageManagerName),
135
140
  hasGithubWorkflows: cliArgs.hasGithubWorkflows,
136
141
  hasGithubLevitateWorkflow: cliArgs.hasGithubLevitateWorkflow,
@@ -160,6 +165,7 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
160
165
  useReactRouterV6: shouldUseReactRouterV6(pluginJson.type),
161
166
  reactRouterVersion: getReactRouterVersion(pluginJson.type),
162
167
  usePlaywright,
168
+ useCypress,
163
169
  e2eTestCmd: getE2eTestCmd(packageManagerName),
164
170
  hasGithubWorkflows: isFile(path.join(githubFolder, 'ci.yml')),
165
171
  hasGithubLevitateWorkflow: isFile(path.join(githubFolder, 'is-compatible.yml')),
@@ -9,18 +9,19 @@
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
26
  "@grafana/plugin-e2e": "^1.0.1",{{/if}}
26
27
  "@grafana/tsconfig": "^1.2.0-rc1",