hale-commenting-system 3.4.3 → 3.4.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/README.md CHANGED
@@ -27,6 +27,8 @@ The automated integration script (`npx hale-commenting-system init`) works best
27
27
  npm install hale-commenting-system
28
28
  ```
29
29
 
30
+ > **⚠️ Important:** This package modifies your project files during installation. Before uninstalling, always run `npx hale-commenting-system remove` to cleanly remove the integration and avoid breaking your application.
31
+
30
32
  ## Quick Start
31
33
 
32
34
  1. **Install the package:**
@@ -50,6 +52,53 @@ npm install hale-commenting-system
50
52
  npm run start:dev
51
53
  ```
52
54
 
55
+ ## Uninstalling
56
+
57
+ **IMPORTANT:** Before uninstalling the package, you must first remove the integration to avoid breaking your application.
58
+
59
+ ### Clean Uninstall Process
60
+
61
+ 1. **Run the removal script:**
62
+ ```bash
63
+ npx hale-commenting-system remove
64
+ ```
65
+
66
+ 2. **Uninstall the package:**
67
+ ```bash
68
+ npm uninstall hale-commenting-system
69
+ ```
70
+
71
+ 3. **Restart your dev server:**
72
+ ```bash
73
+ npm run start:dev
74
+ ```
75
+
76
+ ### What the Removal Script Does
77
+
78
+ The removal script will automatically:
79
+ - Remove imports from `src/app/index.tsx`
80
+ - Remove imports from `src/app/AppLayout/AppLayout.tsx`
81
+ - Notify you about webpack middleware (may require manual removal)
82
+ - Keep `.env` and `.env.server` files (you can delete manually if needed)
83
+
84
+ ### Manual Uninstall (If Needed)
85
+
86
+ If you need to manually remove the integration:
87
+
88
+ 1. **In `src/app/index.tsx`**, remove:
89
+ ```typescript
90
+ import { CommentProvider, GitHubAuthProvider } from "hale-commenting-system";
91
+ ```
92
+ And remove the `<GitHubAuthProvider>` and `<CommentProvider>` wrappers.
93
+
94
+ 2. **In `src/app/AppLayout/AppLayout.tsx`**, remove:
95
+ ```typescript
96
+ import { CommentPanel, CommentOverlay } from "hale-commenting-system";
97
+ ```
98
+ And remove the `<CommentPanel>` and `<CommentOverlay />` components.
99
+
100
+ 3. **In `webpack.dev.js`**, remove the middleware configuration added for GitHub OAuth and Jira API proxying.
101
+
53
102
  ## Usage
54
103
 
55
104
  After running the integration script, the commenting system will be available in your PatternFly React Seed application.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "hale-commenting-system",
3
- "version": "3.4.3",
3
+ "version": "3.4.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
  "license": "MIT",
7
7
  "main": "src/app/commenting-system/index.ts",
8
8
  "types": "src/app/commenting-system/index.ts",
9
9
  "bin": {
10
- "hale-commenting-system": "scripts/integrate.js"
10
+ "hale-commenting-system": "scripts/cli.js"
11
11
  },
12
12
  "files": [
13
13
  "src/app/commenting-system/",
package/scripts/cli.js ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+
6
+ const command = process.argv[2];
7
+
8
+ const scriptMap = {
9
+ init: 'integrate.js',
10
+ remove: 'remove.js',
11
+ uninstall: 'remove.js',
12
+ };
13
+
14
+ if (!command || command === 'init') {
15
+ // Default to init
16
+ const scriptPath = path.join(__dirname, 'integrate.js');
17
+ const child = spawn('node', [scriptPath], { stdio: 'inherit' });
18
+ child.on('exit', (code) => process.exit(code));
19
+ } else if (scriptMap[command]) {
20
+ const scriptPath = path.join(__dirname, scriptMap[command]);
21
+ const child = spawn('node', [scriptPath], { stdio: 'inherit' });
22
+ child.on('exit', (code) => process.exit(code));
23
+ } else {
24
+ console.log('\n╔════════════════════════════════════════════════════╗');
25
+ console.log('║ Hale Commenting System - CLI ║');
26
+ console.log('╚════════════════════════════════════════════════════╝\n');
27
+ console.log('Usage:');
28
+ console.log(' npx hale-commenting-system init Install and integrate the commenting system');
29
+ console.log(' npx hale-commenting-system remove Remove the commenting system');
30
+ console.log(' npx hale-commenting-system uninstall Remove the commenting system (alias)\n');
31
+ process.exit(1);
32
+ }
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const readline = require('readline');
6
+
7
+ const rl = readline.createInterface({
8
+ input: process.stdin,
9
+ output: process.stdout,
10
+ });
11
+
12
+ const prompt = (questions) => {
13
+ return new Promise((resolve) => {
14
+ const answers = {};
15
+ let currentIndex = 0;
16
+
17
+ const askNext = () => {
18
+ if (currentIndex >= questions.length) {
19
+ rl.close();
20
+ resolve(answers);
21
+ return;
22
+ }
23
+
24
+ const q = questions[currentIndex];
25
+ rl.question(q.message + ' ', (answer) => {
26
+ answers[q.name] = answer.trim();
27
+ currentIndex++;
28
+ askNext();
29
+ });
30
+ };
31
+
32
+ askNext();
33
+ });
34
+ };
35
+
36
+ console.log('\n╔════════════════════════════════════════════════════╗');
37
+ console.log('║ Hale Commenting System - Uninstall Script ║');
38
+ console.log('╚════════════════════════════════════════════════════╝\n');
39
+
40
+ console.log('⚠️ This will remove the Hale Commenting System from your project.\n');
41
+ console.log('The following changes will be reverted:');
42
+ console.log(' • Remove imports from src/app/index.tsx');
43
+ console.log(' • Remove imports from src/app/AppLayout/AppLayout.tsx');
44
+ console.log(' • Remove middleware from webpack.dev.js');
45
+ console.log(' • Keep .env and .env.server files (you can delete manually if needed)\n');
46
+
47
+ async function main() {
48
+ const confirm = await prompt([
49
+ {
50
+ name: 'proceed',
51
+ message: 'Do you want to proceed? (yes/no):',
52
+ },
53
+ ]);
54
+
55
+ if (confirm.proceed.toLowerCase() !== 'yes' && confirm.proceed.toLowerCase() !== 'y') {
56
+ console.log('\n❌ Uninstall cancelled.\n');
57
+ rl.close();
58
+ return;
59
+ }
60
+
61
+ console.log('\n🔧 Removing Hale Commenting System...\n');
62
+
63
+ // Find project root
64
+ const projectRoot = process.cwd();
65
+ let filesModified = 0;
66
+
67
+ // 1. Remove from src/app/index.tsx
68
+ const indexPath = path.join(projectRoot, 'src/app/index.tsx');
69
+ if (fs.existsSync(indexPath)) {
70
+ let content = fs.readFileSync(indexPath, 'utf8');
71
+ const originalContent = content;
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, '');
75
+
76
+ // Remove the providers from JSX
77
+ content = content.replace(/<GitHubAuthProvider>\s*/g, '');
78
+ content = content.replace(/<\/GitHubAuthProvider>/g, '');
79
+ content = content.replace(/<CommentProvider>\s*/g, '');
80
+ content = content.replace(/<\/CommentProvider>/g, '');
81
+
82
+ if (content !== originalContent) {
83
+ fs.writeFileSync(indexPath, content, 'utf8');
84
+ console.log('✅ Removed from src/app/index.tsx');
85
+ filesModified++;
86
+ }
87
+ }
88
+
89
+ // 2. Remove from src/app/AppLayout/AppLayout.tsx
90
+ const appLayoutPath = path.join(projectRoot, 'src/app/AppLayout/AppLayout.tsx');
91
+ if (fs.existsSync(appLayoutPath)) {
92
+ let content = fs.readFileSync(appLayoutPath, 'utf8');
93
+ const originalContent = content;
94
+
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, '');
97
+
98
+ // Remove the components from JSX
99
+ content = content.replace(/<CommentPanel>\s*/g, '');
100
+ content = content.replace(/<\/CommentPanel>/g, '');
101
+ content = content.replace(/<CommentOverlay\s*\/>\s*/g, '');
102
+
103
+ if (content !== originalContent) {
104
+ fs.writeFileSync(appLayoutPath, content, 'utf8');
105
+ console.log('✅ Removed from src/app/AppLayout/AppLayout.tsx');
106
+ filesModified++;
107
+ }
108
+ }
109
+
110
+ // 3. Remove middleware from webpack.dev.js (optional - can be complex)
111
+ const webpackPath = path.join(projectRoot, 'webpack.dev.js');
112
+ if (fs.existsSync(webpackPath)) {
113
+ console.log('ℹ️ webpack.dev.js - You may want to manually remove the middleware configuration');
114
+ }
115
+
116
+ console.log('\n╔══════════════════════════════════════════════════════════╗');
117
+ console.log('║ ✅ Uninstall Complete! ║');
118
+ console.log('╚══════════════════════════════════════════════════════════╝\n');
119
+
120
+ console.log(`Modified ${filesModified} file(s)\n`);
121
+
122
+ console.log('Next steps:');
123
+ console.log('1. Run: npm uninstall hale-commenting-system');
124
+ console.log('2. Restart your dev server: npm run start:dev');
125
+ console.log('3. (Optional) Delete .env and .env.server if no longer needed\n');
126
+
127
+ rl.close();
128
+ }
129
+
130
+ main().catch((err) => {
131
+ console.error('❌ Error during uninstall:', err);
132
+ rl.close();
133
+ process.exit(1);
134
+ });