Skip to content

pnpm config set for array and object values #10015

@karlhorky

Description

@karlhorky

Contribution

Describe the user story

A user would like to add a non-string config setting via pnpm config set, eg:

  • adding a new element to an array (eg. adding 'webpack' to the minimumReleaseAgeExclude array)
  • setting a new property in a deeper config object (eg. setting packageExtensions['react-redux'].peerDependencies['react-dom'] to '*')

Describe the solution you'd like

For example, adding to the arrays for minimumReleaseAgeExclude or onlyBuiltDependencies:

$ pnpm config set 'minimumReleaseAgeExclude[]' 'webpack' --location project
$ pnpm config set 'minimumReleaseAgeExclude[]' 'react' --location project
$ pnpm config set 'onlyBuiltDependencies[]' 'sharp' --location project
$ pnpm config set 'onlyBuiltDependencies[]' 'bcrypt' --location project

$ cat pnpm-workspace.yaml
minimumReleaseAgeExclude:
  - webpack
  - react
onlyBuiltDependencies:
  - sharp
  - bcrypt

This could also apply to global configuration (INI format currently, with kebab case settings):

$ pnpm config set 'minimum-release-age-exclude[]' 'webpack'
$ pnpm config set 'minimum-release-age-exclude[]' 'react'
$ pnpm config set 'only-built-dependencies[]' 'sharp'
$ pnpm config set 'only-built-dependencies[]' 'bcrypt'

$ cat "$HOME/Library/Preferences/pnpm/rc"
minimum-release-age-exclude[]=webpack
minimum-release-age-exclude[]=react
only-built-dependencies[]=sharp
only-built-dependencies[]=bcrypt

Describe the drawbacks of your solution

Possibly: costs of building? I can't see big drawbacks of the solution

Describe alternatives you've considered

The alternatives are more prone to error:

  1. Editing the files by hand
  2. Editing the files using yq or Perl or echo
  3. --json flag usage eg. pnpm config set --location=project --json minimumReleaseAgeExclude '["webpack", "react"]' - this does not append to an existing array or allow for setting via property path

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions