@theholocron/cli 5.0.0-alpha.369 → 5.0.0-alpha.370

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/dist/cli.mjs CHANGED
@@ -761,6 +761,9 @@ const COMMAND_CONTEXTS = {
761
761
  "doctor github-app": "workspace",
762
762
  "project move": "workspace",
763
763
  "repo properties apply": "workspace",
764
+ "migrate issue": "workspace",
765
+ "migrate issues": "workspace",
766
+ "migrate project": "workspace",
764
767
  "doctor dns": "workspace",
765
768
  "doctor repo": "workspace",
766
769
  "doctor secrets": "workspace",
@@ -769,6 +772,7 @@ const COMMAND_CONTEXTS = {
769
772
  "doctor variables": "workspace",
770
773
  "doctor ci": "repo-aware",
771
774
  probe: "workspace",
775
+ provider: "workspace",
772
776
  deploy: "workspace",
773
777
  "deploy cleanup-preview": "workspace",
774
778
  "monitoring check": "workspace",
@@ -1026,6 +1030,15 @@ var PluginLoader = class extends system.PluginLoader {
1026
1030
  for (const [provider, plugin] of this.plugins()) if (plugin.probes && Object.keys(plugin.probes).length > 0) found.set(provider, plugin.probes);
1027
1031
  return found;
1028
1032
  }
1033
+ /** The `setup` and `doctor` each loaded provider offers, by provider name. A provider with neither is left out. */
1034
+ providerActions() {
1035
+ const found = /* @__PURE__ */ new Map();
1036
+ for (const [provider, plugin] of this.plugins()) if (plugin.setup || plugin.doctor) found.set(provider, {
1037
+ ...plugin.setup ? { setup: plugin.setup } : {},
1038
+ ...plugin.doctor ? { doctor: plugin.doctor } : {}
1039
+ });
1040
+ return found;
1041
+ }
1029
1042
  };
1030
1043
  // src/plugin/verify-vercel-project/verify-vercel-project.ts
1031
1044
  /**
@@ -2118,6 +2131,110 @@ const githubAppCreateEntry = {
2118
2131
  ],
2119
2132
  supportsDryRun: false
2120
2133
  };
2134
+ // src/commands/migrate/migrate-issue/migrate-issue.entry.ts
2135
+ const migrateIssueEntry = {
2136
+ name: "migrate issue",
2137
+ description: "Move one issue from one tracker to another, with its comments, labels and priority",
2138
+ positionals: [{
2139
+ key: "key",
2140
+ message: "Issue to move (#42, ENG-42):",
2141
+ type: "input"
2142
+ }],
2143
+ options: [{
2144
+ key: "from",
2145
+ flag: "--from",
2146
+ type: "input",
2147
+ required: true,
2148
+ message: "Move it from (github, linear:team=ENG):"
2149
+ }, {
2150
+ key: "to",
2151
+ flag: "--to",
2152
+ type: "input",
2153
+ required: true,
2154
+ message: "Move it to:"
2155
+ }],
2156
+ skipOptions: [
2157
+ "open-only",
2158
+ "milestone",
2159
+ "yes"
2160
+ ],
2161
+ supportsDryRun: true
2162
+ };
2163
+ // src/commands/migrate/migrate-issues/migrate-issues.entry.ts
2164
+ const migrateIssuesEntry = {
2165
+ name: "migrate issues",
2166
+ description: "Move every issue, a milestone or project's issues, or a list of keys from one tracker to another",
2167
+ positionals: [],
2168
+ options: [
2169
+ {
2170
+ key: "from",
2171
+ flag: "--from",
2172
+ type: "input",
2173
+ required: true,
2174
+ message: "Move them from (github, linear:team=ENG):"
2175
+ },
2176
+ {
2177
+ key: "to",
2178
+ flag: "--to",
2179
+ type: "input",
2180
+ required: true,
2181
+ message: "Move them to:"
2182
+ },
2183
+ {
2184
+ key: "all",
2185
+ flag: "--all",
2186
+ type: "confirm",
2187
+ message: "Every issue?"
2188
+ },
2189
+ {
2190
+ key: "sourceMilestone",
2191
+ flag: "--source-milestone",
2192
+ type: "input",
2193
+ message: "Only this milestone or project:"
2194
+ },
2195
+ {
2196
+ key: "keys",
2197
+ flag: "--keys",
2198
+ type: "input",
2199
+ message: "Only these keys (#1,#2):"
2200
+ }
2201
+ ],
2202
+ skipOptions: [
2203
+ "open-only",
2204
+ "milestone",
2205
+ "yes"
2206
+ ],
2207
+ supportsDryRun: true
2208
+ };
2209
+ // src/commands/migrate/migrate-project/migrate-project.entry.ts
2210
+ const migrateProjectEntry = {
2211
+ name: "migrate project",
2212
+ description: "Move a board's issues to another tracker, with the board's status and priority",
2213
+ positionals: [{
2214
+ key: "name",
2215
+ message: "Board to move (by name):",
2216
+ type: "input"
2217
+ }],
2218
+ options: [{
2219
+ key: "from",
2220
+ flag: "--from",
2221
+ type: "input",
2222
+ required: true,
2223
+ message: "Move it from (github, linear:team=ENG):"
2224
+ }, {
2225
+ key: "to",
2226
+ flag: "--to",
2227
+ type: "input",
2228
+ required: true,
2229
+ message: "Move it to:"
2230
+ }],
2231
+ skipOptions: [
2232
+ "open-only",
2233
+ "milestone",
2234
+ "yes"
2235
+ ],
2236
+ supportsDryRun: true
2237
+ };
2121
2238
  // src/commands/monitoring-check/monitoring-check.entry.ts
2122
2239
  const monitoringCheckEntry = {
2123
2240
  name: "monitoring check",
@@ -2335,6 +2452,14 @@ const projectReconcileEntry = {
2335
2452
  options: [],
2336
2453
  supportsDryRun: true
2337
2454
  };
2455
+ // src/commands/provider/provider.entry.ts
2456
+ const providerEntry = {
2457
+ name: "provider",
2458
+ description: "List the providers that have their own setup and doctor (`provider <name> setup|doctor` runs one)",
2459
+ positionals: [],
2460
+ skipOptions: ["yes"],
2461
+ supportsDryRun: false
2462
+ };
2338
2463
  // src/commands/publish/publish.entry.ts
2339
2464
  const env$7 = createEnvLookup();
2340
2465
  const PUBLISH_TAG_OPTION = {
@@ -2368,6 +2493,7 @@ const registry = createCommandRegistry([
2368
2493
  doctorEntry,
2369
2494
  doctorAllEntry,
2370
2495
  probeEntry,
2496
+ providerEntry,
2371
2497
  {
2372
2498
  name: "repo setup",
2373
2499
  description: "Apply infra setup actions across every configured capability",
@@ -2415,6 +2541,9 @@ const registry = createCommandRegistry([
2415
2541
  skipOptions: ["yes"],
2416
2542
  supportsDryRun: true
2417
2543
  },
2544
+ migrateIssueEntry,
2545
+ migrateIssuesEntry,
2546
+ migrateProjectEntry,
2418
2547
  doctorDnsEntry,
2419
2548
  doctorRepoEntry,
2420
2549
  doctorSecretsEntry,
@@ -9302,6 +9431,10 @@ async function readWorkspacePackageJsons(repoRoot, workspacePackages) {
9302
9431
  return results;
9303
9432
  }
9304
9433
  // src/commands/setup/labels.ts
9434
+ /**
9435
+ * The labels every repository gets from `repo setup`, with their GitHub colours (hex, no `#`) and descriptions. A
9436
+ * plugin that makes labels of its own, such as Linear's setup, takes the colour of the one with the same name.
9437
+ */
9305
9438
  const CANONICAL_LABELS = [
9306
9439
  {
9307
9440
  name: "bug",
@@ -10945,6 +11078,358 @@ const menuCommand = (version) => ({
10945
11078
  await launchMenu([...COMMAND_REGISTRY, ...runEntries], argv);
10946
11079
  }
10947
11080
  });
11081
+ // src/commands/migrate/collect-records/collect-records.ts
11082
+ /** An empty template: a board's items are read for their keys, status and priority, not judged against statuses. */
11083
+ const NO_TEMPLATE = {
11084
+ name: "migrate",
11085
+ statuses: [],
11086
+ fields: [],
11087
+ views: []
11088
+ };
11089
+ const CATEGORY = {
11090
+ backlog: "open",
11091
+ planned: "open",
11092
+ active: "in-progress",
11093
+ blocked: "in-progress",
11094
+ done: "done"
11095
+ };
11096
+ /**
11097
+ * Reads the records a scope names from the source: one issue, a selection, or every item of a board. A board's items
11098
+ * are read through the `projects` provider and then exported by key; the board's status and priority are laid over
11099
+ * the record because on a board they belong to the item, not the issue.
11100
+ */
11101
+ async function collectRecords(input) {
11102
+ const { source, scope } = input;
11103
+ const issues = source.issues;
11104
+ if (!issues?.export) return {
11105
+ ok: false,
11106
+ reason: `the \`${source.provider}\` provider cannot export issues`
11107
+ };
11108
+ try {
11109
+ if (scope.kind === "issue") return {
11110
+ ok: true,
11111
+ records: await issues.export({ keys: [scope.key] }),
11112
+ notes: []
11113
+ };
11114
+ if (scope.kind === "issues") return {
11115
+ ok: true,
11116
+ records: await issues.export({
11117
+ ...scope.selector,
11118
+ ...input.openOnly ? { openOnly: true } : {}
11119
+ }),
11120
+ notes: []
11121
+ };
11122
+ const projects = source.projects;
11123
+ if (!projects?.items) return {
11124
+ ok: false,
11125
+ reason: `the \`${source.provider}\` provider cannot list the items of a board`
11126
+ };
11127
+ const board = await projects.find(scope.owner, scope.name) ?? (await projects.list(scope.owner)).find((b) => b.name === scope.name);
11128
+ if (!board) return {
11129
+ ok: false,
11130
+ reason: `no board named "${scope.name}" in ${source.provider}`
11131
+ };
11132
+ const items = (await projects.items(scope.owner, board, NO_TEMPLATE)).filter((i) => !input.openOnly || i.open);
11133
+ const local = items.filter((i) => !i.key.includes("/"));
11134
+ const notes = items.length > local.length ? [`${items.length - local.length} item(s) from other repositories were skipped`] : [];
11135
+ const byKey = new Map(local.map((i) => [i.key, i]));
11136
+ return {
11137
+ ok: true,
11138
+ records: (await issues.export({ keys: local.map((i) => i.key) })).map((r) => overlay(r, byKey.get(r.key))),
11139
+ notes
11140
+ };
11141
+ } catch (err) {
11142
+ return {
11143
+ ok: false,
11144
+ reason: describeError(err)
11145
+ };
11146
+ }
11147
+ }
11148
+ function overlay(record, item) {
11149
+ if (!item) return record;
11150
+ return {
11151
+ ...record,
11152
+ ...item.status ? { status: item.status } : {},
11153
+ ...item.category && !record.closed ? { statusCategory: CATEGORY[item.category] } : {},
11154
+ ...!record.priority && item.priority ? { priority: item.priority } : {}
11155
+ };
11156
+ }
11157
+ // src/commands/migrate/open-side/open-side.ts
11158
+ /**
11159
+ * Loads one provider for a migration. `issues` is a single provider in a config, so each side gets its own loader over
11160
+ * a copy of the config whose `providers` hold only this endpoint; the repo's own entry for the same provider (its
11161
+ * `repo`, `team`, lifecycle labels) is the base the endpoint's options are laid over.
11162
+ */
11163
+ async function openSide(input) {
11164
+ const { endpoint, capabilities } = input;
11165
+ const base = input.loaded.resolved.providers;
11166
+ const providers = {};
11167
+ for (const key of capabilities) {
11168
+ const own = base[key];
11169
+ const ownOptions = own?.cardinality === "single" && own.tuple.provider === endpoint.provider ? own.tuple.options : {};
11170
+ providers[key] = {
11171
+ cardinality: "single",
11172
+ tuple: {
11173
+ provider: endpoint.provider,
11174
+ packageName: resolvePluginPackage$1(endpoint.provider),
11175
+ options: {
11176
+ ...ownOptions,
11177
+ ...endpoint.options
11178
+ }
11179
+ }
11180
+ };
11181
+ }
11182
+ const resolved = {
11183
+ ...input.loaded.resolved,
11184
+ providers
11185
+ };
11186
+ const loader = input.makeLoader?.(resolved, input.context) ?? new PluginLoader(resolved, input.context);
11187
+ await loader.load();
11188
+ assertPluginsResolvable$1(loader, "migrate");
11189
+ const side = {
11190
+ ok: true,
11191
+ provider: endpoint.provider
11192
+ };
11193
+ for (const key of capabilities) {
11194
+ if (!loader.has(key)) {
11195
+ const failure = loader.loadFailures().find((f) => f.key === key);
11196
+ return {
11197
+ ok: false,
11198
+ reason: `the \`${key}\` capability of \`${endpoint.provider}\` is not available${failure ? ` (${describeError(failure.error)})` : ""}`
11199
+ };
11200
+ }
11201
+ if (key === "issues") side.issues = loader.get("issues");
11202
+ else side.projects = loader.get("projects");
11203
+ }
11204
+ return side;
11205
+ }
11206
+ // src/commands/migrate/parse-endpoint/parse-endpoint.ts
11207
+ /**
11208
+ * Reads `provider` or `provider:key=value,key=value` (`github:repo=theholocron/holocron`, `linear:team=ENG`) from
11209
+ * `--from` and `--to`. Values are text; a provider that wants more shape reads it from the config entry the options
11210
+ * are laid over.
11211
+ */
11212
+ function parseEndpoint(spec, flag = "--from") {
11213
+ const colon = spec.indexOf(":");
11214
+ const provider = (colon === -1 ? spec : spec.slice(0, colon)).trim();
11215
+ if (!/^[a-z][a-z0-9-]*$/.test(provider)) throw new ConfigError$1(`${flag}: "${spec}" does not start with a provider name, e.g. github or linear:team=ENG`);
11216
+ const options = {};
11217
+ const rest = colon === -1 ? "" : spec.slice(colon + 1);
11218
+ for (const pair of rest.split(",").filter((p) => p.trim() !== "")) {
11219
+ const eq = pair.indexOf("=");
11220
+ if (eq <= 0) throw new ConfigError$1(`${flag}: "${pair}" is not key=value`);
11221
+ options[pair.slice(0, eq).trim()] = pair.slice(eq + 1).trim();
11222
+ }
11223
+ return {
11224
+ provider,
11225
+ options
11226
+ };
11227
+ }
11228
+ // src/commands/migrate/tally-dropped/tally-dropped.ts
11229
+ /** Folds every result's `dropped` lines into counts, most common first, so a migration prints each loss once. */
11230
+ function tallyDropped(results) {
11231
+ const counts = /* @__PURE__ */ new Map();
11232
+ for (const result of results) for (const line of new Set(result.dropped.map((d) => d.replace(/#\d+|\b[A-Z][A-Z0-9]*-\d+\b/g, "…")))) counts.set(line, (counts.get(line) ?? 0) + 1);
11233
+ return [...counts].map(([what, count]) => ({
11234
+ what,
11235
+ count
11236
+ })).sort((a, b) => b.count - a.count || a.what.localeCompare(b.what));
11237
+ }
11238
+ // src/commands/migrate/run-migrate/run-migrate.ts
11239
+ /**
11240
+ * `holocron migrate` — move issues, a selection or a board's items from one tracker to another.
11241
+ *
11242
+ * The source's `export` produces tracker-neutral records and the target's `import` makes them, so any pair of
11243
+ * providers that have both works (GitHub to Linear and back today). A second run skips what an earlier one made, since
11244
+ * each target records the source address. Two trackers never hold exactly the same things, so every run ends by
11245
+ * listing what the target could not carry (`notCarried`); a dry run lists it before anything is written.
11246
+ * It writes, so it asks first (`--yes` skips the question; without a terminal it refuses instead of hanging).
11247
+ */
11248
+ async function runMigrate(input) {
11249
+ const print = input.print ?? ((line) => console.log(line));
11250
+ const stop = (status, reason) => {
11251
+ print(statusRow(status, ["migrate", reason]));
11252
+ return {
11253
+ status,
11254
+ reason
11255
+ };
11256
+ };
11257
+ const from = parseEndpoint(input.from, "--from");
11258
+ const to = parseEndpoint(input.to, "--to");
11259
+ if (from.provider === to.provider && JSON.stringify(from.options) === JSON.stringify(to.options)) return stop("fail", "--from and --to are the same; name a different repo, team or provider");
11260
+ const project = input.scope.kind === "project";
11261
+ const source = await openSide({
11262
+ loaded: input.loaded,
11263
+ context: input.context,
11264
+ endpoint: from,
11265
+ capabilities: project ? ["issues", "projects"] : ["issues"],
11266
+ makeLoader: input.makeLoader
11267
+ });
11268
+ if (!source.ok) return stop("fail", `source: ${source.reason}`);
11269
+ const target = await openSide({
11270
+ loaded: input.loaded,
11271
+ context: input.context,
11272
+ endpoint: to,
11273
+ capabilities: ["issues"],
11274
+ makeLoader: input.makeLoader
11275
+ });
11276
+ if (!target.ok) return stop("fail", `target: ${target.reason}`);
11277
+ const importer = target.issues;
11278
+ if (!importer?.import) return stop("skip", `the \`${target.provider}\` provider cannot import issues`);
11279
+ const collected = await collectRecords({
11280
+ source,
11281
+ scope: input.scope,
11282
+ openOnly: input.openOnly
11283
+ });
11284
+ if (!collected.ok) return stop(collected.reason.startsWith("the `") ? "skip" : "fail", collected.reason);
11285
+ const { records, notes } = collected;
11286
+ for (const note of notes) print(statusRow("skip", ["migrate", note]));
11287
+ if (records.length === 0) return stop("skip", "nothing to migrate");
11288
+ const dryRun = Boolean(input.context.dryRun);
11289
+ const milestone = input.milestone ?? (input.scope.kind === "project" ? input.scope.name : void 0);
11290
+ const where = `${source.provider} to ${target.provider}`;
11291
+ if (!dryRun && !input.yes) {
11292
+ if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`migrate\` creates issues on ${target.provider}; pass --yes to run it without asking`);
11293
+ if (!await (input.confirm ?? ((message) => confirm({
11294
+ message,
11295
+ default: false
11296
+ })))(`Create ${records.length} issue(s) on ${target.provider} from ${source.provider}?`)) {
11297
+ print(statusRow("skip", ["migrate", "cancelled; nothing was changed"]));
11298
+ return { status: "cancelled" };
11299
+ }
11300
+ }
11301
+ try {
11302
+ const results = await importer.import(records, {
11303
+ ...milestone ? { milestone } : {},
11304
+ dryRun
11305
+ });
11306
+ for (const r of results) {
11307
+ const state = !r.created ? "already migrated" : dryRun ? "would create" : "created";
11308
+ print(statusRow(r.created ? "ok" : "skip", ["migrate", `${r.source} → ${r.key ?? "(new)"} (${state})`]));
11309
+ }
11310
+ const created = results.filter((r) => r.created).length;
11311
+ print(statusRow(dryRun ? "skip" : "ok", ["migrate", `${where}: ${dryRun ? "dry run, nothing written; would create" : "created"} ${created}, skipped ${results.length - created}`]));
11312
+ const notCarried = tallyDropped(results);
11313
+ if (notCarried.length > 0) {
11314
+ print(" not carried across:");
11315
+ for (const { what, count } of notCarried) print(` ${what}: ${count} issue(s)`);
11316
+ }
11317
+ return {
11318
+ status: "ok",
11319
+ results,
11320
+ notCarried
11321
+ };
11322
+ } catch (err) {
11323
+ return stop("fail", `${describeError(err)} (a second run continues where this stopped)`);
11324
+ }
11325
+ }
11326
+ // src/commands/migrate/migrate-handler/migrate-handler.ts
11327
+ /** What each subcommand does after yargs: load the config and tokens, build its scope from the org, run, set the exit code. */
11328
+ async function handleMigrate(argv, scope) {
11329
+ const tokens = tokenContext$1(argv.token);
11330
+ if (!tokens) return;
11331
+ const loaded = await loadConfig(argv.cwd);
11332
+ applyResolvedConfig(argv, loaded.resolved);
11333
+ const org = resolveOrg(argv, loaded.resolved);
11334
+ if ((await runMigrate({
11335
+ loaded,
11336
+ context: {
11337
+ repoRoot: argv.cwd,
11338
+ dryRun: argv.dryRun,
11339
+ ...tokens,
11340
+ org
11341
+ },
11342
+ from: argv.from,
11343
+ to: argv.to,
11344
+ scope: scope(org ?? ""),
11345
+ ...argv.openOnly ? { openOnly: true } : {},
11346
+ ...argv.milestone ? { milestone: argv.milestone } : {},
11347
+ ...argv.yes ? { yes: true } : {}
11348
+ })).status === "fail") process.exitCode = 1;
11349
+ }
11350
+ // src/commands/migrate/migrate-options/migrate-options.ts
11351
+ /** The options every `migrate` subcommand shares: the two ends, closed issues, the milestone and the question. */
11352
+ const migrateOptions = (y) => y.option("from", {
11353
+ type: "string",
11354
+ demandOption: true,
11355
+ describe: "Where the issues are now: `provider` or `provider:key=value,...`, e.g. github or linear:team=ENG"
11356
+ }).option("to", {
11357
+ type: "string",
11358
+ demandOption: true,
11359
+ describe: "Where they go, in the same form"
11360
+ }).option("open-only", {
11361
+ type: "boolean",
11362
+ describe: "Leave closed issues behind"
11363
+ }).option("milestone", {
11364
+ type: "string",
11365
+ describe: "Put every migrated issue in this milestone (GitHub) or project (Linear); made if missing"
11366
+ }).option("yes", {
11367
+ type: "boolean",
11368
+ describe: "Migrate without asking"
11369
+ });
11370
+ // src/commands/migrate/migrate-issue/migrate-issue.command.ts
11371
+ const migrateIssueCommand = {
11372
+ command: "issue <key>",
11373
+ describe: "Move one issue from one tracker to another, with its comments, labels and priority",
11374
+ builder: (y) => migrateOptions(y).positional("key", {
11375
+ type: "string",
11376
+ demandOption: true,
11377
+ describe: "The issue in the source tracker (#42, ENG-42)"
11378
+ }),
11379
+ handler: (argv) => handleMigrate(argv, () => ({
11380
+ kind: "issue",
11381
+ key: argv.key
11382
+ }))
11383
+ };
11384
+ // src/commands/migrate/migrate-issues/migrate-issues.command.ts
11385
+ const migrateIssuesCommand = {
11386
+ command: "issues",
11387
+ describe: "Move several issues: every issue (--all), the issues of a milestone or project, or a list of keys",
11388
+ builder: (y) => migrateOptions(y).option("all", {
11389
+ type: "boolean",
11390
+ describe: "Every issue the source is configured for"
11391
+ }).option("source-milestone", {
11392
+ type: "string",
11393
+ describe: "Every issue of this milestone (GitHub) or project (Linear) in the source"
11394
+ }).option("keys", {
11395
+ type: "string",
11396
+ describe: "Comma-separated keys, e.g. #1,#2,#3"
11397
+ }),
11398
+ handler: (argv) => {
11399
+ const a = argv;
11400
+ if ([
11401
+ a.all,
11402
+ a.sourceMilestone,
11403
+ a.keys
11404
+ ].filter(Boolean).length !== 1) throw new ConfigError$1("migrate issues: pass exactly one of --all, --source-milestone or --keys");
11405
+ return handleMigrate(a, () => ({
11406
+ kind: "issues",
11407
+ selector: a.all ? { all: true } : a.sourceMilestone ? { milestone: a.sourceMilestone } : { keys: a.keys.split(",").map((k) => k.trim()).filter(Boolean) }
11408
+ }));
11409
+ }
11410
+ };
11411
+ // src/commands/migrate/migrate-project/migrate-project.command.ts
11412
+ const migrateProjectCommand = {
11413
+ command: "project <name>",
11414
+ describe: "Move a board's issues to another tracker, with the board's status and priority; they land in a project of the same name",
11415
+ builder: (y) => migrateOptions(y).positional("name", {
11416
+ type: "string",
11417
+ demandOption: true,
11418
+ describe: "The board in the source tracker, by name"
11419
+ }),
11420
+ handler: (argv) => handleMigrate(argv, (owner) => ({
11421
+ kind: "project",
11422
+ name: argv.name,
11423
+ owner
11424
+ }))
11425
+ };
11426
+ // src/commands/migrate/migrate.command.ts
11427
+ const migrateCommand = {
11428
+ command: "migrate <subcommand>",
11429
+ describe: "Move issues, or a whole board, from one tracker to another (GitHub and Linear) and say what did not carry over",
11430
+ builder: (y) => y.command(migrateIssueCommand).command(migrateIssuesCommand).command(migrateProjectCommand).command(groupMenu$1("migrate")),
11431
+ handler: () => {}
11432
+ };
10948
11433
  // src/commands/monitoring-check/monitoring-check.ts
10949
11434
  /**
10950
11435
  * `holocron monitoring check <url>` — runs every configured `monitoring`
@@ -17944,6 +18429,142 @@ const projectCommand = {
17944
18429
  builder: (y) => y.command(projectListCommand).command(projectCreateCommand).command(projectCloseCommand).command(projectSetupCommand).command(projectMoveCommand).command(projectReconcileCommand).command(groupMenu$1("project")),
17945
18430
  handler: () => {}
17946
18431
  };
18432
+ // src/commands/provider/provider.ts
18433
+ /**
18434
+ * `holocron provider [<name> [setup|doctor]]` — what only one provider has. With nothing it lists the providers that
18435
+ * return a `setup` or a `doctor` from `createPlugin`; with a name it lists that provider's; with both it runs one.
18436
+ *
18437
+ * `doctor` is read-only and fails the run when a row fails. `setup` changes things: `--dry-run` reports what it would
18438
+ * change, and without `--dry-run` or `--yes` it asks first (and refuses to run without a terminal). A step that fails is
18439
+ * a row, not the end of the run. Whatever the provider prints is scrubbed of the tokens the run was given.
18440
+ */
18441
+ const ACTIONS = ["setup", "doctor"];
18442
+ const fail = (print, ...text) => {
18443
+ print(statusRow("fail", text));
18444
+ return {
18445
+ status: "fail",
18446
+ rows: []
18447
+ };
18448
+ };
18449
+ /** `linear: setup, doctor` lines for the providers given, sorted by name. */
18450
+ function listing(groups) {
18451
+ const width = Math.max(0, ...[...groups.keys()].map((name) => name.length));
18452
+ return [...groups].sort(([a], [b]) => a.localeCompare(b)).map(([name, actions]) => ` ${name.padEnd(width)} ${ACTIONS.filter((a) => actions[a]).join(", ")}`);
18453
+ }
18454
+ async function runProvider(input) {
18455
+ const print = input.print ?? ((line) => console.log(line));
18456
+ /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
18457
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
18458
+ await loader.load();
18459
+ assertPluginsResolvable$1(loader, "provider");
18460
+ const groups = loader.providerActions();
18461
+ if (!input.provider) {
18462
+ if (groups.size === 0) print(" no configured provider offers `setup` or `doctor`");
18463
+ else {
18464
+ print(style.header("Providers with their own setup and doctor"));
18465
+ for (const line of listing(groups)) print(line);
18466
+ }
18467
+ return {
18468
+ status: "listed",
18469
+ rows: []
18470
+ };
18471
+ }
18472
+ const actions = groups.get(input.provider);
18473
+ if (!actions) return fail(print, `no configured provider \`${input.provider}\` offers \`setup\` or \`doctor\``, groups.size > 0 ? `try: ${[...groups.keys()].sort().join(", ")}` : "none does");
18474
+ if (!input.action) {
18475
+ for (const line of listing(/* @__PURE__ */ new Map([[input.provider, actions]]))) print(line);
18476
+ return {
18477
+ status: "listed",
18478
+ rows: []
18479
+ };
18480
+ }
18481
+ const name = ACTIONS.find((a) => a === input.action);
18482
+ const run = name && actions[name];
18483
+ if (!name || !run) return fail(print, `\`${input.provider}\` has no \`${input.action}\``, `try: ${ACTIONS.filter((a) => actions[a]).join(", ")}`);
18484
+ const dryRun = input.context.dryRun ?? false;
18485
+ if (name === "setup" && !dryRun && !input.yes) {
18486
+ if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`provider ${input.provider} setup\` changes things on ${input.provider}; pass --yes to run it without asking, or --dry-run to preview`);
18487
+ if (!await (input.confirm ?? ((message) => confirm({
18488
+ message,
18489
+ default: false
18490
+ })))(`provider ${input.provider} setup changes things on ${input.provider}. Continue?`)) {
18491
+ print(` ${style.skip("cancelled; nothing was changed")}`);
18492
+ return {
18493
+ status: "cancelled",
18494
+ rows: []
18495
+ };
18496
+ }
18497
+ }
18498
+ const scrub = createScrubber([input.context.cliToken, ...Object.values(input.context.cliTokens ?? {})].filter((t) => typeof t === "string"));
18499
+ const clean = (text) => scrub(sanitizeDetail(stripControl(text)));
18500
+ print(style.header(`Holocron provider ${input.provider} ${name}${dryRun ? " (dry-run)" : ""}`));
18501
+ print("");
18502
+ let rows;
18503
+ try {
18504
+ rows = await run({ dryRun });
18505
+ } catch (err) {
18506
+ rows = [{
18507
+ id: `${input.provider}:${name}`,
18508
+ title: `${input.provider} ${name}`,
18509
+ status: "fail",
18510
+ detail: describeError(err),
18511
+ problems: []
18512
+ }];
18513
+ }
18514
+ rows = rows.map((row) => ({
18515
+ ...row,
18516
+ title: clean(row.title),
18517
+ detail: clean(row.detail),
18518
+ problems: row.problems.map(clean)
18519
+ }));
18520
+ printCheckRows(rows, print);
18521
+ const summary = summariseChecks(rows);
18522
+ printCheckSummary(summary, print);
18523
+ const status = summary.fail > 0 ? "fail" : "ok";
18524
+ getLogger().info({
18525
+ ...summary,
18526
+ status
18527
+ }, `provider ${input.provider} ${name}`);
18528
+ return {
18529
+ status,
18530
+ rows
18531
+ };
18532
+ }
18533
+ // src/commands/provider/provider.command.ts
18534
+ const providerArgs = (y) => y.positional("provider", {
18535
+ type: "string",
18536
+ describe: "Which provider (omit to list the ones that offer setup or doctor)"
18537
+ }).positional("action", {
18538
+ type: "string",
18539
+ describe: "`setup` or `doctor` (omit to list the provider's)"
18540
+ }).option("yes", {
18541
+ type: "boolean",
18542
+ default: false,
18543
+ describe: "Run `setup` without asking first (required without a terminal)"
18544
+ });
18545
+ const providerCommand = {
18546
+ command: "provider [provider] [action]",
18547
+ describe: "Set up or check what only one provider has, from its own block of holocron.config",
18548
+ builder: providerArgs,
18549
+ handler: async (argv) => {
18550
+ const tokens = tokenContext$1(argv.token);
18551
+ if (!tokens) return;
18552
+ const loaded = await loadConfig(argv.cwd);
18553
+ applyResolvedConfig(argv, loaded.resolved);
18554
+ if ((await runProvider({
18555
+ loaded,
18556
+ context: {
18557
+ repoRoot: argv.cwd,
18558
+ dryRun: argv.dryRun,
18559
+ ...tokens,
18560
+ org: resolveOrg(argv, loaded.resolved)
18561
+ },
18562
+ ...argv.provider ? { provider: argv.provider } : {},
18563
+ ...argv.action ? { action: argv.action } : {},
18564
+ yes: argv.yes
18565
+ })).status === "fail") process.exitCode = 1;
18566
+ }
18567
+ };
17947
18568
  // src/commands/repo-properties/run-properties-apply/run-properties-apply.ts
17948
18569
  /**
17949
18570
  * `holocron repo properties apply` — add the capabilities the organization's `holocron_capabilities` property lacks.
@@ -23004,7 +23625,7 @@ try {
23004
23625
  org: argv.org
23005
23626
  });
23006
23627
  finishCommand = startCommand(name);
23007
- }).command(cloneCommand).command(doctorCommand).command(skillsCommand).command(runCommand).command(configShowCommand).command(authCommand).command(menuCommand(CLI_VERSION)).command(repoCommand).command(newCommand).command(probeCommand).command(secretsCommand).command(notificationsCommand).command(githubAppCommand).command(specsCommand).command(tunnelCommand).command(projectCommand).command(devCommand).command(syncCommand).command(packageCommand).command(deployCommand).command(monitoringCommand).command(projectCommand).strict().help().epilogue(`Execution contexts:
23628
+ }).command(cloneCommand).command(doctorCommand).command(skillsCommand).command(runCommand).command(configShowCommand).command(authCommand).command(menuCommand(CLI_VERSION)).command(repoCommand).command(newCommand).command(probeCommand).command(providerCommand).command(secretsCommand).command(notificationsCommand).command(githubAppCommand).command(specsCommand).command(tunnelCommand).command(projectCommand).command(migrateCommand).command(devCommand).command(syncCommand).command(packageCommand).command(deployCommand).command(monitoringCommand).command(projectCommand).strict().help().epilogue(`Execution contexts:
23008
23629
  global works from a bare 'npm i -g': ${commandsInContext("global").join(", ")}\n repo-aware needs ./holocron.config in cwd: ${commandsInContext("repo-aware").join(", ")}\n workspace also needs the plugin packages: ${commandsInContext("workspace").join(", ")}\n https://docs.theholocron.dev/holocron/execution-contexts`).fail((msg, err) => {
23009
23630
  if (err instanceof Error && USER_FACING_ERRORS.has(err.name)) {
23010
23631
  captureException(err);