hale-commenting-system 3.8.2 → 3.8.5

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": "3.8.2",
3
+ "version": "3.8.5",
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
  "homepage": "https://www.npmjs.com/package/hale-commenting-system",
6
6
  "repository": {
@@ -466,25 +466,64 @@ VITE_JIRA_BASE_URL=
466
466
  if (fs.existsSync(envPath)) {
467
467
  let existing = fs.readFileSync(envPath, 'utf-8');
468
468
 
469
- if (existing.includes('VITE_GITHUB_CLIENT_ID')) {
470
- // Update existing values
469
+ // Check if commenting system config exists (either GitHub or GitLab)
470
+ const hasCommentingSystemConfig = existing.includes('Hale Commenting System') ||
471
+ existing.includes('VITE_GITHUB_CLIENT_ID') ||
472
+ existing.includes('VITE_GITLAB_CLIENT_ID') ||
473
+ existing.includes('VITE_PROVIDER_TYPE');
474
+
475
+ if (hasCommentingSystemConfig) {
476
+ // Remove old commenting system section and replace with new one
471
477
  const lines = existing.split('\n');
472
- const updatedLines = lines.map(line => {
473
- if (line.startsWith('VITE_GITHUB_CLIENT_ID=')) {
474
- return `VITE_GITHUB_CLIENT_ID=${config.github?.clientId || ''}`;
475
- }
476
- if (line.startsWith('VITE_GITHUB_OWNER=')) {
477
- return `VITE_GITHUB_OWNER=${config.owner || ''}`;
478
- }
479
- if (line.startsWith('VITE_GITHUB_REPO=')) {
480
- return `VITE_GITHUB_REPO=${config.repo || ''}`;
478
+ let newLines = [];
479
+ let inCommentingSection = false;
480
+ let foundSection = false;
481
+
482
+ for (let i = 0; i < lines.length; i++) {
483
+ const line = lines[i];
484
+
485
+ // Detect start of commenting system section
486
+ if (line.includes('Hale Commenting System')) {
487
+ inCommentingSection = true;
488
+ foundSection = true;
489
+ // Add the new content at this position
490
+ newLines.push(...envContent.split('\n'));
491
+ continue;
481
492
  }
482
- if (line.startsWith('VITE_JIRA_BASE_URL=')) {
483
- return `VITE_JIRA_BASE_URL=${config.jira?.baseUrl || ''}`;
493
+
494
+ // Skip lines that are part of the commenting system config
495
+ if (inCommentingSection) {
496
+ // Check if this is still part of the commenting system section
497
+ if (line.startsWith('VITE_GITHUB_') ||
498
+ line.startsWith('VITE_GITLAB_') ||
499
+ line.startsWith('VITE_PROVIDER_TYPE') ||
500
+ line.startsWith('VITE_JIRA_BASE_URL') ||
501
+ (line.startsWith('#') && (line.includes('GitHub') || line.includes('GitLab') || line.includes('Jira') || line.includes('Provider')))) {
502
+ // Still in commenting section, skip this line
503
+ continue;
504
+ }
505
+
506
+ // Empty line after commenting section - skip it and exit section
507
+ if (line.trim() === '') {
508
+ inCommentingSection = false;
509
+ continue;
510
+ }
511
+
512
+ // Non-empty, non-commenting line - exit section and keep the line
513
+ inCommentingSection = false;
484
514
  }
485
- return line;
486
- });
487
- fs.writeFileSync(envPath, updatedLines.join('\n'));
515
+
516
+ // Keep lines that are not part of commenting system section
517
+ newLines.push(line);
518
+ }
519
+
520
+ // If we didn't find the section marker, append to end
521
+ if (!foundSection) {
522
+ newLines.push('');
523
+ newLines.push(...envContent.split('\n'));
524
+ }
525
+
526
+ fs.writeFileSync(envPath, newLines.join('\n'));
488
527
  console.log(' ✅ Updated .env file');
489
528
  } else {
490
529
  // Append if commenting system config not present
@@ -1377,6 +1416,21 @@ async function main() {
1377
1416
  process.exit(1);
1378
1417
  }
1379
1418
 
1419
+ // Check if the package is installed
1420
+ const cwd = process.cwd();
1421
+ const packageJsonPath = path.join(cwd, 'package.json');
1422
+ const nodeModulesPath = path.join(cwd, 'node_modules', 'hale-commenting-system');
1423
+
1424
+ if (!fs.existsSync(nodeModulesPath)) {
1425
+ console.error('\n❌ Error: hale-commenting-system is not installed.');
1426
+ console.error('Please install it first:');
1427
+ console.error(' npm install hale-commenting-system');
1428
+ console.error('Then run this command again:');
1429
+ console.error(' npx hale-commenting-system init\n');
1430
+ rl.close();
1431
+ process.exit(1);
1432
+ }
1433
+
1380
1434
  // Detect project setup type
1381
1435
  const gitInfo = detectGitRemote();
1382
1436
  const setupType = detectProjectSetup();
package/scripts/remove.js CHANGED
@@ -70,12 +70,25 @@ async function main() {
70
70
  let content = fs.readFileSync(indexPath, 'utf8');
71
71
  const originalContent = content;
72
72
 
73
- // Remove the import
74
- content = content.replace(/import\s*{\s*CommentProvider\s*,\s*GitHubAuthProvider\s*}\s*from\s*["']hale-commenting-system["'];?\s*\n?/g, '');
73
+ // Remove imports - handle both old (GitHubAuthProvider) and new (ProviderAuthProvider) names
74
+ // Also handle both @app/commenting-system and hale-commenting-system import paths
75
+ const importPatterns = [
76
+ // Pattern 1: Both providers together (any order)
77
+ /import\s*{\s*[^}]*CommentProvider[^}]*,\s*(?:GitHubAuthProvider|ProviderAuthProvider)[^}]*}\s*from\s*["'](?:@app\/commenting-system|hale-commenting-system)["'];?\s*\n?/g,
78
+ /import\s*{\s*(?:GitHubAuthProvider|ProviderAuthProvider)[^}]*,\s*[^}]*CommentProvider[^}]*}\s*from\s*["'](?:@app\/commenting-system|hale-commenting-system)["'];?\s*\n?/g,
79
+ // Pattern 2: Single CommentProvider
80
+ /import\s*{\s*CommentProvider\s*}\s*from\s*["'](?:@app\/commenting-system|hale-commenting-system)["'];?\s*\n?/g,
81
+ // Pattern 3: Single auth provider (old or new)
82
+ /import\s*{\s*(?:GitHubAuthProvider|ProviderAuthProvider)\s*}\s*from\s*["'](?:@app\/commenting-system|hale-commenting-system)["'];?\s*\n?/g,
83
+ ];
84
+
85
+ for (const pattern of importPatterns) {
86
+ content = content.replace(pattern, '');
87
+ }
75
88
 
76
- // Remove the providers from JSX
77
- content = content.replace(/<GitHubAuthProvider>\s*/g, '');
78
- content = content.replace(/<\/GitHubAuthProvider>/g, '');
89
+ // Remove the providers from JSX - handle both old and new provider names
90
+ content = content.replace(/<(?:GitHubAuthProvider|ProviderAuthProvider)>\s*/g, '');
91
+ content = content.replace(/<\/(?:GitHubAuthProvider|ProviderAuthProvider)>/g, '');
79
92
  content = content.replace(/<CommentProvider>\s*/g, '');
80
93
  content = content.replace(/<\/CommentProvider>/g, '');
81
94
 
@@ -92,13 +105,25 @@ async function main() {
92
105
  let content = fs.readFileSync(appLayoutPath, 'utf8');
93
106
  const originalContent = content;
94
107
 
95
- // Remove the import
96
- content = content.replace(/import\s*{\s*CommentPanel\s*,\s*CommentOverlay\s*}\s*from\s*["']hale-commenting-system["'];?\s*\n?/g, '');
108
+ // Remove the import - handle both import paths
109
+ const importPatterns = [
110
+ // Both components together
111
+ /import\s*{\s*CommentPanel\s*,\s*CommentOverlay\s*}\s*from\s*["'](?:@app\/commenting-system|hale-commenting-system)["'];?\s*\n?/g,
112
+ // Single CommentPanel
113
+ /import\s*{\s*CommentPanel\s*}\s*from\s*["'](?:@app\/commenting-system|hale-commenting-system)["'];?\s*\n?/g,
114
+ // Single CommentOverlay
115
+ /import\s*{\s*CommentOverlay\s*}\s*from\s*["'](?:@app\/commenting-system|hale-commenting-system)["'];?\s*\n?/g,
116
+ ];
117
+
118
+ for (const pattern of importPatterns) {
119
+ content = content.replace(pattern, '');
120
+ }
97
121
 
98
122
  // Remove the components from JSX
99
123
  content = content.replace(/<CommentPanel>\s*/g, '');
100
124
  content = content.replace(/<\/CommentPanel>/g, '');
101
125
  content = content.replace(/<CommentOverlay\s*\/>\s*/g, '');
126
+ content = content.replace(/<CommentOverlay\s+[^>]*\/>\s*/g, '');
102
127
 
103
128
  if (content !== originalContent) {
104
129
  fs.writeFileSync(appLayoutPath, content, 'utf8');