@grafana/create-plugin 6.1.13-canary.2313.19498365291.0 → 6.1.14
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 +24 -0
- package/dist/migrations/migrations.js +5 -0
- package/dist/migrations/scripts/007-remove-testing-library-types.js +25 -0
- package/package.json +2 -2
- package/src/migrations/migrations.ts +6 -0
- package/src/migrations/scripts/007-remove-testing-library-types.test.ts +137 -0
- package/src/migrations/scripts/007-remove-testing-library-types.ts +25 -0
- package/templates/common/.config/types/setupTests.d.ts +1 -0
- package/templates/common/_package.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
# v6.1.14 (Wed Nov 19 2025)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Create plugin: Update go templates [#2313](https://github.com/grafana/plugin-tools/pull/2313) ([@jackw](https://github.com/jackw))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Jack Westbrook ([@jackw](https://github.com/jackw))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# v6.1.13 (Wed Nov 19 2025)
|
|
14
|
+
|
|
15
|
+
#### 🐛 Bug Fix
|
|
16
|
+
|
|
17
|
+
- Create Plugin: remove types/testing-library__jest-dom [#2250](https://github.com/grafana/plugin-tools/pull/2250) ([@jackw](https://github.com/jackw))
|
|
18
|
+
|
|
19
|
+
#### Authors: 1
|
|
20
|
+
|
|
21
|
+
- Jack Westbrook ([@jackw](https://github.com/jackw))
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
1
25
|
# v6.1.12 (Mon Nov 17 2025)
|
|
2
26
|
|
|
3
27
|
#### 🐛 Bug Fix
|
|
@@ -31,6 +31,11 @@ var defaultMigrations = {
|
|
|
31
31
|
version: "6.1.11",
|
|
32
32
|
description: "Fix webpack variable replacement in nested plugins files.",
|
|
33
33
|
migrationScript: "./scripts/006-webpack-nested-fix.js"
|
|
34
|
+
},
|
|
35
|
+
"007-remove-testing-library-types": {
|
|
36
|
+
version: "6.1.13",
|
|
37
|
+
description: "Add setupTests.d.ts for @testing-library/jest-dom types and remove @types/testing-library__jest-dom npm package.",
|
|
38
|
+
migrationScript: "./scripts/007-remove-testing-library-types.js"
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isVersionGreater, removeDependenciesFromPackageJson } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
function migrate(context) {
|
|
4
|
+
if (context.doesFileExist("package.json")) {
|
|
5
|
+
const packageJson = JSON.parse(context.getFile("package.json") || "{}");
|
|
6
|
+
if (isVersionGreater(packageJson.devDependencies["@testing-library/jest-dom"], "6.0.0", true)) {
|
|
7
|
+
if (context.doesFileExist("./.config/types/setupTests.d.ts")) {
|
|
8
|
+
const setupTestsContent = context.getFile("./.config/types/setupTests.d.ts");
|
|
9
|
+
if (!setupTestsContent?.includes("@testing-library/jest-dom")) {
|
|
10
|
+
context.updateFile(
|
|
11
|
+
"./.config/types/setupTests.d.ts",
|
|
12
|
+
`import '@testing-library/jest-dom';
|
|
13
|
+
${setupTestsContent}`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
context.addFile("./.config/types/setupTests.d.ts", "import '@testing-library/jest-dom';\n");
|
|
18
|
+
}
|
|
19
|
+
removeDependenciesFromPackageJson(context, [], ["@types/testing-library__jest-dom"]);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { migrate as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.14",
|
|
4
4
|
"repository": {
|
|
5
5
|
"directory": "packages/create-plugin",
|
|
6
6
|
"url": "https://github.com/grafana/plugin-tools"
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=20"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "9216fe4caf37b8ccc977c987f0364d114241c8fb"
|
|
64
64
|
}
|
|
@@ -45,5 +45,11 @@ export default {
|
|
|
45
45
|
description: 'Fix webpack variable replacement in nested plugins files.',
|
|
46
46
|
migrationScript: './scripts/006-webpack-nested-fix.js',
|
|
47
47
|
},
|
|
48
|
+
'007-remove-testing-library-types': {
|
|
49
|
+
version: '6.1.13',
|
|
50
|
+
description:
|
|
51
|
+
'Add setupTests.d.ts for @testing-library/jest-dom types and remove @types/testing-library__jest-dom npm package.',
|
|
52
|
+
migrationScript: './scripts/007-remove-testing-library-types.js',
|
|
53
|
+
},
|
|
48
54
|
},
|
|
49
55
|
} as Migrations;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import migrate from './007-remove-testing-library-types.js';
|
|
3
|
+
import { Context } from '../context.js';
|
|
4
|
+
|
|
5
|
+
describe('006-remove-testing-library-types', () => {
|
|
6
|
+
it('should create setupTests.d.ts, remove types package, and add @testing-library/jest-dom when file does not exist', () => {
|
|
7
|
+
const context = new Context('/virtual');
|
|
8
|
+
|
|
9
|
+
context.addFile(
|
|
10
|
+
'package.json',
|
|
11
|
+
JSON.stringify({
|
|
12
|
+
devDependencies: {
|
|
13
|
+
'@types/testing-library__jest-dom': '^6.0.0',
|
|
14
|
+
'@testing-library/jest-dom': '6.0.0',
|
|
15
|
+
'@testing-library/react': '14.0.0',
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const result = migrate(context);
|
|
21
|
+
const setupTestsContent = result.getFile('./.config/types/setupTests.d.ts');
|
|
22
|
+
expect(setupTestsContent).toBe("import '@testing-library/jest-dom';\n");
|
|
23
|
+
|
|
24
|
+
const packageJson = JSON.parse(result.getFile('package.json') || '{}');
|
|
25
|
+
expect(packageJson.devDependencies).toEqual({
|
|
26
|
+
'@testing-library/jest-dom': '6.0.0',
|
|
27
|
+
'@testing-library/react': '14.0.0',
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should add import to existing setupTests.d.ts, remove types package, and add @testing-library/jest-dom if missing', () => {
|
|
32
|
+
const context = new Context('/virtual');
|
|
33
|
+
|
|
34
|
+
const existingContent = '// Some other type declarations\n';
|
|
35
|
+
context.addFile('./.config/types/setupTests.d.ts', existingContent);
|
|
36
|
+
context.addFile(
|
|
37
|
+
'package.json',
|
|
38
|
+
JSON.stringify({
|
|
39
|
+
devDependencies: {
|
|
40
|
+
'@types/testing-library__jest-dom': '^6.0.0',
|
|
41
|
+
'@testing-library/jest-dom': '6.1.4',
|
|
42
|
+
'@testing-library/react': '14.0.0',
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const result = migrate(context);
|
|
48
|
+
const setupTestsContent = result.getFile('./.config/types/setupTests.d.ts');
|
|
49
|
+
expect(setupTestsContent).toBe(`import '@testing-library/jest-dom';\n${existingContent}`);
|
|
50
|
+
|
|
51
|
+
const packageJson = JSON.parse(result.getFile('package.json') || '{}');
|
|
52
|
+
expect(packageJson.devDependencies).toEqual({
|
|
53
|
+
'@testing-library/jest-dom': '6.1.4',
|
|
54
|
+
'@testing-library/react': '14.0.0',
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should not modify setupTests.d.ts if import already exists', () => {
|
|
59
|
+
const context = new Context('/virtual');
|
|
60
|
+
|
|
61
|
+
const existingContent = "// Other content\nimport 'react';\nimport '@testing-library/jest-dom';\n";
|
|
62
|
+
context.addFile('./.config/types/setupTests.d.ts', existingContent);
|
|
63
|
+
context.addFile(
|
|
64
|
+
'package.json',
|
|
65
|
+
JSON.stringify({
|
|
66
|
+
devDependencies: {
|
|
67
|
+
'@types/testing-library__jest-dom': '^6.0.0',
|
|
68
|
+
'@testing-library/jest-dom': '6.1.4',
|
|
69
|
+
'@testing-library/react': '14.0.0',
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const result = migrate(context);
|
|
75
|
+
|
|
76
|
+
const setupTestsContent = result.getFile('./.config/types/setupTests.d.ts');
|
|
77
|
+
expect(setupTestsContent).toBe(existingContent);
|
|
78
|
+
|
|
79
|
+
const packageJson = JSON.parse(result.getFile('package.json') || '{}');
|
|
80
|
+
expect(packageJson.devDependencies).toEqual({
|
|
81
|
+
'@testing-library/jest-dom': '6.1.4',
|
|
82
|
+
'@testing-library/react': '14.0.0',
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should not modify anything if @testing-library/jest-dom is not greater than 6.0.0', () => {
|
|
87
|
+
const context = new Context('/virtual');
|
|
88
|
+
const packageJsonContent = JSON.stringify({
|
|
89
|
+
devDependencies: { '@testing-library/jest-dom': '5.14.2' },
|
|
90
|
+
});
|
|
91
|
+
context.addFile('package.json', packageJsonContent);
|
|
92
|
+
|
|
93
|
+
const result = migrate(context);
|
|
94
|
+
expect(result.getFile('package.json')).toEqual(packageJsonContent);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should handle package.json without the types package', () => {
|
|
98
|
+
const context = new Context('/virtual');
|
|
99
|
+
|
|
100
|
+
context.addFile(
|
|
101
|
+
'package.json',
|
|
102
|
+
JSON.stringify({
|
|
103
|
+
devDependencies: {
|
|
104
|
+
'@testing-library/react': '14.0.0',
|
|
105
|
+
'@testing-library/jest-dom': '6.1.4',
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const result = migrate(context);
|
|
111
|
+
const setupTestsContent = result.getFile('./.config/types/setupTests.d.ts');
|
|
112
|
+
expect(setupTestsContent).toBe("import '@testing-library/jest-dom';\n");
|
|
113
|
+
|
|
114
|
+
const packageJson = JSON.parse(result.getFile('package.json') || '{}');
|
|
115
|
+
expect(packageJson.devDependencies).toEqual({
|
|
116
|
+
'@testing-library/jest-dom': '6.1.4',
|
|
117
|
+
'@testing-library/react': '14.0.0',
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should be idempotent', async () => {
|
|
122
|
+
const context = new Context('/virtual');
|
|
123
|
+
|
|
124
|
+
context.addFile(
|
|
125
|
+
'package.json',
|
|
126
|
+
JSON.stringify({
|
|
127
|
+
devDependencies: {
|
|
128
|
+
'@types/testing-library__jest-dom': '^6.0.0',
|
|
129
|
+
'@testing-library/jest-dom': '6.1.4',
|
|
130
|
+
'@testing-library/react': '14.0.0',
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
await expect(migrate).toBeIdempotent(context);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Context } from '../context.js';
|
|
2
|
+
import { removeDependenciesFromPackageJson, isVersionGreater } from '../utils.js';
|
|
3
|
+
|
|
4
|
+
export default function migrate(context: Context) {
|
|
5
|
+
if (context.doesFileExist('package.json')) {
|
|
6
|
+
const packageJson = JSON.parse(context.getFile('package.json') || '{}');
|
|
7
|
+
if (isVersionGreater(packageJson.devDependencies['@testing-library/jest-dom'], '6.0.0', true)) {
|
|
8
|
+
if (context.doesFileExist('./.config/types/setupTests.d.ts')) {
|
|
9
|
+
const setupTestsContent = context.getFile('./.config/types/setupTests.d.ts');
|
|
10
|
+
if (!setupTestsContent?.includes('@testing-library/jest-dom')) {
|
|
11
|
+
context.updateFile(
|
|
12
|
+
'./.config/types/setupTests.d.ts',
|
|
13
|
+
`import '@testing-library/jest-dom';\n${setupTestsContent}`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
context.addFile('./.config/types/setupTests.d.ts', "import '@testing-library/jest-dom';\n");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
removeDependenciesFromPackageJson(context, [], ['@types/testing-library__jest-dom']);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"@types/react": "^18.3.0",
|
|
34
34
|
"@types/react-dom": "^18.3.0",{{#if isAppType}}{{#unless useReactRouterV6}}
|
|
35
35
|
"@types/react-router-dom": "^{{ reactRouterVersion }}",{{/unless}}{{/if}}
|
|
36
|
-
"@types/testing-library__jest-dom": "5.14.8",
|
|
37
36
|
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
|
38
37
|
"@typescript-eslint/parser": "^8.3.0",{{#unless useExperimentalRspack}}
|
|
39
38
|
"copy-webpack-plugin": "^11.0.0",{{/unless}}
|