or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-10/

Workspace Dependency Manager

A utility library that provides package manager detection and dependency management functionality for monorepo workspaces. The library should automatically detect which package manager is being used in a workspace and provide methods to manage dependencies appropriately.

Capabilities

Package Manager Detection

  • It detects the package manager being used in the current workspace @test
  • It returns the correct package manager when a lock file exists @test

Dependency Addition

  • It adds dependencies to package.json with correct formatting @test
  • It preserves existing dependencies when adding new ones @test

Installation Task Generation

  • It generates an installation task for the detected package manager @test

Implementation

@generates

API

import { Tree } from '@nx/devkit';

/**
 * Detects the package manager used in the workspace.
 *
 * @param workspaceRoot - The root directory of the workspace
 * @returns The detected package manager ('npm', 'yarn', 'pnpm', or 'bun')
 */
export function detectWorkspacePackageManager(workspaceRoot: string): string;

/**
 * Adds dependencies to the workspace's package.json.
 *
 * @param tree - The file system tree
 * @param dependencies - Object mapping package names to version strings
 * @param devDependencies - Object mapping dev package names to version strings
 * @returns A callback function to install the added packages
 */
export function addDependencies(
  tree: Tree,
  dependencies: Record<string, string>,
  devDependencies?: Record<string, string>
): () => void;

/**
 * Creates a task that installs packages using the workspace's package manager.
 *
 * @param workspaceRoot - The root directory of the workspace
 * @returns A callback function that executes the install command
 */
export function createInstallTask(workspaceRoot: string): () => void;

Dependencies { .dependencies }

@nx/devkit { .dependency }

Provides workspace utilities and file system operations.