hale-commenting-system 2.2.0 → 2.2.1

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.
Files changed (99) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/.editorconfig +17 -0
  3. package/.eslintrc.js +75 -0
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
  5. package/.github/workflows/ci.yaml +51 -0
  6. package/.prettierignore +1 -0
  7. package/.prettierrc +4 -0
  8. package/GITHUB_OAUTH_ENV_TEMPLATE.md +53 -0
  9. package/LICENSE +21 -0
  10. package/README.md +92 -21
  11. package/package.json +74 -50
  12. package/scripts/README.md +42 -0
  13. package/scripts/integrate.js +440 -0
  14. package/src/app/AppLayout/AppLayout.tsx +248 -0
  15. package/src/app/Comments/Comments.tsx +273 -0
  16. package/src/app/Dashboard/Dashboard.tsx +10 -0
  17. package/src/app/NotFound/NotFound.tsx +35 -0
  18. package/src/app/Settings/General/GeneralSettings.tsx +16 -0
  19. package/src/app/Settings/Profile/ProfileSettings.tsx +18 -0
  20. package/src/app/Support/Support.tsx +50 -0
  21. package/src/app/__snapshots__/app.test.tsx.snap +524 -0
  22. package/src/app/app.css +11 -0
  23. package/src/app/app.test.tsx +55 -0
  24. package/src/app/bgimages/Patternfly-Logo.svg +28 -0
  25. package/src/app/commenting-system/components/CommentOverlay.tsx +93 -0
  26. package/src/app/commenting-system/components/CommentPanel.tsx +534 -0
  27. package/src/app/commenting-system/components/CommentPin.tsx +60 -0
  28. package/src/app/commenting-system/components/DetailsTab.tsx +516 -0
  29. package/src/app/commenting-system/components/FloatingWidget.tsx +130 -0
  30. package/src/app/commenting-system/components/JiraTab.tsx +696 -0
  31. package/src/app/commenting-system/contexts/CommentContext.tsx +1033 -0
  32. package/src/app/commenting-system/contexts/GitHubAuthContext.tsx +84 -0
  33. package/{dist/index.d.ts → src/app/commenting-system/index.ts} +5 -4
  34. package/src/app/commenting-system/services/githubAdapter.ts +359 -0
  35. package/src/app/commenting-system/types/index.ts +27 -0
  36. package/src/app/commenting-system/utils/version.ts +19 -0
  37. package/src/app/index.tsx +22 -0
  38. package/src/app/routes.tsx +81 -0
  39. package/src/app/utils/useDocumentTitle.ts +13 -0
  40. package/src/favicon.png +0 -0
  41. package/src/index.html +18 -0
  42. package/src/index.tsx +25 -0
  43. package/src/test/setup.ts +33 -0
  44. package/src/typings.d.ts +12 -0
  45. package/stylePaths.js +14 -0
  46. package/tsconfig.json +34 -0
  47. package/vitest.config.ts +19 -0
  48. package/webpack.common.js +139 -0
  49. package/webpack.dev.js +318 -0
  50. package/webpack.prod.js +38 -0
  51. package/bin/detect.d.ts +0 -10
  52. package/bin/detect.js +0 -134
  53. package/bin/generators.d.ts +0 -20
  54. package/bin/generators.js +0 -272
  55. package/bin/hale-commenting.js +0 -4
  56. package/bin/index.d.ts +0 -2
  57. package/bin/index.js +0 -61
  58. package/bin/onboarding.d.ts +0 -1
  59. package/bin/onboarding.js +0 -395
  60. package/bin/postinstall.d.ts +0 -2
  61. package/bin/postinstall.js +0 -65
  62. package/bin/validators.d.ts +0 -2
  63. package/bin/validators.js +0 -66
  64. package/dist/cli/detect.d.ts +0 -10
  65. package/dist/cli/detect.js +0 -134
  66. package/dist/cli/generators.d.ts +0 -20
  67. package/dist/cli/generators.js +0 -272
  68. package/dist/cli/index.d.ts +0 -2
  69. package/dist/cli/index.js +0 -61
  70. package/dist/cli/onboarding.d.ts +0 -1
  71. package/dist/cli/onboarding.js +0 -395
  72. package/dist/cli/postinstall.d.ts +0 -2
  73. package/dist/cli/postinstall.js +0 -65
  74. package/dist/cli/validators.d.ts +0 -2
  75. package/dist/cli/validators.js +0 -66
  76. package/dist/components/CommentOverlay.d.ts +0 -2
  77. package/dist/components/CommentOverlay.js +0 -101
  78. package/dist/components/CommentPanel.d.ts +0 -6
  79. package/dist/components/CommentPanel.js +0 -334
  80. package/dist/components/CommentPin.d.ts +0 -11
  81. package/dist/components/CommentPin.js +0 -64
  82. package/dist/components/DetailsTab.d.ts +0 -2
  83. package/dist/components/DetailsTab.js +0 -380
  84. package/dist/components/FloatingWidget.d.ts +0 -8
  85. package/dist/components/FloatingWidget.js +0 -128
  86. package/dist/components/JiraTab.d.ts +0 -2
  87. package/dist/components/JiraTab.js +0 -507
  88. package/dist/contexts/CommentContext.d.ts +0 -30
  89. package/dist/contexts/CommentContext.js +0 -891
  90. package/dist/contexts/GitHubAuthContext.d.ts +0 -13
  91. package/dist/contexts/GitHubAuthContext.js +0 -96
  92. package/dist/index.js +0 -27
  93. package/dist/services/githubAdapter.d.ts +0 -56
  94. package/dist/services/githubAdapter.js +0 -321
  95. package/dist/types/index.d.ts +0 -25
  96. package/dist/types/index.js +0 -2
  97. package/dist/utils/version.d.ts +0 -1
  98. package/dist/utils/version.js +0 -23
  99. package/templates/webpack-middleware.js +0 -226
@@ -1,20 +0,0 @@
1
- interface GitHubConfig {
2
- clientId?: string;
3
- clientSecret?: string;
4
- owner?: string;
5
- repo?: string;
6
- }
7
- interface JiraConfig {
8
- baseUrl?: string;
9
- apiToken?: string;
10
- email?: string;
11
- }
12
- interface Config {
13
- github: GitHubConfig | null;
14
- jira: JiraConfig | null;
15
- owner: string;
16
- repo: string;
17
- }
18
- export declare function generateFiles(config: Config): Promise<void>;
19
- export declare function integrateIntoProject(): Promise<void>;
20
- export {};
@@ -1,272 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.generateFiles = generateFiles;
37
- exports.integrateIntoProject = integrateIntoProject;
38
- const fs = __importStar(require("fs"));
39
- const path = __importStar(require("path"));
40
- async function generateFiles(config) {
41
- const cwd = process.cwd();
42
- // Generate .env file (client-safe)
43
- const envPath = path.join(cwd, '.env');
44
- let envContent = `# Hale Commenting System Configuration
45
- # Client-safe environment variables (these are exposed to the browser)
46
-
47
- `;
48
- if (config.github && config.github.clientId) {
49
- envContent += `# GitHub OAuth (client-side; safe to expose)
50
- # Get your Client ID from: https://github.com/settings/developers
51
- # 1. Click "New OAuth App"
52
- # 2. Fill in the form (Homepage: http://localhost:9000, Callback: http://localhost:9000/api/github-oauth-callback)
53
- # 3. Copy the Client ID
54
- VITE_GITHUB_CLIENT_ID=${config.github.clientId}
55
-
56
- # Target repo for Issues/Comments
57
- VITE_GITHUB_OWNER=${config.github.owner || config.owner}
58
- VITE_GITHUB_REPO=${config.github.repo || config.repo}
59
-
60
- `;
61
- }
62
- else {
63
- envContent += `# GitHub OAuth (client-side; safe to expose)
64
- # Get your Client ID from: https://github.com/settings/developers
65
- # 1. Click "New OAuth App"
66
- # 2. Fill in the form (Homepage: http://localhost:9000, Callback: http://localhost:9000/api/github-oauth-callback)
67
- # 3. Copy the Client ID
68
- VITE_GITHUB_CLIENT_ID=
69
-
70
- # Target repo for Issues/Comments
71
- VITE_GITHUB_OWNER=${config.owner}
72
- VITE_GITHUB_REPO=${config.repo}
73
-
74
- `;
75
- }
76
- if (config.jira && config.jira.baseUrl) {
77
- envContent += `# Jira Base URL
78
- # For Red Hat Jira, use: https://issues.redhat.com
79
- VITE_JIRA_BASE_URL=${config.jira.baseUrl}
80
- `;
81
- }
82
- else {
83
- envContent += `# Jira Base URL
84
- # For Red Hat Jira, use: https://issues.redhat.com
85
- VITE_JIRA_BASE_URL=
86
- `;
87
- }
88
- // Check if .env exists and append or create
89
- if (fs.existsSync(envPath)) {
90
- const existing = fs.readFileSync(envPath, 'utf-8');
91
- // Only add if not already present
92
- if (!existing.includes('VITE_GITHUB_CLIENT_ID')) {
93
- fs.appendFileSync(envPath, '\n' + envContent);
94
- console.log(' ✅ Updated .env file');
95
- }
96
- else {
97
- console.log(' ⚠️ .env already contains commenting system config');
98
- }
99
- }
100
- else {
101
- fs.writeFileSync(envPath, envContent);
102
- console.log(' ✅ Created .env file');
103
- }
104
- // Note about empty values
105
- if (!config.github || !config.jira) {
106
- console.log(' ℹ️ Some values are empty - see comments in .env for setup instructions');
107
- }
108
- // Generate .env.server file (secrets)
109
- const envServerPath = path.join(cwd, '.env.server');
110
- let envServerContent = `# Hale Commenting System - Server Secrets
111
- # ⚠️ DO NOT COMMIT THIS FILE - It contains sensitive credentials
112
- # This file is automatically added to .gitignore
113
-
114
- `;
115
- if (config.github && config.github.clientSecret) {
116
- envServerContent += `# GitHub OAuth Client Secret (server-only)
117
- # Get this from your GitHub OAuth App settings: https://github.com/settings/developers
118
- # Click on your OAuth App, then "Generate a new client secret"
119
- GITHUB_CLIENT_SECRET=${config.github.clientSecret}
120
-
121
- `;
122
- }
123
- else {
124
- envServerContent += `# GitHub OAuth Client Secret (server-only)
125
- # Get this from your GitHub OAuth App settings: https://github.com/settings/developers
126
- # Click on your OAuth App, then "Generate a new client secret"
127
- GITHUB_CLIENT_SECRET=
128
-
129
- `;
130
- }
131
- if (config.jira && config.jira.apiToken) {
132
- envServerContent += `# Jira API Token (server-only)
133
- # For Red Hat Jira, generate a Personal Access Token:
134
- # 1. Visit: https://issues.redhat.com/secure/ViewProfile.jspa
135
- # 2. Click "Personal Access Tokens" in the left sidebar
136
- # 3. Click "Create token"
137
- # 4. Give it a name and remove expiration
138
- # 5. Copy the token
139
- JIRA_API_TOKEN=${config.jira.apiToken}
140
- `;
141
- }
142
- else {
143
- envServerContent += `# Jira API Token (server-only)
144
- # For Red Hat Jira, generate a Personal Access Token:
145
- # 1. Visit: https://issues.redhat.com/secure/ViewProfile.jspa
146
- # 2. Click "Personal Access Tokens" in the left sidebar
147
- # 3. Click "Create token"
148
- # 4. Give it a name and remove expiration
149
- # 5. Copy the token
150
- JIRA_API_TOKEN=
151
- `;
152
- }
153
- if (config.jira && config.jira.email) {
154
- envServerContent += `JIRA_EMAIL=${config.jira.email}\n`;
155
- }
156
- if (fs.existsSync(envServerPath)) {
157
- const existing = fs.readFileSync(envServerPath, 'utf-8');
158
- if (!existing.includes('GITHUB_CLIENT_SECRET')) {
159
- fs.appendFileSync(envServerPath, '\n' + envServerContent);
160
- console.log(' ✅ Updated .env.server file');
161
- }
162
- else {
163
- console.log(' ⚠️ .env.server already contains commenting system config');
164
- }
165
- }
166
- else {
167
- fs.writeFileSync(envServerPath, envServerContent);
168
- console.log(' ✅ Created .env.server file');
169
- }
170
- // Note about empty values
171
- if (!config.github || !config.jira) {
172
- console.log(' ℹ️ Some values are empty - see comments in .env.server for setup instructions');
173
- }
174
- // Ensure .env.server is in .gitignore
175
- const gitignorePath = path.join(cwd, '.gitignore');
176
- if (fs.existsSync(gitignorePath)) {
177
- const gitignore = fs.readFileSync(gitignorePath, 'utf-8');
178
- if (!gitignore.includes('.env.server')) {
179
- fs.appendFileSync(gitignorePath, '\n.env.server\n');
180
- console.log(' ✅ Added .env.server to .gitignore');
181
- }
182
- }
183
- else {
184
- fs.writeFileSync(gitignorePath, '.env.server\n');
185
- console.log(' ✅ Created .gitignore with .env.server');
186
- }
187
- }
188
- async function integrateIntoProject() {
189
- const cwd = process.cwd();
190
- const webpackDevPath = path.join(cwd, 'webpack.dev.js');
191
- if (!fs.existsSync(webpackDevPath)) {
192
- console.error(' ❌ webpack.dev.js not found. Cannot auto-integrate.');
193
- return;
194
- }
195
- // Read webpack.dev.js
196
- let webpackContent = fs.readFileSync(webpackDevPath, 'utf-8');
197
- // Check if already integrated
198
- if (webpackContent.includes('/api/github-oauth-callback') || webpackContent.includes('/api/jira-issue')) {
199
- console.log(' ⚠️ webpack.dev.js already appears to have commenting system integration');
200
- return;
201
- }
202
- // Read the template
203
- // In compiled output, templates are in the package root (same level as bin/)
204
- const packageRoot = path.resolve(__dirname, '..');
205
- const templatePath = path.join(packageRoot, 'templates', 'webpack-middleware.js');
206
- if (!fs.existsSync(templatePath)) {
207
- console.log(' ⚠️ Template file not found. Manual integration required.');
208
- console.log(' See README for webpack.dev.js integration instructions.\n');
209
- return;
210
- }
211
- const templateContent = fs.readFileSync(templatePath, 'utf-8');
212
- // Find the setupMiddlewares function and inject our code
213
- // Look for: setupMiddlewares: (middlewares, devServer) => {
214
- const setupMiddlewaresRegex = /(setupMiddlewares\s*:\s*\([^)]+\)\s*=>\s*\{)/;
215
- const match = webpackContent.match(setupMiddlewaresRegex);
216
- if (!match) {
217
- console.log(' ⚠️ Could not find setupMiddlewares in webpack.dev.js');
218
- console.log(' 📋 Manual integration required. See templates/webpack-middleware.js\n');
219
- return;
220
- }
221
- // Find where to inject (after express.json() setup, before return middlewares)
222
- const expressJsonMatch = webpackContent.match(/devServer\.app\.use\(express\.json\(\)\);/);
223
- if (expressJsonMatch) {
224
- // Inject after express.json()
225
- const insertIndex = expressJsonMatch.index + expressJsonMatch[0].length;
226
- const before = webpackContent.substring(0, insertIndex);
227
- const after = webpackContent.substring(insertIndex);
228
- // Extract just the middleware code from template (skip comments)
229
- const middlewareCode = templateContent
230
- .replace(/^\/\/.*$/gm, '') // Remove comment lines
231
- .trim()
232
- .split('\n')
233
- .filter(line => line.trim() && !line.trim().startsWith('//'))
234
- .join('\n');
235
- webpackContent = before + '\n\n' + middlewareCode + '\n' + after;
236
- fs.writeFileSync(webpackDevPath, webpackContent);
237
- console.log(' ✅ Updated webpack.dev.js with server middleware');
238
- }
239
- else {
240
- // Try to inject at the beginning of setupMiddlewares
241
- const insertIndex = match.index + match[0].length;
242
- const before = webpackContent.substring(0, insertIndex);
243
- const after = webpackContent.substring(insertIndex);
244
- // Add dotenv loading and express setup if not present
245
- let middlewareCode = templateContent.trim();
246
- // Check if dotenv is already loaded
247
- if (!webpackContent.includes('dotenv.config')) {
248
- middlewareCode = `// Load env vars for local OAuth/token exchange
249
- try {
250
- const dotenv = require('dotenv');
251
- dotenv.config({ path: path.resolve(__dirname, '.env') });
252
- dotenv.config({ path: path.resolve(__dirname, '.env.server'), override: true });
253
- } catch (e) {
254
- // no-op
255
- }
256
-
257
- const express = require('express');
258
- devServer.app.use(express.json());
259
-
260
- ` + middlewareCode;
261
- }
262
- else if (!webpackContent.includes('express.json()')) {
263
- middlewareCode = `const express = require('express');
264
- devServer.app.use(express.json());
265
-
266
- ` + middlewareCode;
267
- }
268
- webpackContent = before + '\n\n' + middlewareCode + '\n' + after;
269
- fs.writeFileSync(webpackDevPath, webpackContent);
270
- console.log(' ✅ Updated webpack.dev.js with server middleware');
271
- }
272
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/cli/index.js DELETED
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- const detect = __importStar(require("./detect"));
38
- const onboarding = __importStar(require("./onboarding"));
39
- const args = process.argv.slice(2);
40
- const command = args[0] || 'init';
41
- async function main() {
42
- if (command === 'init') {
43
- // Check if we're in a PatternFly Seed project
44
- const isPFSeed = detect.detectPatternFlySeed();
45
- if (!isPFSeed) {
46
- console.error('❌ Error: This package is designed for PatternFly Seed projects.');
47
- console.error('Please run this command from a PatternFly Seed project directory.');
48
- process.exit(1);
49
- }
50
- console.log('🚀 Hale Commenting System - Onboarding\n');
51
- await onboarding.runOnboarding();
52
- }
53
- else {
54
- console.log('Usage: hale-commenting-system [init]');
55
- process.exit(1);
56
- }
57
- }
58
- main().catch((error) => {
59
- console.error('❌ Error:', error.message);
60
- process.exit(1);
61
- });
@@ -1 +0,0 @@
1
- export declare function runOnboarding(): Promise<void>;