Global

Methods

createPackage(config) → {Promise.<void>}

Description:
  • Creates a project package (e.g., a zip file) based on the provided options. This is the main asynchronous function to initiate the packaging process.

Source:
Parameters:
Name Type Description
config object

Options for creating the package.

Properties
Name Type Attributes Default Description
inputDir string

The path to the directory containing files to be packaged. This is a mandatory option and must be a valid, existing path.

name string <optional>
"project-package"

The base name for the output package file.

outputDir string <optional>
"./dist/packages/"

The path where the package file will be created.

timestamp boolean <optional>
true

Whether to append a timestamp (YYYYMMDD) to the package filename.

increment boolean <optional>
true

Whether to append an incrementing number if a file with the same base name and timestamp already exists. This only applies if config.overwrite is false.

overwrite boolean <optional>
false

Whether to overwrite an existing file if config.increment is false and a filename clash occurs. If true, the existing file will be replaced.

format string <optional>
"zip"

The archive format (e.g., "zip", "tar"). Must be supported by the 'archiver' library.

archiverOptions object <optional>
{}

Additional options passed directly to the 'archiver' library's instance.

Throws:

If outputDir or inputDir do not exist, or if overwriting is disabled and a filename conflict occurs.

Type
Error
Returns:

A Promise that resolves when the package is successfully created.

Type
Promise.<void>

getFilepath(options, countopt) → {string}

Description:
  • Generates a unique filepath for the package, incorporating the base name, timestamp, and an incrementing number (if enabled) to prevent overwrites based on options. This function uses recursion to find an available filename if incrementing is active.

Source:
Parameters:
Name Type Attributes Default Description
options PackageOptions

The resolved options for packaging.

count number <optional>
0

Internal counter used during recursion to generate incremented filenames. Users should not set this manually.

Throws:

If options.overwrite is false, options.increment is false, and a file with the exact generated name already exists.

Type
Error
Returns:

The full, unique path for the new package file, including filename and extension.

Type
string

getTimeStamp() → {string}

Description:
  • Generates a formatted timestamp string for the current date in YYYYMMDD format.

Source:
Returns:

The current date as an 8-digit string (e.g., "20250627").

Type
string

Type Definitions

PackageOptions

Source:
Properties:
Name Type Attributes Default Description
name string <optional>
"project-package"

The base name for the output package file.

inputDir string

The path to the directory containing files to be packaged. This is a mandatory option.

outputDir string <optional>
"./dist/packages/"

The path where the package file will be created.

timestamp boolean <optional>
true

Whether to append a timestamp (YYYYMMDD) to the package filename.

increment boolean <optional>
true

Whether to append an incrementing number if a file with the same base name and timestamp already exists. This only applies if overwrite is false.

overwrite boolean <optional>
false

Whether to overwrite an existing file if increment is false and a filename clash occurs. If true, the existing file will be replaced.

format string <optional>
"zip"

The archive format (e.g., "zip", "tar"). Must be supported by the 'archiver' library.

archiverOptions object <optional>
{}

Additional options passed directly to the 'archiver' library's instance.

Type:
  • object