# node-postbuild-cli

> Postbuild script for node package

Latest version **1.0.4** (published 2025-05-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-postbuild-cli
pnpm add node-postbuild-cli
yarn add node-postbuild-cli
bun add node-postbuild-cli
```

Provides the commands `npbc`, `node-postbuild-cli`.

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2025-05-14 |
| First published | 2024-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 20.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Damian Polak |
| Maintainers | damianpolak |
| Keywords | node, nest, nestjs, postbuild, cli, script, build, deploy, package |

## Links

- npm: https://www.npmjs.com/package/node-postbuild-cli
- Repository: https://github.com/damianpolak/node-postbuild-cli
- Homepage: https://github.com/damianpolak/node-postbuild-cli#readme
- Issues: https://github.com/damianpolak/node-postbuild-cli/issues
- npm.io page: https://npm.io/package/node-postbuild-cli

## Dependencies (2)

- [jszip](https://npm.io/package/jszip.md) ^3.10.1
- [yargs](https://npm.io/package/yargs.md) ^17.7.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2025-05-14
- 1.0.3 — 2024-09-04
- 1.0.2 — 2024-03-26
- 1.0.1 — 2024-03-22
- 1.0.0 — 2024-03-22

## README

<h1 align="center">Node-postbuild-cli</h1>
<p align="center">
  <b>Postbuild script for node package</b>
</p>
<br>

![npm](https://img.shields.io/npm/dw/node-postbuild-cli) ![npm](https://img.shields.io/npm/v/node-postbuild-cli) ![NPM](https://img.shields.io/npm/l/node-postbuild-cli) ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/damianpolak/node-postbuild-cli/main.yml)

## Description

This tool helps automate post-build processes. It allows you to copy and modify `package.json` (retaining only essential properties for production), copy specific files to a destination directory, run `npm install` in the target location, execute custom shell commands, remove specified files/directories, and compress the output directory into a zip file. Tasks are executed in the order they are specified.

## Installation

Latest version:

```bash
npm i -g node-postbuild-cli@latest
```

or in working directory

```bash
npx node-postbuild-cli --task ...
npx node-postbuild-cli --tasks ...
```

## Usage

```javascript
USAGE:
$ node-postbuild-cli --tasks ... [options]
$ npbc --tasks ... [options]

Available tasks: `package`, `zip`, `deps`, `copyfiles`, `remove`, `commands`.

- package: Copies `package.json`, keeping only essential properties (e.g., `name`, `version`, `dependencies`).
- copyfiles: Copies files specified in the CLI arguments.
- deps: Installs dependencies in the target `package.json` directory.
- zip: Compresses the specified directory (default: `./dist`) into a zip file.
- remove: Removes files or directories specified in the CLI arguments.
- commands: Runs OS commands specified in the CLI arguments.

Options:
      --help               Show help                                   [boolean]
      --version            Show version number                         [boolean]
  -j, --pkg-src            `package.json` source directory[string] [default: "."]
  -k, --pkg-dst            `package.json` destination directory[string] [default: "./dist"]
  -c, --zip-dir            Directory to compress      [string] [default: "./dist"]
  -d, --zip-out            Output directory for the zip file [string] [default: "./dist-zip"]
  -f, --files-src-to-copy  Source file paths to copy       [array] [default: []]
  -g, --files-dst-to-copy  Destination paths for copied files[array] [default: []]
  -R, --remove             Paths to files or directories to remove [array] [default: []]
  -r, --tasks              Tasks to run, in the specified order
          [array] [choices: "package", "zip", "deps", "copyfiles", "remove", "commands"] [default: []]
  -a, --commands           OS commands to execute           [array] [default: []]

Examples:
  $ npx node-postbuild-cli --tasks package copyfiles deps zip --files-src-to-copy ./.env ./ecosystem.config.js --files-dst-to-copy ./dist/.env ./dist/ecosystem.config.js
  It runs tasks: package, copyfiles, deps, and zip. It copies .env and ecosystem.config.js to ./dist, using default values for other task-specific options.

  $ npx node-postbuild-cli --tasks package deps zip --zip-out ./zipped
  It runs tasks: package and deps with default values, and the zip task with a custom output directory ./zipped.
```

## Example

```javascript
$ npx node-postbuild-cli --tasks package deps zip
// It copies package.json file from . to ./dist, run npm install in ./dist and zipping ./dist to ./dist-zip/dist.zip

$ npx node-postbuild-cli --tasks package deps zip --pkg-dst ./foo --zip-dir ./foo
// It copies package.json file from . to ./foo, run npm install in ./foo and zipping ./foo to ./dist-zip/dist.zip

$ npx node-postbuild-cli --tasks copyfiles -f ./.env ./config.json -g ./foo/.env ./foo/new_config.json
// It copies files: .env and config.json from . to ./foo directory but changes name of config.json to new_config.json

$ npx node-postbuild-cli --tasks copyfiles zip -f ./.env ./config.json -g ./foo/.env ./foo/new_config.json --zip-dir ./foo
// Same as above, but zips the directory ./foo to ./dist-zip/dist.zip
```

## License

MIT © Damian Polak

---
_Source: https://npm.io/package/node-postbuild-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
