@decohere/ci-tools 0.0.1-dev.20261123.408 → 0.0.1-dev.20261123.410

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/ci-tools",
3
- "version": "0.0.1-dev.20261123.408",
3
+ "version": "0.0.1-dev.20261123.410",
4
4
  "description": "CI utility scripts for badge generation, coverage reporting, pages artifact assembly, and GitHub API tooling",
5
5
  "keywords": [
6
6
  "typescript",
@@ -35,7 +35,9 @@ function fromNpmV2(data) {
35
35
  for (const vuln of Object.values(data?.vulnerabilities ?? {})) {
36
36
  const vias = Array.isArray(vuln.via) ? vuln.via : [];
37
37
  for (const via of vias) {
38
- if (via == null || typeof via !== "object") continue;
38
+ if (via == null || typeof via !== "object") {
39
+ continue;
40
+ }
39
41
  const url = via.url ?? "";
40
42
  const key = url || `${via.name ?? vuln.name}:${via.title ?? ""}`;
41
43
  const existing = byKey.get(key);
@@ -77,7 +79,9 @@ export function parseAudit(data) {
77
79
 
78
80
  advisories.sort((a, b) => {
79
81
  const d = SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity);
80
- if (d !== 0) return d;
82
+ if (d !== 0) {
83
+ return d;
84
+ }
81
85
  return String(a.module).localeCompare(String(b.module));
82
86
  });
83
87
 
@@ -93,8 +97,12 @@ export function formatLog(parsed) {
93
97
  lines.push(
94
98
  ` [${a.severity}] ${a.module} ${id}: ${a.title} (vulnerable ${a.vulnerable}; patched ${a.patched})`,
95
99
  );
96
- if (a.url) lines.push(` ${a.url}`);
97
- if (a.paths[0]) lines.push(` ${a.paths[0]}`);
100
+ if (a.url) {
101
+ lines.push(` ${a.url}`);
102
+ }
103
+ if (a.paths[0]) {
104
+ lines.push(` ${a.paths[0]}`);
105
+ }
98
106
  }
99
107
  return `${lines.join("\n")}\n`;
100
108
  }
@@ -123,7 +131,9 @@ export function formatMarkdown(parsed) {
123
131
  const link = a.url ? `[${id}](${a.url})` : id;
124
132
  lines.push(`- **${a.severity}** \`${a.module}\` ${link} — ${a.title}`);
125
133
  lines.push(` - vulnerable: \`${a.vulnerable}\`; patched: \`${a.patched}\``);
126
- if (a.paths[0]) lines.push(` - ${a.paths[0]}`);
134
+ if (a.paths[0]) {
135
+ lines.push(` - ${a.paths[0]}`);
136
+ }
127
137
  }
128
138
  return `${lines.join("\n")}\n`;
129
139
  }
@@ -94,9 +94,13 @@ function forgeBuildSuite() {
94
94
  },
95
95
  },
96
96
  );
97
- if (result.status !== 0) throw new Error(`vitest bench exited ${result.status}`);
97
+ if (result.status !== 0) {
98
+ throw new Error(`vitest bench exited ${result.status}`);
99
+ }
98
100
  // vitest swallows errors in bench callbacks, so a missing file means it failed.
99
- if (!existsSync(outJson)) throw new Error("vitest bench wrote no output JSON");
101
+ if (!existsSync(outJson)) {
102
+ throw new Error("vitest bench wrote no output JSON");
103
+ }
100
104
  return fromVitest(JSON.parse(readFileSync(outJson, "utf8")));
101
105
  } finally {
102
106
  rmSync(tmpDir, { recursive: true, force: true });
@@ -112,7 +116,9 @@ const SUITES = {
112
116
  };
113
117
 
114
118
  function currentSha() {
115
- if (process.env.GITHUB_SHA) return process.env.GITHUB_SHA;
119
+ if (process.env.GITHUB_SHA) {
120
+ return process.env.GITHUB_SHA;
121
+ }
116
122
  return execFileSync("git", ["rev-parse", "HEAD"], {
117
123
  cwd: WORKSPACE_ROOT,
118
124
  encoding: "utf8",
@@ -49,8 +49,9 @@ export function parseResults(output, suite) {
49
49
  .split(/\r?\n/)
50
50
  .reverse()
51
51
  .find((candidate) => candidate.startsWith(RESULT_PREFIX));
52
- if (line == null)
52
+ if (line == null) {
53
53
  throw new Error(`suite "${suite}" printed no ${RESULT_PREFIX.trim()} line`);
54
+ }
54
55
  return JSON.parse(line.slice(RESULT_PREFIX.length));
55
56
  }
56
57
 
@@ -70,7 +71,9 @@ export function fromVitest(vitestOutput) {
70
71
  .flatMap((group) => group.benchmarks)
71
72
  .map((benchmark) => {
72
73
  const id = FORGE_BENCHMARKS.find(([prefix]) => benchmark.name.startsWith(prefix))?.[1];
73
- if (id == null) throw new Error(`unknown forge benchmark "${benchmark.name}"`);
74
+ if (id == null) {
75
+ throw new Error(`unknown forge benchmark "${benchmark.name}"`);
76
+ }
74
77
  const files = Number(benchmark.name.match(/\((\d+) files\)/)?.[1]);
75
78
  return {
76
79
  id,
@@ -102,13 +105,17 @@ export function assertValid(results) {
102
105
  * trend carries on; anything unrecognised starts empty rather than mixing formats.
103
106
  */
104
107
  export function normalize(raw) {
105
- if (raw?.version === HISTORY_VERSION && raw.contexts != null) return raw;
108
+ if (raw?.version === HISTORY_VERSION && raw.contexts != null) {
109
+ return raw;
110
+ }
106
111
  const contexts = {};
107
112
  for (const [id, entry] of Object.entries(raw?.runs ?? {})) {
108
113
  const runs = (entry.runs ?? [])
109
114
  .filter((run) => run.vitestOutput != null)
110
115
  .map((run) => ({ date: run.date, sha: null, results: fromVitest(run.vitestOutput) }));
111
- if (runs.length > 0) contexts[id] = { context: entry.context, runs };
116
+ if (runs.length > 0) {
117
+ contexts[id] = { context: entry.context, runs };
118
+ }
112
119
  }
113
120
  return { version: HISTORY_VERSION, contexts };
114
121
  }
@@ -161,7 +168,9 @@ export function compare(results, previous) {
161
168
  const before = new Map((previous?.results ?? []).map((result) => [result.id, result]));
162
169
  return results.map((result) => {
163
170
  const old = before.get(result.id);
164
- if (old == null) return { id: result.id, current: result.median };
171
+ if (old == null) {
172
+ return { id: result.id, current: result.median };
173
+ }
165
174
  const delta = result.median - old.median;
166
175
  return {
167
176
  id: result.id,
@@ -218,7 +227,9 @@ export const REGRESSION = { threshold: 0.2, rounds: 2 };
218
227
  */
219
228
  export function compareRounds(headRounds, baseRounds, options = REGRESSION) {
220
229
  const rounds = Math.min(headRounds.length, baseRounds.length);
221
- if (rounds < options.rounds) return [];
230
+ if (rounds < options.rounds) {
231
+ return [];
232
+ }
222
233
  const medianIn = (results, id) => results.find((result) => result.id === id)?.median;
223
234
  const regressions = [];
224
235
  for (const head of headRounds[0]) {
@@ -229,9 +240,13 @@ export function compareRounds(headRounds, baseRounds, options = REGRESSION) {
229
240
  const comparable = pairs.every(
230
241
  (pair) => Number.isFinite(pair.head) && Number.isFinite(pair.base) && pair.base > 0,
231
242
  );
232
- if (!comparable) continue;
243
+ if (!comparable) {
244
+ continue;
245
+ }
233
246
  const slower = pairs.every((pair) => pair.head > pair.base * (1 + options.threshold));
234
- if (!slower) continue;
247
+ if (!slower) {
248
+ continue;
249
+ }
235
250
  const mean = (values) => values.reduce((sum, value) => sum + value, 0) / values.length;
236
251
  const headMs = mean(pairs.map((pair) => pair.head));
237
252
  const baseMs = mean(pairs.map((pair) => pair.base));
@@ -65,7 +65,9 @@ function benchRound(cwd, label, round, workDir) {
65
65
  : join(cwd, "projects/ci-tools/dist/ci/bench/bench-history.json");
66
66
  const saved = normalize(JSON.parse(readFileSync(file, "utf8")));
67
67
  const newest = latestRun(saved);
68
- if (newest == null) throw new Error(`${label} round ${round + 1} saved no run`);
68
+ if (newest == null) {
69
+ throw new Error(`${label} round ${round + 1} saved no run`);
70
+ }
69
71
  return newest.results;
70
72
  }
71
73
 
@@ -11,7 +11,9 @@ const TRACE_SPEC = "projects/cli/e2e/build.trace.e2e.spec.ts";
11
11
  const TRACE_LOG_DIR = join(WORKSPACE_ROOT, ".decohere", "logs");
12
12
 
13
13
  function truthy(value, defaultValue = false) {
14
- if (value == null) return defaultValue;
14
+ if (value == null) {
15
+ return defaultValue;
16
+ }
15
17
  return !["0", "false", "no", "off"].includes(String(value).toLowerCase());
16
18
  }
17
19
 
@@ -34,7 +36,9 @@ function parseTraceSamples(rawOutput) {
34
36
  const samples = [];
35
37
  for (const rawLine of rawOutput.split(/\r?\n/)) {
36
38
  const line = rawLine.trim();
37
- if (!line.startsWith("{")) continue;
39
+ if (!line.startsWith("{")) {
40
+ continue;
41
+ }
38
42
 
39
43
  let parsed;
40
44
  try {
@@ -43,12 +47,18 @@ function parseTraceSamples(rawOutput) {
43
47
  continue;
44
48
  }
45
49
 
46
- if (typeof parsed?.name !== "string" || typeof parsed?.msg !== "string") continue;
50
+ if (typeof parsed?.name !== "string" || typeof parsed?.msg !== "string") {
51
+ continue;
52
+ }
47
53
  const match = parsed.msg.match(/^(.*):\s+([0-9]+(?:\.[0-9]+)?)ms$/);
48
- if (match == null) continue;
54
+ if (match == null) {
55
+ continue;
56
+ }
49
57
 
50
58
  const durationMs = Number(match[2]);
51
- if (!Number.isFinite(durationMs)) continue;
59
+ if (!Number.isFinite(durationMs)) {
60
+ continue;
61
+ }
52
62
 
53
63
  samples.push({
54
64
  className: parsed.name,
@@ -73,7 +83,9 @@ function aggregateSamples(samples, keyBuilder) {
73
83
  };
74
84
  current.hitCount += 1;
75
85
  current.totalMs += sample.durationMs;
76
- if (sample.durationMs > current.maxMs) current.maxMs = sample.durationMs;
86
+ if (sample.durationMs > current.maxMs) {
87
+ current.maxMs = sample.durationMs;
88
+ }
77
89
  aggregates.set(key, current);
78
90
  }
79
91
  return [...aggregates.values()];
@@ -169,8 +181,12 @@ const result = spawnSync(
169
181
 
170
182
  const stdout = typeof result.stdout === "string" ? result.stdout : "";
171
183
  const stderr = typeof result.stderr === "string" ? result.stderr : "";
172
- if (stdout.length > 0) process.stdout.write(stdout);
173
- if (stderr.length > 0) process.stderr.write(stderr);
184
+ if (stdout.length > 0) {
185
+ process.stdout.write(stdout);
186
+ }
187
+ if (stderr.length > 0) {
188
+ process.stderr.write(stderr);
189
+ }
174
190
 
175
191
  const combined = `${stdout}${stderr.length > 0 ? `\n${stderr}` : ""}`;
176
192
  if (traceLogPath != null) {
@@ -46,11 +46,15 @@ if (entries.length === 0) {
46
46
  /** Parse a single changeset file → { packages: Record<string, string>, body: string } */
47
47
  function parseEntry(content) {
48
48
  const match = content.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
49
- if (!match) return null;
49
+ if (!match) {
50
+ return null;
51
+ }
50
52
  const packages = {};
51
53
  for (const line of match[1].split("\n")) {
52
54
  const m = line.match(/^"([^"]+)"\s*:\s*(\w+)/);
53
- if (m) packages[m[1]] = m[2];
55
+ if (m) {
56
+ packages[m[1]] = m[2];
57
+ }
54
58
  }
55
59
  return { packages, body: match[2].trim() };
56
60
  }
@@ -36,7 +36,9 @@ const bumpTypes = new Set();
36
36
  for (const filePath of pendingChangesets) {
37
37
  const content = await readFile(path.join(root, filePath), "utf8");
38
38
  const match = content.match(/^---\n([\s\S]*?)\n---/);
39
- if (!match) continue;
39
+ if (!match) {
40
+ continue;
41
+ }
40
42
  for (const line of match[1].split("\n")) {
41
43
  const m = line.match(/^"([^"]+)"\s*:\s*(\w+)/);
42
44
  if (m) {
@@ -50,7 +50,9 @@ const projectCoverage = parseLcovByProject(readFileSync(lcovPath, "utf8"));
50
50
  for (const [project, metrics] of [...projectCoverage.entries()].sort(([a], [b]) =>
51
51
  a.localeCompare(b),
52
52
  )) {
53
- if (metrics.totalLines === 0) continue;
53
+ if (metrics.totalLines === 0) {
54
+ continue;
55
+ }
54
56
  const pct = Number(((metrics.coveredLines / metrics.totalLines) * 100).toFixed(1));
55
57
  const projectBadgePath = path.join(projectBadgesDirectory, `${project}.svg`);
56
58
  writeFileSync(projectBadgePath, createBadgeSvg(project, `${pct}%`, getColor(pct)));
@@ -30,18 +30,24 @@ function parseArgs(argv) {
30
30
  }
31
31
  if (arg === "--top") {
32
32
  const parsed = Number(argv[index + 1]);
33
- if (!Number.isNaN(parsed) && parsed > 0) options.top = parsed;
33
+ if (!Number.isNaN(parsed) && parsed > 0) {
34
+ options.top = parsed;
35
+ }
34
36
  index += 1;
35
37
  continue;
36
38
  }
37
- if (arg === "--json") options.json = true;
39
+ if (arg === "--json") {
40
+ options.json = true;
41
+ }
38
42
  }
39
43
 
40
44
  return options;
41
45
  }
42
46
 
43
47
  function formatLineRanges(lines) {
44
- if (lines.length === 0) return "-";
48
+ if (lines.length === 0) {
49
+ return "-";
50
+ }
45
51
  const ranges = [];
46
52
  let rangeStart = lines[0];
47
53
  let previous = lines[0];
@@ -114,7 +120,9 @@ const filtered = files.filter((file) => {
114
120
  ? file.project != null
115
121
  : file.sourcePath.startsWith(options.pathPrefix);
116
122
  }
117
- if (file.project !== options.project) return false;
123
+ if (file.project !== options.project) {
124
+ return false;
125
+ }
118
126
  return options.pathPrefix == null || file.sourcePath.startsWith(options.pathPrefix);
119
127
  });
120
128
 
@@ -51,7 +51,9 @@ export class CodeDesign {
51
51
  for (const file of this.files(dir)) {
52
52
  const rel = relative(this.root, file);
53
53
  if (SPEC.test(file)) {
54
- if (!relative(dir, file).startsWith("src/")) add("specsAway", rel);
54
+ if (!relative(dir, file).startsWith("src/")) {
55
+ add("specsAway", rel);
56
+ }
55
57
  continue;
56
58
  }
57
59
  if (
@@ -72,39 +74,52 @@ export class CodeDesign {
72
74
  measureFile(file, rel, name, bins, add) {
73
75
  const text = readFileSync(file, "utf8");
74
76
  const base = basename(file).replace(/\.(ts|mts)$/, "");
75
- if (BANNED.test(base)) add("bannedNames", rel);
77
+ if (BANNED.test(base)) {
78
+ add("bannedNames", rel);
79
+ }
76
80
  const role = base.split(".");
77
- if (base !== "index" && (role.length < 2 || !this.roles.has(role.at(-1))))
81
+ if (base !== "index" && (role.length < 2 || !this.roles.has(role.at(-1)))) {
78
82
  add("noRole", rel);
83
+ }
79
84
  const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true);
80
85
  const isPluginFile = role.at(-1) === "plugin";
81
86
  if (name !== "config" && !bins.has(relative(this.root, file))) {
82
- for (let i = countEnvReads(source); i > 0; i--) add("envReads", rel);
87
+ for (let i = countEnvReads(source); i > 0; i--) {
88
+ add("envReads", rel);
89
+ }
83
90
  }
84
91
  let classes = 0;
85
92
  for (const statement of source.statements) {
86
- if (ts.isClassDeclaration(statement)) classes++;
87
- if (!isExported(statement)) continue;
93
+ if (ts.isClassDeclaration(statement)) {
94
+ classes++;
95
+ }
96
+ if (!isExported(statement)) {
97
+ continue;
98
+ }
88
99
  if (ts.isFunctionDeclaration(statement)) {
89
100
  const fn = statement.name?.text ?? "default";
90
101
  // A .plugin.ts file holds a plugin factory, whatever writer or module it returns.
91
- if (!isPluginFile && !isAllowedFunction(fn, statement))
102
+ if (!isPluginFile && !isAllowedFunction(fn, statement)) {
92
103
  add("looseFunctions", `${rel}: ${fn}`);
104
+ }
93
105
  }
94
106
  if (ts.isVariableStatement(statement)) {
95
107
  for (const declaration of statement.declarationList.declarations) {
96
108
  const init = declaration.initializer;
97
109
  const variable = declaration.name.getText();
98
110
  if (init && (ts.isArrowFunction(init) || ts.isFunctionExpression(init))) {
99
- if (!isAllowedFunction(variable, init))
111
+ if (!isAllowedFunction(variable, init)) {
100
112
  add("looseFunctions", `${rel}: ${variable}`);
113
+ }
101
114
  } else if (init && ts.isObjectLiteralExpression(init) && holdsFunctions(init)) {
102
115
  add("namespaceObjects", `${rel}: ${variable}`);
103
116
  }
104
117
  }
105
118
  }
106
119
  }
107
- if (classes > 1) add("severalClasses", rel);
120
+ if (classes > 1) {
121
+ add("severalClasses", rel);
122
+ }
108
123
  }
109
124
 
110
125
  /** @private Every package under projects/, with the source files its bins start from. */
@@ -113,9 +128,13 @@ export class CodeDesign {
113
128
  const found = [];
114
129
  const visit = (dir) => {
115
130
  for (const entry of readdirSync(dir)) {
116
- if (entry === "node_modules" || entry === "__fixtures__" || entry === "dist") continue;
131
+ if (entry === "node_modules" || entry === "__fixtures__" || entry === "dist") {
132
+ continue;
133
+ }
117
134
  const path = join(dir, entry);
118
- if (!statSync(path).isDirectory()) continue;
135
+ if (!statSync(path).isDirectory()) {
136
+ continue;
137
+ }
119
138
  if (!existsSync(join(path, "package.json"))) {
120
139
  visit(path);
121
140
  continue;
@@ -155,13 +174,19 @@ export class CodeDesign {
155
174
  const out = [];
156
175
  const visit = (current) => {
157
176
  for (const entry of readdirSync(current)) {
158
- if (["node_modules", "dist", "e2e", "__fixtures__"].includes(entry)) continue;
177
+ if (["node_modules", "dist", "e2e", "__fixtures__"].includes(entry)) {
178
+ continue;
179
+ }
159
180
  const path = join(current, entry);
160
181
  if (statSync(path).isDirectory()) {
161
182
  // A nested package is measured on its own.
162
- if (path !== dir && existsSync(join(path, "package.json"))) continue;
183
+ if (path !== dir && existsSync(join(path, "package.json"))) {
184
+ continue;
185
+ }
163
186
  visit(path);
164
- } else out.push(path);
187
+ } else {
188
+ out.push(path);
189
+ }
165
190
  }
166
191
  };
167
192
  visit(dir);
@@ -207,9 +232,13 @@ function isExported(statement) {
207
232
  * @param {ts.FunctionLikeDeclaration} fn
208
233
  */
209
234
  function isAllowedFunction(name, fn) {
210
- if (/^(is|has)[A-Z]/.test(name) || /^define[A-Z]/.test(name)) return true;
235
+ if (/^(is|has)[A-Z]/.test(name) || /^define[A-Z]/.test(name)) {
236
+ return true;
237
+ }
211
238
  const returns = fn.type?.getText() ?? "";
212
- if (/Plugin\b|Decorator\b/.test(returns)) return true;
239
+ if (/Plugin\b|Decorator\b/.test(returns)) {
240
+ return true;
241
+ }
213
242
  const body = fn.body?.getText() ?? "";
214
243
  // A factory returning `(builder) => …`, or a decorator returning `(target…) => …`.
215
244
  return /return \(?(builder|target|_target)\b/.test(body);
@@ -53,7 +53,9 @@ export function runDesignCheck(options = {}) {
53
53
  `design: ${pkg} ${RULES[rule]} ${was} → ${now} (+${now - was}), among:\n ${where.join("\n ")}`,
54
54
  );
55
55
  }
56
- if (now < was) fell.push(`design: ${pkg} ${RULES[rule]} ${was} → ${now}`);
56
+ if (now < was) {
57
+ fell.push(`design: ${pkg} ${RULES[rule]} ${was} → ${now}`);
58
+ }
57
59
  }
58
60
  }
59
61
 
@@ -25,7 +25,9 @@ export class FileRoles {
25
25
  this.roles = new Set();
26
26
  for (const line of readFileSync(path, "utf8").split("\n")) {
27
27
  const cell = ROW.exec(line)?.[1] ?? "";
28
- for (const [, role] of cell.matchAll(ROLE)) this.roles.add(role);
28
+ for (const [, role] of cell.matchAll(ROLE)) {
29
+ this.roles.add(role);
30
+ }
29
31
  }
30
32
  if (this.roles.size === 0) {
31
33
  throw new Error(
@@ -19,7 +19,9 @@ function parseArgs(argv) {
19
19
  continue;
20
20
  }
21
21
  const next = args[index + 1];
22
- if (next == null) throw new Error(`Missing value for ${arg}`);
22
+ if (next == null) {
23
+ throw new Error(`Missing value for ${arg}`);
24
+ }
23
25
  switch (arg) {
24
26
  case "--repo":
25
27
  flags.repo = next;
@@ -46,16 +48,23 @@ function parseArgs(argv) {
46
48
  }
47
49
  }
48
50
 
49
- if (!flags.title) throw new Error("Missing required argument: --title");
50
- if (!flags.bodyFile) throw new Error("Missing required argument: --body-file");
51
- if (!existsSync(flags.bodyFile)) throw new Error(`Body file not found: ${flags.bodyFile}`);
51
+ if (!flags.title) {
52
+ throw new Error("Missing required argument: --title");
53
+ }
54
+ if (!flags.bodyFile) {
55
+ throw new Error("Missing required argument: --body-file");
56
+ }
57
+ if (!existsSync(flags.bodyFile)) {
58
+ throw new Error(`Body file not found: ${flags.bodyFile}`);
59
+ }
52
60
  return flags;
53
61
  }
54
62
 
55
63
  function runGh(args) {
56
64
  const result = spawnSync("gh", args, { encoding: "utf8", env: process.env });
57
- if (result.status !== 0)
65
+ if (result.status !== 0) {
58
66
  throw new Error(result.stderr || result.stdout || `gh command failed: ${args.join(" ")}`);
67
+ }
59
68
  return result.stdout;
60
69
  }
61
70
 
@@ -65,7 +74,9 @@ function runGhJson(args) {
65
74
 
66
75
  function splitRepo(repo) {
67
76
  const [owner, name] = repo.split("/");
68
- if (!owner || !name) throw new Error(`Invalid repo format: ${repo}. Expected owner/name`);
77
+ if (!owner || !name) {
78
+ throw new Error(`Invalid repo format: ${repo}. Expected owner/name`);
79
+ }
69
80
  return { owner, name };
70
81
  }
71
82
 
@@ -101,7 +112,9 @@ function getRepositoryMetadata(repo, typeName) {
101
112
  `name=${name}`,
102
113
  ]);
103
114
  const repository = response?.data?.repository;
104
- if (!repository?.id) throw new Error(`Repository not found: ${repo}`);
115
+ if (!repository?.id) {
116
+ throw new Error(`Repository not found: ${repo}`);
117
+ }
105
118
  const typeMatch = repository.issueTypes?.nodes?.find((node) => node.name === typeName);
106
119
  if (!typeMatch) {
107
120
  const available = (repository.issueTypes?.nodes ?? []).map((node) => node.name).join(", ");
@@ -157,7 +170,9 @@ if (args.typeId) {
157
170
  `name=${name}`,
158
171
  ]);
159
172
  const repositoryId = response?.data?.repository?.id;
160
- if (!repositoryId) throw new Error(`Repository not found: ${args.repo}`);
173
+ if (!repositoryId) {
174
+ throw new Error(`Repository not found: ${args.repo}`);
175
+ }
161
176
  metadata = { repositoryId, issueTypeId: args.typeId };
162
177
  } else {
163
178
  metadata = getRepositoryMetadata(args.repo, args.type);
@@ -169,5 +184,7 @@ const createdIssue = createIssue(
169
184
  args.title,
170
185
  body,
171
186
  );
172
- if (!createdIssue) throw new Error("Issue creation failed: API response missing issue data");
187
+ if (!createdIssue) {
188
+ throw new Error("Issue creation failed: API response missing issue data");
189
+ }
173
190
  console.log(`Created issue: #${createdIssue.number} ${createdIssue.url}`);
@@ -24,7 +24,9 @@ function parseArgs(argv) {
24
24
  continue;
25
25
  }
26
26
  const next = args[i + 1];
27
- if (next == null) throw new Error(`Missing value for ${arg}`);
27
+ if (next == null) {
28
+ throw new Error(`Missing value for ${arg}`);
29
+ }
28
30
  switch (arg) {
29
31
  case "--repo":
30
32
  flags.repo = next;
@@ -48,8 +50,9 @@ function parseArgs(argv) {
48
50
  break;
49
51
  case "--estimate": {
50
52
  const value = Number.parseFloat(next);
51
- if (!Number.isFinite(value) || value < 0)
53
+ if (!Number.isFinite(value) || value < 0) {
52
54
  throw new Error(`Invalid --estimate value: ${next}`);
55
+ }
53
56
  flags.estimate = value;
54
57
  i += 1;
55
58
  break;
@@ -70,8 +73,9 @@ function parseArgs(argv) {
70
73
 
71
74
  function runGh(args) {
72
75
  const result = spawnSync("gh", args, { encoding: "utf8", env: process.env });
73
- if (result.status !== 0)
76
+ if (result.status !== 0) {
74
77
  throw new Error(result.stderr || result.stdout || `gh command failed: ${args.join(" ")}`);
78
+ }
75
79
  return result.stdout;
76
80
  }
77
81
 
@@ -81,7 +85,9 @@ function runGhJson(args) {
81
85
 
82
86
  function splitRepo(repo) {
83
87
  const [owner, name] = repo.split("/");
84
- if (!owner || !name) throw new Error(`Invalid repo format: ${repo}. Expected owner/name`);
88
+ if (!owner || !name) {
89
+ throw new Error(`Invalid repo format: ${repo}. Expected owner/name`);
90
+ }
85
91
  return { owner, name };
86
92
  }
87
93
 
@@ -101,7 +107,9 @@ function getIssue(repo, issueNumber) {
101
107
  `number=${issueNumber}`,
102
108
  ]);
103
109
  const issue = response?.data?.repository?.issue;
104
- if (!issue) throw new Error(`Issue #${issueNumber} not found in ${repo}`);
110
+ if (!issue) {
111
+ throw new Error(`Issue #${issueNumber} not found in ${repo}`);
112
+ }
105
113
  return issue;
106
114
  }
107
115
 
@@ -110,7 +118,9 @@ function getProjectByTitle(org, projectTitle) {
110
118
  const response = runGhJson(["api", "graphql", "-f", `query=${query}`, "-f", `org=${org}`]);
111
119
  const projects = response?.data?.organization?.projectsV2?.nodes ?? [];
112
120
  const project = projects.find((p) => p.title === projectTitle);
113
- if (!project) throw new Error(`Project "${projectTitle}" not found for org "${org}"`);
121
+ if (!project) {
122
+ throw new Error(`Project "${projectTitle}" not found for org "${org}"`);
123
+ }
114
124
  return project;
115
125
  }
116
126
 
@@ -155,8 +165,9 @@ function computeMissing(issue, projectTitle, sprintFieldName, estimateFieldName)
155
165
 
156
166
  function getRequiredField(project, fieldName) {
157
167
  const field = (project?.fields?.nodes ?? []).find((node) => node?.name === fieldName);
158
- if (!field?.id)
168
+ if (!field?.id) {
159
169
  throw new Error(`Field "${fieldName}" not found on project "${project.title}"`);
170
+ }
160
171
  return field;
161
172
  }
162
173
 
@@ -220,15 +231,17 @@ function applySprintValue(project, projectId, itemId, sprintFieldName, iteration
220
231
  const iteration = sprintField.configuration.iterations.find(
221
232
  (v) => v.title === iterationName,
222
233
  );
223
- if (!iteration)
234
+ if (!iteration) {
224
235
  throw new Error(`Iteration "${iterationName}" not found in field "${sprintFieldName}"`);
236
+ }
225
237
  setProjectItemIterationField(projectId, itemId, sprintField.id, iteration.id);
226
238
  return;
227
239
  }
228
240
  if (sprintField?.options) {
229
241
  const option = sprintField.options.find((v) => v.name === iterationName);
230
- if (!option)
242
+ if (!option) {
231
243
  throw new Error(`Option "${iterationName}" not found in field "${sprintFieldName}"`);
244
+ }
232
245
  setProjectItemSingleSelectField(projectId, itemId, sprintField.id, option.id);
233
246
  return;
234
247
  }
@@ -259,11 +272,14 @@ if (args.apply) {
259
272
 
260
273
  let refreshed = getIssue(args.repo, args.issueNumber);
261
274
  let refreshedItem = getProjectItem(refreshed, args.project);
262
- if (!project) project = getProjectByTitle(owner, args.project);
263
- if (!refreshedItem)
275
+ if (!project) {
276
+ project = getProjectByTitle(owner, args.project);
277
+ }
278
+ if (!refreshedItem) {
264
279
  throw new Error(
265
280
  `Issue #${args.issueNumber} is still not assigned to project "${args.project}"`,
266
281
  );
282
+ }
267
283
 
268
284
  if (missing.sprint && args.iteration) {
269
285
  applySprintValue(project, project.id, refreshedItem.id, args.sprintField, args.iteration);
@@ -272,8 +288,9 @@ if (args.apply) {
272
288
  }
273
289
 
274
290
  if (missing.estimate) {
275
- if (args.estimate == null)
291
+ if (args.estimate == null) {
276
292
  throw new Error("Issue is missing estimate. Re-run with --estimate <days> --apply");
293
+ }
277
294
  const estimateField = getRequiredField(project, args.estimateField);
278
295
  setProjectItemNumberField(project.id, refreshedItem.id, estimateField.id, args.estimate);
279
296
  }
@@ -30,8 +30,12 @@ export function extractFailure(log) {
30
30
  const all = cleanLines(log);
31
31
 
32
32
  let end = all.findLastIndex((line) => EXIT_LINE.test(line));
33
- if (end === -1) end = all.findLastIndex((line) => line.startsWith("##[error]"));
34
- if (end === -1) return { reason: NO_REASON, lines: [] };
33
+ if (end === -1) {
34
+ end = all.findLastIndex((line) => line.startsWith("##[error]"));
35
+ }
36
+ if (end === -1) {
37
+ return { reason: NO_REASON, lines: [] };
38
+ }
35
39
 
36
40
  const start = all.findLastIndex(
37
41
  (line, index) => index < end && line.startsWith("##[group]Run"),
@@ -107,7 +111,9 @@ async function github(path, token, accept = "application/vnd.github+json") {
107
111
  const response = await fetch(`https://api.github.com/${path}`, {
108
112
  headers: { authorization: `Bearer ${token}`, accept },
109
113
  });
110
- if (!response.ok) throw new Error(`GET ${path}: ${response.status} ${response.statusText}`);
114
+ if (!response.ok) {
115
+ throw new Error(`GET ${path}: ${response.status} ${response.statusText}`);
116
+ }
111
117
  return response;
112
118
  }
113
119
 
@@ -120,7 +126,9 @@ async function failedJobs(repo, runId, attempt, token) {
120
126
  );
121
127
  const batch = (await response.json()).jobs;
122
128
  jobs.push(...batch);
123
- if (batch.length < 100) break;
129
+ if (batch.length < 100) {
130
+ break;
131
+ }
124
132
  }
125
133
  return jobs.filter((job) => job.conclusion === "failure");
126
134
  }
@@ -154,7 +162,9 @@ async function main() {
154
162
  for (const { job, step, reason } of failures) {
155
163
  console.log(errorCommand(`${job} / ${step}`, reason));
156
164
  }
157
- if (summaryPath && failures.length > 0) appendFileSync(summaryPath, formatSummary(failures));
165
+ if (summaryPath && failures.length > 0) {
166
+ appendFileSync(summaryPath, formatSummary(failures));
167
+ }
158
168
  }
159
169
 
160
170
  if (process.argv[1] != null && import.meta.url === pathToFileURL(process.argv[1]).href) {
@@ -48,7 +48,9 @@ export async function checkFirstPublish(options) {
48
48
  if (!response.ok && response.status !== 404) {
49
49
  throw new Error(`Could not check ${name} on npm: ${response.status}`);
50
50
  }
51
- if (response.status === 404) return { name, missing: true, fromCi: false };
51
+ if (response.status === 404) {
52
+ return { name, missing: true, fromCi: false };
53
+ }
52
54
  return { name, missing: false, fromCi: publishedFromCi(await response.json()) };
53
55
  }),
54
56
  );
@@ -94,7 +94,9 @@ async function isOnBranch(name, root) {
94
94
  const git = (/** @type {string[]} */ args) =>
95
95
  spawnSync("git", args, { cwd: root, encoding: "utf8" });
96
96
  const fetched = git(["fetch", "--quiet", "origin"]);
97
- if (fetched.status !== 0) throw new Error(`git fetch origin failed: ${fetched.stderr}`);
97
+ if (fetched.status !== 0) {
98
+ throw new Error(`git fetch origin failed: ${fetched.stderr}`);
99
+ }
98
100
  const refs = git(["for-each-ref", "--format=%(refname)", "refs/remotes/origin"])
99
101
  .stdout.split("\n")
100
102
  .filter((ref) => ref !== "" && !ref.endsWith("/HEAD"));
@@ -158,8 +160,12 @@ function registry({ token, otp, fetch }) {
158
160
  /** @param {string} name */
159
161
  async exists(name) {
160
162
  const response = await fetch(`${REGISTRY}/${encoded(name)}`, { headers });
161
- if (response.status === 404) return false;
162
- if (!response.ok) throw new Error(`reading ${name}: ${response.status}`);
163
+ if (response.status === 404) {
164
+ return false;
165
+ }
166
+ if (!response.ok) {
167
+ throw new Error(`reading ${name}: ${response.status}`);
168
+ }
163
169
  return true;
164
170
  },
165
171
  /** @param {string} name @returns {Promise<TrustEntry[]>} */
@@ -206,7 +212,9 @@ function runNpm(args, { capture = false, otp } = {}) {
206
212
  */
207
213
  function readLoginToken(npm) {
208
214
  const userconfig = npm(["config", "get", "userconfig"], { capture: true }).output.trim();
209
- if (userconfig.length === 0) return undefined;
215
+ if (userconfig.length === 0) {
216
+ return undefined;
217
+ }
210
218
  const npmrc = readFileSync(userconfig, "utf8");
211
219
  return /^\/\/registry\.npmjs\.org\/:_authToken=(.+)$/m.exec(npmrc)?.[1]?.trim();
212
220
  }
@@ -375,7 +383,9 @@ export async function runBootstrap(options = {}) {
375
383
  }
376
384
  }
377
385
 
378
- if (dryRun) return 0;
386
+ if (dryRun) {
387
+ return 0;
388
+ }
379
389
  log(
380
390
  "\nDone: these packages can be published and promoted from CI. If Publish already failed on one, " +
381
391
  "rerun it: `gh run rerun --failed <run-id>`. Otherwise add the PR to the merge queue.",
@@ -69,7 +69,9 @@ export function resolveIssue(options, run = gh) {
69
69
  const { title, comment } = options;
70
70
  const repo = options.repo ? ["--repo", options.repo] : [];
71
71
  const open = pickIssue(listIssues(title, repo, run), title);
72
- if (open == null || open.state !== "OPEN") return null;
72
+ if (open == null || open.state !== "OPEN") {
73
+ return null;
74
+ }
73
75
  run(["issue", "close", String(open.number), ...repo, "--comment", comment]);
74
76
  return open.number;
75
77
  }
package/src/lib/lcov.mjs CHANGED
@@ -54,7 +54,9 @@ export function parseLcovByProject(content) {
54
54
  }
55
55
 
56
56
  const project = getProjectFromPath(sourcePath);
57
- if (project == null || totalLines === 0) continue;
57
+ if (project == null || totalLines === 0) {
58
+ continue;
59
+ }
58
60
 
59
61
  const current = byProject.get(project) ?? { totalLines: 0, coveredLines: 0 };
60
62
  current.totalLines += totalLines;
@@ -111,7 +113,9 @@ export function parseLcovFiles(content) {
111
113
  }
112
114
  }
113
115
 
114
- if (sourcePath.length === 0 || totalLines === 0) continue;
116
+ if (sourcePath.length === 0 || totalLines === 0) {
117
+ continue;
118
+ }
115
119
 
116
120
  files.push({
117
121
  sourcePath,
package/src/lib/svg.mjs CHANGED
@@ -8,10 +8,18 @@
8
8
  * @returns {string}
9
9
  */
10
10
  export function getColor(percentage) {
11
- if (percentage >= 90) return "#2ea043";
12
- if (percentage >= 80) return "#3fb950";
13
- if (percentage >= 70) return "#9a6700";
14
- if (percentage >= 60) return "#db6d28";
11
+ if (percentage >= 90) {
12
+ return "#2ea043";
13
+ }
14
+ if (percentage >= 80) {
15
+ return "#3fb950";
16
+ }
17
+ if (percentage >= 70) {
18
+ return "#9a6700";
19
+ }
20
+ if (percentage >= 60) {
21
+ return "#db6d28";
22
+ }
15
23
  return "#cf222e";
16
24
  }
17
25
 
@@ -43,10 +51,18 @@ export function createBadgeSvg(label, value, color) {
43
51
  * @returns {string}
44
52
  */
45
53
  export function statusToColor(status, conclusion) {
46
- if (status === "in_progress" || status === "queued") return "#fb8500";
47
- if (conclusion === "success") return "#2ea043";
48
- if (conclusion === "failure") return "#cf222e";
49
- if (conclusion === "cancelled") return "#6e7781";
54
+ if (status === "in_progress" || status === "queued") {
55
+ return "#fb8500";
56
+ }
57
+ if (conclusion === "success") {
58
+ return "#2ea043";
59
+ }
60
+ if (conclusion === "failure") {
61
+ return "#cf222e";
62
+ }
63
+ if (conclusion === "cancelled") {
64
+ return "#6e7781";
65
+ }
50
66
  return "#6e7781";
51
67
  }
52
68
 
@@ -57,10 +73,20 @@ export function statusToColor(status, conclusion) {
57
73
  * @returns {string}
58
74
  */
59
75
  export function statusToText(status, conclusion) {
60
- if (status === "in_progress") return "running";
61
- if (status === "queued") return "queued";
62
- if (conclusion === "success") return "passing";
63
- if (conclusion === "failure") return "failing";
64
- if (conclusion === "cancelled") return "cancelled";
76
+ if (status === "in_progress") {
77
+ return "running";
78
+ }
79
+ if (status === "queued") {
80
+ return "queued";
81
+ }
82
+ if (conclusion === "success") {
83
+ return "passing";
84
+ }
85
+ if (conclusion === "failure") {
86
+ return "failing";
87
+ }
88
+ if (conclusion === "cancelled") {
89
+ return "cancelled";
90
+ }
65
91
  return "unknown";
66
92
  }
@@ -30,9 +30,15 @@ function escapeHtml(value) {
30
30
  }
31
31
 
32
32
  function fmtMs(ms) {
33
- if (typeof ms !== "number" || Number.isNaN(ms)) return "–";
34
- if (ms === 0) return "0 ms";
35
- if (ms >= 100) return `${Math.round(ms)} ms`;
33
+ if (typeof ms !== "number" || Number.isNaN(ms)) {
34
+ return "–";
35
+ }
36
+ if (ms === 0) {
37
+ return "0 ms";
38
+ }
39
+ if (ms >= 100) {
40
+ return `${Math.round(ms)} ms`;
41
+ }
36
42
  return `${ms.toFixed(1)} ms`;
37
43
  }
38
44
 
@@ -42,7 +48,9 @@ function fmtDate(iso) {
42
48
  }
43
49
 
44
50
  function commitLink(repoUrl, sha) {
45
- if (sha == null) return "–";
51
+ if (sha == null) {
52
+ return "–";
53
+ }
46
54
  return `<a href="${escapeHtml(`${repoUrl}/commit/${sha}`)}"><code>${escapeHtml(sha.slice(0, 7))}</code></a>`;
47
55
  }
48
56
 
@@ -81,8 +89,9 @@ function benchmarkIds(contexts) {
81
89
  const time = new Date(run.date).getTime();
82
90
  for (const result of run.results) {
83
91
  const seen = newest.get(result.id);
84
- if (seen == null || time > seen.time)
92
+ if (seen == null || time > seen.time) {
85
93
  newest.set(result.id, { time, label: result.label });
94
+ }
86
95
  }
87
96
  }
88
97
  }
@@ -111,7 +120,9 @@ export function trendSvg(lines) {
111
120
  const height = 180;
112
121
  const pad = { top: 12, right: 12, bottom: 24, left: 56 };
113
122
  const points = lines.flatMap((line) => line.points);
114
- if (points.length === 0) return "";
123
+ if (points.length === 0) {
124
+ return "";
125
+ }
115
126
  const minTime = Math.min(...points.map((p) => p.time));
116
127
  const maxTime = Math.max(...points.map((p) => p.time));
117
128
  const maxValue = Math.max(...points.map((p) => p.p90 ?? p.median)) * 1.1 || 1;
@@ -159,10 +170,14 @@ export function trendSvg(lines) {
159
170
  function changeText(points) {
160
171
  const last = points.at(-1);
161
172
  const before = points.at(-2);
162
- if (last == null || before == null || before.median === 0) return "";
173
+ if (last == null || before == null || before.median === 0) {
174
+ return "";
175
+ }
163
176
  const percent = ((last.median - before.median) / before.median) * 100;
164
177
  const direction = percent > 0 ? "slower" : "faster";
165
- if (Math.abs(percent) < 0.5) return `<span class="change">no change</span>`;
178
+ if (Math.abs(percent) < 0.5) {
179
+ return `<span class="change">no change</span>`;
180
+ }
166
181
  return `<span class="change ${percent > 0 ? "worse" : "better"}">${Math.abs(percent).toFixed(1)}% ${direction}</span>`;
167
182
  }
168
183
 
@@ -226,7 +241,9 @@ export function buildBenchmarkHtml(
226
241
  const other = [...labels.keys()].filter(
227
242
  (id) => !GROUPS.some((group) => id.startsWith(group.prefix)),
228
243
  );
229
- if (other.length > 0) grouped.push({ title: "Other", ids: other });
244
+ if (other.length > 0) {
245
+ grouped.push({ title: "Other", ids: other });
246
+ }
230
247
  const sections = grouped
231
248
  .filter((group) => group.ids.length > 0)
232
249
  .map(
@@ -15,8 +15,12 @@ const PAGES_URL = process.env.PAGES_URL ?? "https://typesmiths.github.io/decoher
15
15
 
16
16
  async function fetchOrNull(url) {
17
17
  const response = await fetch(url);
18
- if (response.status === 404) return null;
19
- if (!response.ok) throw new Error(`GET ${url}: HTTP ${response.status}`);
18
+ if (response.status === 404) {
19
+ return null;
20
+ }
21
+ if (!response.ok) {
22
+ throw new Error(`GET ${url}: HTTP ${response.status}`);
23
+ }
20
24
  return response;
21
25
  }
22
26
 
@@ -26,7 +30,9 @@ const badges = manifest != null ? (await manifest.json()).badges : [];
26
30
  let restored = 0;
27
31
  for (const badge of badges) {
28
32
  const response = await fetchOrNull(`${PAGES_URL}/badges/${badge}`);
29
- if (response == null) continue;
33
+ if (response == null) {
34
+ continue;
35
+ }
30
36
  const file = path.join(BADGES_DIR, badge);
31
37
  await mkdir(path.dirname(file), { recursive: true });
32
38
  await writeFile(file, await response.text());
@@ -16,7 +16,9 @@ function isOlderOrSame(version, than) {
16
16
  const parts = (text) => VERSION.exec(text)?.slice(1).map(Number) ?? [0, 0, 0];
17
17
  const [a, b] = [parts(version), parts(than)];
18
18
  for (const index of [0, 1, 2]) {
19
- if (a[index] !== b[index]) return a[index] < b[index];
19
+ if (a[index] !== b[index]) {
20
+ return a[index] < b[index];
21
+ }
20
22
  }
21
23
  return !version.includes("-") && !than.includes("-");
22
24
  }
@@ -24,7 +24,9 @@ function tryGit(args, cwd, notFound) {
24
24
  try {
25
25
  return git(args, cwd);
26
26
  } catch (error) {
27
- if (error.status === notFound) return undefined;
27
+ if (error.status === notFound) {
28
+ return undefined;
29
+ }
28
30
  throw error;
29
31
  }
30
32
  }
@@ -36,7 +38,9 @@ function tryGit(args, cwd, notFound) {
36
38
  */
37
39
  export function findPublishBase(sha, cwd = process.cwd()) {
38
40
  const parent = tryGit(["rev-parse", "--verify", "--quiet", `${sha}^1`], cwd, 1);
39
- if (parent == null) return undefined;
41
+ if (parent == null) {
42
+ return undefined;
43
+ }
40
44
  const tag = tryGit(
41
45
  ["describe", "--tags", "--abbrev=0", "--match", "v[0-9]*", parent],
42
46
  cwd,
@@ -47,5 +51,7 @@ export function findPublishBase(sha, cwd = process.cwd()) {
47
51
 
48
52
  if (import.meta.url === pathToFileURL(process.argv[1]).href) {
49
53
  const base = findPublishBase(process.argv[2]);
50
- if (base != null) console.log(base);
54
+ if (base != null) {
55
+ console.log(base);
56
+ }
51
57
  }
@@ -101,7 +101,9 @@ export function promoteLatest(options) {
101
101
  log(`already there: ${name}`);
102
102
  continue;
103
103
  }
104
- if (npm("dist-tag", "add", `${name}@${version}`, "latest").status !== 0) failed.push(name);
104
+ if (npm("dist-tag", "add", `${name}@${version}`, "latest").status !== 0) {
105
+ failed.push(name);
106
+ }
105
107
  }
106
108
 
107
109
  const wrong = packages.filter((name) => !failed.includes(name) && !onLatest(name));
@@ -20,13 +20,17 @@ import { pathToFileURL } from "node:url";
20
20
  export function findPublicPackages(dir) {
21
21
  const found = [];
22
22
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
23
- if (entry.name === "node_modules") continue;
23
+ if (entry.name === "node_modules") {
24
+ continue;
25
+ }
24
26
  const path = join(dir, entry.name);
25
27
  if (entry.isDirectory()) {
26
28
  found.push(...findPublicPackages(path));
27
29
  } else if (entry.name === "package.json") {
28
30
  const pkg = JSON.parse(readFileSync(path, "utf8"));
29
- if (pkg.name?.startsWith("@decohere/") && pkg.private !== true) found.push(dir);
31
+ if (pkg.name?.startsWith("@decohere/") && pkg.private !== true) {
32
+ found.push(dir);
33
+ }
30
34
  }
31
35
  }
32
36
  return found;
@@ -53,7 +53,9 @@ export function restampBuild({ dir, from, to }) {
53
53
  }
54
54
  }
55
55
  const output = `${JSON.stringify(manifest, null, 2)}\n`;
56
- if (output.includes(from)) elsewhere.push(relative(dir, file));
56
+ if (output.includes(from)) {
57
+ elsewhere.push(relative(dir, file));
58
+ }
57
59
  stamped.push({ file, name: manifest.name, output });
58
60
  } else if (text.includes(from)) {
59
61
  elsewhere.push(relative(dir, file));
@@ -25,7 +25,9 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
25
25
  const response = await fetch(`${base}/${path}`, {
26
26
  headers: { Authorization: `Bearer ${token}`, Accept: "application/vnd.github+json" },
27
27
  });
28
- if (!response.ok) throw new Error(`GitHub answered ${response.status} to GET ${path}`);
28
+ if (!response.ok) {
29
+ throw new Error(`GitHub answered ${response.status} to GET ${path}`);
30
+ }
29
31
  return response.json();
30
32
  };
31
33
 
@@ -34,7 +36,9 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
34
36
  console.error(`Tested by ${found.url} (${found.event})`);
35
37
  console.log(found.runId);
36
38
  } catch (error) {
37
- if (!(error instanceof TestedBuildError)) throw error;
39
+ if (!(error instanceof TestedBuildError)) {
40
+ throw error;
41
+ }
38
42
  console.error(`::error::${error.message}`);
39
43
  process.exit(1);
40
44
  }
@@ -53,7 +53,9 @@ export class TestedBuild {
53
53
  for (;;) {
54
54
  const runs = await this.runs(sha, event);
55
55
  const passed = runs.find((run) => run.conclusion === "success");
56
- if (passed != null) return this.withBuild(sha, passed, event);
56
+ if (passed != null) {
57
+ return this.withBuild(sha, passed, event);
58
+ }
57
59
  const running = runs.filter((run) => run.status !== "completed");
58
60
  if (running.length === 0) {
59
61
  notes.push(
@@ -50,7 +50,9 @@ function fakeNpm({ packages = {}, loggedIn = true, failPosting = [] } = {}) {
50
50
  const published = [];
51
51
  const npm = (args, { otp } = {}) => {
52
52
  calls.push(`${args.join(" ")}${otp ? ` [otp ${otp}]` : ""}`);
53
- if (args[0] === "whoami") return { status: loggedIn ? 0 : 1, output: "" };
53
+ if (args[0] === "whoami") {
54
+ return { status: loggedIn ? 0 : 1, output: "" };
55
+ }
54
56
  // A first publish creates the name, with no Trusted Publishers yet.
55
57
  if (args[0] === "publish") {
56
58
  const stub = JSON.parse(readFileSync(`${args[1]}/package.json`, "utf8"));
@@ -66,8 +68,12 @@ function fakeNpm({ packages = {}, loggedIn = true, failPosting = [] } = {}) {
66
68
  }
67
69
  const trust = /\/-\/package\/(.+)\/trust$/.exec(url);
68
70
  const name = decodeURIComponent(trust?.[1] ?? new URL(url).pathname.slice(1));
69
- if (!(name in packages)) return new Response("not found", { status: 404 });
70
- if (trust == null) return new Response(JSON.stringify({ name }));
71
+ if (!(name in packages)) {
72
+ return new Response("not found", { status: 404 });
73
+ }
74
+ if (trust == null) {
75
+ return new Response(JSON.stringify({ name }));
76
+ }
71
77
  // Like npm: Trusted Publishers need a code, even to read them.
72
78
  if (headers.get("npm-otp") == null) {
73
79
  return new Response('{"message":"Unauthorized"}', {
@@ -76,7 +82,9 @@ function fakeNpm({ packages = {}, loggedIn = true, failPosting = [] } = {}) {
76
82
  });
77
83
  }
78
84
  if (init.method === "POST") {
79
- if (failPosting.includes(name)) return new Response("denied", { status: 403 });
85
+ if (failPosting.includes(name)) {
86
+ return new Response("denied", { status: 403 });
87
+ }
80
88
  posts.push({ name, body: JSON.parse(String(init.body)), otp: headers.get("npm-otp") });
81
89
  return new Response("[]");
82
90
  }
@@ -9,8 +9,12 @@ function fakeGh(issues) {
9
9
  const calls = [];
10
10
  const run = (args, input) => {
11
11
  calls.push({ args, input });
12
- if (args[1] === "list") return JSON.stringify(issues);
13
- if (args[1] === "create") return "https://github.com/typesmiths/decohere/issues/42\n";
12
+ if (args[1] === "list") {
13
+ return JSON.stringify(issues);
14
+ }
15
+ if (args[1] === "create") {
16
+ return "https://github.com/typesmiths/decohere/issues/42\n";
17
+ }
14
18
  return "";
15
19
  };
16
20
  return { run, calls };