threadlines 0.1.13 ā 0.1.15
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/dist/commands/check.js +34 -3
- package/dist/git/repo.js +37 -2
- package/dist/utils/ci-detection.js +52 -1
- package/package.json +1 -1
package/dist/commands/check.js
CHANGED
|
@@ -52,19 +52,29 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
52
52
|
* Returns: 'vercel', 'github', 'gitlab', or 'local'
|
|
53
53
|
*/
|
|
54
54
|
function detectEnvironment() {
|
|
55
|
+
console.log(chalk_1.default.gray(' [DEBUG] detectEnvironment: Starting detection...'));
|
|
56
|
+
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: VERCEL = "${process.env.VERCEL || 'NOT SET'}"`));
|
|
57
|
+
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: GITHUB_ACTIONS = "${process.env.GITHUB_ACTIONS || 'NOT SET'}"`));
|
|
58
|
+
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: GITLAB_CI = "${process.env.GITLAB_CI || 'NOT SET'}"`));
|
|
59
|
+
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: CI = "${process.env.CI || 'NOT SET'}"`));
|
|
60
|
+
console.log(chalk_1.default.gray(` [DEBUG] detectEnvironment: CI_COMMIT_SHA = "${process.env.CI_COMMIT_SHA || 'NOT SET'}"`));
|
|
55
61
|
// Vercel: VERCEL env var is always set in Vercel builds
|
|
56
62
|
if (process.env.VERCEL) {
|
|
63
|
+
console.log(chalk_1.default.green(' [DEBUG] detectEnvironment: Detected VERCEL'));
|
|
57
64
|
return 'vercel';
|
|
58
65
|
}
|
|
59
66
|
// GitHub Actions: GITHUB_ACTIONS env var is always set
|
|
60
67
|
if (process.env.GITHUB_ACTIONS) {
|
|
68
|
+
console.log(chalk_1.default.green(' [DEBUG] detectEnvironment: Detected GITHUB_ACTIONS'));
|
|
61
69
|
return 'github';
|
|
62
70
|
}
|
|
63
71
|
// GitLab CI: GITLAB_CI env var is always set, or CI is set with GitLab-specific vars
|
|
64
72
|
if (process.env.GITLAB_CI || (process.env.CI && process.env.CI_COMMIT_SHA)) {
|
|
73
|
+
console.log(chalk_1.default.green(' [DEBUG] detectEnvironment: Detected GITLAB_CI'));
|
|
65
74
|
return 'gitlab';
|
|
66
75
|
}
|
|
67
76
|
// Local development: none of the above
|
|
77
|
+
console.log(chalk_1.default.yellow(' [DEBUG] detectEnvironment: No CI env vars detected - returning "local"'));
|
|
68
78
|
return 'local';
|
|
69
79
|
}
|
|
70
80
|
async function checkCommand(options) {
|
|
@@ -232,16 +242,37 @@ async function checkCommand(options) {
|
|
|
232
242
|
};
|
|
233
243
|
});
|
|
234
244
|
// 4. Get repo name and branch name
|
|
245
|
+
console.log(chalk_1.default.gray('\nš” Detecting repository and branch information...'));
|
|
246
|
+
// Log Vercel-specific env vars that might help with repo detection
|
|
247
|
+
if (process.env.VERCEL) {
|
|
248
|
+
console.log(chalk_1.default.gray(' [DEBUG] Vercel environment variables:'));
|
|
249
|
+
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_REPO_OWNER = "${process.env.VERCEL_GIT_REPO_OWNER || 'NOT SET'}"`));
|
|
250
|
+
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_REPO_SLUG = "${process.env.VERCEL_GIT_REPO_SLUG || 'NOT SET'}"`));
|
|
251
|
+
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_REPO_ID = "${process.env.VERCEL_GIT_REPO_ID || 'NOT SET'}"`));
|
|
252
|
+
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_COMMIT_REF = "${process.env.VERCEL_GIT_COMMIT_REF || 'NOT SET'}"`));
|
|
253
|
+
console.log(chalk_1.default.gray(` [DEBUG] VERCEL_GIT_COMMIT_SHA = "${process.env.VERCEL_GIT_COMMIT_SHA || 'NOT SET'}"`));
|
|
254
|
+
}
|
|
235
255
|
const repoName = await (0, repo_1.getRepoName)(repoRoot);
|
|
236
256
|
const branchName = await (0, repo_1.getBranchName)(repoRoot);
|
|
237
257
|
// 5. Get API URL
|
|
238
258
|
const apiUrl = options.apiUrl ||
|
|
239
259
|
process.env.THREADLINE_API_URL ||
|
|
240
260
|
'https://devthreadline.com';
|
|
241
|
-
// 6.
|
|
242
|
-
console.log(chalk_1.default.gray('
|
|
243
|
-
const client = new client_1.ReviewAPIClient(apiUrl);
|
|
261
|
+
// 6. Detect environment
|
|
262
|
+
console.log(chalk_1.default.gray('\nš Detecting environment...'));
|
|
244
263
|
const environment = detectEnvironment();
|
|
264
|
+
// 7. Log final values being sent to API
|
|
265
|
+
console.log(chalk_1.default.gray('\nš¤ Final values being sent to API:'));
|
|
266
|
+
console.log(chalk_1.default.gray(` repoName: ${repoName ? `"${repoName}"` : 'null/undefined'}`));
|
|
267
|
+
console.log(chalk_1.default.gray(` branchName: ${branchName ? `"${branchName}"` : 'null/undefined'}`));
|
|
268
|
+
console.log(chalk_1.default.gray(` commitSha: ${commitSha ? `"${commitSha}"` : 'null/undefined'}`));
|
|
269
|
+
console.log(chalk_1.default.gray(` commitMessage: ${commitMessage ? `"${commitMessage.substring(0, 50)}..."` : 'null/undefined'}`));
|
|
270
|
+
console.log(chalk_1.default.gray(` prTitle: ${prTitle ? `"${prTitle}"` : 'null/undefined'}`));
|
|
271
|
+
console.log(chalk_1.default.gray(` environment: "${environment}"`));
|
|
272
|
+
console.log(chalk_1.default.gray(` reviewContext: ${JSON.stringify(reviewContext)}`));
|
|
273
|
+
// 8. Call review API
|
|
274
|
+
console.log(chalk_1.default.gray('\nš¤ Running threadline checks...'));
|
|
275
|
+
const client = new client_1.ReviewAPIClient(apiUrl);
|
|
245
276
|
const response = await client.review({
|
|
246
277
|
threadlines: threadlinesWithContext,
|
|
247
278
|
diff: gitDiff.diff,
|
package/dist/git/repo.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getRepoName = getRepoName;
|
|
7
7
|
exports.getBranchName = getBranchName;
|
|
8
8
|
const simple_git_1 = __importDefault(require("simple-git"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
10
|
/**
|
|
10
11
|
* Gets the raw git remote URL from origin.
|
|
11
12
|
* Returns the URL exactly as Git provides it - no parsing or normalization.
|
|
@@ -13,16 +14,38 @@ const simple_git_1 = __importDefault(require("simple-git"));
|
|
|
13
14
|
*/
|
|
14
15
|
async function getRepoName(repoRoot) {
|
|
15
16
|
const git = (0, simple_git_1.default)(repoRoot);
|
|
17
|
+
console.log(chalk_1.default.gray(' [DEBUG] getRepoName: Starting...'));
|
|
18
|
+
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: repoRoot = ${repoRoot}`));
|
|
16
19
|
try {
|
|
17
20
|
const remotes = await git.getRemotes(true);
|
|
21
|
+
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: Found ${remotes.length} remote(s)`));
|
|
22
|
+
if (remotes.length > 0) {
|
|
23
|
+
remotes.forEach((remote, idx) => {
|
|
24
|
+
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: Remote[${idx}] name="${remote.name}", fetch="${remote.refs?.fetch || 'N/A'}", push="${remote.refs?.push || 'N/A'}"`));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
console.log(chalk_1.default.yellow(' [DEBUG] getRepoName: No remotes found'));
|
|
29
|
+
}
|
|
18
30
|
const origin = remotes.find(r => r.name === 'origin');
|
|
19
|
-
if (!origin
|
|
31
|
+
if (!origin) {
|
|
32
|
+
console.log(chalk_1.default.yellow(' [DEBUG] getRepoName: No "origin" remote found'));
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: Found origin remote: fetch="${origin.refs?.fetch || 'N/A'}"`));
|
|
36
|
+
if (!origin.refs?.fetch) {
|
|
37
|
+
console.log(chalk_1.default.yellow(' [DEBUG] getRepoName: Origin remote found but no fetch URL'));
|
|
20
38
|
return null;
|
|
21
39
|
}
|
|
40
|
+
console.log(chalk_1.default.green(` [DEBUG] getRepoName: Success - returning "${origin.refs.fetch}"`));
|
|
22
41
|
// Return raw URL - let server handle normalization if needed
|
|
23
42
|
return origin.refs.fetch;
|
|
24
43
|
}
|
|
25
44
|
catch (error) {
|
|
45
|
+
console.log(chalk_1.default.red(` [DEBUG] getRepoName: Error occurred: ${error.message || error}`));
|
|
46
|
+
if (error.stack) {
|
|
47
|
+
console.log(chalk_1.default.gray(` [DEBUG] getRepoName: Stack: ${error.stack}`));
|
|
48
|
+
}
|
|
26
49
|
return null;
|
|
27
50
|
}
|
|
28
51
|
}
|
|
@@ -32,11 +55,23 @@ async function getRepoName(repoRoot) {
|
|
|
32
55
|
*/
|
|
33
56
|
async function getBranchName(repoRoot) {
|
|
34
57
|
const git = (0, simple_git_1.default)(repoRoot);
|
|
58
|
+
console.log(chalk_1.default.gray(' [DEBUG] getBranchName: Starting...'));
|
|
59
|
+
console.log(chalk_1.default.gray(` [DEBUG] getBranchName: repoRoot = ${repoRoot}`));
|
|
35
60
|
try {
|
|
36
61
|
const branch = await git.revparse(['--abbrev-ref', 'HEAD']);
|
|
37
|
-
|
|
62
|
+
console.log(chalk_1.default.gray(` [DEBUG] getBranchName: git revparse --abbrev-ref HEAD returned: "${branch || '(empty)'}"`));
|
|
63
|
+
if (!branch) {
|
|
64
|
+
console.log(chalk_1.default.yellow(' [DEBUG] getBranchName: Git command returned empty string'));
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
console.log(chalk_1.default.green(` [DEBUG] getBranchName: Success - returning "${branch}"`));
|
|
68
|
+
return branch;
|
|
38
69
|
}
|
|
39
70
|
catch (error) {
|
|
71
|
+
console.log(chalk_1.default.red(` [DEBUG] getBranchName: Error occurred: ${error.message || error}`));
|
|
72
|
+
if (error.stack) {
|
|
73
|
+
console.log(chalk_1.default.gray(` [DEBUG] getBranchName: Stack: ${error.stack}`));
|
|
74
|
+
}
|
|
40
75
|
return null;
|
|
41
76
|
}
|
|
42
77
|
}
|
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getAutoReviewTarget = getAutoReviewTarget;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
4
8
|
function getAutoReviewTarget() {
|
|
9
|
+
console.log(chalk_1.default.gray(' [DEBUG] getAutoReviewTarget: Starting detection...'));
|
|
10
|
+
// Log ALL GitHub Actions env vars that start with GITHUB_ to see what's available
|
|
11
|
+
if (process.env.GITHUB_ACTIONS) {
|
|
12
|
+
console.log(chalk_1.default.gray(' [DEBUG] getAutoReviewTarget: All GITHUB_* env vars:'));
|
|
13
|
+
const githubVars = Object.keys(process.env)
|
|
14
|
+
.filter(key => key.startsWith('GITHUB_'))
|
|
15
|
+
.sort();
|
|
16
|
+
githubVars.forEach(key => {
|
|
17
|
+
const value = process.env[key];
|
|
18
|
+
// Truncate long values for readability
|
|
19
|
+
const displayValue = value && value.length > 100 ? value.substring(0, 100) + '...' : value;
|
|
20
|
+
console.log(chalk_1.default.gray(` ${key} = "${displayValue || 'NOT SET'}"`));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
5
23
|
// 1. Check for PR/MR context (most authoritative)
|
|
6
24
|
// GitHub Actions PR
|
|
25
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: Checking GitHub Actions PR...`));
|
|
26
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_EVENT_NAME = "${process.env.GITHUB_EVENT_NAME || 'NOT SET'}"`));
|
|
7
27
|
if (process.env.GITHUB_EVENT_NAME === 'pull_request') {
|
|
8
28
|
const targetBranch = process.env.GITHUB_BASE_REF;
|
|
9
29
|
const sourceBranch = process.env.GITHUB_HEAD_REF;
|
|
10
|
-
|
|
30
|
+
// Try multiple possible env var names for PR number
|
|
31
|
+
const prNumber = process.env.GITHUB_EVENT_PULL_REQUEST_NUMBER ||
|
|
32
|
+
process.env.GITHUB_PR_NUMBER ||
|
|
33
|
+
process.env.GITHUB_EVENT_NUMBER;
|
|
34
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_BASE_REF = "${targetBranch || 'NOT SET'}"`));
|
|
35
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_HEAD_REF = "${sourceBranch || 'NOT SET'}"`));
|
|
36
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_EVENT_PULL_REQUEST_NUMBER = "${process.env.GITHUB_EVENT_PULL_REQUEST_NUMBER || 'NOT SET'}"`));
|
|
37
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_EVENT_NUMBER = "${process.env.GITHUB_EVENT_NUMBER || 'NOT SET'}"`));
|
|
11
38
|
if (targetBranch && sourceBranch && prNumber) {
|
|
39
|
+
console.log(chalk_1.default.green(` [DEBUG] getAutoReviewTarget: Detected GitHub PR #${prNumber}`));
|
|
12
40
|
return {
|
|
13
41
|
type: 'pr',
|
|
14
42
|
value: prNumber,
|
|
@@ -16,14 +44,23 @@ function getAutoReviewTarget() {
|
|
|
16
44
|
targetBranch
|
|
17
45
|
};
|
|
18
46
|
}
|
|
47
|
+
else {
|
|
48
|
+
console.log(chalk_1.default.yellow(' [DEBUG] getAutoReviewTarget: GitHub PR env vars incomplete'));
|
|
49
|
+
}
|
|
19
50
|
}
|
|
20
51
|
// GitLab CI MR
|
|
52
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: Checking GitLab CI MR...`));
|
|
53
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_MERGE_REQUEST_IID = "${process.env.CI_MERGE_REQUEST_IID || 'NOT SET'}"`));
|
|
21
54
|
if (process.env.CI_MERGE_REQUEST_IID) {
|
|
22
55
|
const targetBranch = process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME;
|
|
23
56
|
const sourceBranch = process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME;
|
|
24
57
|
const mrNumber = process.env.CI_MERGE_REQUEST_IID;
|
|
25
58
|
const mrTitle = process.env.CI_MERGE_REQUEST_TITLE; // Reliable GitLab CI env var
|
|
59
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "${targetBranch || 'NOT SET'}"`));
|
|
60
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_MERGE_REQUEST_SOURCE_BRANCH_NAME = "${sourceBranch || 'NOT SET'}"`));
|
|
61
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_MERGE_REQUEST_TITLE = "${mrTitle || 'NOT SET'}"`));
|
|
26
62
|
if (targetBranch && sourceBranch && mrNumber) {
|
|
63
|
+
console.log(chalk_1.default.green(` [DEBUG] getAutoReviewTarget: Detected GitLab MR #${mrNumber}`));
|
|
27
64
|
return {
|
|
28
65
|
type: 'mr',
|
|
29
66
|
value: mrNumber,
|
|
@@ -32,27 +69,41 @@ function getAutoReviewTarget() {
|
|
|
32
69
|
prTitle: mrTitle || undefined // Only include if present
|
|
33
70
|
};
|
|
34
71
|
}
|
|
72
|
+
else {
|
|
73
|
+
console.log(chalk_1.default.yellow(' [DEBUG] getAutoReviewTarget: GitLab MR env vars incomplete'));
|
|
74
|
+
}
|
|
35
75
|
}
|
|
36
76
|
// 2. Check for branch name (CI with branch)
|
|
77
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: Checking branch env vars...`));
|
|
78
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_REF_NAME = "${process.env.GITHUB_REF_NAME || 'NOT SET'}"`));
|
|
79
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_COMMIT_REF_NAME = "${process.env.CI_COMMIT_REF_NAME || 'NOT SET'}"`));
|
|
80
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: VERCEL_GIT_COMMIT_REF = "${process.env.VERCEL_GIT_COMMIT_REF || 'NOT SET'}"`));
|
|
37
81
|
const branch = process.env.GITHUB_REF_NAME || // GitHub Actions
|
|
38
82
|
process.env.CI_COMMIT_REF_NAME || // GitLab CI
|
|
39
83
|
process.env.VERCEL_GIT_COMMIT_REF; // Vercel
|
|
40
84
|
if (branch) {
|
|
85
|
+
console.log(chalk_1.default.green(` [DEBUG] getAutoReviewTarget: Detected branch "${branch}"`));
|
|
41
86
|
return {
|
|
42
87
|
type: 'branch',
|
|
43
88
|
value: branch
|
|
44
89
|
};
|
|
45
90
|
}
|
|
46
91
|
// 3. Check for commit SHA (CI without branch)
|
|
92
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: Checking commit SHA env vars...`));
|
|
93
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: GITHUB_SHA = "${process.env.GITHUB_SHA || 'NOT SET'}"`));
|
|
94
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: CI_COMMIT_SHA = "${process.env.CI_COMMIT_SHA || 'NOT SET'}"`));
|
|
95
|
+
console.log(chalk_1.default.gray(` [DEBUG] getAutoReviewTarget: VERCEL_GIT_COMMIT_SHA = "${process.env.VERCEL_GIT_COMMIT_SHA || 'NOT SET'}"`));
|
|
47
96
|
const commit = process.env.GITHUB_SHA || // GitHub Actions
|
|
48
97
|
process.env.CI_COMMIT_SHA || // GitLab CI
|
|
49
98
|
process.env.VERCEL_GIT_COMMIT_SHA; // Vercel
|
|
50
99
|
if (commit) {
|
|
100
|
+
console.log(chalk_1.default.green(` [DEBUG] getAutoReviewTarget: Detected commit "${commit}"`));
|
|
51
101
|
return {
|
|
52
102
|
type: 'commit',
|
|
53
103
|
value: commit
|
|
54
104
|
};
|
|
55
105
|
}
|
|
56
106
|
// 4. Local development (no CI env vars)
|
|
107
|
+
console.log(chalk_1.default.yellow(' [DEBUG] getAutoReviewTarget: No CI env vars detected - returning null (local mode)'));
|
|
57
108
|
return null;
|
|
58
109
|
}
|