forgemap 0.7.0-dev.129-714bb16 → 0.7.0-dev.131-28fdedf

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.
@@ -76,7 +76,8 @@ function findConfigUp(start) {
76
76
  }
77
77
  /** Fallback config under $XDG_CONFIG_HOME/forgemap (or ~/.config/forgemap). */
78
78
  function findGlobalConfig() {
79
- const dir = join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "forgemap");
79
+ const base = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
80
+ const dir = join(base, "forgemap");
80
81
  for (const baseName of CONFIG_BASENAMES) {
81
82
  const candidate = join(dir, baseName);
82
83
  if (existsSync(candidate)) return candidate;
@@ -1516,7 +1517,8 @@ function resolveSlug(parsed, options) {
1516
1517
  }
1517
1518
  const depthError = checkNamespaceDepth(forgeName, forge.type, parsed.owner);
1518
1519
  if (depthError) throw new Error(depthError);
1519
- const localPath = join(resolveRoot(config.root, configDir), forge.dir, parsed.owner, parsed.repo);
1520
+ const root = resolveRoot(config.root, configDir);
1521
+ const localPath = join(root, forge.dir, parsed.owner, parsed.repo);
1520
1522
  return {
1521
1523
  forgeName,
1522
1524
  forge,
@@ -1700,7 +1702,8 @@ ${forgeEntries}
1700
1702
  /** Write a `forgemap.config.ts` into `outDir`. Returns null when the file
1701
1703
  * already exists and `force` is not set (the caller decides how to report). */
1702
1704
  async function writeConfigFile(config, options) {
1703
- const target = join(resolve(process.cwd(), options.outDir), "forgemap.config.ts");
1705
+ const outDir = resolve(process.cwd(), options.outDir);
1706
+ const target = join(outDir, "forgemap.config.ts");
1704
1707
  await mkdir(dirname(target), { recursive: true });
1705
1708
  try {
1706
1709
  await writeFile(target, renderConfigModule(config), {
@@ -1724,6 +1727,57 @@ var DEFAULT_CONFIG = {
1724
1727
  dir: "comGithub"
1725
1728
  } }
1726
1729
  };
1730
+ var configInitCommand = defineCommand({
1731
+ meta: {
1732
+ name: "init",
1733
+ description: "Create a forgemap.config.ts in the current (or given) directory"
1734
+ },
1735
+ args: {
1736
+ out: {
1737
+ type: "string",
1738
+ description: "Directory to write forgemap.config.ts into",
1739
+ default: "."
1740
+ },
1741
+ force: {
1742
+ type: "boolean",
1743
+ description: "Overwrite if forgemap.config.ts already exists",
1744
+ default: false
1745
+ }
1746
+ },
1747
+ async run({ args }) {
1748
+ const result = await writeConfigFile(DEFAULT_CONFIG, {
1749
+ outDir: args.out,
1750
+ force: args.force
1751
+ });
1752
+ if (!result) {
1753
+ const target = join(resolve(process.cwd(), args.out), "forgemap.config.ts");
1754
+ consola.error(`${target} already exists. Use --force to overwrite.`);
1755
+ process.exitCode = 1;
1756
+ return;
1757
+ }
1758
+ consola.success(`Wrote ${result.path}`);
1759
+ }
1760
+ });
1761
+ //#endregion
1762
+ //#region src/commands/config/show.ts
1763
+ var configShowCommand = defineCommand({
1764
+ meta: {
1765
+ name: "show",
1766
+ description: "Print the resolved forgemap config and its source path"
1767
+ },
1768
+ args: { config: {
1769
+ type: "string",
1770
+ description: "Path to forgemap.config.ts (overrides walk-up discovery)"
1771
+ } },
1772
+ async run({ args }) {
1773
+ const loaded = await loadForgeMapConfig({ configFile: args.config });
1774
+ process.stdout.write(JSON.stringify({
1775
+ configFile: loaded.configFile ?? null,
1776
+ cwd: loaded.cwd,
1777
+ config: loaded.config
1778
+ }, null, 2) + "\n");
1779
+ }
1780
+ });
1727
1781
  //#endregion
1728
1782
  //#region src/commands/config/index.ts
1729
1783
  var configCommand = defineCommand({
@@ -1732,55 +1786,8 @@ var configCommand = defineCommand({
1732
1786
  description: "Manage the forgemap config file"
1733
1787
  },
1734
1788
  subCommands: {
1735
- init: defineCommand({
1736
- meta: {
1737
- name: "init",
1738
- description: "Create a forgemap.config.ts in the current (or given) directory"
1739
- },
1740
- args: {
1741
- out: {
1742
- type: "string",
1743
- description: "Directory to write forgemap.config.ts into",
1744
- default: "."
1745
- },
1746
- force: {
1747
- type: "boolean",
1748
- description: "Overwrite if forgemap.config.ts already exists",
1749
- default: false
1750
- }
1751
- },
1752
- async run({ args }) {
1753
- const result = await writeConfigFile(DEFAULT_CONFIG, {
1754
- outDir: args.out,
1755
- force: args.force
1756
- });
1757
- if (!result) {
1758
- const target = join(resolve(process.cwd(), args.out), "forgemap.config.ts");
1759
- consola.error(`${target} already exists. Use --force to overwrite.`);
1760
- process.exitCode = 1;
1761
- return;
1762
- }
1763
- consola.success(`Wrote ${result.path}`);
1764
- }
1765
- }),
1766
- show: defineCommand({
1767
- meta: {
1768
- name: "show",
1769
- description: "Print the resolved forgemap config and its source path"
1770
- },
1771
- args: { config: {
1772
- type: "string",
1773
- description: "Path to forgemap.config.ts (overrides walk-up discovery)"
1774
- } },
1775
- async run({ args }) {
1776
- const loaded = await loadForgeMapConfig({ configFile: args.config });
1777
- process.stdout.write(JSON.stringify({
1778
- configFile: loaded.configFile ?? null,
1779
- cwd: loaded.cwd,
1780
- config: loaded.config
1781
- }, null, 2) + "\n");
1782
- }
1783
- })
1789
+ init: configInitCommand,
1790
+ show: configShowCommand
1784
1791
  }
1785
1792
  });
1786
1793
  //#endregion
@@ -2498,14 +2505,16 @@ var forgeRemoveCommand = defineCommand({
2498
2505
  if (!(key in forges)) return fail(`No forge "${key}" in ${file}. Configured: ${Object.keys(forges).join(", ")}.`);
2499
2506
  const remaining = Object.keys(forges).filter((k) => k !== key);
2500
2507
  let newDefault;
2501
- if (loaded.config.defaultForge === key && remaining.length > 0) if (typeof args.default === "string") {
2502
- if (!remaining.includes(args.default)) return fail(`Cannot set default to "${args.default}" — not a remaining forge (${remaining.join(", ")}).`);
2503
- newDefault = args.default;
2504
- } else if (tty) {
2505
- const answer = await promptSelect(`"${key}" is the default forge. Pick a new default:`, [...remaining, LEAVE_UNSET]);
2506
- if (answer === null) return abort();
2507
- if (answer !== LEAVE_UNSET) newDefault = answer;
2508
- } else consola.warn(`Removing the default forge "${key}"; defaultForge now points at a missing forge. Pass --default to reassign it.`);
2508
+ if (loaded.config.defaultForge === key && remaining.length > 0) {
2509
+ if (typeof args.default === "string") {
2510
+ if (!remaining.includes(args.default)) return fail(`Cannot set default to "${args.default}" — not a remaining forge (${remaining.join(", ")}).`);
2511
+ newDefault = args.default;
2512
+ } else if (tty) {
2513
+ const answer = await promptSelect(`"${key}" is the default forge. Pick a new default:`, [...remaining, LEAVE_UNSET]);
2514
+ if (answer === null) return abort();
2515
+ if (answer !== LEAVE_UNSET) newDefault = answer;
2516
+ } else consola.warn(`Removing the default forge "${key}"; defaultForge now points at a missing forge. Pass --default to reassign it.`);
2517
+ }
2509
2518
  consola.info(`Remove forge "${key}" from ${file}${newDefault ? ` (new default: "${newDefault}")` : ""}`);
2510
2519
  if (tty && !args.yes && !await confirmChange("Apply this change?")) return abort();
2511
2520
  if (await applyChange(file, (c) => {
@@ -2721,13 +2730,11 @@ function pushRemoteFinding(report, parsed, result, path) {
2721
2730
  message: `remote ${parsed.owner}/${parsed.repo} no longer exists`
2722
2731
  });
2723
2732
  break;
2724
- case "unknown":
2725
- report.findings.push({
2726
- kind: "remote-check-unknown",
2727
- severity: "warn",
2728
- message: `remote check inconclusive: ${result.reason}`
2729
- });
2730
- break;
2733
+ case "unknown": report.findings.push({
2734
+ kind: "remote-check-unknown",
2735
+ severity: "warn",
2736
+ message: `remote check inconclusive: ${result.reason}`
2737
+ });
2731
2738
  }
2732
2739
  }
2733
2740
  /** Run the network check for one forge's repos, preferring the batched
@@ -3243,7 +3250,7 @@ var infoCommand = defineCommand({
3243
3250
  async run({ args }) {
3244
3251
  const binary = resolveBinary(process.argv[1]);
3245
3252
  const info = {
3246
- version: "0.7.0-dev.129-714bb16",
3253
+ version: "0.7.0-dev.131-28fdedf",
3247
3254
  build: detectBuild(binary.resolved),
3248
3255
  binary,
3249
3256
  node: process.version,
@@ -4065,55 +4072,59 @@ async function runChecks(config, configDir) {
4065
4072
  severity: "fail",
4066
4073
  message: "install from https://git-scm.com/"
4067
4074
  });
4068
- if (needsGh) if (await hasCommand("gh")) {
4069
- checks.push({
4070
- name: "gh CLI",
4071
- severity: "ok",
4072
- message: "on PATH"
4073
- });
4074
- const auth = await execCapture("gh", ["auth", "status"]);
4075
- checks.push(auth.code === 0 ? {
4076
- name: "gh auth",
4077
- severity: "ok",
4078
- message: "authenticated"
4079
- } : {
4080
- name: "gh auth",
4081
- severity: "warn",
4082
- message: "not logged in — run `gh auth login`"
4083
- });
4084
- } else checks.push({
4085
- name: "gh CLI",
4086
- severity: "fail",
4087
- message: "install from https://cli.github.com/"
4088
- });
4089
- if (gitlabForges.length > 0) if (await hasCommand("glab")) {
4090
- checks.push({
4091
- name: "glab CLI",
4092
- severity: "ok",
4093
- message: "on PATH"
4094
- });
4095
- for (const [name, forge] of gitlabForges) {
4096
- const auth = await execCapture("glab", [
4097
- "auth",
4098
- "status",
4099
- "--hostname",
4100
- forge.host
4101
- ]);
4075
+ if (needsGh) {
4076
+ if (await hasCommand("gh")) {
4077
+ checks.push({
4078
+ name: "gh CLI",
4079
+ severity: "ok",
4080
+ message: "on PATH"
4081
+ });
4082
+ const auth = await execCapture("gh", ["auth", "status"]);
4102
4083
  checks.push(auth.code === 0 ? {
4103
- name: `glab auth (${name})`,
4084
+ name: "gh auth",
4104
4085
  severity: "ok",
4105
- message: `authenticated at ${forge.host}`
4086
+ message: "authenticated"
4106
4087
  } : {
4107
- name: `glab auth (${name})`,
4088
+ name: "gh auth",
4108
4089
  severity: "warn",
4109
- message: `not logged in — run \`glab auth login --hostname ${forge.host}\``
4090
+ message: "not logged in — run `gh auth login`"
4110
4091
  });
4111
- }
4112
- } else checks.push({
4113
- name: "glab CLI",
4114
- severity: "fail",
4115
- message: "install from https://gitlab.com/gitlab-org/cli"
4116
- });
4092
+ } else checks.push({
4093
+ name: "gh CLI",
4094
+ severity: "fail",
4095
+ message: "install from https://cli.github.com/"
4096
+ });
4097
+ }
4098
+ if (gitlabForges.length > 0) {
4099
+ if (await hasCommand("glab")) {
4100
+ checks.push({
4101
+ name: "glab CLI",
4102
+ severity: "ok",
4103
+ message: "on PATH"
4104
+ });
4105
+ for (const [name, forge] of gitlabForges) {
4106
+ const auth = await execCapture("glab", [
4107
+ "auth",
4108
+ "status",
4109
+ "--hostname",
4110
+ forge.host
4111
+ ]);
4112
+ checks.push(auth.code === 0 ? {
4113
+ name: `glab auth (${name})`,
4114
+ severity: "ok",
4115
+ message: `authenticated at ${forge.host}`
4116
+ } : {
4117
+ name: `glab auth (${name})`,
4118
+ severity: "warn",
4119
+ message: `not logged in — run \`glab auth login --hostname ${forge.host}\``
4120
+ });
4121
+ }
4122
+ } else checks.push({
4123
+ name: "glab CLI",
4124
+ severity: "fail",
4125
+ message: "install from https://gitlab.com/gitlab-org/cli"
4126
+ });
4127
+ }
4117
4128
  checks.push(await layoutCheck(config, configDir));
4118
4129
  return checks;
4119
4130
  }
@@ -4456,11 +4467,11 @@ var completionCommand = defineCommand({
4456
4467
  }
4457
4468
  });
4458
4469
  //#endregion
4459
- //#region src/bin/forgemap.ts
4460
- runMain(defineCommand({
4470
+ //#region src/cli.ts
4471
+ var rootCommand = defineCommand({
4461
4472
  meta: {
4462
4473
  name: "forgemap",
4463
- version: "0.7.0-dev.129-714bb16",
4474
+ version: "0.7.0-dev.131-28fdedf",
4464
4475
  description: "Manage a local repo layout of the form <root>/<forge.dir>/<owner>/<repo>"
4465
4476
  },
4466
4477
  subCommands: {
@@ -4482,7 +4493,10 @@ runMain(defineCommand({
4482
4493
  config: configCommand,
4483
4494
  forge: forgeCommand
4484
4495
  }
4485
- }));
4496
+ });
4497
+ //#endregion
4498
+ //#region src/bin/forgemap.ts
4499
+ runMain(rootCommand);
4486
4500
  //#endregion
4487
4501
 
4488
4502
  //# sourceMappingURL=forgemap.mjs.map