import { RestEndpointMethodTypes } from "@octokit/rest"; import { AsyncParallelHook, AsyncSeriesBailHook, SyncHook, SyncWaterfallHook, AsyncSeriesHook, AsyncSeriesWaterfallHook } from "tapable"; import { ApiOptions, IInfoOptions, ICanaryOptions, IChangelogOptions, ICommentOptions, ICreateLabelsOptions, 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, { ILabelDefinition } from "./release"; import SEMVER, { IVersionLabels } from "./semver"; import { ILogger } from "./utils/logger"; import { RepoInformation, AuthorInformation, LoadedAutoRc } from "./types"; import { ValidatePluginHook } from "./validate-config"; 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; } declare type ShipitContext = "canary" | "next" | "latest" | "old"; interface ShipitInfo { /** The Version published when shipit ran */ newVersion?: string; /** The commits released during shipit */ commitsInRelease: IExtendedCommit[]; /** The type of release made */ context: ShipitContext; } declare type ShipitRelease = "latest" | "old" | "next" | "canary"; interface BeforeShipitContext { /** The type of release that will be made when shipit runs. */ releaseType: ShipitRelease; } declare type PublishResponse = RestEndpointMethodTypes["repos"]["createRelease"]["response"]; export interface IAutoHooks { /** Modify what is in the config. You must return the config in this hook. */ modifyConfig: SyncWaterfallHook<[LoadedAutoRc]>; /** Validate what is in the config. You must return the config in this hook. */ validateConfig: ValidatePluginHook; /** Happens before anything is done. This is a great place to check for platform specific secrets. */ beforeRun: SyncHook<[LoadedAutoRc]>; /** Happens before `shipit` is run. This is a great way to throw an error if a token or key is not present. */ beforeShipIt: AsyncSeriesHook<[BeforeShipitContext]>; /** 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[], { /** The type of release made by shipit */ context: ShipitContext; }]>; /** 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?: PublishResponse | PublishResponse[]; }]>; /** Override what happens when "releasing" code to a Github release */ makeRelease: AsyncSeriesBailHook<[{ /** Do not actually do anything */ dryRun?: boolean; /** Commit to start calculating the version from */ from: string; /** The version being released */ newVersion: string; /** Whether the release being made is a prerelease */ isPrerelease?: boolean; /** The generated release notes for the commits */ fullReleaseNotes: string; /** The commits included in the release */ commits: IExtendedCommit[]; }], PublishResponse | PublishResponse[] | void>; /** Get git author. Typically from a package distribution description file. */ getAuthor: AsyncSeriesBailHook<[], Partial | 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<[], (RepoInformation & 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 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 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 | { /** A summary to use in a details html element */ newVersion: string; /** The details to use in a details html element */ details: string; } | { /** Error when creating the canary release */ error: string; } | void>; /** * 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; /** Print the current version of "auto" */ export declare function getAutoVersion(): any; /** * 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 remote git to push changes to. This is the full URL with auth */ remote: string; /** The user configuration of auto (.autorc) */ config?: LoadedAutoRc; /** 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); /** List some of the plugins available to auto */ private listPlugins; /** * Load the default hook behaviors. Should run after loadPlugins so * plugins take precedence. */ private loadDefaultBehavior; /** * 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<{ baseBranch: string; extends?: string | undefined; labels: ({ changelogTitle?: string | undefined; color?: string | undefined; description?: string | undefined; releaseType?: "none" | SEMVER.major | SEMVER.minor | SEMVER.patch | "skip" | "release" | undefined; overwrite?: boolean | undefined; } & { name: string; })[]; prereleaseBranches: string[]; plugins?: (string | [string, any])[] | undefined; noVersionPrefix?: boolean | undefined; versionBranches?: string | boolean | undefined; comment?: { delete?: boolean | undefined; edit?: boolean | undefined; } | undefined; changelog?: { message?: string | undefined; } | undefined; release?: { prerelease?: boolean | undefined; } | undefined; shipit?: { onlyGraduateWithReleaseLabel?: boolean | undefined; } | undefined; canary?: { force?: boolean | undefined; message?: string | false | undefined; } | undefined; next?: { message?: string | undefined; } | undefined; repo?: string | undefined; owner?: string | undefined; githubApi?: string | undefined; githubGraphqlApi?: string | undefined; name?: string | undefined; email?: string | undefined; onlyPublishWithReleaseLabel?: boolean | undefined; verbose?: boolean | [boolean, boolean] | undefined; }>; /** Determine the remote we have auth to push to. */ private getRemote; /** Interactive prompt for initializing an .autorc */ init(): Promise; /** Check if auto is set up correctly */ info(args: IInfoOptions): Promise<{ hasError: boolean; }>; /** Determine if the repo is currently in a prerelease branch */ inPrereleaseBranch(): boolean; /** Determine if the repo is currently in a old-version branch */ inOldVersionBranch(): boolean; /** * Create all of the user's labels on the git remote if the don't already exist */ createLabels(options?: ICreateLabelsOptions): Promise; /** * Get the labels on a specific PR. Defaults to the labels of the last merged PR */ label({ pr }?: ILabelOptions): Promise; /** * Create a status on a PR. */ prStatus({ dryRun, pr, url, ...options }: IPRStatusOptions): Promise; /** * Check that a PR has a SEMVER label. Set a success status on the PR. */ 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. */ comment(args: 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. */ 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(args?: ICanaryOptions): Promise; /** * Create a next (or test) version of the project. If on master will * release to the default "next" branch. */ next(args: INextOptions): Promise; /** Force a release to latest and bypass `shipit` safeguards. */ latest(args?: IShipItOptions): Promise; /** * Run the full workflow. * * 1. Calculate version * 2. Make changelog * 3. Publish code * 4. Create a release */ shipit(args?: 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; /** Make a release to an old version */ private oldRelease; /** Publish a new version with changelog, publish, and release */ private publishFullRelease; /** 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 */ getVersion({ from }?: IVersionOptions): Promise; /** 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; /** Get the current git user */ private getGitUser; /** * Set the git user to make releases and commit with. */ setGitUser(): Promise; /** Get the repo to interact with */ private getRepo; /** Find the location of the extended configuration */ private getExtendedLocation; /** * Apply all of the plugins in the config. */ private loadPlugins; /** Get the branch and build number when in CI environment */ private getPrEnvInfo; /** Get the default for a command from the config */ private getCommandDefault; } export * from "./auto-args"; export { default as InteractiveInit } from "./init"; export { getCurrentBranch } from "./utils/get-current-branch"; export { validatePluginConfiguration } from "./validate-config"; 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 { default as getLernaPackages } from "./utils/get-lerna-packages"; export { default as inFolder } from "./utils/in-folder"; export { VersionLabel } from "./release"; //# sourceMappingURL=auto.d.ts.map