1.0.6 • Published 6 months ago

dirliner v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

dirliner

npm version License: MIT TypeScript

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:

  1. Manually navigate through each directory
  2. Copy each file individually
  3. Upload them one by one
  4. 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

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

OptionTypeDefaultDescription
sourcestring'./'Source directory path
targetstring'./output'Target directory path
ignorePatternsstring[][]Array of patterns to ignore
ignoreFilestring'.dirlinerignore'Path to ignore file
verbosebooleanfalseEnable 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

  1. 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
  2. Files Not Copying

    • Check source directory exists
    • Verify target directory is writable
    • Ensure files aren't being ignored
  3. Permission Issues

    • If getting permission denied, run:
      chmod +x $(which dirliner)
    • Or reinstall globally with:
      yarn global add dirliner --prefix /usr/local

Error Messages

ErrorSolution
ENOENT: no such file or directoryVerify the source path exists
EACCES: permission deniedCheck file/directory permissions
EEXIST: file already existsUse a different target directory
TS2307: Cannot find moduleEnsure proper CommonJS require

For more help, please open an issue.

License

MIT © Ali Turki