Skip to content

[RRFC] Top-level command to manage package.json #398

Description

@ruyadorno

Motivation ("The Why")

Some users prefer managing their package.json using npm cli comands rather than manually editing a JSON file.

As of today, some of the npm cli commands already handle the automated management of the package.json file, such as npm install adding / updating dependency declarations, npm version bumping the version value, or in the case of npm set-script a top-level command that serves specifically the purpose of managing "scripts" data in the package.json file.

Example

$ cat package.json
{
  "name": "a",
  "version": "1.0.0"
}

$ npm install abbrev

added 1 package, and audited 2 packages in 493ms

found 0 vulnerabilities

$ cat package.json
{
  "name": "a",
  "version": "1.0.0",
  "dependencies": {
    "abbrev": "^1.1.1"
  }
}

$ npm set-script test echo
{
  "name": "a",
  "version": "1.0.0",
  "dependencies": {
    "abbrev": "^1.1.1"
  },
  "scripts": {
    "test": "echo"
  }
}

How

Introduce a new top-level command npm pkg that would help managing the remaining package.json fields and centralize this management under a single command.

Current Behaviour

Taking the current npm set-script type of behavior:

$ npm set-script lint eslint

Desired Behaviour

Migrate set-script under a single pkg top-level command and expand it to make it possible to manage the reminder of package.json fields.

$ npm pkg set script --key=lint --value=eslint

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions