@theholocron/cli 5.0.0-alpha.381 → 5.0.0-alpha.382

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/README.md CHANGED
@@ -702,7 +702,7 @@ See the [command pages](https://theholocron.dev/holocron/commands/notifications-
702
702
  stops the run with a `left` count. A target needs the optional `Issues.sync`; GitHub and Linear have it. `--limit <n>` and
703
703
  `--order <oldest|newest>` (also on `migrate issues` and `migrate project`) read only that many issues from the source,
704
704
  from the first-created or the last-created end, for a trial run; the source's `Issues.export` honours
705
- `IssueSelector.limit` and `order`, and the run prints `limited to N of M`.
705
+ `IssueSelector.limit` and `order`, and the run prints `limited to N of M`. On a terminal, `migrate` and `sync issues` show a spinner with a counter for the read and the write (`Reading issues from github… 12 of 40`, `Writing to linear… 3 of 20`); piped, in CI or with `--quiet` they print nothing extra. A provider feeds it through the optional `onProgress(done, total)` of `ExportInfo` and `ImportOptions`.
706
706
 
707
707
  ## Cleaning up
708
708
 
package/dist/cli.mjs CHANGED
@@ -11226,8 +11226,8 @@ async function collectRecords(input) {
11226
11226
  ok: false,
11227
11227
  reason: `the \`${source.provider}\` provider cannot export issues`
11228
11228
  };
11229
- const info = {};
11230
- const read = (selector) => input.limit === void 0 ? issues.export(selector) : issues.export({
11229
+ const info = input.onProgress ? { onProgress: input.onProgress } : {};
11230
+ const read = (selector) => input.limit === void 0 ? input.onProgress ? issues.export(selector, info) : issues.export(selector) : issues.export({
11231
11231
  ...selector,
11232
11232
  limit: input.limit,
11233
11233
  order: input.order ?? "oldest"
@@ -11484,6 +11484,7 @@ function tallyDropped(results) {
11484
11484
  */
11485
11485
  async function runMigrate(input) {
11486
11486
  const print = input.print ?? ((line) => console.log(line));
11487
+ const progress = input.progress ?? createProgress(print);
11487
11488
  const stop = (status, reason) => {
11488
11489
  print(statusRow(status, ["migrate", reason]));
11489
11490
  return {
@@ -11532,13 +11533,15 @@ async function runMigrate(input) {
11532
11533
  template: resolved.template
11533
11534
  };
11534
11535
  }
11535
- const collected = await collectRecords({
11536
+ const reading = `Reading issues from ${source.provider}…`;
11537
+ const collected = await progress.run(reading, (update) => collectRecords({
11536
11538
  source,
11537
11539
  scope: input.scope,
11538
11540
  openOnly: input.openOnly,
11539
11541
  limit: input.limit,
11540
- order: input.order
11541
- });
11542
+ order: input.order,
11543
+ onProgress: (done, total) => update(`${reading} ${done} of ${total}`)
11544
+ }));
11542
11545
  if (!collected.ok) return stop(collected.reason.startsWith("the `") ? "skip" : "fail", collected.reason);
11543
11546
  const { records, notes } = collected;
11544
11547
  for (const note of notes) print(statusRow("skip", ["migrate", note]));
@@ -11559,10 +11562,12 @@ async function runMigrate(input) {
11559
11562
  }
11560
11563
  }
11561
11564
  try {
11562
- const results = await importer.import(records, {
11565
+ const writing = dryRun ? `Checking ${target.provider}…` : `Writing to ${target.provider}…`;
11566
+ const results = await progress.run(writing, (update) => importer.import(records, {
11563
11567
  ...milestone ? { milestone } : {},
11564
- dryRun
11565
- });
11568
+ dryRun,
11569
+ onProgress: (done, total) => update(`${writing} ${done} of ${total}`)
11570
+ }));
11566
11571
  for (const r of results) {
11567
11572
  const state = !r.created ? "already migrated" : dryRun ? "would create" : "created";
11568
11573
  print(statusRow(r.created ? "ok" : "skip", ["migrate", `${r.source} → ${r.key ?? "(new)"} (${state})`]));
@@ -11571,12 +11576,12 @@ async function runMigrate(input) {
11571
11576
  print(statusRow(dryRun ? "skip" : "ok", ["migrate", `${where}: ${dryRun ? "dry run, nothing written; would create" : "created"} ${created}, skipped ${results.length - created}`]));
11572
11577
  let placement;
11573
11578
  if (plan) {
11574
- placement = await placeOnBoard({
11579
+ placement = await progress.run(`Placing issues on the ${plan.name} board…`, () => placeOnBoard({
11575
11580
  ...plan,
11576
11581
  records,
11577
11582
  results,
11578
11583
  dryRun
11579
- });
11584
+ }));
11580
11585
  printBoard({
11581
11586
  print,
11582
11587
  name: plan.name,
@@ -24035,6 +24040,7 @@ function parseSince(value, now = Date.now()) {
24035
24040
  */
24036
24041
  async function runSyncIssues(input) {
24037
24042
  const print = input.print ?? ((line) => console.log(line));
24043
+ const progress = input.progress ?? createProgress(print);
24038
24044
  const row = (status, text) => print(statusRow(status, ["sync issues", text]));
24039
24045
  const stop = (status, reason) => {
24040
24046
  row(status, reason);
@@ -24066,7 +24072,8 @@ async function runSyncIssues(input) {
24066
24072
  if (!target.ok) return stop("fail", `target: ${target.reason}`);
24067
24073
  const syncer = target.issues;
24068
24074
  if (!syncer?.sync) return stop("skip", `the \`${target.provider}\` provider cannot be a sync target`);
24069
- const collected = await collectRecords({
24075
+ const reading = `Reading issues from ${source.provider}…`;
24076
+ const collected = await progress.run(reading, (update) => collectRecords({
24070
24077
  source,
24071
24078
  scope: {
24072
24079
  kind: "issues",
@@ -24076,8 +24083,9 @@ async function runSyncIssues(input) {
24076
24083
  }
24077
24084
  },
24078
24085
  limit: input.limit,
24079
- order: input.order
24080
- });
24086
+ order: input.order,
24087
+ onProgress: (done, total) => update(`${reading} ${done} of ${total}`)
24088
+ }));
24081
24089
  if (!collected.ok) return stop(collected.reason.startsWith("the `") ? "skip" : "fail", collected.reason);
24082
24090
  const { records } = collected;
24083
24091
  const limited = collected.limit === void 0 ? void 0 : describeLimit(records.length, collected.matched, input.order);
@@ -24100,7 +24108,11 @@ async function runSyncIssues(input) {
24100
24108
  }
24101
24109
  }
24102
24110
  try {
24103
- results = await syncer.sync(toSync, { dryRun });
24111
+ const writing = dryRun ? `Checking ${target.provider}…` : `Writing to ${target.provider}…`;
24112
+ results = await progress.run(writing, (update) => syncer.sync(toSync, {
24113
+ dryRun,
24114
+ onProgress: (done, total) => update(`${writing} ${done} of ${total}`)
24115
+ }));
24104
24116
  } catch (err) {
24105
24117
  return stop("fail", `${describeError(err)} (a second run continues where this stopped)`);
24106
24118
  }