@grafana/create-plugin 6.2.0-canary.2233.19133609453.0 → 6.2.0-canary.2233.19368311379.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 (54) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/CONTRIBUTING.md +3 -0
  3. package/dist/codemods/additions/additions.js +8 -8
  4. package/dist/codemods/additions/scripts/example-addition.js +19 -33
  5. package/dist/codemods/migrations/manager.js +13 -40
  6. package/dist/codemods/migrations/migrations.js +34 -25
  7. package/dist/codemods/migrations/scripts/004-eslint9-flat-config.js +1 -2
  8. package/dist/codemods/migrations/scripts/005-react-18-3.js +20 -0
  9. package/dist/codemods/migrations/scripts/example-migration.js +7 -3
  10. package/dist/codemods/runner.js +38 -0
  11. package/dist/codemods/schema-parser.js +20 -0
  12. package/dist/codemods/utils.js +15 -6
  13. package/dist/commands/add.command.js +24 -55
  14. package/dist/commands/update.command.js +7 -41
  15. package/dist/utils/utils.checks.js +40 -0
  16. package/dist/utils/utils.config.js +1 -16
  17. package/package.json +3 -2
  18. package/src/codemods/additions/additions.test.ts +12 -0
  19. package/src/codemods/additions/additions.ts +9 -22
  20. package/src/codemods/additions/scripts/example-addition.test.ts +14 -33
  21. package/src/codemods/additions/scripts/example-addition.ts +27 -44
  22. package/src/codemods/migrations/fixtures/migrations.ts +19 -18
  23. package/src/codemods/migrations/manager.test.ts +67 -73
  24. package/src/codemods/migrations/manager.ts +17 -50
  25. package/src/codemods/migrations/migrations.test.ts +8 -5
  26. package/src/codemods/migrations/migrations.ts +38 -34
  27. package/src/codemods/migrations/scripts/004-eslint9-flat-config.ts +2 -2
  28. package/src/codemods/migrations/scripts/005-react-18-3.test.ts +145 -0
  29. package/src/codemods/migrations/scripts/005-react-18-3.ts +19 -0
  30. package/src/codemods/migrations/scripts/example-migration.test.ts +1 -1
  31. package/src/codemods/migrations/scripts/example-migration.ts +20 -3
  32. package/src/codemods/runner.ts +57 -0
  33. package/src/codemods/schema-parser.ts +27 -0
  34. package/src/codemods/types.ts +9 -14
  35. package/src/codemods/{migrations/utils.test.ts → utils.test.ts} +8 -7
  36. package/src/codemods/utils.ts +28 -36
  37. package/src/commands/add.command.ts +26 -62
  38. package/src/commands/update.command.ts +8 -47
  39. package/src/migrations/migrations.ts +44 -0
  40. package/src/utils/utils.checks.ts +47 -0
  41. package/src/utils/utils.config.ts +1 -28
  42. package/templates/common/_package.json +7 -5
  43. package/templates/github/workflows/bundle-stats.yml +1 -1
  44. package/templates/github/workflows/ci.yml +11 -11
  45. package/templates/github/workflows/cp-update.yml +9 -14
  46. package/templates/github/workflows/is-compatible.yml +3 -3
  47. package/templates/github/workflows/release.yml +1 -1
  48. package/vitest.config.ts +12 -0
  49. package/dist/codemods/additions/manager.js +0 -115
  50. package/dist/codemods/additions/utils.js +0 -10
  51. package/dist/codemods/migrations/utils.js +0 -10
  52. package/src/codemods/additions/manager.ts +0 -145
  53. package/src/codemods/additions/utils.ts +0 -12
  54. package/src/codemods/migrations/utils.ts +0 -12
@@ -16,7 +16,7 @@
16
16
  "author": "{{ sentenceCase orgName }}",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "@grafana/eslint-config": "^8.2.0",
19
+ "@grafana/eslint-config": "^9.0.0",
20
20
  "@grafana/plugin-e2e": "^3.0.1",
21
21
  "@grafana/tsconfig": "^2.0.1",
22
22
  "@playwright/test": "^1.52.0",{{#if useExperimentalRspack}}
@@ -29,7 +29,9 @@
29
29
  "@testing-library/jest-dom": "6.1.4",
30
30
  "@testing-library/react": "14.0.0",
31
31
  "@types/jest": "^29.5.0",
32
- "@types/node": "^20.8.7",{{#if isAppType}}{{#unless useReactRouterV6}}
32
+ "@types/node": "^20.8.7",
33
+ "@types/react": "^18.3.0",
34
+ "@types/react-dom": "^18.3.0",{{#if isAppType}}{{#unless useReactRouterV6}}
33
35
  "@types/react-router-dom": "^{{ reactRouterVersion }}",{{/unless}}{{/if}}
34
36
  "@types/testing-library__jest-dom": "5.14.8",
35
37
  "@typescript-eslint/eslint-plugin": "^8.3.0",
@@ -40,7 +42,7 @@
40
42
  "eslint-config-prettier": "^8.8.0",
41
43
  "eslint-plugin-jsdoc": "^51.2.3",
42
44
  "eslint-plugin-react": "^7.37.5",
43
- "eslint-plugin-react-hooks": "^5.2.0",
45
+ "eslint-plugin-react-hooks": "^7.0.0",
44
46
  "eslint-webpack-plugin": "^5.0.0",{{#unless useExperimentalRspack}}
45
47
  "fork-ts-checker-webpack-plugin": "^8.0.0",{{/unless}}
46
48
  "glob": "^10.2.7",
@@ -77,8 +79,8 @@
77
79
  "@grafana/ui": "^12.2.1",
78
80
  "@grafana/schema": "^12.2.1",{{#if_eq pluginType "scenesapp" }}
79
81
  "@grafana/scenes": "{{ scenesVersion }}",{{/if_eq}}
80
- "react": "18.2.0",
81
- "react-dom": "18.2.0"{{#if isAppType}},
82
+ "react": "^18.3.0",
83
+ "react-dom": "^18.3.0"{{#if isAppType}},
82
84
  "react-router-dom": "^{{ reactRouterVersion }}",
83
85
  "rxjs": "7.8.2"{{/if}}
84
86
  },
@@ -20,7 +20,7 @@ jobs:
20
20
 
21
21
  steps:
22
22
  - name: Checkout repository
23
- uses: actions/checkout@v4
23
+ uses: actions/checkout@v5
24
24
  with:
25
25
  persist-credentials: false
26
26
 
@@ -25,16 +25,16 @@ jobs:
25
25
  env:
26
26
  GRAFANA_ACCESS_POLICY_TOKEN: $\{{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}
27
27
  steps:
28
- - uses: actions/checkout@v4
28
+ - uses: actions/checkout@v5
29
29
  with:
30
30
  persist-credentials: false
31
31
  {{#if_eq packageManagerName "pnpm"}}
32
32
  # pnpm action uses the packageManager field in package.json to
33
33
  # understand which version to install.
34
- - uses: pnpm/action-setup@v3
34
+ - uses: pnpm/action-setup@v4
35
35
  {{/if_eq}}
36
36
  - name: Setup Node.js environment
37
- uses: actions/setup-node@v4
37
+ uses: actions/setup-node@v6
38
38
  with:
39
39
  node-version: '22'
40
40
  cache: '{{ packageManagerName }}'
@@ -61,7 +61,7 @@ jobs:
61
61
 
62
62
  - name: Setup Go environment
63
63
  if: steps.check-for-backend.outputs.has-backend == 'true'
64
- uses: actions/setup-go@v5
64
+ uses: actions/setup-go@v6
65
65
  with:
66
66
  go-version: '1.22'
67
67
 
@@ -122,7 +122,7 @@ jobs:
122
122
  ARCHIVE: $\{{ steps.metadata.outputs.archive }}
123
123
 
124
124
  - name: Archive Build
125
- uses: actions/upload-artifact@v4
125
+ uses: actions/upload-artifact@v5
126
126
  with:
127
127
  name: $\{{ steps.metadata.outputs.plugin-id }}-$\{{ steps.metadata.outputs.plugin-version }}
128
128
  path: $\{{ steps.metadata.outputs.plugin-id }}
@@ -140,7 +140,7 @@ jobs:
140
140
  matrix: $\{{ steps.resolve-versions.outputs.matrix }}
141
141
  steps:
142
142
  - name: Checkout
143
- uses: actions/checkout@v4
143
+ uses: actions/checkout@v5
144
144
  with:
145
145
  persist-credentials: false
146
146
 
@@ -162,12 +162,12 @@ jobs:
162
162
  name: e2e test $\{{ matrix.GRAFANA_IMAGE.name }}@$\{{ matrix.GRAFANA_IMAGE.VERSION }}
163
163
  runs-on: ubuntu-latest
164
164
  steps:
165
- - uses: actions/checkout@v4
165
+ - uses: actions/checkout@v5
166
166
  with:
167
167
  persist-credentials: false
168
168
 
169
169
  - name: Download plugin
170
- uses: actions/download-artifact@v4
170
+ uses: actions/download-artifact@v6
171
171
  with:
172
172
  path: dist
173
173
  name: $\{{ needs.build.outputs.plugin-id }}-$\{{ needs.build.outputs.plugin-version }}
@@ -180,10 +180,10 @@ jobs:
180
180
  {{#if_eq packageManagerName "pnpm"}}
181
181
  # pnpm action uses the packageManager field in package.json to
182
182
  # understand which version to install.
183
- - uses: pnpm/action-setup@v3
183
+ - uses: pnpm/action-setup@v4
184
184
  {{/if_eq}}
185
185
  - name: Setup Node.js environment
186
- uses: actions/setup-node@v4
186
+ uses: actions/setup-node@v6
187
187
  with:
188
188
  node-version: '22'
189
189
  cache: '{{ packageManagerName }}'
@@ -242,7 +242,7 @@ jobs:
242
242
  needs: [playwright-tests]
243
243
  runs-on: ubuntu-latest
244
244
  steps:
245
- - uses: actions/checkout@v4
245
+ - uses: actions/checkout@v5
246
246
  with:
247
247
  # required for playwright-gh-pages
248
248
  persist-credentials: true
@@ -1,3 +1,4 @@
1
+ {{!-- /* 🚨 The `${{ }}` Github workflow expressions need to be escaped so they are not being interpreted by Handlebars. (this comment is going to be removed after scaffolding) 🚨 */ --}}
1
2
  name: Create Plugin Update
2
3
 
3
4
  on:
@@ -5,22 +6,16 @@ on:
5
6
  schedule:
6
7
  - cron: '0 0 1 * *' # run once a month on the 1st day
7
8
 
8
- # To use the default github token with the following elevated permissions make sure to check:
9
- # **Allow GitHub Actions to create and approve pull requests** in https://github.com/ORG_NAME/REPO_NAME/settings/actions.
10
- # Alternatively create a fine-grained personal access token for your repository with
11
- # `contents: read and write` and `pull requests: read and write` and pass it to the action.
12
-
13
- permissions:
14
- contents: write
15
- pull-requests: write
9
+ # To use this workflow please create a fine-grained personal access token for your repository with:
10
+ # `contents: read and write`
11
+ # `pull requests: read and write`
12
+ # `workflows: read and write`
16
13
 
17
14
  jobs:
18
15
  release:
19
16
  runs-on: ubuntu-latest
20
17
  steps:
21
- - uses: grafana/plugin-actions/create-plugin-update@create-plugin-update/v1.1.0
22
- # Uncomment to use a fine-grained personal access token instead of default github token
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
- # with:
25
- # Make sure to save the token in your repository secrets
26
- # token: ${{ secrets.GH_PAT_TOKEN }}
18
+ - uses: grafana/plugin-actions/create-plugin-update@create-plugin-update/v2.0.1
19
+ with:
20
+ # Make sure to save the token in your repository secrets as `GH_PAT_TOKEN`
21
+ token: $\{{ secrets.GH_PAT_TOKEN }}
@@ -7,18 +7,18 @@ jobs:
7
7
  permissions:
8
8
  contents: read
9
9
  steps:
10
- - uses: actions/checkout@v4
10
+ - uses: actions/checkout@v5
11
11
  with:
12
12
  persist-credentials: false
13
13
 
14
14
  {{#if_eq packageManagerName "pnpm"}}
15
15
  # pnpm action uses the packageManager field in package.json to
16
16
  # understand which version to install.
17
- - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
17
+ - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
18
18
  {{/if_eq}}
19
19
 
20
20
  - name: Setup Node.js environment
21
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
21
+ uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
22
22
  with:
23
23
  node-version: '22'
24
24
  cache: '{{ packageManagerName }}'
@@ -16,7 +16,7 @@ jobs:
16
16
  contents: write
17
17
  runs-on: ubuntu-latest
18
18
  steps:
19
- - uses: actions/checkout@v4
19
+ - uses: actions/checkout@v5
20
20
  with:
21
21
  persist-credentials: false
22
22
 
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
  );
@@ -1,115 +0,0 @@
1
- import { additionsDebug, printChanges } from './utils.js';
2
- import defaultAdditions from './additions.js';
3
- import { formatFiles, flushChanges, installNPMDependencies } from '../utils.js';
4
- import { getConfig, isFeatureEnabled, setFeatureFlag } from '../../utils/utils.config.js';
5
- import { Context } from '../context.js';
6
- import { output } from '../../utils/utils.console.js';
7
-
8
- function getAvailableAdditions(additions = defaultAdditions.additions) {
9
- return additions;
10
- }
11
- function getAdditionByName(name, additions = defaultAdditions.additions) {
12
- return additions[name];
13
- }
14
- async function loadAdditionModule(addition) {
15
- try {
16
- const module = await import(addition.scriptPath);
17
- return module;
18
- } catch (error) {
19
- additionsDebug('Failed to load addition module for "%s" from %s: %O', addition.name, addition.scriptPath, error);
20
- return null;
21
- }
22
- }
23
- async function getAdditionFlags(addition) {
24
- const module = await loadAdditionModule(addition);
25
- return module?.flags || [];
26
- }
27
- async function parseAdditionFlags(addition, argv) {
28
- const module = await loadAdditionModule(addition);
29
- if (module?.parseFlags) {
30
- return module.parseFlags(argv);
31
- }
32
- return {};
33
- }
34
- async function validateAdditionOptions(addition, options) {
35
- const flags = await getAdditionFlags(addition);
36
- if (!flags || flags.length === 0) {
37
- return;
38
- }
39
- const missingFlags = [];
40
- for (const flag of flags) {
41
- if (flag.required) {
42
- const value = options[flag.name];
43
- if (value === void 0 || value === null || Array.isArray(value) && value.length === 0) {
44
- missingFlags.push(flag.name);
45
- }
46
- }
47
- }
48
- if (missingFlags.length > 0) {
49
- const flagDocs = flags.filter((f) => missingFlags.includes(f.name)).map((f) => ` --${f.name}: ${f.description}`);
50
- throw new Error(
51
- `Missing required flag${missingFlags.length > 1 ? "s" : ""}:
52
-
53
- ` + flagDocs.join("\n") + `
54
-
55
- Example: npx @grafana/create-plugin add ${addition.name} --${missingFlags[0]}=value`
56
- );
57
- }
58
- }
59
- async function runAdditionByName(additionName, argv) {
60
- const addition = getAdditionByName(additionName);
61
- if (!addition) {
62
- const availableAdditions = getAvailableAdditions();
63
- const additionsList = Object.keys(availableAdditions);
64
- throw new Error(`Unknown addition: ${additionName}
65
-
66
- Available additions: ${additionsList.join(", ")}`);
67
- }
68
- const options = await parseAdditionFlags(addition, argv);
69
- await validateAdditionOptions(addition, options);
70
- await runAddition(addition, options);
71
- }
72
- async function runAddition(addition, additionOptions = {}) {
73
- const basePath = process.cwd();
74
- const config = getConfig();
75
- if (isFeatureEnabled(config.features, addition.featureName)) {
76
- output.log({
77
- title: `Addition '${addition.name}' is already enabled`,
78
- body: [`The feature flag '${addition.featureName}' is already set to true in .cprc.json.`, "No changes needed."]
79
- });
80
- return;
81
- }
82
- output.log({
83
- title: `Running addition: ${addition.name}`,
84
- body: [addition.description]
85
- });
86
- try {
87
- const context = new Context(basePath);
88
- const updatedContext = await executeAddition(addition, context, additionOptions);
89
- additionsDebug(`context for "${addition.name} (${addition.scriptPath})":`);
90
- additionsDebug("%O", updatedContext.listChanges());
91
- await formatFiles(updatedContext);
92
- flushChanges(updatedContext);
93
- printChanges(updatedContext, addition.name, addition);
94
- installNPMDependencies(updatedContext);
95
- await setFeatureFlag(addition.featureName, true);
96
- additionsDebug(`Set feature flag '${addition.featureName}' to true in .cprc.json`);
97
- output.success({
98
- title: `Successfully added ${addition.name} to your plugin.`
99
- });
100
- } catch (error) {
101
- if (error instanceof Error) {
102
- throw new Error(`Error running addition "${addition.name} (${addition.scriptPath})": ${error.message}`);
103
- }
104
- throw error;
105
- }
106
- }
107
- async function executeAddition(addition, context, options = {}) {
108
- const module = await loadAdditionModule(addition);
109
- if (!module) {
110
- throw new Error(`Failed to load addition module for ${addition.name}`);
111
- }
112
- return module.default(context, options);
113
- }
114
-
115
- export { executeAddition, getAdditionByName, getAdditionFlags, getAvailableAdditions, parseAdditionFlags, runAddition, runAdditionByName };
@@ -1,10 +0,0 @@
1
- import { debug } from '../../utils/utils.cli.js';
2
- import { printChanges as printChanges$1 } from '../utils.js';
3
-
4
- const additionsDebug = debug.extend("additions");
5
- function printChanges(context, key, addition) {
6
- additionsDebug("printChanges for addition: %s", key);
7
- printChanges$1(context, key, addition);
8
- }
9
-
10
- export { additionsDebug, printChanges };
@@ -1,10 +0,0 @@
1
- import { debug } from '../../utils/utils.cli.js';
2
- import { printChanges as printChanges$1 } from '../utils.js';
3
-
4
- const migrationsDebug = debug.extend("migrations");
5
- function printChanges(context, key, migration) {
6
- migrationsDebug("printChanges for migration: %s", key);
7
- printChanges$1(context, key, migration);
8
- }
9
-
10
- export { migrationsDebug, printChanges };
@@ -1,145 +0,0 @@
1
- import type { AdditionModule, FlagDefinition } from '../types.js';
2
- import { additionsDebug, printChanges } from './utils.js';
3
- import defaultAdditions, { AdditionMeta } from './additions.js';
4
- import { flushChanges, formatFiles, installNPMDependencies } from '../utils.js';
5
- import { getConfig, isFeatureEnabled, setFeatureFlag } from '../../utils/utils.config.js';
6
-
7
- import { Context } from '../context.js';
8
- import { output } from '../../utils/utils.console.js';
9
-
10
- export type AdditionOptions = Record<string, any>;
11
-
12
- export function getAvailableAdditions(
13
- additions: Record<string, AdditionMeta> = defaultAdditions.additions
14
- ): Record<string, AdditionMeta> {
15
- return additions;
16
- }
17
-
18
- export function getAdditionByName(
19
- name: string,
20
- additions: Record<string, AdditionMeta> = defaultAdditions.additions
21
- ): AdditionMeta | undefined {
22
- return additions[name];
23
- }
24
-
25
- async function loadAdditionModule(addition: AdditionMeta): Promise<AdditionModule | null> {
26
- try {
27
- const module = (await import(addition.scriptPath)) as AdditionModule;
28
- return module;
29
- } catch (error) {
30
- additionsDebug('Failed to load addition module for "%s" from %s: %O', addition.name, addition.scriptPath, error);
31
- return null;
32
- }
33
- }
34
-
35
- export async function getAdditionFlags(addition: AdditionMeta): Promise<FlagDefinition[]> {
36
- const module = await loadAdditionModule(addition);
37
- return module?.flags || [];
38
- }
39
-
40
- export async function parseAdditionFlags(addition: AdditionMeta, argv: any): Promise<AdditionOptions> {
41
- const module = await loadAdditionModule(addition);
42
- if (module?.parseFlags) {
43
- return module.parseFlags(argv);
44
- }
45
- return {};
46
- }
47
-
48
- async function validateAdditionOptions(addition: AdditionMeta, options: AdditionOptions): Promise<void> {
49
- const flags = await getAdditionFlags(addition);
50
-
51
- if (!flags || flags.length === 0) {
52
- return;
53
- }
54
-
55
- const missingFlags: string[] = [];
56
-
57
- for (const flag of flags) {
58
- if (flag.required) {
59
- const value = options[flag.name];
60
- if (value === undefined || value === null || (Array.isArray(value) && value.length === 0)) {
61
- missingFlags.push(flag.name);
62
- }
63
- }
64
- }
65
-
66
- if (missingFlags.length > 0) {
67
- const flagDocs = flags.filter((f) => missingFlags.includes(f.name)).map((f) => ` --${f.name}: ${f.description}`);
68
-
69
- throw new Error(
70
- `Missing required flag${missingFlags.length > 1 ? 's' : ''}:\n\n` +
71
- flagDocs.join('\n') +
72
- `\n\nExample: npx @grafana/create-plugin add ${addition.name} --${missingFlags[0]}=value`
73
- );
74
- }
75
- }
76
-
77
- export async function runAdditionByName(additionName: string, argv: any): Promise<void> {
78
- const addition = getAdditionByName(additionName);
79
- if (!addition) {
80
- const availableAdditions = getAvailableAdditions();
81
- const additionsList = Object.keys(availableAdditions);
82
- throw new Error(`Unknown addition: ${additionName}\n\nAvailable additions: ${additionsList.join(', ')}`);
83
- }
84
-
85
- const options = await parseAdditionFlags(addition, argv);
86
- await validateAdditionOptions(addition, options);
87
- await runAddition(addition, options);
88
- }
89
-
90
- export async function runAddition(addition: AdditionMeta, additionOptions: AdditionOptions = {}): Promise<void> {
91
- const basePath = process.cwd();
92
-
93
- // Check if the feature is already enabled
94
- const config = getConfig();
95
- if (isFeatureEnabled(config.features, addition.featureName)) {
96
- output.log({
97
- title: `Addition '${addition.name}' is already enabled`,
98
- body: [`The feature flag '${addition.featureName}' is already set to true in .cprc.json.`, 'No changes needed.'],
99
- });
100
- return;
101
- }
102
-
103
- output.log({
104
- title: `Running addition: ${addition.name}`,
105
- body: [addition.description],
106
- });
107
-
108
- try {
109
- const context = new Context(basePath);
110
- const updatedContext = await executeAddition(addition, context, additionOptions);
111
-
112
- additionsDebug(`context for "${addition.name} (${addition.scriptPath})":`);
113
- additionsDebug('%O', updatedContext.listChanges());
114
-
115
- await formatFiles(updatedContext);
116
- flushChanges(updatedContext);
117
- printChanges(updatedContext, addition.name, addition);
118
-
119
- installNPMDependencies(updatedContext);
120
-
121
- await setFeatureFlag(addition.featureName, true);
122
- additionsDebug(`Set feature flag '${addition.featureName}' to true in .cprc.json`);
123
-
124
- output.success({
125
- title: `Successfully added ${addition.name} to your plugin.`,
126
- });
127
- } catch (error) {
128
- if (error instanceof Error) {
129
- throw new Error(`Error running addition "${addition.name} (${addition.scriptPath})": ${error.message}`);
130
- }
131
- throw error;
132
- }
133
- }
134
-
135
- export async function executeAddition(
136
- addition: AdditionMeta,
137
- context: Context,
138
- options: AdditionOptions = {}
139
- ): Promise<Context> {
140
- const module = await loadAdditionModule(addition);
141
- if (!module) {
142
- throw new Error(`Failed to load addition module for ${addition.name}`);
143
- }
144
- return module.default(context, options);
145
- }
@@ -1,12 +0,0 @@
1
- import type { AdditionMeta } from './additions.js';
2
- import type { Context } from '../context.js';
3
- import { debug } from '../../utils/utils.cli.js';
4
- import { printChanges as sharedPrintChanges } from '../utils.js';
5
-
6
- export const additionsDebug = debug.extend('additions');
7
-
8
- // addition-specific wrapper for printChanges.
9
- export function printChanges(context: Context, key: string, addition: AdditionMeta) {
10
- additionsDebug('printChanges for addition: %s', key);
11
- sharedPrintChanges(context, key, addition);
12
- }
@@ -1,12 +0,0 @@
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
- }