@grafana/create-plugin 6.2.0-canary.2233.18946638834.0 → 6.2.0-canary.2233.19095991328.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 (59) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/{additions → codemods/additions}/manager.js +23 -24
  3. package/dist/{additions → codemods/additions}/scripts/add-i18n.js +2 -2
  4. package/dist/codemods/additions/utils.js +10 -0
  5. package/dist/{migrations → codemods}/context.js +3 -2
  6. package/dist/{migrations → codemods/migrations}/manager.js +8 -7
  7. package/dist/{migrations → codemods/migrations}/migrations.js +1 -1
  8. package/dist/{migrations → codemods/migrations}/scripts/003-update-eslint-deprecation-rule.js +1 -1
  9. package/dist/{migrations → codemods/migrations}/scripts/004-eslint9-flat-config.js +2 -1
  10. package/dist/codemods/migrations/utils.js +10 -0
  11. package/dist/{migrations → codemods}/utils.js +3 -17
  12. package/dist/commands/add.command.js +2 -2
  13. package/dist/commands/update.command.js +1 -1
  14. package/package.json +3 -5
  15. package/src/{additions → codemods/additions}/manager.ts +27 -40
  16. package/src/{additions → codemods/additions}/scripts/add-i18n.test.ts +1 -1
  17. package/src/{additions → codemods/additions}/scripts/add-i18n.ts +5 -5
  18. package/src/codemods/additions/utils.ts +12 -0
  19. package/src/{migrations → codemods}/context.test.ts +10 -10
  20. package/src/{migrations → codemods}/context.ts +4 -2
  21. package/src/{migrations → codemods/migrations}/manager.test.ts +15 -10
  22. package/src/{migrations → codemods/migrations}/manager.ts +10 -9
  23. package/src/{migrations → codemods/migrations}/migrations.ts +1 -1
  24. package/src/{migrations → codemods/migrations}/scripts/001-update-grafana-compose-extend.test.ts +1 -1
  25. package/src/{migrations → codemods/migrations}/scripts/001-update-grafana-compose-extend.ts +1 -1
  26. package/src/{migrations → codemods/migrations}/scripts/002-update-is-compatible-workflow.test.ts +1 -1
  27. package/src/{migrations → codemods/migrations}/scripts/002-update-is-compatible-workflow.ts +1 -1
  28. package/src/{migrations → codemods/migrations}/scripts/003-update-eslint-deprecation-rule.test.ts +1 -1
  29. package/src/{migrations → codemods/migrations}/scripts/003-update-eslint-deprecation-rule.ts +2 -2
  30. package/src/{migrations → codemods/migrations}/scripts/004-eslint9-flat-config.test.ts +1 -1
  31. package/src/{migrations → codemods/migrations}/scripts/004-eslint9-flat-config.ts +3 -2
  32. package/src/{migrations → codemods/migrations}/scripts/example-migration.test.ts +1 -1
  33. package/src/{migrations → codemods/migrations}/scripts/example-migration.ts +1 -1
  34. package/src/{migrations → codemods/migrations}/utils.test.ts +4 -4
  35. package/src/codemods/migrations/utils.ts +12 -0
  36. package/src/codemods/types.ts +21 -0
  37. package/src/{migrations → codemods}/utils.ts +35 -22
  38. package/src/commands/add.command.ts +2 -2
  39. package/src/commands/update.command.ts +1 -1
  40. package/src/utils/utils.config.ts +3 -3
  41. package/templates/common/.config/docker-compose-base.yaml +1 -1
  42. package/templates/common/_package.json +7 -7
  43. package/templates/github/workflows/bundle-stats.yml +1 -1
  44. package/templates/github/workflows/ci.yml +4 -4
  45. package/templates/github/workflows/cp-update.yml +1 -1
  46. package/templates/github/workflows/is-compatible.yml +1 -1
  47. package/templates/github/workflows/release.yml +1 -1
  48. package/dist/additions/utils.js +0 -28
  49. package/src/additions/utils.ts +0 -39
  50. /package/dist/{additions → codemods/additions}/additions.js +0 -0
  51. /package/dist/{migrations → codemods/migrations}/scripts/001-update-grafana-compose-extend.js +0 -0
  52. /package/dist/{migrations → codemods/migrations}/scripts/002-update-is-compatible-workflow.js +0 -0
  53. /package/dist/{migrations → codemods/migrations}/scripts/example-migration.js +0 -0
  54. /package/src/{additions → codemods/additions}/additions.ts +0 -0
  55. /package/src/{migrations → codemods/migrations}/fixtures/foo/bar.ts +0 -0
  56. /package/src/{migrations → codemods/migrations}/fixtures/foo/baz.ts +0 -0
  57. /package/src/{migrations → codemods/migrations}/fixtures/migrations.ts +0 -0
  58. /package/src/{migrations → codemods/migrations}/migrations.test.ts +0 -0
  59. /package/src/{migrations → codemods}/test-utils.ts +0 -0
@@ -1,6 +1,8 @@
1
1
  import { constants, accessSync, readFileSync, readdirSync } from 'node:fs';
2
2
  import { relative, normalize, join, dirname } from 'node:path';
3
- import { migrationsDebug } from './utils.js';
3
+ import { debug } from '../utils/utils.cli.js';
4
+
5
+ const codemodsDebug = debug.extend('codemods');
4
6
 
5
7
  export type ContextFile = Record<
6
8
  string,
@@ -58,7 +60,7 @@ export class Context {
58
60
  if (originalContent !== content) {
59
61
  this.files[path] = { content, changeType: 'update' };
60
62
  } else {
61
- migrationsDebug(`Context.updateFile() - no updates for ${filePath}`);
63
+ codemodsDebug(`Context.updateFile() - no updates for ${filePath}`);
62
64
  }
63
65
  }
64
66
 
@@ -1,22 +1,27 @@
1
- import { vi } from 'vitest';
1
+ import { flushChanges, formatFiles } from '../utils.js';
2
2
  import { getMigrationsToRun, runMigration, runMigrations } from './manager.js';
3
- import migrationFixtures from './fixtures/migrations.js';
4
- import { Context } from './context.js';
5
- import { gitCommitNoVerify } from '../utils/utils.git.js';
6
- import { flushChanges, printChanges, formatFiles } from './utils.js';
7
- import { setRootConfig } from '../utils/utils.config.js';
3
+
4
+ import { Context } from '../context.js';
8
5
  import { MigrationMeta } from './migrations.js';
6
+ import { gitCommitNoVerify } from '../../utils/utils.git.js';
7
+ import migrationFixtures from './fixtures/migrations.js';
8
+ import { printChanges } from './utils.js';
9
+ import { setRootConfig } from '../../utils/utils.config.js';
10
+ import { vi } from 'vitest';
9
11
 
10
12
  vi.mock('./utils.js', () => ({
11
- flushChanges: vi.fn(),
12
13
  printChanges: vi.fn(),
13
14
  migrationsDebug: vi.fn(),
15
+ }));
16
+
17
+ vi.mock('../utils.js', () => ({
18
+ flushChanges: vi.fn(),
14
19
  formatFiles: vi.fn(),
15
20
  installNPMDependencies: vi.fn(),
16
21
  }));
17
22
 
18
23
  // Silence terminal output during tests.
19
- vi.mock('../utils/utils.console.js', () => ({
24
+ vi.mock('../../utils/utils.console.js', () => ({
20
25
  output: {
21
26
  log: vi.fn(),
22
27
  addHorizontalLine: vi.fn(),
@@ -25,10 +30,10 @@ vi.mock('../utils/utils.console.js', () => ({
25
30
  },
26
31
  }));
27
32
 
28
- vi.mock('../utils/utils.config.js', () => ({
33
+ vi.mock('../../utils/utils.config.js', () => ({
29
34
  setRootConfig: vi.fn(),
30
35
  }));
31
- vi.mock('../utils/utils.git.js', () => ({
36
+ vi.mock('../../utils/utils.git.js', () => ({
32
37
  gitCommitNoVerify: vi.fn(),
33
38
  }));
34
39
 
@@ -1,13 +1,14 @@
1
- import { satisfies, gte } from 'semver';
2
- import { Context } from './context.js';
3
1
  import defaultMigrations, { MigrationMeta } from './migrations.js';
4
- import { flushChanges, printChanges, migrationsDebug, formatFiles, installNPMDependencies } from './utils.js';
5
- import { gitCommitNoVerify } from '../utils/utils.git.js';
6
- import { setRootConfig } from '../utils/utils.config.js';
7
- import { output } from '../utils/utils.console.js';
8
- import { CURRENT_APP_VERSION } from '../utils/utils.version.js';
2
+ import { flushChanges, formatFiles, installNPMDependencies } from '../utils.js';
3
+ import { gte, satisfies } from 'semver';
4
+ import { migrationsDebug, printChanges } from './utils.js';
9
5
 
10
- export type MigrationFn = (context: Context) => Context | Promise<Context>;
6
+ import { CURRENT_APP_VERSION } from '../../utils/utils.version.js';
7
+ import { Context } from '../context.js';
8
+ import type { MigrationModule } from '../types.js';
9
+ import { gitCommitNoVerify } from '../../utils/utils.git.js';
10
+ import { output } from '../../utils/utils.console.js';
11
+ import { setRootConfig } from '../../utils/utils.config.js';
11
12
 
12
13
  export function getMigrationsToRun(
13
14
  fromVersion: string,
@@ -76,7 +77,7 @@ export async function runMigrations(migrations: Record<string, MigrationMeta>, o
76
77
  }
77
78
 
78
79
  export async function runMigration(migration: MigrationMeta, context: Context): Promise<Context> {
79
- const module: { default: MigrationFn } = await import(migration.migrationScript);
80
+ const module = (await import(migration.migrationScript)) as MigrationModule;
80
81
 
81
82
  return module.default(context);
82
83
  }
@@ -1,4 +1,4 @@
1
- import { LEGACY_UPDATE_CUTOFF_VERSION } from '../constants.js';
1
+ import { LEGACY_UPDATE_CUTOFF_VERSION } from '../../constants.js';
2
2
 
3
3
  export type MigrationMeta = {
4
4
  version: string;
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { Context } from '../context.js';
2
+ import { Context } from '../../context.js';
3
3
  import migrate from './001-update-grafana-compose-extend.js';
4
4
  import { parse, stringify } from 'yaml';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'node:path';
2
- import { type Context } from '../context.js';
2
+ import { type Context } from '../../context.js';
3
3
  import { Node, Pair, parseDocument, Scalar, stringify, visit, YAMLMap, Document, YAMLSeq, visitorFn } from 'yaml';
4
4
 
5
5
  export default async function migrate(context: Context) {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { Context } from '../context.js';
2
+ import { Context } from '../../context.js';
3
3
  import migrate from './002-update-is-compatible-workflow.js';
4
4
  import { parse } from 'yaml';
5
5
 
@@ -1,4 +1,4 @@
1
- import { type Context } from '../context.js';
1
+ import { type Context } from '../../context.js';
2
2
  import { parseDocument, stringify, YAMLSeq } from 'yaml';
3
3
 
4
4
  export default async function migrate(context: Context) {
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import migrate from './003-update-eslint-deprecation-rule.js';
3
- import { Context } from '../context.js';
3
+ import { Context } from '../../context.js';
4
4
 
5
5
  describe('003-update-eslint-deprecation-rule', () => {
6
6
  it('should not update ESLint config if no deprecation rule is present', () => {
@@ -1,5 +1,5 @@
1
- import type { Context } from '../context.js';
2
- import { addDependenciesToPackageJson, removeDependenciesFromPackageJson } from '../utils.js';
1
+ import type { Context } from '../../context.js';
2
+ import { addDependenciesToPackageJson, removeDependenciesFromPackageJson } from '../../utils.js';
3
3
 
4
4
  export default function migrate(context: Context) {
5
5
  if (context.doesFileExist('.config/.eslintrc') && context.doesFileExist('package.json')) {
@@ -1,5 +1,5 @@
1
1
  import migrate from './004-eslint9-flat-config.js';
2
- import { Context } from '../context.js';
2
+ import { Context } from '../../context.js';
3
3
 
4
4
  describe('004-eslint9-flat-config', () => {
5
5
  describe('migration', () => {
@@ -5,8 +5,9 @@ import { parse } from 'jsonc-parser';
5
5
  import minimist from 'minimist';
6
6
  import { dirname, relative, resolve } from 'node:path';
7
7
  import * as recast from 'recast';
8
- import type { Context } from '../context.js';
9
- import { addDependenciesToPackageJson, migrationsDebug } from '../utils.js';
8
+ import type { Context } from '../../context.js';
9
+ import { addDependenciesToPackageJson } from '../../utils.js';
10
+ import { migrationsDebug } from '../utils.js';
10
11
 
11
12
  type Imports = Map<string, { name?: string; bindings?: string[] }>;
12
13
 
@@ -1,5 +1,5 @@
1
1
  import migrate from './example-migration.js';
2
- import { createDefaultContext } from '../test-utils.js';
2
+ import { createDefaultContext } from '../../test-utils.js';
3
3
 
4
4
  describe('Migration - append profile to webpack', () => {
5
5
  test('should update the package.json', async () => {
@@ -1,4 +1,4 @@
1
- import type { Context } from '../context.js';
1
+ import type { Context } from '../../context.js';
2
2
 
3
3
  export default function migrate(context: Context): Context {
4
4
  const rawPkgJson = context.getFile('./package.json') ?? '{}';
@@ -1,18 +1,18 @@
1
1
  import { dirSync } from 'tmp';
2
- import { Context } from './context.js';
2
+ import { Context } from '../context.js';
3
3
  import {
4
4
  addDependenciesToPackageJson,
5
5
  removeDependenciesFromPackageJson,
6
6
  flushChanges,
7
7
  formatFiles,
8
- printChanges,
9
8
  readJsonFile,
10
9
  isVersionGreater,
11
- } from './utils.js';
10
+ } from '../utils.js';
11
+ import { printChanges } from './utils.js';
12
12
  import { join } from 'node:path';
13
13
  import { mkdir, rm, writeFile } from 'node:fs/promises';
14
14
  import { readFileSync } from 'node:fs';
15
- import { output } from '../utils/utils.console.js';
15
+ import { output } from '../../utils/utils.console.js';
16
16
 
17
17
  describe('utils', () => {
18
18
  const tmpObj = dirSync({ unsafeCleanup: true });
@@ -0,0 +1,12 @@
1
+ import type { Context } from '../context.js';
2
+ import type { MigrationMeta } from './migrations.js';
3
+ import { debug } from '../../utils/utils.cli.js';
4
+ import { printChanges as sharedPrintChanges } from '../utils.js';
5
+
6
+ export const migrationsDebug = debug.extend('migrations');
7
+
8
+ // migration-specific wrapper for printChanges
9
+ export function printChanges(context: Context, key: string, migration: MigrationMeta) {
10
+ migrationsDebug('printChanges for migration: %s', key);
11
+ sharedPrintChanges(context, key, migration);
12
+ }
@@ -0,0 +1,21 @@
1
+ import type { Context } from './context.js';
2
+
3
+ export interface CodemodModule {
4
+ default: (context: Context) => Context | Promise<Context>;
5
+ }
6
+
7
+ export interface FlagDefinition {
8
+ name: string;
9
+ description: string;
10
+ required: boolean;
11
+ }
12
+
13
+ export interface AdditionModule<TOptions = any> extends CodemodModule {
14
+ default: (context: Context, options?: TOptions) => Context | Promise<Context>;
15
+ flags?: FlagDefinition[];
16
+ parseFlags?: (argv: any) => TOptions;
17
+ }
18
+
19
+ export interface MigrationModule extends CodemodModule {
20
+ default: (context: Context) => Context | Promise<Context>;
21
+ }
@@ -1,16 +1,30 @@
1
+ /**
2
+ * Shared utilities for codemods (migrations and additions).
3
+ * These functions work with the Context class to modify plugin codebases.
4
+ */
5
+
1
6
  import { dirname, join } from 'node:path';
2
7
  import { createRequire } from 'node:module';
3
8
  import { Context } from './context.js';
4
9
  import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
5
- import { debug } from '../utils/utils.cli.js';
6
10
  import chalk from 'chalk';
7
- import { MigrationMeta } from './migrations.js';
8
11
  import { output } from '../utils/utils.console.js';
9
12
  import { getPackageManagerSilentInstallCmd, getPackageManagerWithFallback } from '../utils/utils.packageManager.js';
10
13
  import { execSync } from 'node:child_process';
11
14
  import { clean, coerce, gt } from 'semver';
12
15
 
13
- export function printChanges(context: Context, key: string, migration: MigrationMeta) {
16
+ /**
17
+ * Generic metadata type for printChanges
18
+ */
19
+ type ChangeMetadata = {
20
+ description: string;
21
+ };
22
+
23
+ /**
24
+ * Prints changes made to the context in a formatted way.
25
+ * Works with both migrations and additions.
26
+ */
27
+ export function printChanges(context: Context, key: string, meta: ChangeMetadata) {
14
28
  const changes = context.listChanges();
15
29
  const lines = [];
16
30
 
@@ -25,7 +39,7 @@ export function printChanges(context: Context, key: string, migration: Migration
25
39
  }
26
40
 
27
41
  output.addHorizontalLine('gray');
28
- output.logSingleLine(`${key} (${migration.description})`);
42
+ output.logSingleLine(`${key} (${meta.description})`);
29
43
 
30
44
  if (lines.length === 0) {
31
45
  output.logSingleLine('No changes were made');
@@ -34,6 +48,9 @@ export function printChanges(context: Context, key: string, migration: Migration
34
48
  }
35
49
  }
36
50
 
51
+ /**
52
+ * Writes all changes from the context to the filesystem.
53
+ */
37
54
  export function flushChanges(context: Context) {
38
55
  const basePath = context.basePath;
39
56
  const changes = context.listChanges();
@@ -51,10 +68,8 @@ export function flushChanges(context: Context) {
51
68
  }
52
69
  }
53
70
 
54
- export const migrationsDebug = debug.extend('migrations');
55
-
56
71
  /**
57
- * Formats the files in the migration context using the version of prettier found in the local node_modules.
72
+ * Formats the files in the context using the version of prettier found in the local node_modules.
58
73
  * If prettier isn't installed or the file is ignored or has no parser, it will not be formatted.
59
74
  *
60
75
  * @param context - The context to format.
@@ -104,9 +119,12 @@ export async function formatFiles(context: Context) {
104
119
  }
105
120
 
106
121
  // Cache the package.json contents to avoid re-installing dependencies if the package.json hasn't changed
107
- // (This runs for each migration used in an update)
122
+ // (This runs for each codemod used in an update)
108
123
  let packageJsonInstallCache: string;
109
124
 
125
+ /**
126
+ * Installs NPM dependencies if package.json has changed.
127
+ */
110
128
  export function installNPMDependencies(context: Context) {
111
129
  const hasPackageJsonChanges = Object.entries(context.listChanges()).some(
112
130
  ([filePath, { changeType }]) => filePath === 'package.json' && changeType === 'update'
@@ -134,6 +152,9 @@ export function installNPMDependencies(context: Context) {
134
152
  }
135
153
  }
136
154
 
155
+ /**
156
+ * Reads and parses a JSON file from the context.
157
+ */
137
158
  export function readJsonFile<T extends object = any>(context: Context, path: string): T {
138
159
  if (!context.doesFileExist(path)) {
139
160
  throw new Error(`Cannot find ${path}`);
@@ -145,6 +166,9 @@ export function readJsonFile<T extends object = any>(context: Context, path: str
145
166
  }
146
167
  }
147
168
 
169
+ /**
170
+ * Adds or updates dependencies in package.json, preventing downgrades.
171
+ */
148
172
  export function addDependenciesToPackageJson(
149
173
  context: Context,
150
174
  dependencies: Record<string, string>,
@@ -160,14 +184,10 @@ export function addDependenciesToPackageJson(
160
184
  if (currentDeps[dep]) {
161
185
  if (isVersionGreater(newVersion, currentDeps[dep])) {
162
186
  currentDeps[dep] = newVersion;
163
- } else {
164
- migrationsDebug('would downgrade dependency %s to %s', dep, newVersion);
165
187
  }
166
188
  } else if (currentDevDeps[dep]) {
167
189
  if (isVersionGreater(newVersion, currentDevDeps[dep])) {
168
190
  currentDevDeps[dep] = newVersion;
169
- } else {
170
- migrationsDebug('would downgrade devDependency %s to %s', dep, newVersion);
171
191
  }
172
192
  } else {
173
193
  // Not present, add to dependencies
@@ -180,14 +200,10 @@ export function addDependenciesToPackageJson(
180
200
  if (currentDeps[dep]) {
181
201
  if (isVersionGreater(newVersion, currentDeps[dep])) {
182
202
  currentDeps[dep] = newVersion;
183
- } else {
184
- migrationsDebug('would downgrade dependency %s to %s', dep, newVersion);
185
203
  }
186
204
  } else if (currentDevDeps[dep]) {
187
205
  if (isVersionGreater(newVersion, currentDevDeps[dep])) {
188
206
  currentDevDeps[dep] = newVersion;
189
- } else {
190
- migrationsDebug('would downgrade devDependency %s to %s', dep, newVersion);
191
207
  }
192
208
  } else {
193
209
  // Not present, add to devDependencies
@@ -214,11 +230,12 @@ export function addDependenciesToPackageJson(
214
230
  ...(Object.keys(sortedDevDeps).length > 0 && { devDependencies: sortedDevDeps }),
215
231
  };
216
232
 
217
- migrationsDebug('updated package.json', updatedPackageJson);
218
-
219
233
  context.updateFile(packageJsonPath, JSON.stringify(updatedPackageJson, null, 2));
220
234
  }
221
235
 
236
+ /**
237
+ * Removes dependencies from package.json.
238
+ */
222
239
  export function removeDependenciesFromPackageJson(
223
240
  context: Context,
224
241
  dependencies: string[],
@@ -232,7 +249,6 @@ export function removeDependenciesFromPackageJson(
232
249
  for (const dep of dependencies) {
233
250
  if (currentPackageJson.dependencies?.[dep]) {
234
251
  delete currentPackageJson.dependencies[dep];
235
- migrationsDebug('removed dependency %s', dep);
236
252
  hasChanges = true;
237
253
  }
238
254
  }
@@ -240,7 +256,6 @@ export function removeDependenciesFromPackageJson(
240
256
  for (const dep of devDependencies) {
241
257
  if (currentPackageJson.devDependencies?.[dep]) {
242
258
  delete currentPackageJson.devDependencies[dep];
243
- migrationsDebug('removed devDependency %s', dep);
244
259
  hasChanges = true;
245
260
  }
246
261
  }
@@ -249,8 +264,6 @@ export function removeDependenciesFromPackageJson(
249
264
  return;
250
265
  }
251
266
 
252
- migrationsDebug('updated package.json', currentPackageJson);
253
-
254
267
  context.updateFile(packageJsonPath, JSON.stringify(currentPackageJson, null, 2));
255
268
  }
256
269
 
@@ -1,4 +1,4 @@
1
- import { getAdditionFlags, getAvailableAdditions, runAdditionByName } from '../additions/manager.js';
1
+ import { getAdditionFlags, getAvailableAdditions, runAdditionByName } from '../codemods/additions/manager.js';
2
2
  import { isGitDirectory, isGitDirectoryClean } from '../utils/utils.git.js';
3
3
 
4
4
  import { isPluginDirectory } from '../utils/utils.plugin.js';
@@ -16,7 +16,7 @@ export const add = async (argv: minimist.ParsedArgs) => {
16
16
  await performPreAddChecks(argv);
17
17
 
18
18
  try {
19
- await runAdditionByName(subCommand, argv, { commitChanges: argv.commit });
19
+ await runAdditionByName(subCommand, argv);
20
20
  } catch (error) {
21
21
  if (error instanceof Error) {
22
22
  output.error({
@@ -1,4 +1,4 @@
1
- import { getMigrationsToRun, runMigrations } from '../migrations/manager.js';
1
+ import { getMigrationsToRun, runMigrations } from '../codemods/migrations/manager.js';
2
2
  import {
3
3
  getPackageManagerExecCmd,
4
4
  getPackageManagerSilentInstallCmd,
@@ -1,6 +1,6 @@
1
1
  import { argv, commandName } from './utils.cli.js';
2
2
 
3
- import type { AdditionFeatureName } from '../additions/additions.js';
3
+ import type { AdditionFeatureName } from '../codemods/additions/additions.js';
4
4
  import { CURRENT_APP_VERSION } from './utils.version.js';
5
5
  import { DEFAULT_FEATURE_FLAGS } from '../constants.js';
6
6
  import { EOL } from 'node:os';
@@ -27,8 +27,8 @@ type AdditionFeatureFlags = {
27
27
 
28
28
  export type FeatureFlags = CoreFeatureFlags & AdditionFeatureFlags;
29
29
 
30
- export function isFeatureEnabled(features: FeatureFlags, featureName: string): boolean {
31
- return features[featureName as AdditionFeatureName] === true;
30
+ export function isFeatureEnabled(features: FeatureFlags, featureName: AdditionFeatureName): boolean {
31
+ return features[featureName] === true;
32
32
  }
33
33
 
34
34
  export type CreatePluginConfig = UserConfig & {
@@ -7,7 +7,7 @@ services:
7
7
  context: .
8
8
  args:
9
9
  grafana_image: ${GRAFANA_IMAGE:-{{~grafanaImage~}} }
10
- grafana_version: ${GRAFANA_VERSION:-12.2.0}
10
+ grafana_version: ${GRAFANA_VERSION:-12.2.1}
11
11
  development: ${DEVELOPMENT:-false}
12
12
  anonymous_auth_enabled: ${ANONYMOUS_AUTH_ENABLED:-true}
13
13
  ports:
@@ -17,8 +17,8 @@
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
19
  "@grafana/eslint-config": "^8.2.0",
20
- "@grafana/plugin-e2e": "^2.2.0",
21
- "@grafana/tsconfig": "^2.0.0",
20
+ "@grafana/plugin-e2e": "^3.0.1",
21
+ "@grafana/tsconfig": "^2.0.1",
22
22
  "@playwright/test": "^1.52.0",{{#if useExperimentalRspack}}
23
23
  "@rspack/core": "^1.3.0",
24
24
  "@rspack/cli": "^1.3.0",{{/if}}
@@ -71,11 +71,11 @@
71
71
  },
72
72
  "dependencies": {
73
73
  "@emotion/css": "11.10.6",
74
- "@grafana/data": "^12.2.0",
75
- "@grafana/i18n": "^12.2.0",
76
- "@grafana/runtime": "^12.2.0",
77
- "@grafana/ui": "^12.2.0",
78
- "@grafana/schema": "^12.2.0",{{#if_eq pluginType "scenesapp" }}
74
+ "@grafana/data": "^12.2.1",
75
+ "@grafana/i18n": "^12.2.1",
76
+ "@grafana/runtime": "^12.2.1",
77
+ "@grafana/ui": "^12.2.1",
78
+ "@grafana/schema": "^12.2.1",{{#if_eq pluginType "scenesapp" }}
79
79
  "@grafana/scenes": "{{ scenesVersion }}",{{/if_eq}}
80
80
  "react": "18.2.0",
81
81
  "react-dom": "18.2.0"{{#if isAppType}},
@@ -24,4 +24,4 @@ jobs:
24
24
  with:
25
25
  persist-credentials: false
26
26
 
27
- - uses: grafana/plugin-actions/bundle-size@v1.0.2
27
+ - uses: grafana/plugin-actions/bundle-size@bundle-size/v1.0.2
@@ -146,7 +146,7 @@ jobs:
146
146
 
147
147
  - name: Resolve Grafana E2E versions
148
148
  id: resolve-versions
149
- uses: grafana/plugin-actions/e2e-version@v1.1.2
149
+ uses: grafana/plugin-actions/e2e-version@e2e-version/v1.1.2
150
150
 
151
151
  playwright-tests:
152
152
  needs: [resolve-versions, build]
@@ -197,7 +197,7 @@ jobs:
197
197
  ANONYMOUS_AUTH_ENABLED=false DEVELOPMENT=false GRAFANA_VERSION=$\{{ matrix.GRAFANA_IMAGE.VERSION }} GRAFANA_IMAGE=$\{{ matrix.GRAFANA_IMAGE.NAME }} docker compose up -d
198
198
 
199
199
  - name: Wait for grafana server
200
- uses: grafana/plugin-actions/wait-for-grafana@v1.0.2
200
+ uses: grafana/plugin-actions/wait-for-grafana@wait-for-grafana/v1.0.2
201
201
  with:
202
202
  url: http://localhost:3000/login
203
203
 
@@ -209,7 +209,7 @@ jobs:
209
209
  run: {{ packageManagerName }} run e2e
210
210
 
211
211
  - name: Upload e2e test summary
212
- uses: grafana/plugin-actions/playwright-gh-pages/upload-report-artifacts@v1.0.1
212
+ uses: grafana/plugin-actions/playwright-gh-pages/upload-report-artifacts@upload-report-artifacts/v1.0.1
213
213
  if: $\{{ always() && !cancelled() }}
214
214
  with:
215
215
  upload-report: false
@@ -247,7 +247,7 @@ jobs:
247
247
  # required for playwright-gh-pages
248
248
  persist-credentials: true
249
249
  - name: Publish report
250
- uses: grafana/plugin-actions/playwright-gh-pages/deploy-report-pages@v1.0.1
250
+ uses: grafana/plugin-actions/playwright-gh-pages/deploy-report-pages@deploy-report-pages/v1.0.1
251
251
  with:
252
252
  github-token: $\{{ secrets.GITHUB_TOKEN }}
253
253
 
@@ -18,7 +18,7 @@ jobs:
18
18
  release:
19
19
  runs-on: ubuntu-latest
20
20
  steps:
21
- - uses: grafana/plugin-actions/create-plugin-update@v1.1.0
21
+ - uses: grafana/plugin-actions/create-plugin-update@create-plugin-update/v1.1.0
22
22
  # Uncomment to use a fine-grained personal access token instead of default github token
23
23
  # (For more info on how to generate the token see https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
24
24
  # with:
@@ -36,7 +36,7 @@ jobs:
36
36
  echo "modulets=${MODULETS}" >> $GITHUB_OUTPUT
37
37
 
38
38
  - name: Compatibility check
39
- uses: grafana/plugin-actions/is-compatible@v1.0.2
39
+ uses: grafana/plugin-actions/is-compatible@is-compatible/v1.0.2
40
40
  with:
41
41
  module: $\{{ steps.find-module-ts.outputs.modulets }}
42
42
  comment-pr: "no"
@@ -20,7 +20,7 @@ jobs:
20
20
  with:
21
21
  persist-credentials: false
22
22
 
23
- - uses: grafana/plugin-actions/build-plugin@v1.0.2
23
+ - uses: grafana/plugin-actions/build-plugin@build-plugin/v1.0.2
24
24
  # Uncomment to enable plugin signing
25
25
  # (For more info on how to generate the access policy token see https://grafana.com/developers/plugin-tools/publish-a-plugin/sign-a-plugin#generate-an-access-policy-token)
26
26
  #with:
@@ -1,28 +0,0 @@
1
- export { addDependenciesToPackageJson, flushChanges, formatFiles, installNPMDependencies } from '../migrations/utils.js';
2
- import chalk from 'chalk';
3
- import { debug } from '../utils/utils.cli.js';
4
- import { output } from '../utils/utils.console.js';
5
-
6
- const additionsDebug = debug.extend("additions");
7
- function printChanges(context, key, addition) {
8
- const changes = context.listChanges();
9
- const lines = [];
10
- for (const [filePath, { changeType }] of Object.entries(changes)) {
11
- if (changeType === "add") {
12
- lines.push(`${chalk.green("ADD")} ${filePath}`);
13
- } else if (changeType === "update") {
14
- lines.push(`${chalk.yellow("UPDATE")} ${filePath}`);
15
- } else if (changeType === "delete") {
16
- lines.push(`${chalk.red("DELETE")} ${filePath}`);
17
- }
18
- }
19
- output.addHorizontalLine("gray");
20
- output.logSingleLine(`${key} (${addition.description})`);
21
- if (lines.length === 0) {
22
- output.logSingleLine("No changes were made");
23
- } else {
24
- output.log({ title: "Changes:", withPrefix: false, body: output.bulletList(lines) });
25
- }
26
- }
27
-
28
- export { additionsDebug, printChanges };
@@ -1,39 +0,0 @@
1
- export {
2
- formatFiles,
3
- installNPMDependencies,
4
- flushChanges,
5
- addDependenciesToPackageJson,
6
- } from '../migrations/utils.js';
7
-
8
- import type { AdditionMeta } from './additions.js';
9
- import { Context } from '../migrations/context.js';
10
- import chalk from 'chalk';
11
- // Re-export debug with additions namespace
12
- import { debug } from '../utils/utils.cli.js';
13
- import { output } from '../utils/utils.console.js';
14
-
15
- export const additionsDebug = debug.extend('additions');
16
-
17
- export function printChanges(context: Context, key: string, addition: AdditionMeta) {
18
- const changes = context.listChanges();
19
- const lines = [];
20
-
21
- for (const [filePath, { changeType }] of Object.entries(changes)) {
22
- if (changeType === 'add') {
23
- lines.push(`${chalk.green('ADD')} ${filePath}`);
24
- } else if (changeType === 'update') {
25
- lines.push(`${chalk.yellow('UPDATE')} ${filePath}`);
26
- } else if (changeType === 'delete') {
27
- lines.push(`${chalk.red('DELETE')} ${filePath}`);
28
- }
29
- }
30
-
31
- output.addHorizontalLine('gray');
32
- output.logSingleLine(`${key} (${addition.description})`);
33
-
34
- if (lines.length === 0) {
35
- output.logSingleLine('No changes were made');
36
- } else {
37
- output.log({ title: 'Changes:', withPrefix: false, body: output.bulletList(lines) });
38
- }
39
- }