gtx-cli 2.1.1 → 2.1.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#562](https://github.com/generaltranslation/gt/pull/562) [`8461c5e`](https://github.com/generaltranslation/gt/commit/8461c5ee2ca25cf50d4e366cb4d1e765107851fd) Thanks [@SamEggert](https://github.com/SamEggert)! - localStaticImports gracefully handles invalid MDX
8
+
3
9
  ## 2.1.1
4
10
 
5
11
  ### Patch Changes
@@ -221,12 +221,24 @@ function transformMdxImports(mdxContent, defaultLocale, targetLocale, hideDefaul
221
221
  }
222
222
  }
223
223
  // Parse the MDX content into an AST
224
- const parseProcessor = unified()
225
- .use(remarkParse)
226
- .use(remarkFrontmatter, ['yaml', 'toml'])
227
- .use(remarkMdx);
228
- const ast = parseProcessor.parse(mdxContent);
229
- const processedAst = parseProcessor.runSync(ast);
224
+ let processedAst;
225
+ try {
226
+ const parseProcessor = unified()
227
+ .use(remarkParse)
228
+ .use(remarkFrontmatter, ['yaml', 'toml'])
229
+ .use(remarkMdx);
230
+ const ast = parseProcessor.parse(mdxContent);
231
+ processedAst = parseProcessor.runSync(ast);
232
+ }
233
+ catch (error) {
234
+ console.warn(`Failed to parse MDX content: ${error instanceof Error ? error.message : String(error)}`);
235
+ console.warn('Returning original content unchanged due to parsing error.');
236
+ return {
237
+ content: mdxContent,
238
+ hasChanges: false,
239
+ transformedImports: [],
240
+ };
241
+ }
230
242
  // Visit only mdxjsEsm nodes (import/export statements)
231
243
  visit(processedAst, 'mdxjsEsm', (node) => {
232
244
  if (node.value && node.value.includes(patternHead.replace(/\/$/, ''))) {
@@ -282,11 +294,23 @@ function transformMdxImports(mdxContent, defaultLocale, targetLocale, hideDefaul
282
294
  }
283
295
  });
284
296
  // Convert the modified AST back to MDX string
285
- const stringifyProcessor = unified()
286
- .use(remarkStringify)
287
- .use(remarkFrontmatter, ['yaml', 'toml'])
288
- .use(remarkMdx);
289
- let content = stringifyProcessor.stringify(processedAst);
297
+ let content;
298
+ try {
299
+ const stringifyProcessor = unified()
300
+ .use(remarkStringify)
301
+ .use(remarkFrontmatter, ['yaml', 'toml'])
302
+ .use(remarkMdx);
303
+ content = stringifyProcessor.stringify(processedAst);
304
+ }
305
+ catch (error) {
306
+ console.warn(`Failed to stringify MDX content: ${error instanceof Error ? error.message : String(error)}`);
307
+ console.warn('Returning original content unchanged due to stringify error.');
308
+ return {
309
+ content: mdxContent,
310
+ hasChanges: false,
311
+ transformedImports: [],
312
+ };
313
+ }
290
314
  // Handle newline formatting to match original input
291
315
  if (content.endsWith('\n') && !mdxContent.endsWith('\n')) {
292
316
  content = content.slice(0, -1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [