@grafana/create-plugin 6.1.1-canary.2232.18584719214.0 → 6.2.0-canary.2233.18586197736.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.
package/src/constants.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { fileURLToPath } from 'node:url';
2
1
  import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
3
 
4
4
  const __dirname = fileURLToPath(new URL('.', import.meta.url));
5
5
 
@@ -51,11 +51,19 @@ export const EXTRA_TEMPLATE_VARIABLES = {
51
51
  export const DEFAULT_FEATURE_FLAGS = {
52
52
  useReactRouterV6: true,
53
53
  bundleGrafanaUI: false,
54
+ usePlaywright: true,
54
55
  useExperimentalRspack: false,
55
56
  useExperimentalUpdates: true,
56
57
  };
57
58
 
58
- export const GRAFANA_FE_PACKAGES = ['@grafana/data', '@grafana/runtime', '@grafana/schema', '@grafana/ui'];
59
+ export const GRAFANA_FE_PACKAGES = [
60
+ '@grafana/data',
61
+ '@grafana/e2e-selectors',
62
+ '@grafana/e2e',
63
+ '@grafana/runtime',
64
+ '@grafana/schema',
65
+ '@grafana/ui',
66
+ ];
59
67
 
60
68
  export const MIGRATION_CONFIG = {
61
69
  // Files that should be overriden during a migration.
package/src/types.ts CHANGED
@@ -25,6 +25,8 @@ export type TemplateData = {
25
25
  useReactRouterV6: boolean;
26
26
  scenesVersion: string;
27
27
  reactRouterVersion: string;
28
+ usePlaywright: boolean;
29
+ useCypress: boolean;
28
30
  useExperimentalRspack: boolean;
29
31
  pluginExecutable?: string;
30
32
  frontendBundler: 'webpack' | 'rspack';
@@ -1,12 +1,11 @@
1
- import { argv, commandName } from './utils.cli.js';
2
-
1
+ import fs from 'node:fs';
2
+ import { writeFile } from 'node:fs/promises';
3
+ import path from 'node:path';
3
4
  import { CURRENT_APP_VERSION } from './utils.version.js';
5
+ import { argv, commandName } from './utils.cli.js';
4
6
  import { DEFAULT_FEATURE_FLAGS } from '../constants.js';
5
- import fs from 'node:fs';
6
7
  import { output } from './utils.console.js';
7
8
  import { partitionArr } from './utils.helpers.js';
8
- import path from 'node:path';
9
- import { writeFile } from 'node:fs/promises';
10
9
 
11
10
  export type FeatureFlags = {
12
11
  bundleGrafanaUI?: boolean;
@@ -14,6 +13,7 @@ export type FeatureFlags = {
14
13
  // If set to true, the plugin will be scaffolded with React Router v6. Defaults to true.
15
14
  // (Attention! We always scaffold new projects with React Router v6, so if you are changing this to `false` manually you will need to make changes to the React code as well.)
16
15
  useReactRouterV6?: boolean;
16
+ usePlaywright?: boolean;
17
17
  useExperimentalRspack?: boolean;
18
18
  useExperimentalUpdates?: boolean;
19
19
  };
@@ -1,27 +1,27 @@
1
+ import { lt as semverLt } from 'semver';
2
+ import { glob } from 'glob';
3
+ import path from 'node:path';
4
+ import fs from 'node:fs';
5
+ import { filterOutCommonFiles, isFile, isFileStartingWith } from './utils.files.js';
6
+ import { normalizeId, renderHandlebarsTemplate } from './utils.handlebars.js';
7
+ import { getPluginJson } from './utils.plugin.js';
8
+ import { debug } from './utils.cli.js';
1
9
  import {
2
- DEFAULT_FEATURE_FLAGS,
10
+ TEMPLATE_PATHS,
3
11
  EXPORT_PATH_PREFIX,
4
12
  EXTRA_TEMPLATE_VARIABLES,
5
13
  PLUGIN_TYPES,
6
- TEMPLATE_PATHS,
14
+ DEFAULT_FEATURE_FLAGS,
7
15
  } from '../constants.js';
8
16
  import { GenerateCliArgs, TemplateData } from '../types.js';
9
- import { filterOutCommonFiles, isFile, isFileStartingWith } from './utils.files.js';
10
17
  import {
11
- getPackageManagerFromUserAgent,
12
18
  getPackageManagerInstallCmd,
13
19
  getPackageManagerWithFallback,
20
+ getPackageManagerFromUserAgent,
14
21
  } from './utils.packageManager.js';
15
- import { normalizeId, renderHandlebarsTemplate } from './utils.handlebars.js';
16
-
17
- import { CURRENT_APP_VERSION } from './utils.version.js';
18
- import { debug } from './utils.cli.js';
19
- import fs from 'node:fs';
20
- import { getConfig } from './utils.config.js';
21
22
  import { getExportFileName } from '../utils/utils.files.js';
22
- import { getPluginJson } from './utils.plugin.js';
23
- import { glob } from 'glob';
24
- import path from 'node:path';
23
+ import { getGrafanaRuntimeVersion, CURRENT_APP_VERSION } from './utils.version.js';
24
+ import { getConfig } from './utils.config.js';
25
25
 
26
26
  const templatesDebugger = debug.extend('templates');
27
27
 
@@ -95,6 +95,11 @@ export function renderTemplateFromFile(templateFile: string, data?: any) {
95
95
  export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
96
96
  const { features } = getConfig();
97
97
  const currentVersion = CURRENT_APP_VERSION;
98
+ const grafanaVersion = getGrafanaRuntimeVersion();
99
+ const usePlaywright = features.usePlaywright === true || isFile(path.join(process.cwd(), 'playwright.config.ts'));
100
+ //@grafana/e2e was deprecated in Grafana 11
101
+ const useCypress =
102
+ !usePlaywright && semverLt(grafanaVersion, '11.0.0') && fs.existsSync(path.join(process.cwd(), 'cypress'));
98
103
  const bundleGrafanaUI = features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI;
99
104
  const getReactRouterVersion = () => (features.useReactRouterV6 ? '6.22.0' : '5.2.0');
100
105
  const isAppType = (pluginType: string) => pluginType === PLUGIN_TYPES.app || pluginType === PLUGIN_TYPES.scenes;
@@ -125,6 +130,8 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
125
130
  useReactRouterV6: features.useReactRouterV6 ?? DEFAULT_FEATURE_FLAGS.useReactRouterV6,
126
131
  reactRouterVersion: getReactRouterVersion(),
127
132
  scenesVersion: features.useReactRouterV6 ? '^6.10.4' : '^5.41.3',
133
+ usePlaywright,
134
+ useCypress,
128
135
  useExperimentalRspack: Boolean(features.useExperimentalRspack),
129
136
  frontendBundler,
130
137
  };
@@ -151,6 +158,8 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
151
158
  useReactRouterV6: features.useReactRouterV6 ?? DEFAULT_FEATURE_FLAGS.useReactRouterV6,
152
159
  reactRouterVersion: getReactRouterVersion(),
153
160
  scenesVersion: features.useReactRouterV6 ? '^6.10.4' : '^5.41.3',
161
+ usePlaywright,
162
+ useCypress,
154
163
  pluginExecutable: pluginJson.executable,
155
164
  useExperimentalRspack: Boolean(features.useExperimentalRspack),
156
165
  frontendBundler,
@@ -8,18 +8,22 @@
8
8
  "test:ci": "jest --passWithNoTests --maxWorkers 4",
9
9
  "typecheck": "tsc --noEmit",
10
10
  "lint": "eslint --cache .",
11
- "lint:fix": "{{ packageManagerName }} run lint{{#if isNPM}} --{{/if}} --fix && prettier --write --list-different .",
12
- "e2e": "playwright test",
11
+ "lint:fix": "{{ packageManagerName }} run lint{{#if isNPM}} --{{/if}} --fix && prettier --write --list-different .",{{#if usePlaywright}}
12
+ "e2e": "playwright test",{{/if}}{{#if useCypress}}
13
+ "e2e": "{{ packageManagerName }} exec cypress install && {{ packageManagerName }} exec grafana-e2e run",
14
+ "e2e:update": "{{ packageManagerName }} exec cypress install && {{ packageManagerName }} exec grafana-e2e run --update-screenshots",{{/if}}
13
15
  "server": "docker compose up --build",
14
16
  "sign": "npx --yes @grafana/sign-plugin@latest"
15
17
  },
16
18
  "author": "{{ sentenceCase orgName }}",
17
19
  "license": "Apache-2.0",
18
20
  "devDependencies": {
19
- "@grafana/eslint-config": "^8.2.0",
20
- "@grafana/plugin-e2e": "^2.2.0",
21
- "@grafana/tsconfig": "^2.0.0",
22
- "@playwright/test": "^1.52.0",{{#if useExperimentalRspack}}
21
+ {{#if useCypress}} "@grafana/e2e": "^11.0.7",
22
+ "@grafana/e2e-selectors": "^12.2.0",{{/if}}
23
+ "@grafana/eslint-config": "^8.2.0",{{#if usePlaywright}}
24
+ "@grafana/plugin-e2e": "^2.2.0",{{/if}}
25
+ "@grafana/tsconfig": "^2.0.0",{{#if usePlaywright}}
26
+ "@playwright/test": "^1.52.0",{{/if}}{{#if useExperimentalRspack}}
23
27
  "@rspack/core": "^1.3.0",
24
28
  "@rspack/cli": "^1.3.0",{{/if}}
25
29
  "@stylistic/eslint-plugin-ts": "^2.9.0",
@@ -52,8 +56,8 @@
52
56
  "replace-in-file-webpack-plugin": "^1.0.6",{{#if useExperimentalRspack}}
53
57
  "rspack-plugin-virtual-module": "^0.1.13",{{/if}}
54
58
  "sass": "1.63.2",
55
- "sass-loader": "13.3.1",
56
- "semver": "^7.6.3",
59
+ "sass-loader": "13.3.1",{{#if usePlaywright}}
60
+ "semver": "^7.6.3",{{/if}}
57
61
  "style-loader": "3.3.3",{{#unless useExperimentalRspack}}
58
62
  "swc-loader": "^0.2.3",{{/unless}}
59
63
  "terser-webpack-plugin": "^5.3.10",
@@ -10,3 +10,6 @@ public-hoist-pattern[]="*prettier*"
10
10
  # Hoist all types packages to the root for better TS support
11
11
  public-hoist-pattern[]="@types/*"
12
12
  public-hoist-pattern[]="*terser-webpack-plugin*"
13
+ {{#unless usePlaywright}}
14
+ # @grafana/e2e expects cypress to exist in the root of the node_modules directory
15
+ public-hoist-pattern[]="*cypress*"{{/unless}}