@flakiness/sdk 0.145.0 → 0.145.1

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/lib/cli/cli.js CHANGED
@@ -744,7 +744,7 @@ import path11 from "path";
744
744
  // ../package.json
745
745
  var package_default = {
746
746
  name: "flakiness",
747
- version: "0.145.0",
747
+ version: "0.145.1",
748
748
  private: true,
749
749
  scripts: {
750
750
  minor: "./version.mjs minor",
@@ -784,7 +784,7 @@ var package_default = {
784
784
  }
785
785
  };
786
786
 
787
- // src/flakinessConfig.ts
787
+ // src/flakinessProjectConfig.ts
788
788
  import fs2 from "fs";
789
789
  import path2 from "path";
790
790
 
@@ -1094,7 +1094,7 @@ function createEnvironments(projects) {
1094
1094
  return result;
1095
1095
  }
1096
1096
 
1097
- // src/flakinessConfig.ts
1097
+ // src/flakinessProjectConfig.ts
1098
1098
  function createConfigPath(dir) {
1099
1099
  return path2.join(dir, ".flakiness", "config.json");
1100
1100
  }
@@ -1117,7 +1117,7 @@ function computeConfigPath() {
1117
1117
  return createConfigPath(process.cwd());
1118
1118
  }
1119
1119
  }
1120
- var FlakinessConfig = class _FlakinessConfig {
1120
+ var FlakinessProjectConfig = class _FlakinessProjectConfig {
1121
1121
  constructor(_configPath, _config) {
1122
1122
  this._configPath = _configPath;
1123
1123
  this._config = _config;
@@ -1126,20 +1126,10 @@ var FlakinessConfig = class _FlakinessConfig {
1126
1126
  const configPath = ensureConfigPath();
1127
1127
  const data = await fs2.promises.readFile(configPath, "utf-8").catch((e) => void 0);
1128
1128
  const json = data ? JSON.parse(data) : {};
1129
- return new _FlakinessConfig(configPath, json);
1130
- }
1131
- static async projectOrDie(session2) {
1132
- const config = await _FlakinessConfig.load();
1133
- const projectPublicId = config.projectPublicId();
1134
- if (!projectPublicId)
1135
- throw new Error(`Please link to flakiness project with 'npx flakiness link'`);
1136
- const project = await session2.api.project.getProject.GET({ projectPublicId }).catch((e) => void 0);
1137
- if (!project)
1138
- throw new Error(`Failed to fetch linked project; please re-link with 'npx flakiness link'`);
1139
- return project;
1129
+ return new _FlakinessProjectConfig(configPath, json);
1140
1130
  }
1141
1131
  static createEmpty() {
1142
- return new _FlakinessConfig(ensureConfigPath(), {});
1132
+ return new _FlakinessProjectConfig(ensureConfigPath(), {});
1143
1133
  }
1144
1134
  path() {
1145
1135
  return this._configPath;
@@ -1147,6 +1137,9 @@ var FlakinessConfig = class _FlakinessConfig {
1147
1137
  projectPublicId() {
1148
1138
  return this._config.projectPublicId;
1149
1139
  }
1140
+ reportViewerEndpoint() {
1141
+ return this._config.customReportViewerEndpoint ?? "https://report.flakiness.io";
1142
+ }
1150
1143
  setProjectPublicId(projectId) {
1151
1144
  this._config.projectPublicId = projectId;
1152
1145
  }
@@ -1526,7 +1519,7 @@ async function cmdLink(session2, slug) {
1526
1519
  console.log(`Failed to find project ${slug}`);
1527
1520
  process.exit(1);
1528
1521
  }
1529
- const config = FlakinessConfig.createEmpty();
1522
+ const config = FlakinessProjectConfig.createEmpty();
1530
1523
  config.setProjectPublicId(project.projectPublicId);
1531
1524
  await config.save();
1532
1525
  console.log(`\u2713 Linked to ${session2.endpoint()}/${project.org.orgSlug}/${project.projectSlug}`);
@@ -1795,22 +1788,24 @@ var LocalReportServer = class _LocalReportServer {
1795
1788
  // src/cli/cmd-show-report.ts
1796
1789
  async function cmdShowReport(reportFolder) {
1797
1790
  const reportPath = path8.join(reportFolder, "report.json");
1798
- const session2 = await FlakinessSession.load();
1799
- const config = await FlakinessConfig.load();
1791
+ const config = await FlakinessProjectConfig.load();
1800
1792
  const projectPublicId = config.projectPublicId();
1801
- const project = projectPublicId && session2 ? await session2.api.project.getProject.GET({ projectPublicId }).catch((e) => void 0) : void 0;
1802
- const endpoint = session2?.endpoint() ?? "https://flakiness.io";
1793
+ const reportViewerEndpoint = config.reportViewerEndpoint();
1803
1794
  const server = await LocalReportServer.create({
1804
- endpoint,
1795
+ endpoint: reportViewerEndpoint,
1805
1796
  port: 9373,
1806
1797
  reportPath,
1807
1798
  attachmentsFolder: reportFolder
1808
1799
  });
1809
- const reportEndpoint = project ? `${endpoint}/localreport/${project.org.orgSlug}/${project.projectSlug}?port=${server.port()}&token=${server.authToken()}` : `${endpoint}/localreport?port=${server.port()}&token=${server.authToken()}`;
1800
+ const url = new URL(reportViewerEndpoint);
1801
+ url.searchParams.set("port", String(server.port()));
1802
+ url.searchParams.set("token", server.authToken());
1803
+ if (projectPublicId)
1804
+ url.searchParams.set("ppid", projectPublicId);
1810
1805
  console.log(chalk.cyan(`
1811
- Serving Flakiness report at ${reportEndpoint}
1806
+ Serving Flakiness report at ${url.toString()}
1812
1807
  Press Ctrl+C to quit.`));
1813
- await open2(reportEndpoint);
1808
+ await open2(url.toString());
1814
1809
  await new Promise(() => {
1815
1810
  });
1816
1811
  }
@@ -1824,7 +1819,7 @@ async function cmdStatus() {
1824
1819
  }
1825
1820
  const user = await session2.api.user.whoami.GET();
1826
1821
  console.log(`user: ${user.userName} (${user.userLogin})`);
1827
- const config = await FlakinessConfig.load();
1822
+ const config = await FlakinessProjectConfig.load();
1828
1823
  const projectPublicId = config.projectPublicId();
1829
1824
  if (!projectPublicId) {
1830
1825
  console.log(`project: <not linked>`);
@@ -1836,7 +1831,7 @@ async function cmdStatus() {
1836
1831
 
1837
1832
  // src/cli/cmd-unlink.ts
1838
1833
  async function cmdUnlink() {
1839
- const config = await FlakinessConfig.load();
1834
+ const config = await FlakinessProjectConfig.load();
1840
1835
  if (!config.projectPublicId())
1841
1836
  return;
1842
1837
  config.setProjectPublicId(void 0);
@@ -2249,7 +2244,7 @@ var program = new Command().name("flakiness").description("Flakiness CLI tool").
2249
2244
  async function ensureAccessToken(options) {
2250
2245
  let accessToken = options.accessToken;
2251
2246
  if (!accessToken) {
2252
- const config = await FlakinessConfig.load();
2247
+ const config = await FlakinessProjectConfig.load();
2253
2248
  const projectPublicId = config.projectPublicId();
2254
2249
  if (session && projectPublicId) {
2255
2250
  try {
@@ -2328,8 +2323,14 @@ var optParallel = new Option("-j, --parallel <date>", "Parallel jobs to run").ar
2328
2323
  return parsed;
2329
2324
  });
2330
2325
  program.command("download").description("Download run").addOption(optSince).addOption(optRunId).addOption(optParallel).action(async (options) => runCommand(async () => {
2326
+ const config = await FlakinessProjectConfig.load();
2331
2327
  const session2 = await FlakinessSession.loadOrDie();
2332
- const project = await FlakinessConfig.projectOrDie(session2);
2328
+ const projectPublicId = config.projectPublicId();
2329
+ if (!projectPublicId)
2330
+ throw new Error(`Please link to flakiness project with 'npx flakiness link'`);
2331
+ const project = await session2.api.project.getProject.GET({ projectPublicId }).catch((e) => void 0);
2332
+ if (!project)
2333
+ throw new Error(`Failed to fetch linked project; please re-link with 'npx flakiness link'`);
2333
2334
  let runIds = [];
2334
2335
  if (options.runId) {
2335
2336
  runIds = [options.runId, options.runId];
@@ -1,4 +1,4 @@
1
- // src/flakinessConfig.ts
1
+ // src/flakinessProjectConfig.ts
2
2
  import fs from "fs";
3
3
  import path2 from "path";
4
4
 
@@ -123,7 +123,7 @@ function normalizePath(aPath) {
123
123
  return aPath;
124
124
  }
125
125
 
126
- // src/flakinessConfig.ts
126
+ // src/flakinessProjectConfig.ts
127
127
  function createConfigPath(dir) {
128
128
  return path2.join(dir, ".flakiness", "config.json");
129
129
  }
@@ -146,7 +146,7 @@ function computeConfigPath() {
146
146
  return createConfigPath(process.cwd());
147
147
  }
148
148
  }
149
- var FlakinessConfig = class _FlakinessConfig {
149
+ var FlakinessProjectConfig = class _FlakinessProjectConfig {
150
150
  constructor(_configPath, _config) {
151
151
  this._configPath = _configPath;
152
152
  this._config = _config;
@@ -155,20 +155,10 @@ var FlakinessConfig = class _FlakinessConfig {
155
155
  const configPath = ensureConfigPath();
156
156
  const data = await fs.promises.readFile(configPath, "utf-8").catch((e) => void 0);
157
157
  const json = data ? JSON.parse(data) : {};
158
- return new _FlakinessConfig(configPath, json);
159
- }
160
- static async projectOrDie(session) {
161
- const config = await _FlakinessConfig.load();
162
- const projectPublicId = config.projectPublicId();
163
- if (!projectPublicId)
164
- throw new Error(`Please link to flakiness project with 'npx flakiness link'`);
165
- const project = await session.api.project.getProject.GET({ projectPublicId }).catch((e) => void 0);
166
- if (!project)
167
- throw new Error(`Failed to fetch linked project; please re-link with 'npx flakiness link'`);
168
- return project;
158
+ return new _FlakinessProjectConfig(configPath, json);
169
159
  }
170
160
  static createEmpty() {
171
- return new _FlakinessConfig(ensureConfigPath(), {});
161
+ return new _FlakinessProjectConfig(ensureConfigPath(), {});
172
162
  }
173
163
  path() {
174
164
  return this._configPath;
@@ -176,6 +166,9 @@ var FlakinessConfig = class _FlakinessConfig {
176
166
  projectPublicId() {
177
167
  return this._config.projectPublicId;
178
168
  }
169
+ reportViewerEndpoint() {
170
+ return this._config.customReportViewerEndpoint ?? "https://report.flakiness.io";
171
+ }
179
172
  setProjectPublicId(projectId) {
180
173
  this._config.projectPublicId = projectId;
181
174
  }
@@ -196,7 +189,7 @@ async function cmdLink(session, slug) {
196
189
  console.log(`Failed to find project ${slug}`);
197
190
  process.exit(1);
198
191
  }
199
- const config = FlakinessConfig.createEmpty();
192
+ const config = FlakinessProjectConfig.createEmpty();
200
193
  config.setProjectPublicId(project.projectPublicId);
201
194
  await config.save();
202
195
  console.log(`\u2713 Linked to ${session.endpoint()}/${project.org.orgSlug}/${project.projectSlug}`);
@@ -1,9 +1,9 @@
1
1
  // src/cli/cmd-show-report.ts
2
2
  import chalk from "chalk";
3
3
  import open from "open";
4
- import path5 from "path";
4
+ import path4 from "path";
5
5
 
6
- // src/flakinessConfig.ts
6
+ // src/flakinessProjectConfig.ts
7
7
  import fs2 from "fs";
8
8
  import path2 from "path";
9
9
 
@@ -163,7 +163,7 @@ function normalizePath(aPath) {
163
163
  return aPath;
164
164
  }
165
165
 
166
- // src/flakinessConfig.ts
166
+ // src/flakinessProjectConfig.ts
167
167
  function createConfigPath(dir) {
168
168
  return path2.join(dir, ".flakiness", "config.json");
169
169
  }
@@ -186,7 +186,7 @@ function computeConfigPath() {
186
186
  return createConfigPath(process.cwd());
187
187
  }
188
188
  }
189
- var FlakinessConfig = class _FlakinessConfig {
189
+ var FlakinessProjectConfig = class _FlakinessProjectConfig {
190
190
  constructor(_configPath, _config) {
191
191
  this._configPath = _configPath;
192
192
  this._config = _config;
@@ -195,20 +195,10 @@ var FlakinessConfig = class _FlakinessConfig {
195
195
  const configPath = ensureConfigPath();
196
196
  const data = await fs2.promises.readFile(configPath, "utf-8").catch((e) => void 0);
197
197
  const json = data ? JSON.parse(data) : {};
198
- return new _FlakinessConfig(configPath, json);
199
- }
200
- static async projectOrDie(session) {
201
- const config = await _FlakinessConfig.load();
202
- const projectPublicId = config.projectPublicId();
203
- if (!projectPublicId)
204
- throw new Error(`Please link to flakiness project with 'npx flakiness link'`);
205
- const project = await session.api.project.getProject.GET({ projectPublicId }).catch((e) => void 0);
206
- if (!project)
207
- throw new Error(`Failed to fetch linked project; please re-link with 'npx flakiness link'`);
208
- return project;
198
+ return new _FlakinessProjectConfig(configPath, json);
209
199
  }
210
200
  static createEmpty() {
211
- return new _FlakinessConfig(ensureConfigPath(), {});
201
+ return new _FlakinessProjectConfig(ensureConfigPath(), {});
212
202
  }
213
203
  path() {
214
204
  return this._configPath;
@@ -216,6 +206,9 @@ var FlakinessConfig = class _FlakinessConfig {
216
206
  projectPublicId() {
217
207
  return this._config.projectPublicId;
218
208
  }
209
+ reportViewerEndpoint() {
210
+ return this._config.customReportViewerEndpoint ?? "https://report.flakiness.io";
211
+ }
219
212
  setProjectPublicId(projectId) {
220
213
  this._config.projectPublicId = projectId;
221
214
  }
@@ -225,72 +218,8 @@ var FlakinessConfig = class _FlakinessConfig {
225
218
  }
226
219
  };
227
220
 
228
- // src/flakinessSession.ts
229
- import fs3 from "fs/promises";
230
- import os from "os";
231
- import path3 from "path";
232
-
233
- // src/serverapi.ts
234
- import { TypedHTTP } from "@flakiness/shared/common/typedHttp.js";
235
- function createServerAPI(endpoint, options) {
236
- endpoint += "/api/";
237
- const fetcher = options?.auth ? (url, init) => fetch(url, {
238
- ...init,
239
- headers: {
240
- ...init.headers,
241
- "Authorization": `Bearer ${options.auth}`
242
- }
243
- }) : fetch;
244
- if (options?.retries)
245
- return TypedHTTP.createClient(endpoint, (url, init) => retryWithBackoff(() => fetcher(url, init), options.retries));
246
- return TypedHTTP.createClient(endpoint, fetcher);
247
- }
248
-
249
- // src/flakinessSession.ts
250
- var CONFIG_DIR = (() => {
251
- const configDir = process.platform === "darwin" ? path3.join(os.homedir(), "Library", "Application Support", "flakiness") : process.platform === "win32" ? path3.join(os.homedir(), "AppData", "Roaming", "flakiness") : path3.join(os.homedir(), ".config", "flakiness");
252
- return configDir;
253
- })();
254
- var CONFIG_PATH = path3.join(CONFIG_DIR, "config.json");
255
- var FlakinessSession = class _FlakinessSession {
256
- constructor(_config) {
257
- this._config = _config;
258
- this.api = createServerAPI(this._config.endpoint, { auth: this._config.token });
259
- }
260
- static async loadOrDie() {
261
- const session = await _FlakinessSession.load();
262
- if (!session)
263
- throw new Error(`Please login first with 'npx flakiness login'`);
264
- return session;
265
- }
266
- static async load() {
267
- const data = await fs3.readFile(CONFIG_PATH, "utf-8").catch((e) => void 0);
268
- if (!data)
269
- return void 0;
270
- const json = JSON.parse(data);
271
- return new _FlakinessSession(json);
272
- }
273
- static async remove() {
274
- await fs3.unlink(CONFIG_PATH).catch((e) => void 0);
275
- }
276
- api;
277
- endpoint() {
278
- return this._config.endpoint;
279
- }
280
- path() {
281
- return CONFIG_PATH;
282
- }
283
- sessionToken() {
284
- return this._config.token;
285
- }
286
- async save() {
287
- await fs3.mkdir(CONFIG_DIR, { recursive: true });
288
- await fs3.writeFile(CONFIG_PATH, JSON.stringify(this._config, null, 2));
289
- }
290
- };
291
-
292
221
  // src/localReportServer.ts
293
- import { TypedHTTP as TypedHTTP3 } from "@flakiness/shared/common/typedHttp.js";
222
+ import { TypedHTTP as TypedHTTP2 } from "@flakiness/shared/common/typedHttp.js";
294
223
  import { randomUUIDBase62 } from "@flakiness/shared/node/nodeutils.js";
295
224
  import { createTypedHttpExpressMiddleware } from "@flakiness/shared/node/typedHttpExpress.js";
296
225
  import bodyParser from "body-parser";
@@ -301,9 +230,9 @@ import "express-async-errors";
301
230
  import http2 from "http";
302
231
 
303
232
  // src/localReportApi.ts
304
- import { TypedHTTP as TypedHTTP2 } from "@flakiness/shared/common/typedHttp.js";
305
- import fs4 from "fs";
306
- import path4 from "path";
233
+ import { TypedHTTP } from "@flakiness/shared/common/typedHttp.js";
234
+ import fs3 from "fs";
235
+ import path3 from "path";
307
236
  import { z } from "zod/v4";
308
237
 
309
238
  // src/localGit.ts
@@ -358,7 +287,7 @@ var ReportInfo = class {
358
287
  attachmentIdToPath = /* @__PURE__ */ new Map();
359
288
  commits = [];
360
289
  async refresh() {
361
- const report = await fs4.promises.readFile(this._options.reportPath, "utf-8").then((x) => JSON.parse(x)).catch((e) => void 0);
290
+ const report = await fs3.promises.readFile(this._options.reportPath, "utf-8").then((x) => JSON.parse(x)).catch((e) => void 0);
362
291
  if (!report) {
363
292
  this.report = void 0;
364
293
  this.commits = [];
@@ -368,7 +297,7 @@ var ReportInfo = class {
368
297
  if (JSON.stringify(report) === JSON.stringify(this.report))
369
298
  return;
370
299
  this.report = report;
371
- this.commits = await listLocalCommits(path4.dirname(this._options.reportPath), report.commitId, 100);
300
+ this.commits = await listLocalCommits(path3.dirname(this._options.reportPath), report.commitId, 100);
372
301
  const attachmentsDir = this._options.attachmentsFolder;
373
302
  const { attachmentIdToPath, missingAttachments } = await resolveAttachmentPaths(report, attachmentsDir);
374
303
  if (missingAttachments.length) {
@@ -381,7 +310,7 @@ var ReportInfo = class {
381
310
  this.attachmentIdToPath = attachmentIdToPath;
382
311
  }
383
312
  };
384
- var t = TypedHTTP2.Router.create();
313
+ var t = TypedHTTP.Router.create();
385
314
  var localReportRouter = {
386
315
  ping: t.get({
387
316
  handler: async () => {
@@ -401,9 +330,9 @@ var localReportRouter = {
401
330
  handler: async ({ ctx, input }) => {
402
331
  const idx = ctx.reportInfo.attachmentIdToPath.get(input.attachmentId);
403
332
  if (!idx)
404
- throw TypedHTTP2.HttpError.withCode("NOT_FOUND");
405
- const buffer = await fs4.promises.readFile(idx.path);
406
- return TypedHTTP2.ok(buffer, idx.contentType);
333
+ throw TypedHTTP.HttpError.withCode("NOT_FOUND");
334
+ const buffer = await fs3.promises.readFile(idx.path);
335
+ return TypedHTTP.ok(buffer, idx.contentType);
407
336
  }
408
337
  }),
409
338
  json: t.get({
@@ -431,7 +360,7 @@ var LocalReportServer = class _LocalReportServer {
431
360
  app.use(bodyParser.json({ limit: 256 * 1024 }));
432
361
  app.use((req, res, next) => {
433
362
  if (!req.path.startsWith("/" + authToken))
434
- throw TypedHTTP3.HttpError.withCode("UNAUTHORIZED");
363
+ throw TypedHTTP2.HttpError.withCode("UNAUTHORIZED");
435
364
  res.setHeader("Access-Control-Allow-Headers", "*");
436
365
  res.setHeader("Access-Control-Allow-Origin", options.endpoint);
437
366
  res.setHeader("Access-Control-Allow-Methods", "*");
@@ -452,7 +381,7 @@ var LocalReportServer = class _LocalReportServer {
452
381
  createRootContext: async ({ req, res, input }) => ({ reportInfo })
453
382
  }));
454
383
  app.use((err, req, res, next) => {
455
- if (err instanceof TypedHTTP3.HttpError)
384
+ if (err instanceof TypedHTTP2.HttpError)
456
385
  return res.status(err.status).send({ error: err.message });
457
386
  logHTTPServer(err);
458
387
  res.status(500).send({ error: "Internal Server Error" });
@@ -483,23 +412,25 @@ var LocalReportServer = class _LocalReportServer {
483
412
 
484
413
  // src/cli/cmd-show-report.ts
485
414
  async function cmdShowReport(reportFolder) {
486
- const reportPath = path5.join(reportFolder, "report.json");
487
- const session = await FlakinessSession.load();
488
- const config = await FlakinessConfig.load();
415
+ const reportPath = path4.join(reportFolder, "report.json");
416
+ const config = await FlakinessProjectConfig.load();
489
417
  const projectPublicId = config.projectPublicId();
490
- const project = projectPublicId && session ? await session.api.project.getProject.GET({ projectPublicId }).catch((e) => void 0) : void 0;
491
- const endpoint = session?.endpoint() ?? "https://flakiness.io";
418
+ const reportViewerEndpoint = config.reportViewerEndpoint();
492
419
  const server = await LocalReportServer.create({
493
- endpoint,
420
+ endpoint: reportViewerEndpoint,
494
421
  port: 9373,
495
422
  reportPath,
496
423
  attachmentsFolder: reportFolder
497
424
  });
498
- const reportEndpoint = project ? `${endpoint}/localreport/${project.org.orgSlug}/${project.projectSlug}?port=${server.port()}&token=${server.authToken()}` : `${endpoint}/localreport?port=${server.port()}&token=${server.authToken()}`;
425
+ const url = new URL(reportViewerEndpoint);
426
+ url.searchParams.set("port", String(server.port()));
427
+ url.searchParams.set("token", server.authToken());
428
+ if (projectPublicId)
429
+ url.searchParams.set("ppid", projectPublicId);
499
430
  console.log(chalk.cyan(`
500
- Serving Flakiness report at ${reportEndpoint}
431
+ Serving Flakiness report at ${url.toString()}
501
432
  Press Ctrl+C to quit.`));
502
- await open(reportEndpoint);
433
+ await open(url.toString());
503
434
  await new Promise(() => {
504
435
  });
505
436
  }
@@ -1,4 +1,4 @@
1
- // src/flakinessConfig.ts
1
+ // src/flakinessProjectConfig.ts
2
2
  import fs from "fs";
3
3
  import path2 from "path";
4
4
 
@@ -123,7 +123,7 @@ function normalizePath(aPath) {
123
123
  return aPath;
124
124
  }
125
125
 
126
- // src/flakinessConfig.ts
126
+ // src/flakinessProjectConfig.ts
127
127
  function createConfigPath(dir) {
128
128
  return path2.join(dir, ".flakiness", "config.json");
129
129
  }
@@ -146,7 +146,7 @@ function computeConfigPath() {
146
146
  return createConfigPath(process.cwd());
147
147
  }
148
148
  }
149
- var FlakinessConfig = class _FlakinessConfig {
149
+ var FlakinessProjectConfig = class _FlakinessProjectConfig {
150
150
  constructor(_configPath, _config) {
151
151
  this._configPath = _configPath;
152
152
  this._config = _config;
@@ -155,20 +155,10 @@ var FlakinessConfig = class _FlakinessConfig {
155
155
  const configPath = ensureConfigPath();
156
156
  const data = await fs.promises.readFile(configPath, "utf-8").catch((e) => void 0);
157
157
  const json = data ? JSON.parse(data) : {};
158
- return new _FlakinessConfig(configPath, json);
159
- }
160
- static async projectOrDie(session) {
161
- const config = await _FlakinessConfig.load();
162
- const projectPublicId = config.projectPublicId();
163
- if (!projectPublicId)
164
- throw new Error(`Please link to flakiness project with 'npx flakiness link'`);
165
- const project = await session.api.project.getProject.GET({ projectPublicId }).catch((e) => void 0);
166
- if (!project)
167
- throw new Error(`Failed to fetch linked project; please re-link with 'npx flakiness link'`);
168
- return project;
158
+ return new _FlakinessProjectConfig(configPath, json);
169
159
  }
170
160
  static createEmpty() {
171
- return new _FlakinessConfig(ensureConfigPath(), {});
161
+ return new _FlakinessProjectConfig(ensureConfigPath(), {});
172
162
  }
173
163
  path() {
174
164
  return this._configPath;
@@ -176,6 +166,9 @@ var FlakinessConfig = class _FlakinessConfig {
176
166
  projectPublicId() {
177
167
  return this._config.projectPublicId;
178
168
  }
169
+ reportViewerEndpoint() {
170
+ return this._config.customReportViewerEndpoint ?? "https://report.flakiness.io";
171
+ }
179
172
  setProjectPublicId(projectId) {
180
173
  this._config.projectPublicId = projectId;
181
174
  }
@@ -258,7 +251,7 @@ async function cmdStatus() {
258
251
  }
259
252
  const user = await session.api.user.whoami.GET();
260
253
  console.log(`user: ${user.userName} (${user.userLogin})`);
261
- const config = await FlakinessConfig.load();
254
+ const config = await FlakinessProjectConfig.load();
262
255
  const projectPublicId = config.projectPublicId();
263
256
  if (!projectPublicId) {
264
257
  console.log(`project: <not linked>`);
@@ -1,4 +1,4 @@
1
- // src/flakinessConfig.ts
1
+ // src/flakinessProjectConfig.ts
2
2
  import fs from "fs";
3
3
  import path2 from "path";
4
4
 
@@ -123,7 +123,7 @@ function normalizePath(aPath) {
123
123
  return aPath;
124
124
  }
125
125
 
126
- // src/flakinessConfig.ts
126
+ // src/flakinessProjectConfig.ts
127
127
  function createConfigPath(dir) {
128
128
  return path2.join(dir, ".flakiness", "config.json");
129
129
  }
@@ -146,7 +146,7 @@ function computeConfigPath() {
146
146
  return createConfigPath(process.cwd());
147
147
  }
148
148
  }
149
- var FlakinessConfig = class _FlakinessConfig {
149
+ var FlakinessProjectConfig = class _FlakinessProjectConfig {
150
150
  constructor(_configPath, _config) {
151
151
  this._configPath = _configPath;
152
152
  this._config = _config;
@@ -155,20 +155,10 @@ var FlakinessConfig = class _FlakinessConfig {
155
155
  const configPath = ensureConfigPath();
156
156
  const data = await fs.promises.readFile(configPath, "utf-8").catch((e) => void 0);
157
157
  const json = data ? JSON.parse(data) : {};
158
- return new _FlakinessConfig(configPath, json);
159
- }
160
- static async projectOrDie(session) {
161
- const config = await _FlakinessConfig.load();
162
- const projectPublicId = config.projectPublicId();
163
- if (!projectPublicId)
164
- throw new Error(`Please link to flakiness project with 'npx flakiness link'`);
165
- const project = await session.api.project.getProject.GET({ projectPublicId }).catch((e) => void 0);
166
- if (!project)
167
- throw new Error(`Failed to fetch linked project; please re-link with 'npx flakiness link'`);
168
- return project;
158
+ return new _FlakinessProjectConfig(configPath, json);
169
159
  }
170
160
  static createEmpty() {
171
- return new _FlakinessConfig(ensureConfigPath(), {});
161
+ return new _FlakinessProjectConfig(ensureConfigPath(), {});
172
162
  }
173
163
  path() {
174
164
  return this._configPath;
@@ -176,6 +166,9 @@ var FlakinessConfig = class _FlakinessConfig {
176
166
  projectPublicId() {
177
167
  return this._config.projectPublicId;
178
168
  }
169
+ reportViewerEndpoint() {
170
+ return this._config.customReportViewerEndpoint ?? "https://report.flakiness.io";
171
+ }
179
172
  setProjectPublicId(projectId) {
180
173
  this._config.projectPublicId = projectId;
181
174
  }
@@ -187,7 +180,7 @@ var FlakinessConfig = class _FlakinessConfig {
187
180
 
188
181
  // src/cli/cmd-unlink.ts
189
182
  async function cmdUnlink() {
190
- const config = await FlakinessConfig.load();
183
+ const config = await FlakinessProjectConfig.load();
191
184
  if (!config.projectPublicId())
192
185
  return;
193
186
  config.setProjectPublicId(void 0);
@@ -1,4 +1,4 @@
1
- // src/flakinessConfig.ts
1
+ // src/flakinessProjectConfig.ts
2
2
  import fs from "fs";
3
3
  import path2 from "path";
4
4
 
@@ -123,7 +123,7 @@ function normalizePath(aPath) {
123
123
  return aPath;
124
124
  }
125
125
 
126
- // src/flakinessConfig.ts
126
+ // src/flakinessProjectConfig.ts
127
127
  function createConfigPath(dir) {
128
128
  return path2.join(dir, ".flakiness", "config.json");
129
129
  }
@@ -146,7 +146,7 @@ function computeConfigPath() {
146
146
  return createConfigPath(process.cwd());
147
147
  }
148
148
  }
149
- var FlakinessConfig = class _FlakinessConfig {
149
+ var FlakinessProjectConfig = class _FlakinessProjectConfig {
150
150
  constructor(_configPath, _config) {
151
151
  this._configPath = _configPath;
152
152
  this._config = _config;
@@ -155,20 +155,10 @@ var FlakinessConfig = class _FlakinessConfig {
155
155
  const configPath = ensureConfigPath();
156
156
  const data = await fs.promises.readFile(configPath, "utf-8").catch((e) => void 0);
157
157
  const json = data ? JSON.parse(data) : {};
158
- return new _FlakinessConfig(configPath, json);
159
- }
160
- static async projectOrDie(session) {
161
- const config = await _FlakinessConfig.load();
162
- const projectPublicId = config.projectPublicId();
163
- if (!projectPublicId)
164
- throw new Error(`Please link to flakiness project with 'npx flakiness link'`);
165
- const project = await session.api.project.getProject.GET({ projectPublicId }).catch((e) => void 0);
166
- if (!project)
167
- throw new Error(`Failed to fetch linked project; please re-link with 'npx flakiness link'`);
168
- return project;
158
+ return new _FlakinessProjectConfig(configPath, json);
169
159
  }
170
160
  static createEmpty() {
171
- return new _FlakinessConfig(ensureConfigPath(), {});
161
+ return new _FlakinessProjectConfig(ensureConfigPath(), {});
172
162
  }
173
163
  path() {
174
164
  return this._configPath;
@@ -176,6 +166,9 @@ var FlakinessConfig = class _FlakinessConfig {
176
166
  projectPublicId() {
177
167
  return this._config.projectPublicId;
178
168
  }
169
+ reportViewerEndpoint() {
170
+ return this._config.customReportViewerEndpoint ?? "https://report.flakiness.io";
171
+ }
179
172
  setProjectPublicId(projectId) {
180
173
  this._config.projectPublicId = projectId;
181
174
  }
@@ -185,6 +178,6 @@ var FlakinessConfig = class _FlakinessConfig {
185
178
  }
186
179
  };
187
180
  export {
188
- FlakinessConfig
181
+ FlakinessProjectConfig
189
182
  };
190
- //# sourceMappingURL=flakinessConfig.js.map
183
+ //# sourceMappingURL=flakinessProjectConfig.js.map