@grafana/create-plugin 6.5.0-canary.2320.20262762522.0 → 6.5.0-canary.2320.20267597497.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.
@@ -123,28 +123,8 @@ function addI18nextToExternalsArray(externalsArray) {
123
123
  additionsDebug("'i18next' already in externals array");
124
124
  return false;
125
125
  }
126
- let insertIndex = -1;
127
- for (let i = 0; i < externalsArray.elements.length; i++) {
128
- const element = externalsArray.elements[i];
129
- if (element && (element.type === "Literal" || element.type === "StringLiteral") && element.value === "rxjs") {
130
- insertIndex = i + 1;
131
- break;
132
- }
133
- }
134
- if (insertIndex === -1) {
135
- for (let i = externalsArray.elements.length - 1; i >= 0; i--) {
136
- const element = externalsArray.elements[i];
137
- if (element && element.type !== "FunctionExpression" && element.type !== "ArrowFunctionExpression") {
138
- insertIndex = i + 1;
139
- break;
140
- }
141
- }
142
- if (insertIndex === -1) {
143
- insertIndex = externalsArray.elements.length;
144
- }
145
- }
146
- externalsArray.elements.splice(insertIndex, 0, builders.literal("i18next"));
147
- additionsDebug(`Added 'i18next' to externals array at position ${insertIndex}`);
126
+ externalsArray.elements.push(builders.literal("i18next"));
127
+ additionsDebug("Added 'i18next' to externals array");
148
128
  return true;
149
129
  }
150
130
  function ensureI18nextExternal(context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "6.5.0-canary.2320.20262762522.0",
3
+ "version": "6.5.0-canary.2320.20267597497.0",
4
4
  "repository": {
5
5
  "directory": "packages/create-plugin",
6
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -56,5 +56,5 @@
56
56
  "engines": {
57
57
  "node": ">=20"
58
58
  },
59
- "gitHead": "1df74d43ab143d2868f8dc98703faf6f4b120fa9"
59
+ "gitHead": "98307e6a7ae71c85e59d5b7bf2f2eeb98f9fb332"
60
60
  }
@@ -38,7 +38,7 @@ Additions are optional features that developers choose to add via `create-plugin
38
38
  ### Addition Behavior
39
39
 
40
40
  - Additions add new features or capabilities to a plugin (e.g., i18n support, testing frameworks, etc.)
41
- - Each addition must be idempotent - it should be safe to run multiple times
41
+ - it should be safe to run multiple times
42
42
  - Always use defensive programming: check if features already exist before adding them
43
43
  - Use `additionsDebug()` for logging to help with troubleshooting
44
44
  - If the addition accepts user input, export a `schema` object using `valibot` for input validation
@@ -164,35 +164,9 @@ function addI18nextToExternalsArray(externalsArray: recast.types.namedTypes.Arra
164
164
  return false;
165
165
  }
166
166
 
167
- // Find the position after 'rxjs' to insert 'i18next'
168
- let insertIndex = -1;
169
- for (let i = 0; i < externalsArray.elements.length; i++) {
170
- const element = externalsArray.elements[i];
171
- if (element && (element.type === 'Literal' || element.type === 'StringLiteral') && element.value === 'rxjs') {
172
- insertIndex = i + 1;
173
- break;
174
- }
175
- }
176
-
177
- // If 'rxjs' not found, append to the end (before the function at the end)
178
- if (insertIndex === -1) {
179
- // Find the last non-function element
180
- for (let i = externalsArray.elements.length - 1; i >= 0; i--) {
181
- const element = externalsArray.elements[i];
182
- if (element && element.type !== 'FunctionExpression' && element.type !== 'ArrowFunctionExpression') {
183
- insertIndex = i + 1;
184
- break;
185
- }
186
- }
187
- // If still not found, append at the end
188
- if (insertIndex === -1) {
189
- insertIndex = externalsArray.elements.length;
190
- }
191
- }
192
-
193
- // Insert 'i18next' at the found position
194
- externalsArray.elements.splice(insertIndex, 0, builders.literal('i18next'));
195
- additionsDebug(`Added 'i18next' to externals array at position ${insertIndex}`);
167
+ // Append 'i18next' to the end of the array
168
+ externalsArray.elements.push(builders.literal('i18next'));
169
+ additionsDebug("Added 'i18next' to externals array");
196
170
  return true;
197
171
  }
198
172