github-update-submodule 1.1.0 → 1.2.0

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
@@ -72,22 +72,31 @@ github-update-submodule --no-push
72
72
  | `--verbose` | Show full git output for every operation |
73
73
  | `--no-color` | Disable colored output |
74
74
  | `--no-progress` | Disable the progress bar |
75
+ | `--make-config` | Generate a `submodule.config.json` in the current repo with all defaults, then exit |
75
76
 
76
77
  ---
77
78
 
78
79
  ## Config File
79
80
 
80
- Place a `.submodulerc` or `submodule.config.json` file in your repo root to set persistent defaults. CLI flags always override the config file.
81
+ Run `--make-config` once inside your repo to generate a pre-filled `submodule.config.json` with all available keys and their defaults:
81
82
 
82
- **`.submodulerc`** (JSON):
83
+ ```bash
84
+ github-update-submodule --make-config
85
+ ```
86
+
87
+ This creates `submodule.config.json` in the current directory and prints a description of every key. Edit the values to set your preferred defaults — CLI flags always override the config file.
88
+
89
+ Example generated file:
83
90
  ```json
84
91
  {
85
92
  "defaultBranch": "main",
86
- "parallel": true,
87
- "ignore": ["legacy-lib", "vendor"],
88
- "commitMessage": "ci: bump submodule refs",
93
+ "parallel": false,
94
+ "ignore": [],
95
+ "commitMessage": "chore: update submodule refs",
89
96
  "interactive": false,
90
- "verbose": false
97
+ "verbose": false,
98
+ "color": true,
99
+ "progress": true
91
100
  }
92
101
  ```
93
102
 
@@ -24,6 +24,7 @@
24
24
  * --verbose Show full git output
25
25
  * --no-color Disable colored output
26
26
  * --no-progress Disable the progress bar
27
+ * --make-config Generate a submodule.config.json in the current repo and exit
27
28
  */
28
29
 
29
30
  const { spawnSync, spawn } = require("child_process");
@@ -102,6 +103,7 @@ for (let i = 0; i < cliArgs.length; i++) {
102
103
  else if (a === "--verbose") options.verbose = true;
103
104
  else if (a === "--no-color") options.color = false;
104
105
  else if (a === "--no-progress") options.progress = false;
106
+ else if (a === "--make-config") options.makeConfig = true;
105
107
  else if (a === "--branch") options.defaultBranch = cliArgs[++i];
106
108
  else if (a === "--message") options.commitMessage = cliArgs[++i];
107
109
  else if (a === "--depth") options.maxDepth = parseInt(cliArgs[++i], 10);
@@ -546,9 +548,71 @@ async function commitAndPush(repoDir, label, depth = 0) {
546
548
  stats.pushed++;
547
549
  }
548
550
 
551
+ // ─── Config generator ────────────────────────────────────────────────────────
552
+
553
+ async function runMakeConfig() {
554
+ const dest = path.join(options.repoPath, "submodule.config.json");
555
+ const exists = fs.existsSync(dest);
556
+
557
+ const template = {
558
+ defaultBranch: "main",
559
+ parallel: false,
560
+ ignore: [],
561
+ commitMessage: "chore: update submodule refs",
562
+ interactive: false,
563
+ verbose: false,
564
+ color: true,
565
+ progress: true
566
+ };
567
+
568
+ console.log();
569
+ console.log(`${C.bold}${C.blue}╔══════════════════════════════════════════╗${C.reset}`);
570
+ console.log(`${C.bold}${C.blue}║ github-update-submodule v2.0.0 ║${C.reset}`);
571
+ console.log(`${C.bold}${C.blue}╚══════════════════════════════════════════╝${C.reset}`);
572
+ console.log();
573
+
574
+ if (exists) {
575
+ console.log(`${C.bold}${C.yellow}⚠ Config file already exists:${C.reset} ${dest}`);
576
+ console.log();
577
+ const answer = await askUser(` ${C.bold}${C.yellow}Overwrite it with defaults? [y/N] ${C.reset}`);
578
+ console.log();
579
+ if (answer !== "y" && answer !== "yes") {
580
+ console.log(`${C.dim} Cancelled — existing config file left unchanged.${C.reset}`);
581
+ console.log();
582
+ process.exit(0);
583
+ }
584
+ }
585
+
586
+ fs.writeFileSync(dest, JSON.stringify(template, null, 2) + "\n", "utf8");
587
+
588
+ const action = exists ? "overwritten" : "created";
589
+ console.log(`${C.green}${C.bold}✔ Config file ${action}:${C.reset} ${dest}`);
590
+ console.log();
591
+ console.log(` ${C.dim}Edit the values to set your preferred defaults.`);
592
+ console.log(` CLI flags always override the config file.${C.reset}`);
593
+ console.log();
594
+ console.log(` ${C.bold}Available keys:${C.reset}`);
595
+ console.log(` ${C.cyan}defaultBranch${C.reset} branch to use when not set in .gitmodules ${C.dim}(default: "main")${C.reset}`);
596
+ console.log(` ${C.cyan}parallel${C.reset} fetch all submodules concurrently ${C.dim}(default: false)${C.reset}`);
597
+ console.log(` ${C.cyan}ignore${C.reset} array of submodule names to skip ${C.dim}(default: [])${C.reset}`);
598
+ console.log(` ${C.cyan}commitMessage${C.reset} commit message for pointer updates ${C.dim}(default: "chore: update submodule refs")${C.reset}`);
599
+ console.log(` ${C.cyan}interactive${C.reset} prompt before pushing each repo ${C.dim}(default: false)${C.reset}`);
600
+ console.log(` ${C.cyan}verbose${C.reset} show full git output ${C.dim}(default: false)${C.reset}`);
601
+ console.log(` ${C.cyan}color${C.reset} colored terminal output ${C.dim}(default: true)${C.reset}`);
602
+ console.log(` ${C.cyan}progress${C.reset} show progress bar ${C.dim}(default: true)${C.reset}`);
603
+ console.log();
604
+ process.exit(0);
605
+ }
606
+
549
607
  // ─── Entry point ─────────────────────────────────────────────────────────────
550
608
 
551
609
  async function main() {
610
+ // --make-config: generate a config file and exit immediately
611
+ if (options.makeConfig) {
612
+ await runMakeConfig();
613
+ return;
614
+ }
615
+
552
616
  console.log();
553
617
  console.log(`${C.bold}${C.blue}╔══════════════════════════════════════════╗${C.reset}`);
554
618
  console.log(`${C.bold}${C.blue}║ github-update-submodule v2.0.0 ║${C.reset}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-update-submodule",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
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": {