Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

yumauri/pika-plugin-package.json

Repository files navigation

THIS PROJECT IS UNMAINTAINED AND DEPRECATED

@pika/pack project is unmaintained and archived, last release was 4 years ago. Even while there is an issue about author looking for help witn maintenance, it was created 3 years ago itself, and still has no answers. So, I think, it would be safe to say, that, sadly, but @pika/pack is dead. So this project is too.

pika-plugin-package.json

Build Status Coverage Status License NPM Made with Love

@pika/pack build plugin to modify package.json file.

Install

$ yarn add --dev pika-plugin-package.json

Or using npm

$ npm install --save-dev pika-plugin-package.json

Usage

{
  "name": "example-package-json",
  "version": "1.0.0",
  "@pika/pack": {
    "pipeline": [
      // ---8<---
      [
        "pika-plugin-package.json",
        {
          "+dependencies": {
            "lodash": "^"
          },
          "*keywords": ["+example"],
          "*files": ["-bin/"],
          "+author": "^",
          "-devDependencies": {}
        }
      ]
    ]
  }
}

Options

Pass any object, and it will be merged to result pkg/package.json
There are three modifiers, which you can add to properties / array items:

  • -: remove this property / item
  • *: merge this property (if there is no such property - it will be added)
  • +: add this property / item (if already exists - it will be replaced)

By default (without modifier) - merge (*) is applied. But I recomment always define modifiers for more expressness and clarity.

If you want, for some reason, add property named *prop (for example) — you can escape modifier like this - \\*prop - or just explicitly define needed modifier - +*prop - as I recommended before.

For example

"+license": "MIT"
will add (or replace) license field.

"-devDependencies": {}
will remove devDependencies (value is not really matters here).

"*dependencies": { "lodash": "^4.17.15" }
will add lodash dependency to existing dependencies (or will create dependencies with lodash, if there were no any dependencies).

"*files": ["-bin/"]
will remove bin/ item from files property.

Inheritance

You can specify special value ^ to any property, and value will be populated from original package.json. For example:

"+author": "^"
will add author field with value from original package.json (if defined).

This should work on any deep level, but only with object properties (no arrays).

Real world example

You can check this package's package.json, I use pika-plugin-package.json in pipeline to modify pika-plugin-package.json's package.json ^_^

Sponsored

Setplex OTT Platform

Setplex OTT Platform

About

@pika/pack build plugin to modify package.json file

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published