Code Monkey home page Code Monkey logo

package-postage's Introduction

Package Postage Logo

Description

Package Postage helps ship utility libraries. It is designed to work with np as a low-level utility to copy the important parts of package.json into a sub-directory for publishing. I personally hook into npm postversion

Why would you do this?

  • ๐Ÿ—œShip smaller packages: only publish the transpiled code.
  • ๐Ÿ’โ€โ€Pretty pathing: import "your-package/utils" works. No more your-package/src/utils
  • ๐Ÿ‘ฏโ€Avoid managing 2 package.json: encode your deployment stream.

npm publish will allow you to publish a sub-directory, but does not copy package-json into that sub-directory. It is reasonable to want to publish that sub-directory but to ensure consistency of a ./dist/package.json with ./package.json would require some level of scripting. Enter Package Postage

Installation

$ npm install --save-dev package-postage

โš™๏ธ API

  • indent: ["tab", "4", "2"] - Specify the indentation of the resultant package.json
  • use-file: Use an arbitrary file as package.json
  • omit: Some tags are included by default, you may want to manually exclude them: "author", "bin", "bugs", "contributors", "dependencies", "description", "keywords", "license", "main", "module", "peerDependencies", "repository".
  • include: If you'd like to ensure some non-standard keys are shipped pass the key to this.

note omit & include can be combined to only include some child keys while stripping the rest: e.g.

{
  "postage": {
    "omit": ["peerDependencies"],
    "include": ["peerDependencies.react"]
  }
}

๐Ÿ“ฆ Configure in package.json

{
  "name": "my-awesome-package",
  "version": "0.1.1",
  "postage": {
    "omit": ["omit", "any", "top-level", "keys", "included", "by", "default"],
    "include": ["include", "any.top-level.or.sub.keys"],
    "indent": "tab"
  }
}

๐Ÿ‘พ Call from Gulp

const postage = require("package-postage");
// ...
postage("path_to_dest", {
  omit: ["peerDependencies"],
  include: ["peerDependencies.react"],
  indent: "tab"
});

๐Ÿ’ป Execute from terminal

# Copy package.json from your working-directory into `./dist`
$ postage

# Copy package.json from your working directory into `./any-folder-name`
$ postage any-folder-name/

# Use an arbitrary file: `./package.dist.json`
$ postage build/ --use-file package.dist.json

# Indent with tabs
$ postage --indent tab

# Include a few extra top-level keys
$ postage --include eslint,babel,prettier

# Omit a few top-level keys
$ postage --omit repository,bugs,homepage

# Include some sub-keys
$ postage \
  --omit devDependencies,optionalDependencies \
  --include devDependencies.prettier,devDependencies.eslint;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.