@grafana/create-plugin 6.2.0-canary.2283.19173715977.0 → 6.2.0-canary.2283.19225164741.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.
@@ -24,7 +24,7 @@ var defaultMigrations = {
24
24
  },
25
25
  "005-react-18-3": {
26
26
  version: "6.1.7-beta.1",
27
- description: "Update React 18.0.0 to 18.3.1.",
27
+ description: "Update React and ReactDOM 18.x versions to ^18.3.0 to surface React 19 compatibility issues.",
28
28
  migrationScript: "./scripts/005-react-18-3.js"
29
29
  }
30
30
  }
@@ -5,12 +5,12 @@ function migrate(context) {
5
5
  const packageJson = JSON.parse(context.getFile("package.json") || "{}");
6
6
  if (packageJson.dependencies?.react) {
7
7
  if (isVersionGreater(packageJson.dependencies.react, "18.0.0", true)) {
8
- addDependenciesToPackageJson(context, { react: "^18.3.1" }, { "@types/react": "^18.3.1" });
8
+ addDependenciesToPackageJson(context, { react: "^18.3.0" }, { "@types/react": "^18.3.0" });
9
9
  }
10
10
  }
11
11
  if (packageJson.dependencies?.["react-dom"]) {
12
12
  if (isVersionGreater(packageJson.dependencies["react-dom"], "18.0.0", true)) {
13
- addDependenciesToPackageJson(context, { "react-dom": "^18.3.1" }, { "@types/react-dom": "^18.3.1" });
13
+ addDependenciesToPackageJson(context, { "react-dom": "^18.3.0" }, { "@types/react-dom": "^18.3.0" });
14
14
  }
15
15
  }
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "6.2.0-canary.2283.19173715977.0",
3
+ "version": "6.2.0-canary.2283.19225164741.0",
4
4
  "repository": {
5
5
  "directory": "packages/create-plugin",
6
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -59,5 +59,5 @@
59
59
  "engines": {
60
60
  "node": ">=20"
61
61
  },
62
- "gitHead": "d05bd68a9727b078ce0c15029a1dbc86644714d3"
62
+ "gitHead": "2771e041152fce899b6ecbbf3a37dce085a4a563"
63
63
  }
@@ -117,14 +117,14 @@ describe('Migrations', () => {
117
117
  const mockContext = new Context('/virtual');
118
118
  const migrationFn = vi.fn().mockResolvedValue(mockContext);
119
119
 
120
- vi.doMock('./test-migration.js', () => ({
120
+ vi.doMock('virtual-test-migration.js', () => ({
121
121
  default: migrationFn,
122
122
  }));
123
123
 
124
124
  const migration: MigrationMeta = {
125
125
  version: '1.0.0',
126
126
  description: 'test migration',
127
- migrationScript: './test-migration.js',
127
+ migrationScript: 'virtual-test-migration.js',
128
128
  };
129
129
 
130
130
  const result = await runMigration(migration, mockContext);
@@ -139,10 +139,10 @@ describe('Migrations', () => {
139
139
  const migrationTwoFn = vi.fn();
140
140
  const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => undefined);
141
141
 
142
- vi.doMock('./migration-one.js', () => ({
142
+ vi.doMock('virtual-test-migration.js', async () => ({
143
143
  default: migrationOneFn,
144
144
  }));
145
- vi.doMock('./migration-two.js', () => ({
145
+ vi.doMock('virtual-test-migration2.js', async () => ({
146
146
  default: migrationTwoFn,
147
147
  }));
148
148
 
@@ -150,12 +150,12 @@ describe('Migrations', () => {
150
150
  'migration-one': {
151
151
  version: '1.0.0',
152
152
  description: '...',
153
- migrationScript: './migration-one.js',
153
+ migrationScript: 'virtual-test-migration.js',
154
154
  },
155
155
  'migration-two': {
156
156
  version: '1.2.0',
157
157
  description: '...',
158
- migrationScript: './migration-two.js',
158
+ migrationScript: 'virtual-test-migration2.js',
159
159
  },
160
160
  };
161
161
 
@@ -203,7 +203,7 @@ describe('Migrations', () => {
203
203
  it('should commit the changes for each migration if the CLI arg is present', async () => {
204
204
  await runMigrations(migrations, { commitEachMigration: true });
205
205
 
206
- expect(gitCommitNoVerify).toHaveBeenCalledTimes(3);
206
+ expect(gitCommitNoVerify).toHaveBeenCalledTimes(2);
207
207
  });
208
208
 
209
209
  it('should not create a commit for a migration that has no changes', async () => {
@@ -211,7 +211,7 @@ describe('Migrations', () => {
211
211
 
212
212
  await runMigrations(migrations, { commitEachMigration: true });
213
213
 
214
- expect(gitCommitNoVerify).toHaveBeenCalledTimes(2);
214
+ expect(gitCommitNoVerify).toHaveBeenCalledTimes(1);
215
215
  });
216
216
 
217
217
  it('should update version in ".config/.cprc.json" on a successful update', async () => {
@@ -1,12 +1,16 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
1
3
  import defaultMigrations from './migrations.js';
2
4
 
3
5
  describe('migrations json', () => {
4
6
  // As migration scripts are imported dynamically when update is run we assert the path is valid
7
+ // Vitest 4 reimplemented it's workers which caused the previous dynamic import tests to fail.
8
+ // This test now only asserts that the source file exists.
5
9
  Object.entries(defaultMigrations.migrations).forEach(([key, migration]) => {
6
10
  it(`should have a valid migration script path for ${key}`, () => {
7
- expect(async () => {
8
- await import(migration.migrationScript);
9
- }).not.toThrow();
11
+ const migrationPathString = migration.migrationScript.replace('.js', '.ts');
12
+ const path = join(__dirname, migrationPathString);
13
+ expect(existsSync(path)).toBe(true);
10
14
  });
11
15
  });
12
16
  });
@@ -37,7 +37,7 @@ export default {
37
37
  },
38
38
  '005-react-18-3': {
39
39
  version: '6.1.7-beta.1',
40
- description: 'Update React 18.0.0 to 18.3.1.',
40
+ description: 'Update React and ReactDOM 18.x versions to ^18.3.0 to surface React 19 compatibility issues.',
41
41
  migrationScript: './scripts/005-react-18-3.js',
42
42
  },
43
43
  },
@@ -44,30 +44,7 @@ describe('005-react-18-3', () => {
44
44
  expect(context.getFile('./package.json')).toBe(initialPackageJson);
45
45
  });
46
46
 
47
- it('should not downgrade React 19.0.0 to 18.3.1', async () => {
48
- const context = new Context('/virtual');
49
- const packageJson = {
50
- dependencies: {
51
- react: '^19.0.0',
52
- 'react-dom': '^19.0.0',
53
- },
54
- devDependencies: {
55
- '@types/react': '^19.0.0',
56
- '@types/react-dom': '^19.0.0',
57
- },
58
- };
59
- context.addFile('./package.json', JSON.stringify(packageJson, null, 2));
60
-
61
- await migrate(context);
62
-
63
- const updatedPackageJson = JSON.parse(context.getFile('./package.json') || '{}');
64
- expect(updatedPackageJson.dependencies.react).toBe('^19.0.0');
65
- expect(updatedPackageJson.dependencies['react-dom']).toBe('^19.0.0');
66
- expect(updatedPackageJson.devDependencies['@types/react']).toBe('^19.0.0');
67
- expect(updatedPackageJson.devDependencies['@types/react-dom']).toBe('^19.0.0');
68
- });
69
-
70
- it('should update React 18.0.0 to 18.3.1', async () => {
47
+ it('should update React 18.0.0 to ^18.3.0', async () => {
71
48
  const context = new Context('/virtual');
72
49
  context.addFile(
73
50
  './package.json',
@@ -81,31 +58,52 @@ describe('005-react-18-3', () => {
81
58
  await migrate(context);
82
59
 
83
60
  const updatedPackageJson = JSON.parse(context.getFile('./package.json') || '{}');
84
- expect(updatedPackageJson.dependencies.react).toBe('^18.3.1');
85
- expect(updatedPackageJson.devDependencies?.['@types/react']).toBe('^18.3.1');
61
+ expect(updatedPackageJson.dependencies.react).toBe('^18.3.0');
62
+ expect(updatedPackageJson.devDependencies?.['@types/react']).toBe('^18.3.0');
86
63
  });
87
64
 
88
- it('should not update React if version is already 18.3.1 or higher', async () => {
65
+ it('should not update React if version is already 18.3.0 or higher', async () => {
89
66
  const context = new Context('/virtual');
90
67
  const packageJson = {
91
68
  dependencies: {
92
- react: '^18.3.1',
93
- 'react-dom': '^18.3.1',
69
+ react: '^18.3.0',
70
+ 'react-dom': '^18.3.0',
94
71
  },
95
72
  devDependencies: {
96
- '@types/react': '^18.3.1',
97
- '@types/react-dom': '^18.3.1',
73
+ '@types/react': '^18.3.0',
74
+ '@types/react-dom': '^18.3.0',
98
75
  },
99
76
  };
100
77
  context.addFile('./package.json', JSON.stringify(packageJson, null, 2));
101
78
 
102
79
  await migrate(context);
103
80
 
104
- // Since the versions are already 18.3.1, the migration should still run
105
- // but the versions should remain 18.3.1
106
81
  const updatedPackageJson = JSON.parse(context.getFile('./package.json') || '{}');
107
- expect(updatedPackageJson.dependencies.react).toBe('^18.3.1');
108
- expect(updatedPackageJson.dependencies['react-dom']).toBe('^18.3.1');
82
+ expect(updatedPackageJson.dependencies.react).toBe('^18.3.0');
83
+ expect(updatedPackageJson.dependencies['react-dom']).toBe('^18.3.0');
84
+ });
85
+
86
+ it('should not downgrade React 19.0.0 to 18.3.0', async () => {
87
+ const context = new Context('/virtual');
88
+ const packageJson = {
89
+ dependencies: {
90
+ react: '^19.0.0',
91
+ 'react-dom': '^19.0.0',
92
+ },
93
+ devDependencies: {
94
+ '@types/react': '^19.0.0',
95
+ '@types/react-dom': '^19.0.0',
96
+ },
97
+ };
98
+ context.addFile('./package.json', JSON.stringify(packageJson, null, 2));
99
+
100
+ await migrate(context);
101
+
102
+ const updatedPackageJson = JSON.parse(context.getFile('./package.json') || '{}');
103
+ expect(updatedPackageJson.dependencies.react).toBe('^19.0.0');
104
+ expect(updatedPackageJson.dependencies['react-dom']).toBe('^19.0.0');
105
+ expect(updatedPackageJson.devDependencies['@types/react']).toBe('^19.0.0');
106
+ expect(updatedPackageJson.devDependencies['@types/react-dom']).toBe('^19.0.0');
109
107
  });
110
108
 
111
109
  it('should handle version ranges correctly', async () => {
@@ -123,8 +121,8 @@ describe('005-react-18-3', () => {
123
121
  await migrate(context);
124
122
 
125
123
  const updatedPackageJson = JSON.parse(context.getFile('./package.json') || '{}');
126
- expect(updatedPackageJson.dependencies.react).toBe('^18.3.1');
127
- expect(updatedPackageJson.dependencies['react-dom']).toBe('^18.3.1');
124
+ expect(updatedPackageJson.dependencies.react).toBe('^18.3.0');
125
+ expect(updatedPackageJson.dependencies['react-dom']).toBe('^18.3.0');
128
126
  });
129
127
 
130
128
  it('should be idempotent', async () => {
@@ -6,12 +6,12 @@ export default function migrate(context: Context) {
6
6
  const packageJson = JSON.parse(context.getFile('package.json') || '{}');
7
7
  if (packageJson.dependencies?.react) {
8
8
  if (isVersionGreater(packageJson.dependencies.react, '18.0.0', true)) {
9
- addDependenciesToPackageJson(context, { react: '^18.3.1' }, { '@types/react': '^18.3.1' });
9
+ addDependenciesToPackageJson(context, { react: '^18.3.0' }, { '@types/react': '^18.3.0' });
10
10
  }
11
11
  }
12
12
  if (packageJson.dependencies?.['react-dom']) {
13
13
  if (isVersionGreater(packageJson.dependencies['react-dom'], '18.0.0', true)) {
14
- addDependenciesToPackageJson(context, { 'react-dom': '^18.3.1' }, { '@types/react-dom': '^18.3.1' });
14
+ addDependenciesToPackageJson(context, { 'react-dom': '^18.3.0' }, { '@types/react-dom': '^18.3.0' });
15
15
  }
16
16
  }
17
17
  }
package/vitest.config.ts CHANGED
@@ -9,5 +9,17 @@ export default mergeConfig(
9
9
  root: resolve(__dirname),
10
10
  setupFiles: ['./vitest.setup.ts'],
11
11
  },
12
+ plugins: [
13
+ // This plugin is used to convince Vitest the mocked virtual migrations exist.
14
+ // https://vitest.dev/guide/mocking/modules.html#mocking-non-existing-module
15
+ {
16
+ name: 'virtual-migrations',
17
+ resolveId(id) {
18
+ if (id === 'virtual-test-migration.js' || id === 'virtual-test-migration2.js') {
19
+ return id;
20
+ }
21
+ },
22
+ },
23
+ ],
12
24
  })
13
25
  );