@grafana/create-plugin 6.2.0-canary.2233.19368311379.0 → 6.2.0-canary.2233.19500011348.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/codemods/additions/additions.js +2 -4
  3. package/dist/codemods/additions/scripts/example-addition.js +1 -1
  4. package/dist/codemods/migrations/migrations.js +17 -6
  5. package/dist/codemods/migrations/scripts/004-eslint9-flat-config.js +2 -2
  6. package/dist/codemods/migrations/scripts/006-webpack-nested-fix.js +80 -0
  7. package/dist/codemods/migrations/scripts/007-remove-testing-library-types.js +25 -0
  8. package/dist/codemods/runner.js +0 -5
  9. package/dist/codemods/utils.js +5 -8
  10. package/dist/commands/add.command.js +0 -4
  11. package/package.json +3 -2
  12. package/src/codemods/additions/additions.test.ts +9 -4
  13. package/src/codemods/additions/additions.ts +2 -3
  14. package/src/codemods/additions/scripts/example-addition.test.ts +1 -1
  15. package/src/codemods/additions/scripts/example-addition.ts +1 -1
  16. package/src/codemods/migrations/manager.test.ts +1 -1
  17. package/src/codemods/migrations/migrations.test.ts +4 -2
  18. package/src/codemods/migrations/migrations.ts +18 -6
  19. package/src/codemods/migrations/scripts/004-eslint9-flat-config.ts +2 -3
  20. package/src/codemods/migrations/scripts/006-webpack-nested-fix.test.ts +169 -0
  21. package/src/codemods/migrations/scripts/006-webpack-nested-fix.ts +117 -0
  22. package/src/codemods/migrations/scripts/007-remove-testing-library-types.test.ts +137 -0
  23. package/src/codemods/migrations/scripts/007-remove-testing-library-types.ts +25 -0
  24. package/src/codemods/runner.ts +0 -6
  25. package/src/codemods/utils.ts +4 -14
  26. package/src/commands/add.command.ts +0 -5
  27. package/src/utils/utils.config.ts +2 -2
  28. package/templates/backend/go.mod +67 -47
  29. package/templates/backend/go.sum +197 -222
  30. package/templates/backend-app/go.mod +67 -48
  31. package/templates/backend-app/go.sum +197 -222
  32. package/templates/common/.config/types/setupTests.d.ts +1 -0
  33. package/templates/common/.config/webpack/webpack.config.ts +1 -1
  34. package/templates/common/_package.json +0 -1
  35. package/dist/codemods/migrations/scripts/example-migration.js +0 -29
  36. package/src/codemods/migrations/scripts/example-migration.test.ts +0 -40
  37. package/src/codemods/migrations/scripts/example-migration.ts +0 -51
  38. package/src/migrations/migrations.ts +0 -44
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -187,7 +187,7 @@ const config = async (env: Env): Promise<Configuration> => {
187
187
  new ReplaceInFileWebpackPlugin([
188
188
  {
189
189
  dir: DIST_DIR,
190
- files: ['plugin.json', 'README.md'],
190
+ test: [/(^|\/)plugin\.json$/, /(^|\/)README\.md$/],
191
191
  rules: [
192
192
  {
193
193
  search: /\%VERSION\%/g,
@@ -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}}
@@ -1,29 +0,0 @@
1
- function migrate(context, options = {}) {
2
- const { profile = false, skipBackup = false, verbose = false } = options;
3
- if (verbose) {
4
- console.log("Running migration with options:", options);
5
- }
6
- const rawPkgJson = context.getFile("./package.json") ?? "{}";
7
- const packageJson = JSON.parse(rawPkgJson);
8
- if (packageJson.scripts && packageJson.scripts.build) {
9
- const buildScript = packageJson.scripts.build;
10
- const pattern = /(webpack.+-c\s.+\.ts)\s(.+)/;
11
- if (profile && pattern.test(buildScript) && !buildScript.includes("--profile")) {
12
- packageJson.scripts.build = buildScript.replace(pattern, `$1 --profile $2`);
13
- }
14
- context.updateFile("./package.json", JSON.stringify(packageJson, null, 2));
15
- }
16
- if (!skipBackup && context.doesFileExist("./src/README.md")) {
17
- context.deleteFile("./src/README.md");
18
- }
19
- if (!context.doesFileExist("./src/foo.json")) {
20
- context.addFile("./src/foo.json", JSON.stringify({ foo: "bar" }));
21
- }
22
- if (context.doesFileExist(".eslintrc")) {
23
- context.renameFile(".eslintrc", ".eslint.config.json");
24
- }
25
- context.readDir("./src");
26
- return context;
27
- }
28
-
29
- export { migrate as default };
@@ -1,40 +0,0 @@
1
- import migrate from './example-migration.js';
2
- import { createDefaultContext } from '../../test-utils.js';
3
-
4
- describe('Migration - append profile to webpack', () => {
5
- test('should update the package.json', async () => {
6
- const context = createDefaultContext();
7
-
8
- context.updateFile(
9
- './package.json',
10
- JSON.stringify({
11
- scripts: {
12
- build: 'webpack -c ./.config/webpack/webpack.config.ts --env production',
13
- },
14
- })
15
- );
16
-
17
- const updatedContext = await migrate(context, { profile: true, skipBackup: false, verbose: false });
18
-
19
- expect(updatedContext.getFile('./package.json')).toMatch(
20
- 'webpack -c ./.config/webpack/webpack.config.ts --profile --env production'
21
- );
22
-
23
- expect(updatedContext.readDir('./src')).toEqual(['src/FOO.md', 'src/foo.json']);
24
- });
25
-
26
- it('should not make additional changes when run multiple times', async () => {
27
- const context = await createDefaultContext();
28
-
29
- await context.updateFile(
30
- './package.json',
31
- JSON.stringify({
32
- scripts: {
33
- build: 'webpack -c ./.config/webpack/webpack.config.ts --env production',
34
- },
35
- })
36
- );
37
-
38
- await expect(migrate).toBeIdempotent(context);
39
- });
40
- });
@@ -1,51 +0,0 @@
1
- import type { Context } from '../../context.js';
2
-
3
- /**
4
- * Example migration that demonstrates basic context operations
5
- * This example shows how to modify package.json, add/delete files, and rename files
6
- */
7
-
8
- type MigrateOptions = {
9
- profile?: boolean;
10
- skipBackup?: boolean;
11
- verbose?: boolean;
12
- };
13
-
14
- export default function migrate(context: Context, options: MigrateOptions = {}): Context {
15
- const { profile = false, skipBackup = false, verbose = false } = options;
16
-
17
- if (verbose) {
18
- console.log('Running migration with options:', options);
19
- }
20
-
21
- const rawPkgJson = context.getFile('./package.json') ?? '{}';
22
- const packageJson = JSON.parse(rawPkgJson);
23
-
24
- if (packageJson.scripts && packageJson.scripts.build) {
25
- const buildScript = packageJson.scripts.build;
26
-
27
- const pattern = /(webpack.+-c\s.+\.ts)\s(.+)/;
28
-
29
- if (profile && pattern.test(buildScript) && !buildScript.includes('--profile')) {
30
- packageJson.scripts.build = buildScript.replace(pattern, `$1 --profile $2`);
31
- }
32
-
33
- context.updateFile('./package.json', JSON.stringify(packageJson, null, 2));
34
- }
35
-
36
- if (!skipBackup && context.doesFileExist('./src/README.md')) {
37
- context.deleteFile('./src/README.md');
38
- }
39
-
40
- if (!context.doesFileExist('./src/foo.json')) {
41
- context.addFile('./src/foo.json', JSON.stringify({ foo: 'bar' }));
42
- }
43
-
44
- if (context.doesFileExist('.eslintrc')) {
45
- context.renameFile('.eslintrc', '.eslint.config.json');
46
- }
47
-
48
- context.readDir('./src');
49
-
50
- return context;
51
- }
@@ -1,44 +0,0 @@
1
- import { LEGACY_UPDATE_CUTOFF_VERSION } from '../constants.js';
2
-
3
- export type MigrationMeta = {
4
- version: string;
5
- description: string;
6
- migrationScript: string;
7
- };
8
-
9
- type Migrations = {
10
- migrations: Record<string, MigrationMeta>;
11
- };
12
-
13
- // Do not use LEGACY_UPDATE_CUTOFF_VERSION for new migrations. It was used to force migrations to run
14
- // for those written before the switch to updates as migrations.
15
- export default {
16
- migrations: {
17
- '001-update-grafana-compose-extend': {
18
- version: LEGACY_UPDATE_CUTOFF_VERSION,
19
- description: 'Update ./docker-compose.yaml to extend from ./.config/docker-compose-base.yaml.',
20
- migrationScript: './scripts/001-update-grafana-compose-extend.js',
21
- },
22
- '002-update-is-compatible-workflow': {
23
- version: LEGACY_UPDATE_CUTOFF_VERSION,
24
- description:
25
- 'Update ./.github/workflows/is-compatible.yml to use is-compatible github action instead of calling levitate directly',
26
- migrationScript: './scripts/002-update-is-compatible-workflow.js',
27
- },
28
- '003-update-eslint-deprecation-rule': {
29
- version: LEGACY_UPDATE_CUTOFF_VERSION,
30
- description: 'Replace deprecated eslint-plugin-deprecation with @typescript-eslint/no-deprecated rule.',
31
- migrationScript: './scripts/003-update-eslint-deprecation-rule.js',
32
- },
33
- '004-eslint9-flat-config': {
34
- version: LEGACY_UPDATE_CUTOFF_VERSION,
35
- description: 'Migrate eslint config to flat config format and update devDependencies to latest versions.',
36
- migrationScript: './scripts/004-eslint9-flat-config.js',
37
- },
38
- '005-react-18-3': {
39
- version: '6.1.9',
40
- description: 'Update React and ReactDOM 18.x versions to ^18.3.0 to surface React 19 compatibility issues.',
41
- migrationScript: './scripts/005-react-18-3.js',
42
- },
43
- },
44
- } as Migrations;