or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

archive.mdconfiguration.mdcopy.mddelete.mdindex.mdmkdir.mdmove.md
tile.json

archive.mddocs/

Archive Operations

Create archives (zip/tar) from files, directories, or glob patterns with extensive archiver.js options and flexible compression settings.

Capabilities

Archive Action Function

Main archive action function that processes multiple archive tasks.

/**
 * Execute archive tasks with the provided options
 * @param tasks Array of archive tasks to execute
 * @param taskOptions Task execution options including logger and error handling
 */
function archiveAction(tasks: ArchiveTask[], taskOptions: TaskOptions): Promise<void>;

export default archiveAction;

Archive Action Type

Configuration type for archive operations (defined in main plugin module).

/**
 * Configuration for archive operations
 */
type ArchiveAction = {
  /** Source file, directory, or glob pattern */
  source: string;
  /** Archive destination file path */
  destination: string;
  /** Archive format - defaults to file extension */
  format?: 'zip' | 'tar';
  /** Archiver options and glob options */
  options?: ArchiverOptions;
};

Archive Options

Comprehensive options interface extending archiver.js options with additional glob support.

/**
 * Archive options extending archiver.js options
 */
interface ArchiverOptions extends ArchiverJSOptions {
  /** Glob options for pattern-based archiving */
  globOptions?: ReaddirGlobOptions;
}

/**
 * Glob options for readdir-glob functionality
 */
interface ReaddirGlobOptions {
  /** Glob pattern or patterns to match files */
  pattern?: string | string[];
  /** Glob pattern or patterns to exclude */
  ignore?: string | string[];
  /** Glob pattern or patterns to skip directories */
  skip?: string | string[];
  /** Add trailing slash to directory matches */
  mark?: boolean;
  /** Stat all results (reduces performance) */
  stat?: boolean;
  /** Suppress warning messages */
  silent?: boolean;
  /** Do not match directories, only files */
  nodir?: boolean;
  /** Follow symbolic links */
  follow?: boolean;
  /** Match files starting with dot */
  dot?: boolean;
  /** Disable ** globstar matching */
  noglobstar?: boolean;
  /** Case-insensitive matching */
  nocase?: boolean;
  /** Basename-only matching */
  matchBase?: boolean;
}

Internal Task Structure

Internal task structure used by the plugin during archive execution.

/**
 * Internal task structure for archive operations
 */
interface ArchiveTask {
  source: string;
  absoluteSource: string;
  absoluteDestination: string;
  context?: string;
  format?: 'zip' | 'tar';
  options?: ArchiverOptions;
}

Usage Examples:

// Basic ZIP archive
{
  archive: [
    { source: './dist', destination: './release.zip' }
  ]
}

// TAR archive with explicit format
{
  archive: [
    { source: './build', destination: './backup.tar', format: 'tar' }
  ]
}

// Compressed TAR archive
{
  archive: [
    {
      source: './dist',
      destination: './release.tar.gz',
      format: 'tar',
      options: {
        gzip: true,
        gzipOptions: {
          level: 9    // Maximum compression
        }
      }
    }
  ]
}

// Archive with glob patterns
{
  archive: [
    {
      source: './src/**/*.js',
      destination: './scripts.zip',
      options: {
        globOptions: {
          ignore: ['**/*.test.js', '**/*.spec.js']
        }
      }
    }
  ]
}

// Archive single file
{
  archive: [
    { source: './bundle.js', destination: './bundle.zip' }
  ]
}

// Archive with custom archiver options
{
  archive: [
    {
      source: './dist',
      destination: './app.zip',
      options: {
        zlib: { level: 1 },    // Fast compression
        globOptions: {
          dot: true,           // Include hidden files
          ignore: ['**/node_modules/**', '**/*.log']
        }
      }
    }
  ]
}

Archive Formats

ZIP Format

  • Default format when destination ends with .zip
  • Supports compression levels via zlib options
  • Cross-platform compatibility
  • Built-in CRC checking

TAR Format

  • Used when destination ends with .tar or format is explicitly 'tar'
  • Supports gzip compression with .tar.gz extension
  • Unix-style permissions preserved
  • Streaming support for large archives

Archive Behavior

Source Handling

  • File: Single file archived with basename
  • Directory: Entire directory contents archived recursively
  • Glob Pattern: All matching files/directories archived

Path Handling

  • Relative paths in archive maintain directory structure
  • flat option not available (use glob patterns for flattening)
  • Destination file excluded from archive automatically

Compression Options

// ZIP compression
{
  options: {
    zlib: { level: 6 }    // 0-9, higher = better compression
  }
}

// TAR with gzip
{
  options: {
    gzip: true,
    gzipOptions: {
      level: 6,           // 0-9, higher = better compression
      chunkSize: 1024     // Buffer size
    }
  }
}

Error Handling

Archive operations handle various error conditions:

  • Source not found: Error logged and handled based on throwOnError
  • Destination issues: Directory created automatically if needed
  • Compression errors: Archiver errors propagated to error handler
  • Large files: Streaming prevents memory issues

Performance Considerations

  • Large directories: Use glob options to exclude unnecessary files
  • Compression levels: Balance between speed and size
  • Memory usage: Archives streamed to disk, not held in memory
  • Concurrent archives: Multiple archives can run in parallel