or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-6/

pnpm Resolution Strategy Configurator

Create a CLI tool that helps developers configure and test different dependency resolution strategies in pnpm projects.

Background

Package managers need to decide which version of a dependency to install when multiple versions could satisfy the requirements. Different resolution strategies can lead to different dependency graphs, affecting reproducibility, security, and compatibility.

Requirements

Build a Node.js CLI tool called resolution-config with the following functionality:

Set Resolution Mode

The tool should support setting the resolution mode to one of three strategies:

  1. highest - Always resolves to the highest available version that satisfies the range
  2. time-based - Resolves based on the publish timestamp, respecting a configured time baseline
  3. lowest-direct - For direct dependencies, resolves to the lowest version that satisfies the range

The command format should be:

node resolution-config.js set-mode <mode>

Where <mode> is one of: highest, time-based, or lowest-direct.

Configure Time-Based Settings

When using time-based resolution, the tool should allow configuring:

  • Whether the registry supports the time field
  • A minimum release age (in days) for packages to be considered stable

The command format should be:

node resolution-config.js configure-time --registry-time <boolean> --min-age <days>

Both flags are optional. If not provided, registry-time defaults to true and min-age defaults to 0.

Display Current Configuration

The tool should display the current resolution configuration:

node resolution-config.js show

This should output the current settings in a readable format.

Clear Configuration

The tool should allow clearing all resolution-related configuration:

node resolution-config.js clear

Implementation Notes

  • The tool should read from and write to the .npmrc file in the current directory
  • If no .npmrc file exists, create one
  • Preserve any existing configuration that is not related to resolution
  • Use appropriate configuration keys for pnpm
  • Include helpful error messages for invalid inputs
  • The tool should work with pnpm version 8.0 or higher

Test Cases

  • Setting resolution mode to "highest" updates the configuration correctly @test
  • Setting resolution mode to "time-based" updates the configuration correctly @test
  • Setting resolution mode to "lowest-direct" updates the configuration correctly @test
  • Configuring time-based settings with both flags updates both values @test
  • Configuring time-based settings with only registry-time flag works correctly @test
  • Displaying configuration shows current resolution settings @test
  • Clearing configuration removes resolution-related settings while preserving others @test
  • Creating a new .npmrc file when none exists works correctly @test

Dependencies { .dependencies }

pnpm { .dependency }

Provides package management with configurable resolution strategies.

@generates