Skip to content

Commit

Permalink
feat: add Typescript type for config (closes release-it#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCampionJr committed Nov 19, 2023
1 parent e178adf commit 06c55b0
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const searchPlaces = [
'package.json',
'.release-it.json',
'.release-it.js',
'.release-it.ts',
'.release-it.cjs',
'.release-it.yaml',
'.release-it.yml',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"lib",
"test"
],
"types": "./types/index.d.ts",
"scripts": {
"knip": "knip",
"lint": "eslint lib test",
Expand Down
183 changes: 183 additions & 0 deletions types/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
import { Hooks } from './hooks';

export interface Config {
hooks?: Hooks;

plugins?: Record<string, Record<string, any>>;

git?: {
/** @default "git log --pretty=format:\"* %s (%h)\" ${from}...${to}" */
changelog?: string;

/** @default true */
requireCleanWorkingDir?: boolean;

/** @default false */
requireBranch?: boolean;

/** @default true */
requireUpstream?: boolean;

/** @default false */
requireCommits?: boolean;

/** @default true */
requireCommitsFail?: boolean;

/** @default "" */
commitsPath?: string;

/** @default false */
addUntrackedFiles?: boolean;

/** @default true */
commit?: boolean;

/** @default "Release ${version}" */
commitMessage?: string;

commitArgs?: Array<any>;

/** @default true */
tag?: boolean;

/** @default null */
tagExclude?: any;

/** @default null */
tagName?: any;

/** @default null */
tagMatch?: any;

/** @default false */
getLatestTagFromAllRefs?: boolean;

/** @default "Release ${version}" */
tagAnnotation?: string;

tagArgs?: Array<any>;

/** @default true */
push?: boolean;

/** @default ["--follow-tags"] */
pushArgs?: Array<string>;

/** @default "" */
pushRepo?: string;
};

npm?: {
/** @default true */
publish?: boolean;

/** @default "." */
publishPath?: string;

publishArgs?: Array<any>;

/** @default null */
tag?: any;

/** @default null */
otp?: any;

/** @default false */
ignoreVersion?: boolean;

/** @default false */
allowSameVersion?: boolean;

versionArgs?: Array<any>;

/** @default false */
skipChecks?: boolean;

/** @default 10 */
timeout?: number;
};

github?: {
/** @default false */
release?: boolean;

/** @default "Release ${version}" */
releaseName?: string;

/** @default null */
releaseNotes?: any;

/** @default false */
autoGenerate?: boolean;

/** @default false */
preRelease?: boolean;

/** @default false */
draft?: boolean;

/** @default "GITHUB_TOKEN" */
tokenRef?: string;

/** @default null */
assets?: any;

/** @default null */
host?: any;

/** @default 0 */
timeout?: number;

/** @default null */
proxy?: any;

/** @default false */
skipChecks?: boolean;

/** @default false */
web?: boolean;

comments?: {
/** @default false */
submit?: boolean;

/** @default ":rocket?: _This issue has been resolved in v${version}. See [${releaseName}](${releaseUrl}) for release notes._" */
issue?: string;

/** @default ":rocket?: _This pull request is included in v${version}. See [${releaseName}](${releaseUrl}) for release notes._" */
pr?: string;
};
};

gitlab?: {
/** @default false */
release?: boolean;

/** @default "Release ${version}" */
releaseName?: string;

/** @default null */
releaseNotes?: any;

milestones?: Array<any>;

/** @default "GITLAB_TOKEN" */
tokenRef?: string;

/** @default "Private-Token" */
tokenHeader?: string;

/** @default null */
certificateAuthorityFile?: any;

/** @default null */
assets?: any;

/** @default null */
origin?: any;

/** @default false */
skipChecks?: boolean;
};
}
47 changes: 47 additions & 0 deletions types/hooks.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export type HookPrefix = 'before' | 'after';
export type InternalPlugin = 'version' | 'git' | 'npm' | 'github' | 'gitlab';
export type HookName = 'init' | 'bump' | 'release';

export type Hooks = {
['before:init']?: string | string[];
['before:bump']?: string | string[];
['before:release']?: string | string[];
['after:init']?: string | string[];
['after:bump']?: string | string[];
['after:release']?: string | string[];

['before:version:init']?: string | string[];
['before:version:bump']?: string | string[];
['before:version:release']?: string | string[];
['after:version:init']?: string | string[];
['after:version:bump']?: string | string[];
['after:version:release']?: string | string[];

['before:git:init']?: string | string[];
['before:git:bump']?: string | string[];
['before:git:release']?: string | string[];
['after:git:init']?: string | string[];
['after:git:bump']?: string | string[];
['after:git:release']?: string | string[];

['before:npm:init']?: string | string[];
['before:npm:bump']?: string | string[];
['before:npm:release']?: string | string[];
['after:npm:init']?: string | string[];
['after:npm:bump']?: string | string[];
['after:npm:release']?: string | string[];

['before:github:init']?: string | string[];
['before:github:bump']?: string | string[];
['before:github:release']?: string | string[];
['after:github:init']?: string | string[];
['after:github:bump']?: string | string[];
['after:github:release']?: string | string[];

['before:gitlab:init']?: string | string[];
['before:gitlab:bump']?: string | string[];
['before:gitlab:release']?: string | string[];
['after:gitlab:init']?: string | string[];
['after:gitlab:bump']?: string | string[];
['after:gitlab:release']?: string | string[];
};
3 changes: 3 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module 'release-it';

export type { Config } from './config.d';

0 comments on commit 06c55b0

Please sign in to comment.