hale-commenting-system 2.2.0 → 2.2.2
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/.claude/settings.local.json +7 -0
- package/.editorconfig +17 -0
- package/.eslintrc.js +75 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
- package/.github/workflows/ci.yaml +51 -0
- package/.prettierignore +1 -0
- package/.prettierrc +4 -0
- package/GITHUB_OAUTH_ENV_TEMPLATE.md +53 -0
- package/LICENSE +21 -0
- package/README.md +92 -21
- package/package.json +74 -50
- package/scripts/README.md +42 -0
- package/scripts/integrate.js +472 -0
- package/src/app/AppLayout/AppLayout.tsx +248 -0
- package/src/app/Comments/Comments.tsx +273 -0
- package/src/app/Dashboard/Dashboard.tsx +10 -0
- package/src/app/NotFound/NotFound.tsx +35 -0
- package/src/app/Settings/General/GeneralSettings.tsx +16 -0
- package/src/app/Settings/Profile/ProfileSettings.tsx +18 -0
- package/src/app/Support/Support.tsx +50 -0
- package/src/app/__snapshots__/app.test.tsx.snap +524 -0
- package/src/app/app.css +11 -0
- package/src/app/app.test.tsx +55 -0
- package/src/app/bgimages/Patternfly-Logo.svg +28 -0
- package/src/app/commenting-system/components/CommentOverlay.tsx +93 -0
- package/src/app/commenting-system/components/CommentPanel.tsx +534 -0
- package/src/app/commenting-system/components/CommentPin.tsx +60 -0
- package/src/app/commenting-system/components/DetailsTab.tsx +516 -0
- package/src/app/commenting-system/components/FloatingWidget.tsx +130 -0
- package/src/app/commenting-system/components/JiraTab.tsx +696 -0
- package/src/app/commenting-system/contexts/CommentContext.tsx +1033 -0
- package/src/app/commenting-system/contexts/GitHubAuthContext.tsx +84 -0
- package/{dist/index.d.ts → src/app/commenting-system/index.ts} +5 -4
- package/src/app/commenting-system/services/githubAdapter.ts +359 -0
- package/src/app/commenting-system/types/index.ts +27 -0
- package/src/app/commenting-system/utils/version.ts +19 -0
- package/src/app/index.tsx +22 -0
- package/src/app/routes.tsx +81 -0
- package/src/app/utils/useDocumentTitle.ts +13 -0
- package/src/favicon.png +0 -0
- package/src/index.html +18 -0
- package/src/index.tsx +25 -0
- package/src/test/setup.ts +33 -0
- package/src/typings.d.ts +12 -0
- package/stylePaths.js +14 -0
- package/tsconfig.json +34 -0
- package/vitest.config.ts +19 -0
- package/webpack.common.js +139 -0
- package/webpack.dev.js +318 -0
- package/webpack.prod.js +38 -0
- package/bin/detect.d.ts +0 -10
- package/bin/detect.js +0 -134
- package/bin/generators.d.ts +0 -20
- package/bin/generators.js +0 -272
- package/bin/hale-commenting.js +0 -4
- package/bin/index.d.ts +0 -2
- package/bin/index.js +0 -61
- package/bin/onboarding.d.ts +0 -1
- package/bin/onboarding.js +0 -395
- package/bin/postinstall.d.ts +0 -2
- package/bin/postinstall.js +0 -65
- package/bin/validators.d.ts +0 -2
- package/bin/validators.js +0 -66
- package/dist/cli/detect.d.ts +0 -10
- package/dist/cli/detect.js +0 -134
- package/dist/cli/generators.d.ts +0 -20
- package/dist/cli/generators.js +0 -272
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -61
- package/dist/cli/onboarding.d.ts +0 -1
- package/dist/cli/onboarding.js +0 -395
- package/dist/cli/postinstall.d.ts +0 -2
- package/dist/cli/postinstall.js +0 -65
- package/dist/cli/validators.d.ts +0 -2
- package/dist/cli/validators.js +0 -66
- package/dist/components/CommentOverlay.d.ts +0 -2
- package/dist/components/CommentOverlay.js +0 -101
- package/dist/components/CommentPanel.d.ts +0 -6
- package/dist/components/CommentPanel.js +0 -334
- package/dist/components/CommentPin.d.ts +0 -11
- package/dist/components/CommentPin.js +0 -64
- package/dist/components/DetailsTab.d.ts +0 -2
- package/dist/components/DetailsTab.js +0 -380
- package/dist/components/FloatingWidget.d.ts +0 -8
- package/dist/components/FloatingWidget.js +0 -128
- package/dist/components/JiraTab.d.ts +0 -2
- package/dist/components/JiraTab.js +0 -507
- package/dist/contexts/CommentContext.d.ts +0 -30
- package/dist/contexts/CommentContext.js +0 -891
- package/dist/contexts/GitHubAuthContext.d.ts +0 -13
- package/dist/contexts/GitHubAuthContext.js +0 -96
- package/dist/index.js +0 -27
- package/dist/services/githubAdapter.d.ts +0 -56
- package/dist/services/githubAdapter.js +0 -321
- package/dist/types/index.d.ts +0 -25
- package/dist/types/index.js +0 -2
- package/dist/utils/version.d.ts +0 -1
- package/dist/utils/version.js +0 -23
- 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
|
-
}
|
package/bin/generators.d.ts
DELETED
|
@@ -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 {};
|
package/bin/generators.js
DELETED
|
@@ -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
|
-
}
|
package/bin/hale-commenting.js
DELETED
package/bin/index.d.ts
DELETED
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
|
-
});
|
package/bin/onboarding.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function runOnboarding(): Promise<void>;
|