github-update-submodule 1.2.0 → 1.2.2

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.
@@ -25,6 +25,8 @@
25
25
  * --no-color Disable colored output
26
26
  * --no-progress Disable the progress bar
27
27
  * --make-config Generate a submodule.config.json in the current repo and exit
28
+ * --version / -v Print version and exit
29
+ * --help / -h Print this help and exit
28
30
  */
29
31
 
30
32
  const { spawnSync, spawn } = require("child_process");
@@ -73,6 +75,8 @@ const options = {
73
75
  verbose: false,
74
76
  color: true,
75
77
  progress: true,
78
+ showVersion: false,
79
+ showHelp: false,
76
80
  };
77
81
 
78
82
  // Collect positional repo path first so config is loaded from correct dir
@@ -108,6 +112,8 @@ for (let i = 0; i < cliArgs.length; i++) {
108
112
  else if (a === "--message") options.commitMessage = cliArgs[++i];
109
113
  else if (a === "--depth") options.maxDepth = parseInt(cliArgs[++i], 10);
110
114
  else if (a === "--ignore") options.ignore.push(cliArgs[++i]);
115
+ else if (a === "--version" || a === "-v") options.showVersion = true;
116
+ else if (a === "--help" || a === "-h") options.showHelp = true;
111
117
  }
112
118
 
113
119
  // ─── Colour helpers ──────────────────────────────────────────────────────────
@@ -604,9 +610,83 @@ async function runMakeConfig() {
604
610
  process.exit(0);
605
611
  }
606
612
 
613
+ // ─── Version & help ──────────────────────────────────────────────────────────
614
+
615
+ const VERSION = "2.0.0";
616
+
617
+ function printVersion() {
618
+ console.log(`github-update-submodule ${VERSION}`);
619
+ process.exit(0);
620
+ }
621
+
622
+ function printHelp() {
623
+ const b = C.bold;
624
+ const r = C.reset;
625
+ const cy = C.cyan;
626
+ const ye = C.yellow;
627
+ const di = C.dim;
628
+ const gr = C.green;
629
+
630
+ console.log();
631
+ console.log(`${b}${C.blue}╔══════════════════════════════════════════╗${r}`);
632
+ console.log(`${b}${C.blue}║ github-update-submodule v${VERSION} ║${r}`);
633
+ console.log(`${b}${C.blue}╚══════════════════════════════════════════╝${r}`);
634
+ console.log();
635
+ console.log(`${b}USAGE${r}`);
636
+ console.log(` github-update-submodule ${cy}[repo-path]${r} ${ye}[options]${r}`);
637
+ console.log();
638
+ console.log(`${b}DESCRIPTION${r}`);
639
+ console.log(` Recursively pulls every Git submodule to the latest remote commit,`);
640
+ console.log(` then commits and pushes the updated refs up every parent repo so`);
641
+ console.log(` GitHub always points to the latest commit at every nesting level.`);
642
+ console.log();
643
+ console.log(`${b}OPTIONS${r}`);
644
+ const flags = [
645
+ ["--no-push", "", "Pull locally only — skip commit and push"],
646
+ ["--interactive", "", "Prompt yes/no before pushing each parent repo"],
647
+ ["--ignore", "<name>", "Skip a submodule by name (repeatable)"],
648
+ ["--parallel", "", "Fetch all submodules concurrently (faster)"],
649
+ ["--dry-run", "", "Preview changes without modifying anything"],
650
+ ["--message", "<msg>", `Commit message ${di}(default: "chore: update submodule refs")${r}`],
651
+ ["--branch", "<b>", `Default branch if not in .gitmodules ${di}(default: main)${r}`],
652
+ ["--depth", "<n>", "Limit recursion depth"],
653
+ ["--verbose", "", "Show full git output"],
654
+ ["--no-color", "", "Disable colored output"],
655
+ ["--no-progress", "", "Disable the progress bar"],
656
+ ["--make-config", "", "Generate submodule.config.json with all defaults"],
657
+ ["--version, -v", "", "Print version and exit"],
658
+ ["--help, -h", "", "Print this help and exit"],
659
+ ];
660
+ for (const [flag, arg, desc] of flags) {
661
+ const left = ` ${cy}${flag}${r}${arg ? " " + ye + arg + r : ""}`;
662
+ const pad = " ".repeat(Math.max(1, 36 - flag.length - arg.length));
663
+ console.log(`${left}${pad}${desc}`);
664
+ }
665
+ console.log();
666
+ console.log(`${b}EXAMPLES${r}`);
667
+ console.log(` ${gr}github-update-submodule${r} ${di}# pull + commit + push everything${r}`);
668
+ console.log(` ${gr}github-update-submodule${r} ${ye}--dry-run${r} ${di}# preview only${r}`);
669
+ console.log(` ${gr}github-update-submodule${r} ${ye}--parallel${r} ${di}# concurrent fetch${r}`);
670
+ console.log(` ${gr}github-update-submodule${r} ${ye}--interactive${r} ${di}# confirm before each push${r}`);
671
+ console.log(` ${gr}github-update-submodule${r} ${ye}--ignore frontend${r} ${di}# skip a submodule${r}`);
672
+ console.log(` ${gr}github-update-submodule${r} ${ye}--no-push${r} ${di}# local update only${r}`);
673
+ console.log(` ${gr}github-update-submodule${r} ${ye}--make-config${r} ${di}# create config file${r}`);
674
+ console.log(` ${gr}github-update-submodule${r} ${ye}--version${r} ${di}# print version${r}`);
675
+ console.log();
676
+ console.log(`${b}CONFIG FILE${r}`);
677
+ console.log(` Run ${cy}--make-config${r} to generate ${cy}submodule.config.json${r} in your repo root.`);
678
+ console.log(` CLI flags always override config file values.`);
679
+ console.log();
680
+ process.exit(0);
681
+ }
682
+
607
683
  // ─── Entry point ─────────────────────────────────────────────────────────────
608
684
 
609
685
  async function main() {
686
+ // early-exit flags
687
+ if (options.showVersion) { printVersion(); return; }
688
+ if (options.showHelp) { printHelp(); return; }
689
+
610
690
  // --make-config: generate a config file and exit immediately
611
691
  if (options.makeConfig) {
612
692
  await runMakeConfig();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-update-submodule",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Recursively pull all Git submodules to their latest remote commit and push updated refs up every parent repo — so GitHub always points to the latest.",
5
5
  "main": "bin/github-update-submodule.js",
6
6
  "bin": {