@flakiness/sdk 0.135.0 → 0.137.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/lib/cli/cli.js CHANGED
@@ -737,12 +737,14 @@ var Ranges;
737
737
  import { TypedHTTP as TypedHTTP4 } from "@flakiness/shared/common/typedHttp.js";
738
738
  import assert4 from "assert";
739
739
  import { Command, Option } from "commander";
740
+ import fs11 from "fs";
741
+ import ora from "ora";
740
742
  import path11 from "path";
741
743
 
742
744
  // ../package.json
743
745
  var package_default = {
744
746
  name: "flakiness",
745
- version: "0.135.0",
747
+ version: "0.137.0",
746
748
  private: true,
747
749
  scripts: {
748
750
  minor: "./version.mjs minor",
@@ -768,7 +770,6 @@ var package_default = {
768
770
  "./server",
769
771
  "./shared",
770
772
  "./experimental",
771
- "./e2e",
772
773
  "./web"
773
774
  ],
774
775
  devDependencies: {
@@ -1477,17 +1478,16 @@ async function findXmlFiles(dir, result = []) {
1477
1478
  // src/cli/cmd-download.ts
1478
1479
  import fs6 from "fs";
1479
1480
  import path6 from "path";
1480
- async function cmdDownload(session2, project, runId) {
1481
+ async function cmdDownload(session2, project, runId, rootDir) {
1482
+ if (fs6.existsSync(rootDir)) {
1483
+ console.log(`Directory ${rootDir} already exists!`);
1484
+ return;
1485
+ }
1481
1486
  const urls = await session2.api.run.downloadURLs.GET({
1482
1487
  orgSlug: project.org.orgSlug,
1483
1488
  projectSlug: project.projectSlug,
1484
1489
  runId
1485
1490
  });
1486
- const rootDir = `fkrun-${runId}`;
1487
- if (fs6.existsSync(rootDir)) {
1488
- console.log(`Directory ${rootDir} already exists!`);
1489
- return;
1490
- }
1491
1491
  const attachmentsDir = path6.join(rootDir, "attachments");
1492
1492
  await fs6.promises.mkdir(rootDir, { recursive: true });
1493
1493
  if (urls.attachmentURLs.length)
@@ -1512,7 +1512,6 @@ async function cmdDownload(session2, project, runId) {
1512
1512
  for (let i = 0; i < 4; ++i)
1513
1513
  workerPromises.push(attachmentDownloader());
1514
1514
  await Promise.all(workerPromises);
1515
- console.log(`\u2714\uFE0F Saved as ${rootDir}`);
1516
1515
  }
1517
1516
 
1518
1517
  // src/cli/cmd-link.ts
@@ -2341,15 +2340,28 @@ program.command("download").description("Download run").addOption(optSince).addO
2341
2340
  });
2342
2341
  console.log(`Found ${Ranges.cardinality(runIds)} reports uploaded since ${options.since}`);
2343
2342
  }
2344
- const it = Ranges.iterate(runIds);
2343
+ const alreadyExisting = fs11.readdirSync(process.cwd());
2344
+ const downloadedRuns = alreadyExisting.filter((entry) => entry.startsWith("fkrun-")).map((run) => parseInt(run.substring(`fkrun-`.length), 10)).filter((runId) => !isNaN(runId));
2345
+ console.log(`Found ${downloadedRuns.length} locally downloaded reports`);
2346
+ const toBeDownloaded = Ranges.subtract(runIds, Ranges.fromList(downloadedRuns));
2347
+ console.log(`Downloading ${Ranges.cardinality(toBeDownloaded)} reports`);
2348
+ const it = Ranges.iterate(toBeDownloaded);
2345
2349
  const downloaders = [];
2350
+ const spinner = ora("Downloading reports:").start();
2351
+ const total = Ranges.cardinality(toBeDownloaded);
2352
+ let downloaded = 0;
2346
2353
  for (let i = 0; i < (options.parallel ?? 1); ++i) {
2347
2354
  downloaders.push((async () => {
2348
- for (let result = it.next(); !result.done; result = it.next())
2349
- await cmdDownload(session2, project, result.value);
2355
+ for (let result = it.next(); !result.done; result = it.next()) {
2356
+ const runId = result.value;
2357
+ await cmdDownload(session2, project, result.value, `fkrun-${runId}`);
2358
+ ++downloaded;
2359
+ spinner.text = `Downloaded ${Math.floor(downloaded / total * 100)}% [${downloaded}/${total}] reports`;
2360
+ }
2350
2361
  })());
2351
2362
  }
2352
2363
  await Promise.all(downloaders);
2364
+ spinner.stop();
2353
2365
  }));
2354
2366
  program.command("upload").description("Upload Flakiness report to the flakiness.io service").argument("<relative-paths...>", "Paths to the Flakiness report files").addOption(optAccessToken).addOption(optEndpoint).addOption(optAttachmentsDir).action(async (relativePaths, options) => {
2355
2367
  await runCommand(async () => {
@@ -1,17 +1,16 @@
1
1
  // src/cli/cmd-download.ts
2
2
  import fs from "fs";
3
3
  import path from "path";
4
- async function cmdDownload(session, project, runId) {
4
+ async function cmdDownload(session, project, runId, rootDir) {
5
+ if (fs.existsSync(rootDir)) {
6
+ console.log(`Directory ${rootDir} already exists!`);
7
+ return;
8
+ }
5
9
  const urls = await session.api.run.downloadURLs.GET({
6
10
  orgSlug: project.org.orgSlug,
7
11
  projectSlug: project.projectSlug,
8
12
  runId
9
13
  });
10
- const rootDir = `fkrun-${runId}`;
11
- if (fs.existsSync(rootDir)) {
12
- console.log(`Directory ${rootDir} already exists!`);
13
- return;
14
- }
15
14
  const attachmentsDir = path.join(rootDir, "attachments");
16
15
  await fs.promises.mkdir(rootDir, { recursive: true });
17
16
  if (urls.attachmentURLs.length)
@@ -36,7 +35,6 @@ async function cmdDownload(session, project, runId) {
36
35
  for (let i = 0; i < 4; ++i)
37
36
  workerPromises.push(attachmentDownloader());
38
37
  await Promise.all(workerPromises);
39
- console.log(`\u2714\uFE0F Saved as ${rootDir}`);
40
38
  }
41
39
  export {
42
40
  cmdDownload
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flakiness/sdk",
3
- "version": "0.135.0",
3
+ "version": "0.137.0",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "flakiness": "./lib/cli/cli.js"
@@ -50,7 +50,7 @@
50
50
  "author": "Degu Labs, Inc",
51
51
  "license": "Fair Source 100",
52
52
  "devDependencies": {
53
- "@flakiness/server": "0.135.0",
53
+ "@flakiness/server": "0.137.0",
54
54
  "@playwright/test": "^1.54.0",
55
55
  "@types/babel__code-frame": "^7.0.6",
56
56
  "@types/compression": "^1.8.1",
@@ -58,8 +58,8 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@babel/code-frame": "^7.26.2",
61
- "@flakiness/report": "0.135.0",
62
- "@flakiness/shared": "0.135.0",
61
+ "@flakiness/report": "0.137.0",
62
+ "@flakiness/shared": "0.137.0",
63
63
  "@rgrove/parse-xml": "^4.2.0",
64
64
  "body-parser": "^1.20.3",
65
65
  "chalk": "^5.6.2",
@@ -69,6 +69,7 @@
69
69
  "express": "^4.21.2",
70
70
  "express-async-errors": "^3.1.1",
71
71
  "open": "^10.2.0",
72
+ "ora": "^8.2.0",
72
73
  "zod": "^3.25.23"
73
74
  }
74
75
  }