Class

ReleaseScript

ReleaseScript(options)

Constructor

# new ReleaseScript(options)

This script automates the process of creating and pushing new releases. It handles version updates, commit messages, and optionally publishes to NPM. The script supports semantic versioning and can work in both CI and non-CI environments.

A command-line script for managing releases and version updates.

Parameters:
Name Type Description
options Object

Configuration options for the script

ci boolean

Whether the script is running in a CI environment (default: true)

message string

The release message (short: 'm')

tag string

The version tag to use (short: 't', default: undefined)

View Source cli/commands/tag-release.ts, line 21

Extends

Members

Logger

# log

Static logger for the Command class.

Static logger for the Command class.

Overrides:

View Source cli/command.ts, line 30

Methods

# async protected checkRequirements() → {Promise.<void>}

Retrieves the list of dependencies and compares it against the required dependencies for the command.

Checks if all required dependencies are present.

sequenceDiagram participant Command participant getDependencies participant Set Command->>getDependencies: Call getDependencies-->>Command: Return {prod, dev, peer} Command->>Set: Create Set from prod, dev, peer Set-->>Command: Return unique dependencies Command->>Command: Compare against requirements alt Missing dependencies Command->>Command: Add to missing list end Note over Command: If missing.length > 0, handle missing dependencies
Overrides:

View Source cli/command.ts, line 73

A promise that resolves when the check is complete.

Promise.<void>

# async execute() → {Promise.<(R|string|void)>}

This method handles the overall execution flow of the command, including parsing arguments, setting up logging, checking for version or help requests, and running the command.

Executes the command.

sequenceDiagram participant Command participant UserInput participant Logging participant getPackageVersion participant printBanner Command->>UserInput: parseArgs(inputs) UserInput-->>Command: Return ParseArgsResult Command->>Command: Process options Command->>Logging: setConfig(options) alt version requested Command->>getPackageVersion: Call getPackageVersion-->>Command: Return version else help requested Command->>Command: help(args) else banner requested Command->>printBanner: Call end Command->>Command: run(args) alt error occurs Command->>Command: Log error end Command-->>Command: Return result
Overrides:

View Source cli/command.ts, line 126

A promise that resolves with the command's result.

Promise.<(R|string|void)>

# protected help(args) → {void}

This method should be overridden in derived classes to provide specific help information.

Provides help information for the command.

Parameters:
Name Type Description
args ParseArgsResult

The parsed command-line arguments.

Overrides:

View Source cli/command.ts, line 91

void

# async prepareMessage(messageopt) → {Promise.<string>}

This method either returns the provided message or prompts the user for a new one if not provided.

Prepares the release message.

Parameters:
Name Type Attributes Description
message string <optional>

The release message

View Source cli/commands/tag-release.ts, line 214

The prepared release message

Promise.<string>

# async prepareVersion(tag) → {Promise.<string>}

This method validates the provided tag or prompts the user for a new one if not provided or invalid. It also displays the latest git tags for reference.

Prepares the version for the release.

sequenceDiagram participant R as ReleaseScript participant T as TestVersion participant U as UserInput participant G as Git R->>T: testVersion(tag) alt tag is valid T-->>R: return tag else tag is invalid or not provided R->>G: List latest git tags R->>U: Prompt for new tag U-->>R: return new tag end
Parameters:
Name Type Description
tag string

The version tag to prepare

View Source cli/commands/tag-release.ts, line 197

The prepared version tag

Promise.<string>

# async run(args) → {Promise.<void>}

This method orchestrates the entire release process, including version preparation, message creation, git operations, and npm publishing (if not in CI environment).

Runs the release script.

sequenceDiagram participant R as ReleaseScript participant V as PrepareVersion participant M as PrepareMessage participant N as NPM participant G as Git participant U as UserInput R->>V: prepareVersion(tag) R->>M: prepareMessage(message) R->>N: Run prepare-release script R->>G: Check git status alt changes exist R->>U: Ask for confirmation U-->>R: Confirm R->>G: Add and commit changes end R->>N: Update npm version R->>G: Push changes and tags alt not CI environment R->>N: Publish to npm end
Parameters:
Name Type Description
args ParseArgsResult

The parsed command-line arguments

Overrides:

View Source cli/commands/tag-release.ts, line 247

Promise.<void>

# testVersion(version) → {string|undefined}

This method checks if the version is a valid semantic version or a predefined update type (PATCH, MINOR, MAJOR).

Tests if the provided version is valid.

Parameters:
Name Type Description
version string

The version to test

View Source cli/commands/tag-release.ts, line 205

The validated version or undefined if invalid

string | undefined