import { ReposCreateReleaseResponse, Response } from '@octokit/rest'; import { AsyncParallelHook, AsyncSeriesBailHook, SyncHook, SyncWaterfallHook, AsyncSeriesHook, AsyncSeriesWaterfallHook } from 'tapable'; import { ApiOptions, ICanaryOptions, IChangelogOptions, ICommentOptions, ICreateLabelsOptions, IInitOptions, ILabelOptions, IPRCheckOptions, IPRStatusOptions, IReleaseOptions, IShipItOptions, IVersionOptions, INextOptions } from './auto-args'; import Changelog from './changelog'; import Git from './git'; import LogParse, { IExtendedCommit } from './log-parse'; import Release, { IAutoConfig, ILabelDefinition } from './release'; import SEMVER, { IVersionLabels } from './semver'; import { ILogger } from './utils/logger'; import { IAuthorOptions, IRepoOptions } from './auto-args'; interface ChangelogLifecycle { /** The bump being applied to the version */ bump: SEMVER; /** The commits included in the changelog */ commits: IExtendedCommit[]; /** The generated release notes for the commits */ releaseNotes: string; /** The current version of the project */ currentVersion: string; /** The last version of the project */ lastRelease: string; } interface TestingToken { /** A token used for testing */ token?: string; } export interface IAutoHooks { /** Modify what is in the config. You must return the config in this hook. */ modifyConfig: SyncWaterfallHook<[IAutoConfig]>; /** Happens before anything is done. This is a great place to check for platform specific secrets. */ beforeRun: SyncHook<[IAutoConfig]>; /** Happens before `shipit` is run. This is a great way to throw an error if a token or key is not present. */ beforeShipIt: SyncHook<[]>; /** Ran before the `changelog` command commits the new release notes to `CHANGELOG.md`. */ beforeCommitChangelog: AsyncSeriesHook<[ChangelogLifecycle]>; /** Ran after the `changelog` command adds the new release notes to `CHANGELOG.md`. */ afterAddToChangelog: AsyncSeriesHook<[ChangelogLifecycle]>; /** Ran after the `shipit` command has run. */ afterShipIt: AsyncParallelHook<[string | undefined, IExtendedCommit[]]>; /** Ran after the `release` command has run. */ afterRelease: AsyncParallelHook<[{ /** The last version released */ lastRelease: string; /** The version being released */ newVersion?: string; /** The commits included in the release */ commits: IExtendedCommit[]; /** The generated release notes for the commits */ releaseNotes: string; /** The response from creating the new release. */ response?: Response; }]>; /** Get git author. Typically from a package distribution description file. */ getAuthor: AsyncSeriesBailHook<[], IAuthorOptions | void>; /** Get the previous version. Typically from a package distribution description file. */ getPreviousVersion: AsyncSeriesBailHook<[], string>; /** Get owner and repository. Typically from a package distribution description file. */ getRepository: AsyncSeriesBailHook<[], (IRepoOptions & TestingToken) | void>; /** Tap into the things the Release class makes. This isn't the same as `auto release`, but the main class that does most of the work. */ onCreateRelease: SyncHook<[Release]>; /** This is where you hook into the LogParse's hooks. This hook is exposed for convenience on during `this.hooks.onCreateRelease` and at the root `this.hooks` */ onCreateLogParse: SyncHook<[LogParse]>; /** This is where you hook into the changelog's hooks. This hook is exposed for convenience on during `this.hooks.onCreateRelease` and at the root `this.hooks` */ onCreateChangelog: SyncHook<[Changelog, SEMVER | undefined]>; /** Version the package. This is a good opportunity to `git tag` the release also. */ version: AsyncParallelHook<[SEMVER]>; /** Ran after the package has been versioned. */ afterVersion: AsyncParallelHook<[]>; /** Publish the package to some package distributor. You must push the tags to github! */ publish: AsyncParallelHook<[SEMVER]>; /** Used to publish a canary release. In this hook you get the semver bump and the unique canary postfix ID. */ canary: AsyncSeriesBailHook<[SEMVER, string], string | { /** Error when creating the canary release */ error: string; }>; /** * Used to publish a next release. In this hook you get the semver bump * and an array of next versions that been released. If you make another * next release be sure to add it the the array. */ next: AsyncSeriesWaterfallHook<[string[], SEMVER]>; /** Ran after the package has been published. */ afterPublish: AsyncParallelHook<[]>; } /** * Bump the version but no too much. * * @example * currentVersion = 1.0.0 * nextVersion = 2.0.0-next.0 * output = 2.0.0-next.1 */ export declare function determineNextVersion(lastVersion: string, currentVersion: string, bump: SEMVER, tag: string): string; /** * The "auto" node API. Its public interface matches the * commands you can run from the CLI */ export default class Auto { /** Plugin entry points */ hooks: IAutoHooks; /** A logger that uses log levels */ logger: ILogger; /** Options auto was initialized with */ options: ApiOptions; /** The branch auto uses as master. */ baseBranch: string; /** The user configuration of auto (.autorc) */ config?: IAutoConfig; /** A class that handles creating releases */ release?: Release; /** A class that handles interacting with git and GitHub */ git?: Git; /** The labels configured by the user */ labels?: ILabelDefinition[]; /** A map of semver bumps to labels that signify those bumps */ semVerLabels?: IVersionLabels; /** The version bump being used during "shipit" */ private versionBump?; /** Initialize auto and it's environment */ constructor(options?: ApiOptions); /** * Load the .autorc from the file system, set up defaults, combine with CLI args * load the extends property, load the plugins and start the git remote interface. */ loadConfig(): Promise; /** * Interactive prompt for initializing an .autorc */ init(options?: IInitOptions): Promise; /** * Create all of the user's labels on the git remote if the don't already exist * * @param options - Options for the createLabels functionality */ createLabels(options?: ICreateLabelsOptions): Promise; /** * Get the labels on a specific PR. Defaults to the labels of the last merged PR * * @param options - Options for the createLabels functionality */ label({ pr }?: ILabelOptions): Promise; /** * Create a status on a PR. * * @param options - Options for the pr status functionality */ prStatus({ dryRun, pr, url, ...options }: IPRStatusOptions): Promise; /** * Check that a PR has a SEMVER label. Set a success status on the PR. * * @param options - Options for the pr check functionality */ prCheck({ dryRun, pr, url, ...options }: IPRCheckOptions): Promise; /** * Comment on a PR. Only one comment will be present on the PR, Older comments are removed. * You can use the "context" option to multiple comments on a PR. * * @param options - Options for the comment functionality */ comment(options: ICommentOptions): Promise; /** * Update the body of a PR with a message. Only one message will be present in the PR, * Older messages are removed. You can use the "context" option to multiple message * in a PR body. * * @param options - Options */ prBody(options: ICommentOptions): Promise; /** * Calculate the version bump for the current state of the repository. */ version(options?: IVersionOptions): Promise; /** * Calculate the the changelog and commit it. */ changelog(options?: IChangelogOptions): Promise; /** * Make a release to the git remote with the changes. */ runRelease(options?: IReleaseOptions): Promise; /** Create a canary (or test) version of the project */ canary(options?: ICanaryOptions): Promise<{ newVersion: string; commitsInRelease: IExtendedCommit[]; } | undefined>; /** * Create a next (or test) version of the project. If on master will * release to the default "next" branch. */ next(options: INextOptions): Promise<{ newVersion: string; commitsInRelease: IExtendedCommit[]; }>; /** * Run the full workflow. * * 1. Calculate version * 2. Make changelog * 3. Publish code * 4. Create a release */ shipit(options?: IShipItOptions): Promise; /** Get the latest version number of the project */ getCurrentVersion(lastRelease: string): Promise; /** * A utility function for plugins to check the process for tokens. */ checkEnv(pluginName: string, key: string): void; /** On master: publish a new latest version */ private publishLatest; /** Get a pr number from user input or the env */ private getPrNumber; /** Create a client to interact with git */ private startGit; /** Calculate a version from a tag using labels */ private getVersion; /** Make a changelog over a range of commits */ private makeChangelog; /** Make a release over a range of commits */ private makeRelease; /** Check if `git status` is clean. */ readonly checkClean: () => Promise; /** Prefix a version with a "v" if needed */ readonly prefixRelease: (release: string) => string; /** Create an auto initialization error */ private createErrorMessage; /** * Set the git user to make releases and commit with. */ private setGitUser; /** Get the repo to interact with */ private getRepo; /** * Apply all of the plugins in the config. */ private loadPlugins; } export * from './auto-args'; export { ILogger } from './utils/logger'; export { IPlugin } from './utils/load-plugins'; export { default as Auto } from './auto'; export { default as SEMVER } from './semver'; export { default as execPromise } from './utils/exec-promise'; export { VersionLabel } from './release'; //# sourceMappingURL=auto.d.ts.map