README
Pack It!
Pack It! is a packager that bundles source code within a standard Node.js project into a zip file.
Prerequisites
Ensure the following requirements are met prior to usage:
- Node.js 12, 14, or 16 installed
- Git installed
Installation
Via NPM:
npm install --save-dev @triviumsoftware/pack-it
Via Yarn:
yarn add --dev @triviumsoftware/pack-it
Usage
Configuration File
Pack It! looks for a config file named pack-it.config.js
in the project's root directory. The following is an example with all of the configurable settings:
module.exports = {
projectName: 'pack-it',
git: {
url: 'git@github.com:tgillus/pack-it.git',
branch: 'main',
},
tmpDir: '.tmp',
artifactDir: 'deploy',
includeDirs: ['lib', 'node_modules'],
};
Configuration Settings
Setting | Description | Required | Default |
---|---|---|---|
projectName |
Name of the project. Used in the zip file name. | true | |
git.url |
Repo whose source code is cloned and zipped. | true | |
git.branch |
Branch of the repo that is checked out when cloned. | true | |
tmpDir |
Directory where the repo is cloned. | false | '.tmp' |
artifactDir |
Directory where the produced zip file is saved. | false | 'deploy' |
includeDirs |
Array of directories that are included in the zip file. | false | ['src', 'node_modules'] |
Commands
Command | Description |
---|---|
npx pack-it |
Bundle the project as a zip file. |
npx pack-it pack |
Bundle the project as a zip file. |
npx pack-it clean |
Delete tmpDir and artifactDir . |
Pack
Pack It! expects an NPM script named build
to be defined in package.json
. In other words, Pack It! executes the following command to build the project:
npm run build
Pack It! installs an executable named pack-it
. Run the following in the root of the project to bundle it as a zip file:
npx pack-it
or
npx pack-it pack
NOTE: Pack It! clones a fresh copy of the project's repository prior to building and bundling the project. It installs all of the project's dependencies after it's cloned in order to build the project. However, only production dependencies are bundled with the zip file.
Clean Up
Run the following in the root of the project to remove tmpDir
and artifactDir
:
npx pack-it clean
Author
License
Pack It! is distributed under the MIT License. See the LICENSE file for more information.