UNPKG

4.61 kBTypeScriptView Raw
1import cosmiconfig from 'cosmiconfig';
2import { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } from 'tapable';
3import { ArgsType, IChangelogOptions, ICommentCommandOptions, ICreateLabelsCommandOptions, IInitCommandOptions, ILabelCommandOptions, IPRCheckCommandOptions, IPRCommandOptions, IReleaseCommandOptions, IShipItCommandOptions } from './cli/args';
4import Changelog from './changelog';
5import Git from './git';
6import LogParse, { IExtendedCommit } from './log-parse';
7import Release, { ILabelDefinitionMap, IReleaseOptions, VersionLabel } from './release';
8import SEMVER from './semver';
9import { ILogger } from './utils/logger';
10interface IAuthor {
11 name?: string;
12 email?: string;
13}
14interface IRepository {
15 owner?: string;
16 repo?: string;
17 token?: string;
18}
19export interface IAutoHooks {
20 beforeRun: SyncHook<[IReleaseOptions]>;
21 beforeShipIt: SyncHook<[]>;
22 afterShipIt: AsyncParallelHook<[string | undefined, IExtendedCommit[]]>;
23 getAuthor: AsyncSeriesBailHook<[], IAuthor | void>;
24 getPreviousVersion: AsyncSeriesBailHook<[(release: string) => string], string>;
25 getRepository: AsyncSeriesBailHook<[], IRepository | void>;
26 onCreateRelease: SyncHook<[Release]>;
27 onCreateLogParse: SyncHook<[LogParse]>;
28 onCreateChangelog: SyncHook<[Changelog]>;
29 version: AsyncParallelHook<[SEMVER]>;
30 afterVersion: AsyncParallelHook<[]>;
31 publish: AsyncParallelHook<[SEMVER]>;
32 afterPublish: AsyncParallelHook<[]>;
33}
34export default class Auto {
35 hooks: IAutoHooks;
36 logger: ILogger;
37 args: ArgsType;
38 release?: Release;
39 git?: Git;
40 labels?: ILabelDefinitionMap;
41 semVerLabels?: Map<VersionLabel, string>;
42 constructor(args: ArgsType);
43 /**
44 * Loads a config from a path, package name, or special `auto-config` pattern
45 *
46 * ex: auto-config-MY_CONFIG
47 * ex: @MY_CONFIG/auto-config
48 *
49 * @param extend Path or name of config to find
50 */
51 loadExtendConfig(extend: string): cosmiconfig.Config;
52 /**
53 * Load the .autorc from the file system, set up defaults, combine with CLI args
54 * load the extends property, load the plugins and start the git remote interface.
55 */
56 loadConfig(): Promise<void>;
57 /**
58 * Interactive prompt for initializing an .autorc
59 */
60 init(options?: IInitCommandOptions): Promise<void>;
61 /**
62 * Create all of the user's labels on the git remote if the don't already exist
63 *
64 * @param options Options for the createLabels functionality
65 */
66 createLabels(options?: ICreateLabelsCommandOptions): Promise<void>;
67 /**
68 * Get the labels on a specific PR. Defaults to the labels of the last merged PR
69 *
70 * @param options Options for the createLabels functionality
71 */
72 label({ pr }?: ILabelCommandOptions): Promise<void>;
73 /**
74 * Create a status on a PR.
75 *
76 * @param options Options for the pr status functionality
77 */
78 pr({ dryRun, pr, url, ...options }: IPRCommandOptions): Promise<void>;
79 /**
80 * Check that a PR has a SEMVER label. Set a success status on the PR.
81 *
82 * @param options Options for the pr check functionality
83 */
84 prCheck({ dryRun, pr, url, ...options }: IPRCheckCommandOptions): Promise<void>;
85 /**
86 * Comment on a PR. Only one comment will be present on the PR, Older comments are removed.
87 * You can use the "context" option to multiple comments on a PR.
88 *
89 * @param options Options for the comment functionality
90 */
91 comment({ message, pr, context, dryRun }: ICommentCommandOptions): Promise<void>;
92 /**
93 * Calculate the version bump for the current state of the repository.
94 */
95 version(): Promise<void>;
96 /**
97 * Calculate the the changelog and commit it.
98 */
99 changelog(options?: IChangelogOptions): Promise<void>;
100 /**
101 * Make a release to the git remote with the changes.
102 */
103 runRelease(options: IReleaseCommandOptions): Promise<void>;
104 /**
105 * Run the full workflow.
106 *
107 * 1. Calculate version
108 * 2. Make changelog
109 * 3. Publish code
110 * 4. Create a release
111 */
112 shipit(options: IShipItCommandOptions): Promise<void>;
113 private startGit;
114 private getVersion;
115 private getCurrentVersion;
116 private makeChangelog;
117 private makeRelease;
118 private readonly prefixRelease;
119 private createErrorMessage;
120 /**
121 * Set the git user to make releases and commit with.
122 */
123 private setGitUser;
124 private getRepo;
125 /**
126 * Apply all of the plugins in the config.
127 */
128 private loadPlugins;
129}
130export {};