designlang 12.4.0 → 12.8.0

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/src/ci.js CHANGED
@@ -32,9 +32,43 @@ export async function runCi(url, opts) {
32
32
  out.push(`## designlang · design regression guard`);
33
33
  out.push(`\n**URL:** \`${url}\` \n**Run:** ${new Date().toISOString()}\n`);
34
34
 
35
- // 1. Extract
35
+ // 1. Extract — guard the throw site so CI artifacts never come back empty.
36
+ // Playwright can crash on flaky networks, ad-walled URLs, or self-signed
37
+ // proxies; when that happens we still want a report file + a summary.json
38
+ // so downstream jobs (artifact uploads, status comments, dashboards) have
39
+ // something to point at. We preserve the original error via `cause` so the
40
+ // stack survives — losing the trace was a real problem with #76's draft.
36
41
  const { extractDesignLanguage } = await import('./index.js');
37
- const design = await extractDesignLanguage(url);
42
+ let design;
43
+ try {
44
+ design = await extractDesignLanguage(url);
45
+ } catch (err) {
46
+ const stack = err?.stack || String(err);
47
+ out.push(section('Extraction', [
48
+ `_failed — ${err.message}_`,
49
+ '',
50
+ '```',
51
+ stack,
52
+ '```',
53
+ ].join('\n')));
54
+ const md = out.join('\n');
55
+ const mdPath = join(outDir, 'ci-report.md');
56
+ writeFileSync(mdPath, md, 'utf-8');
57
+ const summary = {
58
+ url,
59
+ score: null,
60
+ grade: null,
61
+ driftVerdict: 'unknown',
62
+ extractionFailed: true,
63
+ error: err.message,
64
+ timestamp: new Date().toISOString(),
65
+ };
66
+ writeFileSync(join(outDir, 'ci-summary.json'), JSON.stringify(summary, null, 2), 'utf-8');
67
+ if (process.env.GITHUB_STEP_SUMMARY) {
68
+ try { writeFileSync(process.env.GITHUB_STEP_SUMMARY, md, { flag: 'a' }); } catch {}
69
+ }
70
+ return { mdPath, md, summary, shouldFail: true, cause: err };
71
+ }
38
72
 
39
73
  // 2. Score block
40
74
  if (design.score) {