hale-commenting-system 2.1.1 → 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 -18
  54. package/bin/generators.js +0 -193
  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 -349
  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 -18
  67. package/dist/cli/generators.js +0 -193
  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 -349
  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
package/bin/detect.js DELETED
@@ -1,134 +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.detectPatternFlySeed = detectPatternFlySeed;
37
- exports.detectGitRemote = detectGitRemote;
38
- exports.detectProjectSetup = detectProjectSetup;
39
- const fs = __importStar(require("fs"));
40
- const path = __importStar(require("path"));
41
- const child_process_1 = require("child_process");
42
- function detectPatternFlySeed() {
43
- const cwd = process.cwd();
44
- // Check for webpack config files
45
- const hasWebpack = fs.existsSync(path.join(cwd, 'webpack.config.js')) ||
46
- fs.existsSync(path.join(cwd, 'webpack.dev.js')) ||
47
- fs.existsSync(path.join(cwd, 'webpack.common.js'));
48
- // Check for src/app directory
49
- const hasAppDir = fs.existsSync(path.join(cwd, 'src', 'app'));
50
- // Check for PatternFly dependencies in package.json
51
- let hasPatternFly = false;
52
- try {
53
- const packageJsonPath = path.join(cwd, 'package.json');
54
- if (fs.existsSync(packageJsonPath)) {
55
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
56
- const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
57
- hasPatternFly = !!(deps['@patternfly/react-core'] ||
58
- deps['@patternfly/react-icons']);
59
- }
60
- }
61
- catch {
62
- // Ignore errors
63
- }
64
- return hasWebpack && hasAppDir && hasPatternFly;
65
- }
66
- function detectGitRemote() {
67
- const cwd = process.cwd();
68
- // Check if .git exists
69
- if (!fs.existsSync(path.join(cwd, '.git'))) {
70
- return null;
71
- }
72
- try {
73
- // Get remote URL
74
- const remoteUrl = (0, child_process_1.execSync)('git remote get-url origin', {
75
- cwd,
76
- encoding: 'utf-8',
77
- stdio: ['ignore', 'pipe', 'ignore']
78
- }).trim();
79
- if (!remoteUrl) {
80
- return null;
81
- }
82
- // Parse GitHub URL (supports https://, git@, and ssh formats)
83
- // https://github.com/owner/repo.git
84
- // git@github.com:owner/repo.git
85
- // ssh://git@github.com/owner/repo.git
86
- const githubMatch = remoteUrl.match(/github\.com[/:]([^/]+)\/([^/]+?)(?:\.git)?$/);
87
- if (githubMatch) {
88
- const owner = githubMatch[1];
89
- const repo = githubMatch[2].replace(/\.git$/, '');
90
- // Try to detect if it's a fork by checking if upstream exists
91
- let isFork = false;
92
- try {
93
- (0, child_process_1.execSync)('git remote get-url upstream', {
94
- cwd,
95
- encoding: 'utf-8',
96
- stdio: ['ignore', 'pipe', 'ignore']
97
- });
98
- isFork = true;
99
- }
100
- catch {
101
- // No upstream remote, might still be a fork but we can't tell
102
- // Check if repo name matches patternfly-react-seed (likely a fork)
103
- isFork = repo.includes('patternfly-react-seed') || repo.includes('pfseed');
104
- }
105
- return {
106
- owner,
107
- repo,
108
- url: remoteUrl,
109
- isFork
110
- };
111
- }
112
- }
113
- catch (error) {
114
- // Git command failed or not a git repo
115
- return null;
116
- }
117
- return null;
118
- }
119
- function detectProjectSetup() {
120
- const gitInfo = detectGitRemote();
121
- if (!gitInfo) {
122
- return 'none';
123
- }
124
- // Check if it looks like a fork (has patternfly-react-seed in name or has upstream)
125
- if (gitInfo.isFork || gitInfo.repo?.includes('patternfly-react-seed')) {
126
- return 'forked';
127
- }
128
- // Check if it's a clone of the original
129
- if (gitInfo.owner === 'patternfly' && gitInfo.repo === 'patternfly-react-seed') {
130
- return 'cloned';
131
- }
132
- // Has git remote but unclear
133
- return 'unknown';
134
- }
@@ -1,18 +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;
14
- jira: JiraConfig;
15
- }
16
- export declare function generateFiles(config: Config): Promise<void>;
17
- export declare function integrateIntoProject(): Promise<void>;
18
- export {};
package/bin/generators.js DELETED
@@ -1,193 +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
- const envContent = `# GitHub OAuth (client-side; safe to expose)
45
- VITE_GITHUB_CLIENT_ID=${config.github.clientId}
46
-
47
- # Target repo for Issues/Comments
48
- VITE_GITHUB_OWNER=${config.github.owner}
49
- VITE_GITHUB_REPO=${config.github.repo}
50
-
51
- # Jira Base URL
52
- VITE_JIRA_BASE_URL=${config.jira.baseUrl}
53
- `;
54
- // Check if .env exists and append or create
55
- if (fs.existsSync(envPath)) {
56
- const existing = fs.readFileSync(envPath, 'utf-8');
57
- // Only add if not already present
58
- if (!existing.includes('VITE_GITHUB_CLIENT_ID')) {
59
- fs.appendFileSync(envPath, '\n' + envContent);
60
- console.log(' ✅ Updated .env file');
61
- }
62
- else {
63
- console.log(' ⚠️ .env already contains commenting system config');
64
- }
65
- }
66
- else {
67
- fs.writeFileSync(envPath, envContent);
68
- console.log(' ✅ Created .env file');
69
- }
70
- // Generate .env.server file (secrets)
71
- const envServerPath = path.join(cwd, '.env.server');
72
- let envServerContent = `# GitHub OAuth Client Secret (server-only)
73
- GITHUB_CLIENT_SECRET=${config.github.clientSecret}
74
-
75
- # Jira API Token (server-only)
76
- JIRA_API_TOKEN=${config.jira.apiToken}
77
- `;
78
- if (config.jira.email) {
79
- envServerContent += `JIRA_EMAIL=${config.jira.email}\n`;
80
- }
81
- if (fs.existsSync(envServerPath)) {
82
- const existing = fs.readFileSync(envServerPath, 'utf-8');
83
- if (!existing.includes('GITHUB_CLIENT_SECRET')) {
84
- fs.appendFileSync(envServerPath, '\n' + envServerContent);
85
- console.log(' ✅ Updated .env.server file');
86
- }
87
- else {
88
- console.log(' ⚠️ .env.server already contains commenting system config');
89
- }
90
- }
91
- else {
92
- fs.writeFileSync(envServerPath, envServerContent);
93
- console.log(' ✅ Created .env.server file');
94
- }
95
- // Ensure .env.server is in .gitignore
96
- const gitignorePath = path.join(cwd, '.gitignore');
97
- if (fs.existsSync(gitignorePath)) {
98
- const gitignore = fs.readFileSync(gitignorePath, 'utf-8');
99
- if (!gitignore.includes('.env.server')) {
100
- fs.appendFileSync(gitignorePath, '\n.env.server\n');
101
- console.log(' ✅ Added .env.server to .gitignore');
102
- }
103
- }
104
- else {
105
- fs.writeFileSync(gitignorePath, '.env.server\n');
106
- console.log(' ✅ Created .gitignore with .env.server');
107
- }
108
- }
109
- async function integrateIntoProject() {
110
- const cwd = process.cwd();
111
- const webpackDevPath = path.join(cwd, 'webpack.dev.js');
112
- if (!fs.existsSync(webpackDevPath)) {
113
- console.error(' ❌ webpack.dev.js not found. Cannot auto-integrate.');
114
- return;
115
- }
116
- // Read webpack.dev.js
117
- let webpackContent = fs.readFileSync(webpackDevPath, 'utf-8');
118
- // Check if already integrated
119
- if (webpackContent.includes('/api/github-oauth-callback') || webpackContent.includes('/api/jira-issue')) {
120
- console.log(' ⚠️ webpack.dev.js already appears to have commenting system integration');
121
- return;
122
- }
123
- // Read the template
124
- // In compiled output, templates are in the package root (same level as bin/)
125
- const packageRoot = path.resolve(__dirname, '..');
126
- const templatePath = path.join(packageRoot, 'templates', 'webpack-middleware.js');
127
- if (!fs.existsSync(templatePath)) {
128
- console.log(' ⚠️ Template file not found. Manual integration required.');
129
- console.log(' See README for webpack.dev.js integration instructions.\n');
130
- return;
131
- }
132
- const templateContent = fs.readFileSync(templatePath, 'utf-8');
133
- // Find the setupMiddlewares function and inject our code
134
- // Look for: setupMiddlewares: (middlewares, devServer) => {
135
- const setupMiddlewaresRegex = /(setupMiddlewares\s*:\s*\([^)]+\)\s*=>\s*\{)/;
136
- const match = webpackContent.match(setupMiddlewaresRegex);
137
- if (!match) {
138
- console.log(' ⚠️ Could not find setupMiddlewares in webpack.dev.js');
139
- console.log(' 📋 Manual integration required. See templates/webpack-middleware.js\n');
140
- return;
141
- }
142
- // Find where to inject (after express.json() setup, before return middlewares)
143
- const expressJsonMatch = webpackContent.match(/devServer\.app\.use\(express\.json\(\)\);/);
144
- if (expressJsonMatch) {
145
- // Inject after express.json()
146
- const insertIndex = expressJsonMatch.index + expressJsonMatch[0].length;
147
- const before = webpackContent.substring(0, insertIndex);
148
- const after = webpackContent.substring(insertIndex);
149
- // Extract just the middleware code from template (skip comments)
150
- const middlewareCode = templateContent
151
- .replace(/^\/\/.*$/gm, '') // Remove comment lines
152
- .trim()
153
- .split('\n')
154
- .filter(line => line.trim() && !line.trim().startsWith('//'))
155
- .join('\n');
156
- webpackContent = before + '\n\n' + middlewareCode + '\n' + after;
157
- fs.writeFileSync(webpackDevPath, webpackContent);
158
- console.log(' ✅ Updated webpack.dev.js with server middleware');
159
- }
160
- else {
161
- // Try to inject at the beginning of setupMiddlewares
162
- const insertIndex = match.index + match[0].length;
163
- const before = webpackContent.substring(0, insertIndex);
164
- const after = webpackContent.substring(insertIndex);
165
- // Add dotenv loading and express setup if not present
166
- let middlewareCode = templateContent.trim();
167
- // Check if dotenv is already loaded
168
- if (!webpackContent.includes('dotenv.config')) {
169
- middlewareCode = `// Load env vars for local OAuth/token exchange
170
- try {
171
- const dotenv = require('dotenv');
172
- dotenv.config({ path: path.resolve(__dirname, '.env') });
173
- dotenv.config({ path: path.resolve(__dirname, '.env.server'), override: true });
174
- } catch (e) {
175
- // no-op
176
- }
177
-
178
- const express = require('express');
179
- devServer.app.use(express.json());
180
-
181
- ` + middlewareCode;
182
- }
183
- else if (!webpackContent.includes('express.json()')) {
184
- middlewareCode = `const express = require('express');
185
- devServer.app.use(express.json());
186
-
187
- ` + middlewareCode;
188
- }
189
- webpackContent = before + '\n\n' + middlewareCode + '\n' + after;
190
- fs.writeFileSync(webpackDevPath, webpackContent);
191
- console.log(' ✅ Updated webpack.dev.js with server middleware');
192
- }
193
- }
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require('./index.js');
4
-
package/bin/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/bin/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>;