flatten-tool 1.6.2 → 1.6.3
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 +9 -0
- package/index.ts +21 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
A CLI utility to flatten directory structures, with perfect GitHub Flavored Markdown compatibility.
|
|
6
6
|
|
|
7
|
+
[](https://youtu.be/LCbSoK0Mkjk)
|
|
8
|
+
*Watch the YouTube video for an example of why you might need to flatten project files into a single document for AI discussions and code reviews.*
|
|
9
|
+
|
|
7
10
|
[](https://asciinema.org/a/ThswNC1vrdlK0wdD)
|
|
8
11
|
|
|
9
12
|
## Installation
|
|
@@ -140,6 +143,12 @@ This project uses Bun for runtime, TypeScript for type safety, and follows the g
|
|
|
140
143
|
|
|
141
144
|
## Changelog
|
|
142
145
|
|
|
146
|
+
### v1.6.3
|
|
147
|
+
- Enhanced safety: Automatically exclude common binary file extensions (PNG, JPEG, PDF, archives, executables, etc.) when merging to Markdown to prevent corruption.
|
|
148
|
+
- Added `--ignore` CLI option: Allow additional glob patterns to ignore (e.g., `*.log`, `temp/**`).
|
|
149
|
+
- Minor clean-ups: Improved variable naming and code consistency.
|
|
150
|
+
- Added YouTube video link in README demonstrating use case for AI discussions.
|
|
151
|
+
|
|
143
152
|
### v1.6.2
|
|
144
153
|
- Updated AGENTS.md with revised coding guidelines.
|
|
145
154
|
- Added '..' links in subdirectory file trees for navigation to parent directories.
|
package/index.ts
CHANGED
|
@@ -67,20 +67,28 @@ export async function flattenDirectory(
|
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
// Patterns explicitly ignored (in addition to .gitignore when enabled)
|
|
71
|
+
const extraIgnores = ignorePatterns.map(pattern => `!${pattern}`);
|
|
71
72
|
|
|
72
|
-
const
|
|
73
|
+
const defaultIgnores = ['.git'];
|
|
73
74
|
if (!flattenToDirectory) {
|
|
74
|
-
|
|
75
|
+
// Common binary/media extensions that would corrupt UTF-8 text output
|
|
76
|
+
const binaryExts = [
|
|
77
|
+
'gif', 'png', 'jpg', 'jpeg', 'webp', 'svg', 'bmp', 'ico',
|
|
78
|
+
'pdf', 'zip', 'tar', 'gz', 'xz', '7z',
|
|
79
|
+
'mp3', 'mp4', 'webm', 'ogg', 'wav',
|
|
80
|
+
'exe', 'dll', 'so', 'dylib', 'bin'
|
|
81
|
+
];
|
|
82
|
+
defaultIgnores.push(`**/*.{${binaryExts.join(',')}}`);
|
|
75
83
|
}
|
|
76
84
|
|
|
77
|
-
|
|
85
|
+
const files = await globby(['**', ...extraIgnores], {
|
|
78
86
|
cwd: absSource,
|
|
79
87
|
gitignore: respectGitignore,
|
|
80
88
|
absolute: true,
|
|
81
89
|
dot: true,
|
|
82
90
|
onlyFiles: true,
|
|
83
|
-
ignore:
|
|
91
|
+
ignore: defaultIgnores,
|
|
84
92
|
});
|
|
85
93
|
|
|
86
94
|
if (!flattenToDirectory) {
|
|
@@ -361,13 +369,20 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
|
|
361
369
|
type: 'boolean',
|
|
362
370
|
default: false,
|
|
363
371
|
})
|
|
372
|
+
.option('ignore', {
|
|
373
|
+
alias: 'i',
|
|
374
|
+
type: 'string',
|
|
375
|
+
array: true,
|
|
376
|
+
describe: 'Additional glob patterns to ignore (e.g. "*.log" "temp/**")',
|
|
377
|
+
default: [],
|
|
378
|
+
})
|
|
364
379
|
}, async (argv) => {
|
|
365
380
|
let source = argv.source as string; // now always defined (default '.')
|
|
366
381
|
let target = argv.target as string; // may be undefined
|
|
367
382
|
|
|
368
383
|
const move: boolean = argv.move as boolean;
|
|
369
384
|
const overwrite: boolean = argv.overwrite as boolean;
|
|
370
|
-
const ignorePatterns: string[] = argv.ignore as string[]
|
|
385
|
+
const ignorePatterns: string[] = (argv.ignore as string[] | undefined) ?? [];
|
|
371
386
|
const respectGitignore: boolean = argv.gitignore as boolean;
|
|
372
387
|
const flattenToDirectory: boolean = argv.directory as boolean;
|
|
373
388
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flatten-tool",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "CLI tool to flatten directory structures: merge files into a single Markdown file (default) or copy/move to a flat directory with escaped filenames. Respects .gitignore, supports move/overwrite, and more.",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"type": "module",
|