@grafana/create-plugin 6.5.0-canary.2320.20267441803.0 → 6.5.0-canary.2320.20267963205.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) {
@@ -49,15 +49,15 @@ function i18nAddition(context, options) {
49
49
  } catch (error) {
50
50
  additionsDebug(`Error ensuring i18next external: ${error instanceof Error ? error.message : String(error)}`);
51
51
  }
52
- console.log("\n\u2705 i18n support has been successfully added to your plugin!\n");
53
- console.log("Next steps:");
54
- console.log("1. Follow the instructions to translate your source code:");
55
- console.log(
52
+ additionsDebug("\n\u2705 i18n support has been successfully added to your plugin!\n");
53
+ additionsDebug("Next steps:");
54
+ additionsDebug("1. Follow the instructions to translate your source code:");
55
+ additionsDebug(
56
56
  " https://grafana.com/developers/plugin-tools/how-to-guides/plugin-internationalization-grafana-11#determine-the-text-to-translate"
57
57
  );
58
- console.log("2. Run the i18n-extract script to scan your code for translatable strings:");
59
- console.log(" npm run i18n-extract (or yarn/pnpm run i18n-extract)");
60
- console.log("3. Fill in your locale JSON files with translated strings\n");
58
+ additionsDebug("2. Run the i18n-extract script to scan your code for translatable strings:");
59
+ additionsDebug(" npm run i18n-extract (or yarn/pnpm run i18n-extract)");
60
+ additionsDebug("3. Fill in your locale JSON files with translated strings\n");
61
61
  return context;
62
62
  }
63
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "6.5.0-canary.2320.20267441803.0",
3
+ "version": "6.5.0-canary.2320.20267963205.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": "4f8f948e49999c33b0539f1bba311552d27670eb"
59
+ "gitHead": "2d7dc3b835015e2b3c24f53907ad874b344446af"
60
60
  }
@@ -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
 
@@ -88,15 +88,15 @@ export default function i18nAddition(context: Context, options: I18nOptions): Co
88
88
  }
89
89
 
90
90
  // Success message with next steps
91
- console.log('\n✅ i18n support has been successfully added to your plugin!\n');
92
- console.log('Next steps:');
93
- console.log('1. Follow the instructions to translate your source code:');
94
- console.log(
91
+ additionsDebug('\n✅ i18n support has been successfully added to your plugin!\n');
92
+ additionsDebug('Next steps:');
93
+ additionsDebug('1. Follow the instructions to translate your source code:');
94
+ additionsDebug(
95
95
  ' https://grafana.com/developers/plugin-tools/how-to-guides/plugin-internationalization-grafana-11#determine-the-text-to-translate'
96
96
  );
97
- console.log('2. Run the i18n-extract script to scan your code for translatable strings:');
98
- console.log(' npm run i18n-extract (or yarn/pnpm run i18n-extract)');
99
- console.log('3. Fill in your locale JSON files with translated strings\n');
97
+ additionsDebug('2. Run the i18n-extract script to scan your code for translatable strings:');
98
+ additionsDebug(' npm run i18n-extract (or yarn/pnpm run i18n-extract)');
99
+ additionsDebug('3. Fill in your locale JSON files with translated strings\n');
100
100
 
101
101
  return context;
102
102
  }