dirliner v1.0.6
dirliner
The Problem
Many platforms and tools only accept individual file uploads, not directories or folder structures. This means whenever you need to share your code, you're forced to:
- Manually navigate through each directory
- Copy each file individually
- Upload them one by one
- Somehow keep track of which file came from where
For example, a typical React project structure:
Before:
src/
├── components/
│ └── Button.tsx
└── pages/
└── about.tsx
After:
src-components-Button.tsx
src-pages-about.tsx
Dirliner solves this by automatically flattening your directory structure while preserving the path information in the filename, making it easy to share code with AI tools, code review platforms, or any system that only accepts individual files.
Features
- 🚀 Both CLI and programmatic TypeScript API
- 🎯 Flexible ignore patterns (like .gitignore)
- 📁 Preserves file extensions and relationships
- 🔄 Recursive directory processing
- 📝 Detailed logging options
- ⚡ Fast and efficient
- 💪 Full TypeScript support
- 🛡️ Type-safe operations
Table of Contents
- Installation
- Quick Start
- CLI Usage
- TypeScript API
- Configuration
- Ignore Patterns
- Development
- Troubleshooting
- License
Installation
Global Installation (CLI Usage)
# Using Yarn
yarn global add dirliner
# Using npm
npm install -g dirliner
Local Installation (Programmatic Usage)
# Using Yarn
yarn add dirliner
# Using npm
npm install dirliner
Quick Start
CLI Quick Start
# Basic usage
dirliner -s ./src -t ./dist
# With ignore patterns
dirliner -s ./src -t ./dist -i "node_modules,*.log"
TypeScript Quick Start
const { DirLiner } = require('dirliner');
const liner = new DirLiner({
source: './src',
target: './dist'
});
const result = liner.execute();
CLI Usage
Command Line Options
dirliner [options]
Options:
-V, --version output the version number
-s, --source <dir> Source directory (default: "./")
-t, --target <dir> Target directory (default: "./output")
-v, --verbose Show verbose output
-i, --ignore <patterns> Ignore patterns (comma-separated)
--ignore-file <file> File containing ignore patterns (default: ".dirlinerignore")
-h, --help display help information
TypeScript API
Basic Usage
const { DirLiner } = require('dirliner');
const liner = new DirLiner({
source: './src',
target: './dist'
});
const result = liner.execute();
Advanced Usage
const { DirLiner } = require('dirliner');
const options = {
source: './src',
target: './dist',
ignorePatterns: ['node_modules', '*.log'],
ignoreFile: '.customignore',
verbose: true
};
const liner = new DirLiner(options);
const result = liner.execute();
if (result.success) {
console.log(`Processed files: ${result.processed.length}`);
result.processed.forEach(file => {
console.log(`${file.source} -> ${file.target}`);
});
} else {
console.error(`Error: ${result.error}`);
}
Configuration
Options Object
Option | Type | Default | Description |
---|---|---|---|
source | string | './' | Source directory path |
target | string | './output' | Target directory path |
ignorePatterns | string[] | [] | Array of patterns to ignore |
ignoreFile | string | '.dirlinerignore' | Path to ignore file |
verbose | boolean | false | Enable verbose logging |
Ignore Patterns
Supported Pattern Types
Exact matches: Match specific files or directories
node_modules temp.txt
Wildcards: Use * for matching multiple characters
*.log *.tmp
Directory patterns: Match entire directories
temp/* build/**/*
Negation: Include previously excluded files
!important.log !src/config/*
Ignore File Format
Create a .dirlinerignore
file (or custom name) with one pattern per line:
# This is a comment
node_modules
*.log
temp/*
!important.log
Development
Setup Development Environment
# Clone the repository
git clone https://github.com/anbturki/dirliner.git
# Install dependencies
yarn install
# Build the project
yarn build
# Run tests
yarn test
# Run linting
yarn lint
Troubleshooting
Common Issues
Ignore Patterns Not Working
- Ensure patterns follow the glob syntax
- Check file paths are relative to source directory
- Verify ignore file exists and is readable
Files Not Copying
- Check source directory exists
- Verify target directory is writable
- Ensure files aren't being ignored
Permission Issues
- If getting permission denied, run:
chmod +x $(which dirliner)
- Or reinstall globally with:
yarn global add dirliner --prefix /usr/local
- If getting permission denied, run:
Error Messages
Error | Solution |
---|---|
ENOENT: no such file or directory | Verify the source path exists |
EACCES: permission denied | Check file/directory permissions |
EEXIST: file already exists | Use a different target directory |
TS2307: Cannot find module | Ensure proper CommonJS require |
For more help, please open an issue.
License
MIT © Ali Turki