or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-1/

Monorepo Package Manager

Build a CLI tool that manages packages in a monorepo using pnpm workspaces.

Requirements

The tool should:

  1. Initialize a pnpm workspace with a configuration file defining package locations
  2. List workspace packages by discovering all packages in the workspace
  3. Filter packages based on glob patterns matching package names or paths
  4. Execute commands across filtered workspace packages

Input

The tool accepts command-line arguments:

  • init <dir> - Initialize a new pnpm workspace in the specified directory
  • list <dir> [--filter <pattern>] - List workspace packages, optionally filtered by pattern
  • exec <dir> <command> [--filter <pattern>] - Execute a command in matching packages

Output

For init: Creates pnpm-workspace.yaml with package glob patterns

For list: Prints package names, one per line

For exec: Prints the command output with package name prefix for each execution

Example Usage

# Initialize workspace in current directory
node index.js init ./my-workspace

# List all packages in workspace
node index.js list ./my-workspace

# List packages matching a pattern
node index.js list ./my-workspace --filter "packages/*"

# Execute command in all packages
node index.js exec ./my-workspace "pwd"

Test Cases

  • Initializing a workspace creates a pnpm-workspace.yaml file with package patterns @test
  • Listing packages returns all packages in the workspace @test
  • Filtering packages by glob pattern returns only matching packages @test
  • Executing a command runs it in each matching workspace package @test

Implementation

@generates

API

/**
 * Initialize a pnpm workspace
 * @param {string} workspaceDir - Directory to create the workspace in
 * @returns {Promise<void>}
 */
async function initWorkspace(workspaceDir) {}

/**
 * List packages in a workspace
 * @param {string} workspaceDir - Workspace root directory
 * @param {Object} [options] - Options
 * @param {string} [options.filter] - Glob pattern to filter packages
 * @returns {Promise<string[]>} Array of package names
 */
async function listPackages(workspaceDir, options) {}

/**
 * Execute a command in workspace packages
 * @param {string} workspaceDir - Workspace root directory
 * @param {string} command - Command to execute
 * @param {Object} [options] - Options
 * @param {string} [options.filter] - Glob pattern to filter packages
 * @returns {Promise<void>}
 */
async function execInPackages(workspaceDir, command, options) {}

module.exports = {
  initWorkspace,
  listPackages,
  execInPackages
};

Dependencies { .dependencies }

pnpm { .dependency }

Provides workspace and monorepo management capabilities including workspace configuration, package filtering, and command execution across packages.