hale-commenting-system 2.2.94 → 2.2.95

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hale-commenting-system",
3
- "version": "2.2.94",
3
+ "version": "2.2.95",
4
4
  "description": "A commenting system for PatternFly React applications that allows designers and developers to add comments directly on design pages, sync with GitHub Issues, and link Jira tickets.",
5
5
  "repository": "https://github.com/patternfly/patternfly-react-seed.git",
6
6
  "homepage": "https://www.npmjs.com/package/hale-commenting-system",
@@ -1288,14 +1288,40 @@ function modifyAppLayoutTsx(filePath) {
1288
1288
  }
1289
1289
 
1290
1290
  // Step 3: Add the special renderNavGroup logic
1291
- // Find the renderNavGroup function
1292
- const renderNavGroupMatch = content.match(/const\s+renderNavGroup\s*=\s*\([^)]+\)\s*=>\s*\{?/);
1293
- if (renderNavGroupMatch && !content.includes("group.label === 'Comments'")) {
1294
- const funcStart = content.indexOf(renderNavGroupMatch[0]);
1295
- const funcStartBrace = content.indexOf('{', funcStart) || content.indexOf('(', funcStart);
1296
-
1297
- // Insert the special Comments handling at the start of the function
1298
- const specialHandling = `
1291
+ // Replace the simple arrow function with a block function that has special Comments handling
1292
+ if (!content.includes("group.label === 'Comments'")) {
1293
+ // Find the renderNavGroup function - handle both arrow expression () => (...) and block () => {...}
1294
+ const arrowFuncMatch = content.match(/const\s+renderNavGroup\s*=\s*\(([^)]+)\)\s*=>\s*\(/);
1295
+
1296
+ if (arrowFuncMatch) {
1297
+ const params = arrowFuncMatch[1];
1298
+
1299
+ // Find the entire function including the closing parenthesis and semicolon
1300
+ const funcStart = content.indexOf(arrowFuncMatch[0]);
1301
+ const afterArrow = funcStart + arrowFuncMatch[0].length;
1302
+
1303
+ // Find matching closing paren and semicolon
1304
+ let depth = 1;
1305
+ let endPos = afterArrow;
1306
+ for (let i = afterArrow; i < content.length; i++) {
1307
+ if (content.charAt(i) === '(') depth++;
1308
+ if (content.charAt(i) === ')') {
1309
+ depth--;
1310
+ if (depth === 0) {
1311
+ // Found the closing paren, now find the semicolon
1312
+ endPos = i + 1;
1313
+ while (endPos < content.length && content.charAt(endPos).trim() === '') endPos++;
1314
+ if (content.charAt(endPos) === ';') endPos++;
1315
+ break;
1316
+ }
1317
+ }
1318
+ }
1319
+
1320
+ // Extract the original NavExpandable JSX (we'll use it as the default case)
1321
+ const originalBody = content.slice(funcStart + arrowFuncMatch[0].length - 1, endPos - 1); // Remove opening ( and closing );
1322
+
1323
+ // Create the new block function
1324
+ const newFunction = `const renderNavGroup = (${params}) => {
1299
1325
  // Special handling for Comments group
1300
1326
  if (group.label === 'Comments') {
1301
1327
  return (
@@ -1381,9 +1407,12 @@ function modifyAppLayoutTsx(filePath) {
1381
1407
  }
1382
1408
 
1383
1409
  // Default handling for other groups
1384
- `;
1410
+ return ${originalBody};
1411
+ };`;
1385
1412
 
1386
- content = content.slice(0, funcStartBrace + 1) + specialHandling + content.slice(funcStartBrace + 1);
1413
+ // Replace the old function with the new one
1414
+ content = content.slice(0, funcStart) + newFunction + content.slice(endPos);
1415
+ }
1387
1416
  }
1388
1417
 
1389
1418
  // Step 4: Wrap Page children if not already done