Build Directory Archiver

1.8.0 · active · verified Sun Apr 19

zip-build is a specialized Node.js command-line utility designed for automating the archival of project build artifacts. It streamlines the process of zipping or tarring a specified output directory, making it particularly useful for deployment pipelines or versioned backups. The package automatically generates archive filenames based on the project's `name` and `version` fields extracted from `package.json`, and can optionally include a timestamp for uniqueness. Currently, at version 1.8.0, it demonstrates active maintenance through its GitHub repository, though a formal release cadence is not explicitly defined. Its key differentiators include flexible output formatting (supporting both `.zip` and `.tar`), customizable filename templating, and an optional interactive mode for guided execution. It primarily serves as a `devDependency` to be integrated into `npm scripts` for an automated build workflow, rather than offering a direct programmatic API for `import` into JavaScript or TypeScript modules.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to integrate `zip-build` into an npm script workflow, showing installation, directory creation, and archiving with custom naming.

// package.json snippet to demonstrate integration into a build workflow
// Add this 'scripts' block to your project's package.json:
/*
  {
    "name": "my-project-name",
    "version": "1.2.3",
    "scripts": {
      "clean": "rm -rf dist build",
      "prebuild": "npm run clean",
      "build": "mkdir build && echo 'Hello, this is a build artifact!' > build/main.txt && zip-build build dist --format zip --template 'app_%VERSION%_release_%TIMESTAMP%.%EXT%' --override",
      "postbuild": "echo 'Build and archiving complete! Check the dist directory.'",
      "test-zip": "npm run build && ls dist"
    },
    "devDependencies": {
      "zip-build": "^1.8.0"
    }
  }
*/

// To run this quickstart example:
// 1. Ensure 'zip-build' is installed as a devDependency in your project:
//    npm install --save-dev zip-build
// 2. Add the provided 'scripts' block to your project's package.json file.
// 3. Open your terminal in the project root and run:
//    npm run build
// This will create a 'build' directory, place a dummy file inside, then archive
// that directory into a 'dist' folder with a name like 'app_1.2.3_release_1678886400000.zip'.
// The --override flag ensures it can run multiple times without error.

view raw JSON →