create-claude-workspace 2.1.7 → 2.1.9
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.
|
@@ -15,28 +15,41 @@ export function detectCIPlatform(projectDir) {
|
|
|
15
15
|
return 'none';
|
|
16
16
|
}
|
|
17
17
|
export async function watchPipeline(branch, platform, projectDir, logger, signal) {
|
|
18
|
+
logger.info(`Watching CI pipeline for branch: ${branch} (${platform})`);
|
|
18
19
|
if (platform === 'none') {
|
|
19
20
|
return { status: 'not-found' };
|
|
20
21
|
}
|
|
21
22
|
const startTime = Date.now();
|
|
23
|
+
let notFoundCount = 0;
|
|
24
|
+
const MAX_NOT_FOUND = 3; // Give CI a few polls to appear, then give up
|
|
22
25
|
while (Date.now() - startTime < MAX_POLL_TIME) {
|
|
23
26
|
if (signal?.stopped)
|
|
24
27
|
return { status: 'canceled' };
|
|
25
28
|
const status = platform === 'github'
|
|
26
|
-
? pollGitHub(branch, projectDir)
|
|
27
|
-
: pollGitLab(branch, projectDir);
|
|
29
|
+
? pollGitHub(branch, projectDir, logger)
|
|
30
|
+
: pollGitLab(branch, projectDir, logger);
|
|
28
31
|
if (status === 'passed' || status === 'failed' || status === 'canceled') {
|
|
29
32
|
const logs = status === 'failed'
|
|
30
33
|
? fetchFailureLogs(branch, platform, projectDir)
|
|
31
34
|
: undefined;
|
|
32
35
|
return { status, logs };
|
|
33
36
|
}
|
|
37
|
+
if (status === 'not-found') {
|
|
38
|
+
notFoundCount++;
|
|
39
|
+
if (notFoundCount >= MAX_NOT_FOUND) {
|
|
40
|
+
logger.info('No CI pipeline found — skipping CI watch');
|
|
41
|
+
return { status: 'not-found' };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
notFoundCount = 0;
|
|
46
|
+
}
|
|
34
47
|
logger.info(`CI: ${status}, waiting ${POLL_INTERVAL / 1000}s...`);
|
|
35
48
|
await sleep(POLL_INTERVAL);
|
|
36
49
|
}
|
|
37
50
|
return { status: 'timeout' };
|
|
38
51
|
}
|
|
39
|
-
function pollGitHub(branch, cwd) {
|
|
52
|
+
function pollGitHub(branch, cwd, logger) {
|
|
40
53
|
try {
|
|
41
54
|
const output = execSync(`gh run list --branch "${branch}" --limit 1 --json status,conclusion`, { cwd, encoding: 'utf-8', stdio: 'pipe', timeout: 15_000 }).trim();
|
|
42
55
|
const runs = JSON.parse(output);
|
|
@@ -48,17 +61,19 @@ function pollGitHub(branch, cwd) {
|
|
|
48
61
|
}
|
|
49
62
|
return 'pending';
|
|
50
63
|
}
|
|
51
|
-
catch {
|
|
64
|
+
catch (err) {
|
|
65
|
+
logger?.warn(`gh run list failed: ${err.message?.split('\n')[0]}`);
|
|
52
66
|
return 'not-found';
|
|
53
67
|
}
|
|
54
68
|
}
|
|
55
|
-
function pollGitLab(branch, cwd) {
|
|
69
|
+
function pollGitLab(branch, cwd, logger) {
|
|
56
70
|
try {
|
|
57
71
|
const output = execSync(`glab ci list --branch "${branch}" --output json`, { cwd, encoding: 'utf-8', stdio: 'pipe', timeout: 15_000 }).trim();
|
|
58
72
|
const pipelines = JSON.parse(output);
|
|
59
73
|
if (!pipelines.length)
|
|
60
74
|
return 'not-found';
|
|
61
75
|
const pipeline = pipelines[0];
|
|
76
|
+
logger?.info(`CI pipeline #${pipeline.id ?? '?'}: ${pipeline.status}`);
|
|
62
77
|
switch (pipeline.status) {
|
|
63
78
|
case 'success': return 'passed';
|
|
64
79
|
case 'failed': return 'failed';
|
|
@@ -66,7 +81,8 @@ function pollGitLab(branch, cwd) {
|
|
|
66
81
|
default: return 'pending';
|
|
67
82
|
}
|
|
68
83
|
}
|
|
69
|
-
catch {
|
|
84
|
+
catch (err) {
|
|
85
|
+
logger?.warn(`glab ci list failed: ${err.message?.split('\n')[0]}`);
|
|
70
86
|
return 'not-found';
|
|
71
87
|
}
|
|
72
88
|
}
|