@grafana/create-plugin 4.4.4 → 4.5.0-canary.847.385428e.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/CHANGELOG.md CHANGED
@@ -1,51 +1,3 @@
1
- # v4.4.4 (Thu Mar 28 2024)
2
-
3
- #### 🐛 Bug Fix
4
-
5
- - Create Plugin: Fix hardcoded path [#846](https://github.com/grafana/plugin-tools/pull/846) ([@oshirohugo](https://github.com/oshirohugo))
6
-
7
- #### Authors: 1
8
-
9
- - Hugo Kiyodi Oshiro ([@oshirohugo](https://github.com/oshirohugo))
10
-
11
- ---
12
-
13
- # v4.4.3 (Thu Mar 28 2024)
14
-
15
- #### 🐛 Bug Fix
16
-
17
- - Create Plugin: Update default yarn version to 1.22.22 [#839](https://github.com/grafana/plugin-tools/pull/839) ([@jackw](https://github.com/jackw))
18
-
19
- #### Authors: 1
20
-
21
- - Jack Westbrook ([@jackw](https://github.com/jackw))
22
-
23
- ---
24
-
25
- # v4.4.2 (Thu Mar 28 2024)
26
-
27
- #### 🐛 Bug Fix
28
-
29
- - Create Plugin: Fix grafana running without plugin backend [#844](https://github.com/grafana/plugin-tools/pull/844) ([@oshirohugo](https://github.com/oshirohugo))
30
-
31
- #### Authors: 1
32
-
33
- - Hugo Kiyodi Oshiro ([@oshirohugo](https://github.com/oshirohugo))
34
-
35
- ---
36
-
37
- # v4.4.1 (Wed Mar 27 2024)
38
-
39
- #### 🐛 Bug Fix
40
-
41
- - Create-Plugin: Improve commands intructions [#843](https://github.com/grafana/plugin-tools/pull/843) ([@oshirohugo](https://github.com/oshirohugo))
42
-
43
- #### Authors: 1
44
-
45
- - Hugo Kiyodi Oshiro ([@oshirohugo](https://github.com/oshirohugo))
46
-
47
- ---
48
-
49
1
  # v4.4.0 (Tue Mar 26 2024)
50
2
 
51
3
  #### 🐛 Bug Fix
@@ -14,9 +14,7 @@ export function printGenerateSuccessMessage(answers) {
14
14
  ]
15
15
  : []),
16
16
  '- `docker-compose up` to start a grafana development server. ' +
17
- (answers.hasBackend
18
- ? 'The plugin backend will be reloaded on every code change and a debugger can be attached on port `2345`.'
19
- : ''),
17
+ (answers.hasBackend ? 'Restart this command after each time you run mage to run your new backend code.' : ''),
20
18
  '- Open http://localhost:3000 in your browser to create a dashboard to begin developing your plugin.',
21
19
  ];
22
20
  const msg = `\n# Congratulations on scaffolding a Grafana ${answers.pluginType} plugin! 🚀
@@ -60,6 +60,8 @@ function getTemplateData(answers) {
60
60
  bundleGrafanaUI: features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI,
61
61
  useReactRouterV6,
62
62
  reactRouterVersion: useReactRouterV6 ? '6.22.0' : '5.2.0',
63
+ e2eTestCmd: 'playwright test',
64
+ e2eTestUpdateCmd: 'playwright test --update-snapshots',
63
65
  };
64
66
  return templateData;
65
67
  }
@@ -6,7 +6,7 @@ const NPM_LOCKFILE = 'package-lock.json';
6
6
  const PNPM_LOCKFILE = 'pnpm-lock.yaml';
7
7
  const YARN_LOCKFILE = 'yarn.lock';
8
8
  const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'];
9
- const DEFAULT_PACKAGE_MANAGER = { packageManagerName: 'yarn', packageManagerVersion: '1.22.22' };
9
+ const DEFAULT_PACKAGE_MANAGER = { packageManagerName: 'yarn', packageManagerVersion: '1.22.19' };
10
10
  export function getPackageManagerFromUserAgent() {
11
11
  const agent = process.env.npm_config_user_agent;
12
12
  if (!agent) {
@@ -61,6 +61,13 @@ export function getTemplateData() {
61
61
  const useReactRouterV6 = features.useReactRouterV6 === true && pluginJson.type === PLUGIN_TYPES.app;
62
62
  const { packageManagerName, packageManagerVersion } = getPackageManagerWithFallback();
63
63
  const packageManagerInstallCmd = getPackageManagerInstallCmd(packageManagerName);
64
+ const hasPlaywright = isFile(path.join(process.cwd(), 'playwright.config.ts'));
65
+ const e2eTestCmd = hasPlaywright
66
+ ? 'playwright test'
67
+ : `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run`;
68
+ const e2eTestUpdateCmd = hasPlaywright
69
+ ? 'playwright test --update-snapshots'
70
+ : `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run --update-screenshots`;
64
71
  const templateData = {
65
72
  ...EXTRA_TEMPLATE_VARIABLES,
66
73
  pluginId: pluginJson.id,
@@ -78,6 +85,8 @@ export function getTemplateData() {
78
85
  bundleGrafanaUI: features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI,
79
86
  useReactRouterV6: useReactRouterV6,
80
87
  reactRouterVersion: useReactRouterV6 ? '6.22.0' : '5.2.0',
88
+ e2eTestCmd,
89
+ e2eTestUpdateCmd,
81
90
  };
82
91
  debug('\nTemplate data:\n' + JSON.stringify(templateData, null, 2));
83
92
  return templateData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "4.4.4",
3
+ "version": "4.5.0-canary.847.385428e.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": "a274091414096629a8509b76e136a37f25ecdcbd"
90
+ "gitHead": "385428e1fa55a208afee1c096047ffdb5b9f3a0b"
91
91
  }
@@ -16,9 +16,7 @@ export function printGenerateSuccessMessage(answers: CliArgs) {
16
16
  ]
17
17
  : []),
18
18
  '- `docker-compose up` to start a grafana development server. ' +
19
- (answers.hasBackend
20
- ? 'The plugin backend will be reloaded on every code change and a debugger can be attached on port `2345`.'
21
- : ''),
19
+ (answers.hasBackend ? 'Restart this command after each time you run mage to run your new backend code.' : ''),
22
20
  '- Open http://localhost:3000 in your browser to create a dashboard to begin developing your plugin.',
23
21
  ];
24
22
 
@@ -59,7 +59,9 @@ function getTemplateData(answers: CliArgs) {
59
59
  const { packageManagerName, packageManagerVersion } = getPackageManagerFromUserAgent();
60
60
  const packageManagerInstallCmd = getPackageManagerInstallCmd(packageManagerName);
61
61
  const isAppType = pluginType === PLUGIN_TYPES.app || pluginType === PLUGIN_TYPES.scenes;
62
- const useReactRouterV6 = features.useReactRouterV6 === true && pluginType === PLUGIN_TYPES.app; // We don't enable this by default yet for new scenes plugins.
62
+ // We don't enable this by default yet for new scenes plugins.
63
+ const useReactRouterV6 = features.useReactRouterV6 === true && pluginType === PLUGIN_TYPES.app;
64
+
63
65
  const templateData: TemplateData = {
64
66
  ...answers,
65
67
  pluginId,
@@ -72,6 +74,8 @@ function getTemplateData(answers: CliArgs) {
72
74
  bundleGrafanaUI: features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI,
73
75
  useReactRouterV6,
74
76
  reactRouterVersion: useReactRouterV6 ? '6.22.0' : '5.2.0',
77
+ e2eTestCmd: 'playwright test',
78
+ e2eTestUpdateCmd: 'playwright test --update-snapshots',
75
79
  };
76
80
 
77
81
  return templateData;
package/src/types.ts CHANGED
@@ -21,4 +21,6 @@ export type TemplateData = {
21
21
  bundleGrafanaUI: boolean;
22
22
  useReactRouterV6: boolean;
23
23
  reactRouterVersion: string;
24
+ e2eTestCmd: string;
25
+ e2eTestUpdateCmd: string;
24
26
  };
@@ -7,7 +7,7 @@ const NPM_LOCKFILE = 'package-lock.json';
7
7
  const PNPM_LOCKFILE = 'pnpm-lock.yaml';
8
8
  const YARN_LOCKFILE = 'yarn.lock';
9
9
  const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'];
10
- const DEFAULT_PACKAGE_MANAGER = { packageManagerName: 'yarn', packageManagerVersion: '1.22.22' };
10
+ const DEFAULT_PACKAGE_MANAGER = { packageManagerName: 'yarn', packageManagerVersion: '1.22.19' };
11
11
 
12
12
  export type PackageManager = {
13
13
  packageManagerName: string;
@@ -95,6 +95,13 @@ export function getTemplateData(): TemplateData {
95
95
  const useReactRouterV6 = features.useReactRouterV6 === true && pluginJson.type === PLUGIN_TYPES.app;
96
96
  const { packageManagerName, packageManagerVersion } = getPackageManagerWithFallback();
97
97
  const packageManagerInstallCmd = getPackageManagerInstallCmd(packageManagerName);
98
+ const hasPlaywright = isFile(path.join(process.cwd(), 'playwright.config.ts'));
99
+ const e2eTestCmd = hasPlaywright
100
+ ? 'playwright test'
101
+ : `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run`;
102
+ const e2eTestUpdateCmd = hasPlaywright
103
+ ? 'playwright test --update-snapshots'
104
+ : `${packageManagerName} exec cypress install && ${packageManagerName} exec grafana-e2e run --update-screenshots`;
98
105
 
99
106
  const templateData = {
100
107
  ...EXTRA_TEMPLATE_VARIABLES,
@@ -113,6 +120,8 @@ export function getTemplateData(): TemplateData {
113
120
  bundleGrafanaUI: features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI,
114
121
  useReactRouterV6: useReactRouterV6,
115
122
  reactRouterVersion: useReactRouterV6 ? '6.22.0' : '5.2.0',
123
+ e2eTestCmd,
124
+ e2eTestUpdateCmd,
116
125
  };
117
126
 
118
127
  debug('\nTemplate data:\n' + JSON.stringify(templateData, null, 2));
@@ -5,11 +5,7 @@ user=root
5
5
  [program:grafana]
6
6
  user=root
7
7
  directory=/var/lib/grafana
8
- {{#if hasBackend}}
9
- command=bash -c 'while [ ! -f /root/{{ pluginId }}/dist/gpx_{{ snakeCase pluginName }}* ]; do sleep 1; done; /run.sh'
10
- {{else}}
11
8
  command=/run.sh
12
- {{/if}}
13
9
  stdout_logfile=/dev/fd/1
14
10
  stdout_logfile_maxbytes=0
15
11
  redirect_stderr=true
@@ -10,8 +10,8 @@
10
10
  "typecheck": "tsc --noEmit",
11
11
  "lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
12
12
  "lint:fix": "{{ packageManagerName }} run lint{{#if isNPM}} --{{/if}} --fix",
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",
13
+ "e2e": "{{ e2eTestCmd }}",
14
+ "e2e:update": "{{ e2eTestUpdateCmd }}",
15
15
  "server": "docker-compose up --build",
16
16
  "sign": "npx --yes @grafana/sign-plugin@latest"
17
17
  },
@@ -19,10 +19,10 @@
19
19
  "license": "Apache-2.0",
20
20
  "devDependencies": {
21
21
  "@babel/core": "^7.21.4",
22
- "@grafana/e2e": "{{ grafanaVersion }}",
23
- "@grafana/e2e-selectors": "{{ grafanaVersion }}",
24
22
  "@grafana/eslint-config": "^7.0.0",
23
+ "@grafana/plugin-e2e": "^0.24.0",
25
24
  "@grafana/tsconfig": "^1.2.0-rc1",
25
+ "@playwright/test": "^1.41.2",
26
26
  "@swc/core": "^1.3.90",
27
27
  "@swc/helpers": "^0.5.0",
28
28
  "@swc/jest": "^0.2.26",
@@ -25,11 +25,15 @@ dist/
25
25
  artifacts/
26
26
  work/
27
27
  ci/
28
- e2e-results/
29
- **/cypress/videos
30
- **/cypress/report.json
28
+
29
+ # e2e test directories
30
+ /test-results/
31
+ /playwright-report/
32
+ /blob-report/
33
+ /playwright/.cache/
34
+ /playwright/.auth/
31
35
 
32
36
  # Editor
33
37
  .idea
34
38
 
35
- .eslintcache
39
+ .eslintcache
@@ -0,0 +1,51 @@
1
+ import { defineConfig, devices } from '@playwright/test';
2
+ import { dirname } from 'node:path';
3
+
4
+ const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`;
5
+
6
+ /**
7
+ * Read environment variables from file.
8
+ * https://github.com/motdotla/dotenv
9
+ */
10
+ // require('dotenv').config();
11
+
12
+ /**
13
+ * See https://playwright.dev/docs/test-configuration.
14
+ */
15
+ export default defineConfig({
16
+ testDir: './tests',
17
+ /* Run tests in files in parallel */
18
+ fullyParallel: true,
19
+ /* Fail the build on CI if you accidentally left test.only in the source code. */
20
+ forbidOnly: !!process.env.CI,
21
+ /* Retry on CI only */
22
+ retries: process.env.CI ? 2 : 0,
23
+ /* Opt out of parallel tests on CI. */
24
+ workers: process.env.CI ? 1 : undefined,
25
+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
26
+ reporter: 'html',
27
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
28
+ use: {
29
+ /* Base URL to use in actions like `await page.goto('/')`. */
30
+ baseURL: 'http://localhost:3000',
31
+
32
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
33
+ trace: 'on-first-retry',
34
+ },
35
+
36
+ /* Configure projects for major browsers */
37
+ projects: [
38
+ // 1. Login to Grafana and store the cookie on disk for use in other tests.
39
+ {
40
+ name: 'auth',
41
+ testDir: pluginE2eAuth,
42
+ testMatch: [/.*\.js/],
43
+ },
44
+ {
45
+ name: 'chromium',
46
+ use: { ...devices['Desktop Chrome'], storageState: 'playwright/.auth/admin.json' },
47
+ dependencies: ['auth'],
48
+ },
49
+ ],
50
+
51
+ });
@@ -0,0 +1,5 @@
1
+ import { test, expect } from '@grafana/plugin-e2e';
2
+
3
+ test('should load dashboard page', async ({ dashboardPage }) => {
4
+ expect(dashboardPage.ctx.page).toHaveTitle('New dashboard - Dashboards - Grafana');
5
+ });
@@ -74,15 +74,28 @@ jobs:
74
74
  - name: Check for E2E
75
75
  id: check-for-e2e
76
76
  run: |
77
- if [ -d "cypress" ]
77
+ if [ -f "playwright.config.ts"]
78
78
  then
79
79
  echo "has-e2e=true" >> $GITHUB_OUTPUT
80
80
  fi
81
81
 
82
+ - name: Install Playwright Browsers
83
+ if: steps.check-for-e2e.outputs.has-e2e == 'true'
84
+ run: {{ packageManagerName }} exec playwright install --with-deps
85
+
82
86
  - name: Start grafana docker
83
87
  if: steps.check-for-e2e.outputs.has-e2e == 'true'
84
88
  run: docker-compose up -d
85
89
 
90
+ - name: Wait for Grafana to start
91
+ if: steps.check-for-e2e.outputs.has-e2e == 'true'
92
+ uses: nev7n/wait_for_response@v1
93
+ with:
94
+ url: 'http://localhost:3000/'
95
+ responseCode: 200
96
+ timeout: 60000
97
+ interval: 500
98
+
86
99
  - name: Run e2e tests
87
100
  if: steps.check-for-e2e.outputs.has-e2e == 'true'
88
101
  run: {{ packageManagerName }} run e2e
@@ -95,8 +108,8 @@ jobs:
95
108
  uses: actions/upload-artifact@v4
96
109
  if: steps.check-for-e2e.outputs.has-e2e == 'true' && steps.run-e2e-tests.outcome != 'success'
97
110
  with:
98
- name: cypress-videos
99
- path: cypress/videos
111
+ name: playwright-report
112
+ path: playwright-report/
100
113
  retention-days: 5
101
114
 
102
115
  - name: Sign plugin
@@ -1,10 +0,0 @@
1
- import { e2e } from '@grafana/e2e';
2
-
3
- e2e.scenario({
4
- describeName: 'Smoke test',
5
- itName: 'Smoke test',
6
- scenario: () => {
7
- e2e.pages.Home.visit();
8
- e2e().contains('Welcome to Grafana').should('be.visible');
9
- },
10
- });