make-folder-txt 2.1.2 → 2.1.4

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
@@ -11,7 +11,7 @@
11
11
 
12
12
  Perfect for sharing your codebase with **AI tools**, **teammates**, or **code reviewers** — without zipping files or giving repo access.
13
13
 
14
- [Installation](#-installation) · [Usage](#-usage) · [Help](#-get-help) · [Copy to Clipboard](#-copy-to-clipboard) · [Force Include Everything](#-force-include-everything) · [Shell Autocompletion](#-shell-autocompletion) · [File Size Control](#-file-size-control) · [Output Splitting](#-output-splitting) · [Output Format](#-output-format) · [What Gets Skipped](#-what-gets-skipped) · [Contributing](#-contributing)
14
+ [Installation](#-installation) · [Usage](#-usage) · [Help](#-get-help) · [Copy to Clipboard](#-copy-to-clipboard) · [Force Include Everything](#-force-include-everything) · [File Size Control](#-file-size-control) · [Output Splitting](#-output-splitting) · [Output Format](#-output-format) · [What Gets Skipped](#-what-gets-skipped) · [Contributing](#-contributing)
15
15
 
16
16
  </div>
17
17
 
@@ -23,7 +23,6 @@ Ever needed to share your entire project with ChatGPT, Claude, or a teammate —
23
23
 
24
24
  - ✅ Run it from any project directory — no arguments needed
25
25
  - ✅ Built-in help system with `--help` flag
26
- - ✅ **Built-in shell autocompletion** (installs automatically)
27
26
  - ✅ File size control with `--skip-large` and `--no-skip`
28
27
  - ✅ Output splitting by folders, files, or size
29
28
  - ✅ Copy to clipboard with `--copy` flag
@@ -91,50 +90,6 @@ The `--force` flag overrides all ignore patterns and includes:
91
90
 
92
91
  Use this when you need a complete, unfiltered dump of your entire project.
93
92
 
94
- ### ⚡ Shell Autocompletion (Built-in)
95
-
96
- ```bash
97
- make-folder-txt # Autocompletion installs automatically on first run
98
- ```
99
-
100
- **🎉 No installation required!** The tool automatically installs shell autocompletion the first time you run it.
101
-
102
- **What gets installed automatically:**
103
- - **Flag completion**: `make-folder-txt --<TAB>` shows all available flags
104
- - **Folder completion**: `make-folder-txt --ignore-folder <TAB>` shows folders
105
- - **File completion**: `make-folder-txt --ignore-file <TAB>` shows files
106
-
107
- **Supported Shells:**
108
- - **Bash** - Linux/macOS/Windows (WSL)
109
- - **Zsh** - macOS/Linux
110
- - **PowerShell** - Windows (7+)
111
-
112
- **Example usage:**
113
- ```bash
114
- $ make-folder-txt --ignore-folder b<TAB>
115
- # → completes to "bin/" if bin folder exists
116
-
117
- $ make-folder-txt --ignore-file p<TAB>
118
- # → completes to "package.json" if package.json exists
119
- ```
120
-
121
- **Manual Installation (if needed):**
122
- ```bash
123
- make-folder-txt --install-completion # Force reinstall completion
124
- ```
125
-
126
- **PowerShell Manual Setup:**
127
- ```powershell
128
- # If auto-installation doesn't work, load manually:
129
- . .\completion\make-folder-txt-completion.ps1
130
-
131
- # Or add to your PowerShell profile for persistence:
132
- notepad $PROFILE
133
- # Add: . "C:\path\to\make-folder-txt\completion\make-folder-txt-completion.ps1"
134
- ```
135
-
136
- The completion works out of the box - just run the tool once and restart your terminal!
137
-
138
93
  ### 📏 File Size Control
139
94
 
140
95
  ```bash
@@ -453,179 +453,6 @@ function splitBySize(treeLines, filePaths, rootName, splitSize, effectiveMaxSize
453
453
 
454
454
  const args = process.argv.slice(2);
455
455
 
456
- // Check if completion is already installed, install if not (silent on subsequent runs)
457
- function checkAndInstallCompletion() {
458
- const { execSync } = require('child_process');
459
- const path = require('path');
460
- const os = require('os');
461
- const fs = require('fs');
462
-
463
- try {
464
- const homeDir = os.homedir();
465
- const shell = process.env.SHELL || '';
466
- const platform = process.platform;
467
-
468
- // Use a simple flag file to track installation
469
- const flagFile = path.join(homeDir, '.make-folder-txt-completion-installed');
470
-
471
- if (fs.existsSync(flagFile)) {
472
- // Completion already installed
473
- return;
474
- }
475
-
476
- // Install completion
477
- console.log('🔧 Installing shell autocompletion for make-folder-txt...');
478
-
479
- if (platform === 'win32') {
480
- // Windows PowerShell
481
- try {
482
- execSync('powershell -Command "Get-Host"', { stdio: 'ignore' });
483
- const installScript = path.join(__dirname, '..', 'completion', 'install-powershell-completion.ps1');
484
- execSync(`powershell -ExecutionPolicy Bypass -File "${installScript}"`, { stdio: 'ignore' });
485
- console.log('✅ PowerShell completion installed! Restart your terminal to enable autocompletion');
486
- } catch (err) {
487
- // Silent fail for PowerShell
488
- }
489
-
490
- } else if (shell.includes('zsh')) {
491
- // zsh
492
- try {
493
- const zshrc = path.join(homeDir, '.zshrc');
494
- const completionDir = path.join(homeDir, '.zsh', 'completions');
495
- execSync(`mkdir -p "${completionDir}"`, { stdio: 'ignore' });
496
- const completionPath = path.join(__dirname, '..', 'completion', 'make-folder-txt-completion.zsh');
497
- execSync(`cp "${completionPath}" "${completionDir}/_make-folder-txt"`, { stdio: 'ignore' });
498
-
499
- try {
500
- const zshrcContent = fs.readFileSync(zshrc, 'utf8');
501
- if (!zshrcContent.includes('fpath+=~/.zsh/completions')) {
502
- fs.appendFileSync(zshrc, '\n# make-folder-txt completion\nfpath+=~/.zsh/completions\nautoload -U compinit && compinit\n');
503
- }
504
- } catch (e) {
505
- fs.writeFileSync(zshrc, '# make-folder-txt completion\nfpath+=~/.zsh/completions\nautoload -U compinit && compinit\n');
506
- }
507
- console.log('✅ Zsh completion installed! Restart your terminal or run: source ~/.zshrc');
508
- } catch (err) {
509
- // Silent fail for zsh
510
- }
511
-
512
- } else {
513
- // bash
514
- try {
515
- const bashrc = path.join(homeDir, '.bashrc');
516
- const completionPath = path.join(__dirname, '..', 'completion', 'make-folder-txt-completion.bash');
517
- try {
518
- const bashrcContent = fs.readFileSync(bashrc, 'utf8');
519
- if (!bashrcContent.includes('make-folder-txt-completion.bash')) {
520
- fs.appendFileSync(bashrc, `\n# make-folder-txt completion\nsource "${completionPath}"\n`);
521
- }
522
- } catch (e) {
523
- fs.writeFileSync(bashrc, `# make-folder-txt completion\nsource "${completionPath}"\n`);
524
- }
525
- console.log('✅ Bash completion installed! Restart your terminal or run: source ~/.bashrc');
526
- } catch (err) {
527
- // Silent fail for bash
528
- }
529
- }
530
-
531
- // Create flag file to prevent re-installation
532
- fs.writeFileSync(flagFile, 'installed');
533
- console.log('💡 Restart your terminal to enable autocompletion');
534
- console.log('');
535
-
536
- } catch (err) {
537
- // Silent fail - don't interrupt the main functionality
538
- }
539
- }
540
-
541
- // Run completion check on first run (but not for help/version/install-completion commands)
542
- if (!args.includes("--help") && !args.includes("-h") &&
543
- !args.includes("--version") && !args.includes("-v") &&
544
- !args.includes("--install-completion")) {
545
- checkAndInstallCompletion();
546
- }
547
-
548
- if (args.includes("--install-completion")) {
549
- const { execSync } = require('child_process');
550
- const path = require('path');
551
- const os = require('os');
552
-
553
- try {
554
- const homeDir = os.homedir();
555
- const shell = process.env.SHELL || '';
556
- const platform = process.platform;
557
-
558
- if (platform === 'win32') {
559
- // Windows - Check if PowerShell is available
560
- try {
561
- execSync('powershell -Command "Get-Host"', { stdio: 'ignore' });
562
-
563
- // Install PowerShell completion
564
- const completionScript = path.join(__dirname, '..', 'completion', 'make-folder-txt-completion.ps1');
565
- const installScript = path.join(__dirname, '..', 'completion', 'install-powershell-completion.ps1');
566
-
567
- // Run the PowerShell installation script
568
- execSync(`powershell -ExecutionPolicy Bypass -File "${installScript}"`, { stdio: 'ignore' });
569
- console.log('✅ PowerShell completion installed! Restart your terminal to enable autocompletion');
570
-
571
- } catch (err) {
572
- console.error('❌ Failed to install PowerShell completion:', err.message);
573
- process.exit(1);
574
- }
575
-
576
- } else if (shell.includes('zsh')) {
577
- // Install for zsh
578
- const zshrc = path.join(homeDir, '.zshrc');
579
- const completionDir = path.join(homeDir, '.zsh', 'completions');
580
-
581
- // Create completions directory if it doesn't exist
582
- try {
583
- execSync(`mkdir -p "${completionDir}"`, { stdio: 'ignore' });
584
- } catch (e) {}
585
-
586
- // Copy completion file
587
- const completionPath = path.join(__dirname, '..', 'completion', 'make-folder-txt-completion.zsh');
588
- execSync(`cp "${completionPath}" "${completionDir}/_make-folder-txt"`, { stdio: 'ignore' });
589
-
590
- // Add to .zshrc if not already there
591
- try {
592
- const zshrcContent = fs.readFileSync(zshrc, 'utf8');
593
- if (!zshrcContent.includes('fpath+=~/.zsh/completions')) {
594
- fs.appendFileSync(zshrc, '\n# make-folder-txt completion\nfpath+=~/.zsh/completions\nautoload -U compinit && compinit\n');
595
- }
596
- } catch (e) {
597
- // .zshrc doesn't exist, create it
598
- fs.writeFileSync(zshrc, '# make-folder-txt completion\nfpath+=~/.zsh/completions\nautoload -U compinit && compinit\n');
599
- }
600
-
601
- console.log('✅ Zsh completion installed! Restart your terminal or run: source ~/.zshrc');
602
-
603
- } else {
604
- // Install for bash
605
- const bashrc = path.join(homeDir, '.bashrc');
606
- const completionPath = path.join(__dirname, '..', 'completion', 'make-folder-txt-completion.bash');
607
-
608
- // Add to .bashrc if not already there
609
- try {
610
- const bashrcContent = fs.readFileSync(bashrc, 'utf8');
611
- if (!bashrcContent.includes('make-folder-txt-completion.bash')) {
612
- fs.appendFileSync(bashrc, `\n# make-folder-txt completion\nsource "${completionPath}"\n`);
613
- }
614
- } catch (e) {
615
- // .bashrc doesn't exist, create it
616
- fs.writeFileSync(bashrc, `# make-folder-txt completion\nsource "${completionPath}"\n`);
617
- }
618
-
619
- console.log('✅ Bash completion installed! Restart your terminal or run: source ~/.bashrc');
620
- }
621
- } catch (err) {
622
- console.error('❌ Failed to install completion:', err.message);
623
- process.exit(1);
624
- }
625
-
626
- process.exit(0);
627
- }
628
-
629
456
  if (args.includes("-v") || args.includes("--version")) {
630
457
  console.log(`v${version}`);
631
458
  console.log("Built by Muhammad Saad Amin");
@@ -651,7 +478,6 @@ Dump an entire project folder into a single readable .txt file.
651
478
  --split-size <size> Split output when size exceeds limit (requires --split-method size)
652
479
  --copy Copy output to clipboard
653
480
  --force Include everything (overrides all ignore patterns)
654
- --install-completion Install shell autocompletion (bash/zsh/PowerShell) - usually automatic
655
481
  --help, -h Show this help message
656
482
  --version, -v Show version information
657
483
 
@@ -665,7 +491,6 @@ Dump an entire project folder into a single readable .txt file.
665
491
  make-folder-txt --split-method folder
666
492
  make-folder-txt --split-method file
667
493
  make-folder-txt --split-method size --split-size 5MB
668
- make-folder-txt --install-completion
669
494
  make-folder-txt --ignore-folder node_modules dist
670
495
  make-folder-txt -ifo node_modules dist
671
496
  make-folder-txt --ignore-file .env .env.local
@@ -792,7 +617,12 @@ for (let i = 0; i < args.length; i += 1) {
792
617
  if (arg === "--ignore-folder" || arg === "-ifo") {
793
618
  let consumed = 0;
794
619
  while (i + 1 < args.length && !args[i + 1].startsWith("-")) {
795
- ignoreDirs.add(args[i + 1]);
620
+ // Normalize the folder name: remove backslashes, trailing slashes, and leading ./
621
+ let folderName = args[i + 1];
622
+ folderName = folderName.replace(/\\/g, '/'); // Convert backslashes to forward slashes
623
+ folderName = folderName.replace(/^\.?\//, ''); // Remove leading ./ or /
624
+ folderName = folderName.replace(/\/+$/, ''); // Remove trailing slashes
625
+ ignoreDirs.add(folderName);
796
626
  i += 1;
797
627
  consumed += 1;
798
628
  }
@@ -811,7 +641,12 @@ for (let i = 0; i < args.length; i += 1) {
811
641
  console.error("Error: --ignore-folder requires a folder name.");
812
642
  process.exit(1);
813
643
  }
814
- ignoreDirs.add(value);
644
+ // Normalize the folder name
645
+ let folderName = value;
646
+ folderName = folderName.replace(/\\/g, '/'); // Convert backslashes to forward slashes
647
+ folderName = folderName.replace(/^\.?\//, ''); // Remove leading ./ or /
648
+ folderName = folderName.replace(/\/+$/, ''); // Remove trailing slashes
649
+ ignoreDirs.add(folderName);
815
650
  continue;
816
651
  }
817
652
 
@@ -844,7 +679,12 @@ for (let i = 0; i < args.length; i += 1) {
844
679
  if (arg === "--only-folder" || arg === "-ofo") {
845
680
  let consumed = 0;
846
681
  while (i + 1 < args.length && !args[i + 1].startsWith("-")) {
847
- onlyFolders.add(args[i + 1]);
682
+ // Normalize the folder name
683
+ let folderName = args[i + 1];
684
+ folderName = folderName.replace(/\\/g, '/'); // Convert backslashes to forward slashes
685
+ folderName = folderName.replace(/^\.?\//, ''); // Remove leading ./ or /
686
+ folderName = folderName.replace(/\/+$/, ''); // Remove trailing slashes
687
+ onlyFolders.add(folderName);
848
688
  i += 1;
849
689
  consumed += 1;
850
690
  }
@@ -863,7 +703,12 @@ for (let i = 0; i < args.length; i += 1) {
863
703
  console.error("Error: --only-folder requires a folder name.");
864
704
  process.exit(1);
865
705
  }
866
- onlyFolders.add(value);
706
+ // Normalize the folder name
707
+ let folderName = value;
708
+ folderName = folderName.replace(/\\/g, '/'); // Convert backslashes to forward slashes
709
+ folderName = folderName.replace(/^\.?\//, ''); // Remove leading ./ or /
710
+ folderName = folderName.replace(/\/+$/, ''); // Remove trailing slashes
711
+ onlyFolders.add(folderName);
867
712
  continue;
868
713
  }
869
714