contribute-now 0.8.0-dev.5d00afd → 0.8.0-dev.5fd8c38

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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/dist/cli.js +136 -42
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -274,6 +274,8 @@ List branches with workflow-aware labels and tracking status.
274
274
  cn branch # local branches
275
275
  cn branch --all # local + remote branches
276
276
  cn branch --remote # remote branches only
277
+ cn branch --sync # sync refs (friendly alias of --prune)
278
+ cn branch --prune # fetch remotes + prune deleted remote branches
277
279
  ```
278
280
 
279
281
  Branches are annotated with workflow labels (e.g., base, dev, feature) and tracking info (upstream, gone, no remote).
package/dist/cli.js CHANGED
@@ -2949,7 +2949,9 @@ var init_tips = __esm(() => {
2949
2949
  { command: "cn branch --help", description: "learn branch list modes and filters" },
2950
2950
  { command: "cn branch", description: "list local branches and tracking info" },
2951
2951
  { command: "cn branch --all", description: "include local and remote branches" },
2952
- { command: "cn branch --remote", description: "show only remote branches" }
2952
+ { command: "cn branch --remote", description: "show only remote branches" },
2953
+ { command: "cn branch --sync", description: "sync remote refs before listing branches" },
2954
+ { command: "cn branch --prune", description: "fetch remotes and prune deleted refs first" }
2953
2955
  ]
2954
2956
  },
2955
2957
  hook: {
@@ -9311,6 +9313,9 @@ async function addRemote(name, url) {
9311
9313
  async function fetchAll() {
9312
9314
  return run(["fetch", "--all", "--quiet"]);
9313
9315
  }
9316
+ async function fetchAllPrune() {
9317
+ return run(["fetch", "--all", "--prune", "--quiet"]);
9318
+ }
9314
9319
  async function checkoutBranch(branch) {
9315
9320
  return run(["checkout", branch]);
9316
9321
  }
@@ -9768,10 +9773,16 @@ function isBranchProtected(branch, config) {
9768
9773
  }
9769
9774
 
9770
9775
  // src/commands/branch.ts
9776
+ function shouldPruneBranchRefs(args) {
9777
+ return Boolean(args.prune || args.sync);
9778
+ }
9779
+ function shouldWarnDeletedRemoteBranch(params) {
9780
+ return params.isCurrent && params.gone && (params.hasUncommitted || params.uniqueCommitsAheadOfBase > 0);
9781
+ }
9771
9782
  var branch_default = defineCommand({
9772
9783
  meta: {
9773
9784
  name: "branch",
9774
- description: "List branches with workflow-aware labels and status"
9785
+ description: "List branches with workflow-aware labels and optional remote pruning"
9775
9786
  },
9776
9787
  args: {
9777
9788
  all: {
@@ -9785,6 +9796,18 @@ var branch_default = defineCommand({
9785
9796
  alias: "r",
9786
9797
  description: "Show only remote branches",
9787
9798
  default: false
9799
+ },
9800
+ prune: {
9801
+ type: "boolean",
9802
+ alias: "p",
9803
+ description: "Fetch all remotes and prune deleted remote-tracking branches first",
9804
+ default: false
9805
+ },
9806
+ sync: {
9807
+ type: "boolean",
9808
+ alias: "s",
9809
+ description: "Sync remote branch refs before listing (alias of --prune)",
9810
+ default: false
9788
9811
  }
9789
9812
  },
9790
9813
  async run({ args }) {
@@ -9797,10 +9820,45 @@ var branch_default = defineCommand({
9797
9820
  const currentBranch = await getCurrentBranch();
9798
9821
  const showRemoteOnly = args.remote;
9799
9822
  const showAll = args.all;
9823
+ const shouldPrune = shouldPruneBranchRefs(args);
9800
9824
  await projectHeading("branch", "\uD83C\uDF3F");
9825
+ if (shouldPrune) {
9826
+ info("Fetching remotes and pruning stale remote-tracking branches...");
9827
+ const pruneResult = await fetchAllPrune();
9828
+ if (pruneResult.exitCode === 0) {
9829
+ success("Remote refs refreshed and stale branches pruned.");
9830
+ } else {
9831
+ warn(`Could not fully prune remote refs: ${pruneResult.stderr.trim() || "git fetch --all --prune failed"}`);
9832
+ }
9833
+ }
9801
9834
  console.log();
9802
9835
  if (!showRemoteOnly) {
9803
9836
  const localBranches = await getLocalBranches();
9837
+ const currentLocalBranch = localBranches.find((b2) => b2.isCurrent);
9838
+ if (currentLocalBranch?.gone) {
9839
+ const hasUncommitted = await hasUncommittedChanges();
9840
+ let uniqueCommitsAheadOfBase = 0;
9841
+ if (config) {
9842
+ const syncSource = getSyncSource(config);
9843
+ uniqueCommitsAheadOfBase = await countCommitsAhead(currentLocalBranch.name, syncSource.ref);
9844
+ }
9845
+ if (shouldWarnDeletedRemoteBranch({
9846
+ isCurrent: currentLocalBranch.isCurrent,
9847
+ gone: currentLocalBranch.gone,
9848
+ hasUncommitted,
9849
+ uniqueCommitsAheadOfBase
9850
+ })) {
9851
+ warn(`Current branch ${import_picocolors2.default.bold(currentLocalBranch.name)} was deleted remotely but still has local work.`);
9852
+ if (hasUncommitted) {
9853
+ info("You have uncommitted local changes.");
9854
+ }
9855
+ if (uniqueCommitsAheadOfBase > 0) {
9856
+ info(`You have ${uniqueCommitsAheadOfBase} local commit(s) not in the base sync branch.`);
9857
+ }
9858
+ info(`Run ${import_picocolors2.default.bold("cn update")} to move your work to a fresh branch safely.`, "");
9859
+ console.log();
9860
+ }
9861
+ }
9804
9862
  if (localBranches.length === 0) {
9805
9863
  console.log(import_picocolors2.default.dim(" No local branches found."));
9806
9864
  } else {
@@ -13708,7 +13766,7 @@ var import_picocolors12 = __toESM(require_picocolors(), 1);
13708
13766
  // package.json
13709
13767
  var package_default = {
13710
13768
  name: "contribute-now",
13711
- version: "0.8.0-dev.5d00afd",
13769
+ version: "0.8.0-dev.5fd8c38",
13712
13770
  description: "Developer CLI that automates git workflows \u2014 branching, syncing, committing, and PRs \u2014 with multi-workflow and commit convention support.",
13713
13771
  type: "module",
13714
13772
  bin: {
@@ -17885,6 +17943,26 @@ function getAnnouncementTone(kind) {
17885
17943
  }
17886
17944
 
17887
17945
  // src/cli.ts
17946
+ var CLI_SUBCOMMANDS = {
17947
+ setup: setup_default,
17948
+ config: config_default,
17949
+ sync: sync_default,
17950
+ start: start_default,
17951
+ commit: commit_default,
17952
+ update: update_default,
17953
+ submit: submit_default,
17954
+ switch: switch_default,
17955
+ discard: discard_default,
17956
+ save: save_default,
17957
+ branch: branch_default,
17958
+ clean: clean_default,
17959
+ status: status_default,
17960
+ log: log_default,
17961
+ hook: hook_default,
17962
+ validate: validate_default,
17963
+ doctor: doctor_default,
17964
+ label: label_default
17965
+ };
17888
17966
  function formatVersionInfo() {
17889
17967
  return `Contribute Now v${getVersion()} - Built by Waren Gonzaga`;
17890
17968
  }
@@ -17902,7 +17980,7 @@ function showCompactRootHelp() {
17902
17980
  console.log(cmd("submit", "Push and open a pull request on GitHub"));
17903
17981
  console.log();
17904
17982
  console.log(import_picocolors26.default.bold("BRANCH & COMMITS"));
17905
- console.log(cmd("branch", "List, create, or delete branches"));
17983
+ console.log(cmd("branch", "List local/remote branches and optionally prune remotes"));
17906
17984
  console.log(cmd("switch", "Switch to a different branch"));
17907
17985
  console.log(cmd("save", "Stash uncommitted changes for later"));
17908
17986
  console.log(cmd("discard", "Discard uncommitted changes"));
@@ -17924,6 +18002,53 @@ function showCompactRootHelp() {
17924
18002
  console.log();
17925
18003
  console.log(import_picocolors26.default.dim("Run cn <command> --help for detailed options and examples."));
17926
18004
  }
18005
+ function formatArgLabel(name, arg) {
18006
+ if (arg.type === "positional") {
18007
+ return arg.required ? `<${name}>` : `[${name}]`;
18008
+ }
18009
+ const flags = [];
18010
+ if (arg.alias) {
18011
+ flags.push(`-${arg.alias}`);
18012
+ }
18013
+ flags.push(`--${name}`);
18014
+ const needsValue = arg.type && arg.type !== "boolean";
18015
+ const valueHint = needsValue ? ` <${arg.type}>` : "";
18016
+ return `${flags.join(", ")}${valueHint}`;
18017
+ }
18018
+ function findRequestedSubCommand(argv2) {
18019
+ const names = Object.keys(CLI_SUBCOMMANDS);
18020
+ for (const token of argv2) {
18021
+ if (names.includes(token)) {
18022
+ return token;
18023
+ }
18024
+ }
18025
+ return null;
18026
+ }
18027
+ function showCompactSubCommandHelp(commandName) {
18028
+ const command = CLI_SUBCOMMANDS[commandName];
18029
+ const description = command.meta?.description ?? `Run ${commandName} command`;
18030
+ const args = command.args ?? {};
18031
+ const positionalArgs = Object.entries(args).filter(([, arg]) => arg.type === "positional");
18032
+ const optionArgs = Object.entries(args).filter(([, arg]) => arg.type !== "positional");
18033
+ console.log(description);
18034
+ console.log();
18035
+ const positionalUsage = positionalArgs.map(([name, arg]) => formatArgLabel(name, arg)).join(" ").trim();
18036
+ const usageSuffix = positionalUsage.length > 0 ? ` ${positionalUsage}` : " [OPTIONS]";
18037
+ console.log(`${import_picocolors26.default.bold("USAGE")} ${import_picocolors26.default.cyan(`cn ${commandName}${usageSuffix}`)}`);
18038
+ if (optionArgs.length > 0) {
18039
+ console.log();
18040
+ console.log(import_picocolors26.default.bold("OPTIONS"));
18041
+ console.log();
18042
+ const labels = optionArgs.map(([name, arg]) => formatArgLabel(name, arg));
18043
+ const maxLabel = labels.reduce((max, label) => Math.max(max, label.length), 0);
18044
+ optionArgs.forEach(([, arg], index) => {
18045
+ const label = labels[index].padEnd(maxLabel + 2);
18046
+ const desc = arg.description ?? "";
18047
+ console.log(` ${import_picocolors26.default.cyan(label)}${desc}`);
18048
+ });
18049
+ }
18050
+ console.log();
18051
+ }
17927
18052
  function normalizeCliArgs(argv2) {
17928
18053
  return argv2.map((arg, index) => {
17929
18054
  const previous = argv2[index - 1];
@@ -17939,29 +18064,11 @@ function normalizeCliArgs(argv2) {
17939
18064
  }
17940
18065
  process.argv = normalizeCliArgs(process.argv);
17941
18066
  var isVersion = process.argv.includes("--version") || process.argv.includes("-v");
17942
- var subCommands = [
17943
- "setup",
17944
- "config",
17945
- "sync",
17946
- "start",
17947
- "commit",
17948
- "update",
17949
- "submit",
17950
- "switch",
17951
- "discard",
17952
- "save",
17953
- "clean",
17954
- "status",
17955
- "log",
17956
- "branch",
17957
- "hook",
17958
- "validate",
17959
- "doctor",
17960
- "label"
17961
- ];
18067
+ var subCommands = Object.keys(CLI_SUBCOMMANDS);
17962
18068
  var isHelp = process.argv.includes("--help") || process.argv.includes("-h");
17963
18069
  var hasSubCommand = subCommands.some((cmd2) => process.argv.includes(cmd2));
17964
18070
  var isRootHelp = isHelp && !hasSubCommand;
18071
+ var requestedSubCommand = isHelp ? findRequestedSubCommand(process.argv) : null;
17965
18072
  if (!isVersion) {
17966
18073
  const useBigBanner = !hasSubCommand && !isHelp;
17967
18074
  showBanner(useBigBanner ? "big" : "small");
@@ -17970,6 +18077,10 @@ if (isRootHelp) {
17970
18077
  showCompactRootHelp();
17971
18078
  process.exit(0);
17972
18079
  }
18080
+ if (isHelp && requestedSubCommand) {
18081
+ showCompactSubCommandHelp(requestedSubCommand);
18082
+ process.exit(0);
18083
+ }
17973
18084
  var main = defineCommand({
17974
18085
  meta: {
17975
18086
  name: "cn",
@@ -17984,24 +18095,7 @@ var main = defineCommand({
17984
18095
  }
17985
18096
  },
17986
18097
  subCommands: {
17987
- setup: setup_default,
17988
- config: config_default,
17989
- sync: sync_default,
17990
- start: start_default,
17991
- commit: commit_default,
17992
- update: update_default,
17993
- submit: submit_default,
17994
- switch: switch_default,
17995
- discard: discard_default,
17996
- save: save_default,
17997
- branch: branch_default,
17998
- clean: clean_default,
17999
- status: status_default,
18000
- log: log_default,
18001
- hook: hook_default,
18002
- validate: validate_default,
18003
- doctor: doctor_default,
18004
- label: label_default
18098
+ ...CLI_SUBCOMMANDS
18005
18099
  },
18006
18100
  run({ args }) {
18007
18101
  if (args.version) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contribute-now",
3
- "version": "0.8.0-dev.5d00afd",
3
+ "version": "0.8.0-dev.5fd8c38",
4
4
  "description": "Developer CLI that automates git workflows — branching, syncing, committing, and PRs — with multi-workflow and commit convention support.",
5
5
  "type": "module",
6
6
  "bin": {