UNPKG

@decaf-ts/utils

Version:

module management utils for decaf-ts

106 lines (105 loc) 4.04 kB
import { Command } from "../command"; import { DefaultCommandValues } from "../index"; import { LoggingConfig } from "@decaf-ts/logging"; declare const options: { ci: { type: string; default: boolean; }; message: { type: string; short: string; }; tag: { type: string; short: string; default: undefined; }; }; /** * @class ReleaseScript * @extends {Command} * @cavegory scripts * @description A command-line script for managing releases and version updates. * @summary 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. * * @param {Object} options - Configuration options for the script * @param {boolean} options.ci - Whether the script is running in a CI environment (default: true) * @param {string} options.message - The release message (short: 'm') * @param {string} options.tag - The version tag to use (short: 't', default: undefined) */ export declare class ReleaseScript extends Command<typeof options, void> { constructor(); /** * @description Prepares the version for the release. * @summary 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. * @param {string} tag - The version tag to prepare * @returns {Promise<string>} The prepared version tag * * @mermaid * 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 */ prepareVersion(tag?: string): Promise<string>; /** * @description Tests if the provided version is valid. * @summary This method checks if the version is a valid semantic version or a predefined update type (PATCH, MINOR, MAJOR). * @param {string} version - The version to test * @returns {string | undefined} The validated version or undefined if invalid */ testVersion(version: string): string | undefined; /** * @description Prepares the release message. * @summary This method either returns the provided message or prompts the user for a new one if not provided. * @param {string} [message] - The release message * @returns {Promise<string>} The prepared release message */ prepareMessage(message?: string): Promise<string>; /** * @description Runs the release script. * @summary This method orchestrates the entire release process, including version preparation, message creation, * git operations, and npm publishing (if not in CI environment). * @param {ParseArgsResult} args - The parsed command-line arguments * @returns {Promise<void>} * * @mermaid * 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 */ run(args: LoggingConfig & typeof DefaultCommandValues & { [k in keyof typeof options]: unknown; }): Promise<void>; } export {};