Skip to content

Commit

Permalink
chore: fix build issues of previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Sep 10, 2023
1 parent fe1dc29 commit e81e9bf
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 248 deletions.
Original file line number Diff line number Diff line change
@@ -1,81 +1,72 @@
diff --git a/index.d.ts b/index.d.ts
index 9c397f71d8ac6f192c1ac4c55c298badc9b9aadf..ae65e4582541ba84748953e55a4062b06532492c 100644
index 9c397f71d8ac6f192c1ac4c55c298badc9b9aadf..df834f4d83713cc2df2f0b4ddfb4c36be62e59a0 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -1,4 +1,4 @@
@@ -1,6 +1,7 @@
-// Type definitions for conventional-recommended-bump 6.1
+// Type definitions for conventional-recommended-bump 9.0
// Project: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-recommended-bump#readme
// Definitions by: Jason Kwok <https://github.com/JasonHK>
+// Jeroen "Favna" Claassens <https://github.com/favna>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -17,7 +17,7 @@ import { Commit, Options as ParserOptions } from "conventional-commits-parser";
* * `whatBump`
* @param callback
*/
-declare function conventionalRecommendedBump(options: Options, callback: Callback): void;
+declare function conventionalRecommendedBump(options: Options): Promise<void>;
// TypeScript Version: 2.9

@@ -10,27 +11,18 @@ import { Commit, Options as ParserOptions } from "conventional-commits-parser";

/**
* @param options `options` is an object with the following properties:
@@ -30,9 +30,29 @@ declare function conventionalRecommendedBump(options: Options, callback: Callbac
* @param options `options` is an object with the following properties:
- *
* * `ignoreReverted`
* * `preset`
* * `config`
* * `whatBump`
- * @param callback
- */
-declare function conventionalRecommendedBump(options: Options, callback: Callback): void;
-
-/**
- * @param options `options` is an object with the following properties:
- *
- * * `ignoreReverted`
- * * `preset`
- * * `config`
- * * `whatBump`
- * @param parserOpts See the [conventional-commits-parser](https://github.com/conventional-changelog/conventional-commits-parser)
+ * * `tagPrefix`
+ * * `skipUnstable`
+ * * `lernaPackage`
+ * * `path`
+ * @param parserOpts See the [conventional-commits-parser](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser)
* documentation for available options.
* @param callback
- * @param callback
*/
-declare function conventionalRecommendedBump(options: Options, parserOpts: ParserOptions, callback: Callback): void;
+declare function conventionalRecommendedBump(
+ options: Options,
+ parserOpts: ParserOptions
+): Promise<void>;
+declare function conventionalRecommendedBump(options: Options, parserOpts?: ParserOptions): Promise<Recommendation>;

declare namespace conventionalRecommendedBump {
+ /**
+ * `recommendation` is an `object` with a single property, `releaseType`.
+ *
+ * `releaseType` is a `string`: Possible values: `major`, `minor` and `patch`,
+ * or `undefined` if `whatBump` does not return a valid `level` property, or
+ * the `level` property is not set by `whatBump`.
+ */
+ interface Callback {
+ /**
+ * @param error
+ * @param recommendation `recommendation` is an `object` with a single property,
+ * `releaseType`.
+ */
+ (error: any, recommendation: Callback.Recommendation): void;
+ }
+
+ namespace Callback {
/**
* `recommendation` is an `object` with a single property, `releaseType`.
*
@@ -40,134 +60,117 @@ declare namespace conventionalRecommendedBump {
@@ -40,35 +32,17 @@ declare namespace conventionalRecommendedBump {
* or `undefined` if `whatBump` does not return a valid `level` property, or
* the `level` property is not set by `whatBump`.
*/
- interface Callback {
- /**
+ interface Recommendation extends Options.WhatBump.Result {
/**
- * @param error
- * @param recommendation `recommendation` is an `object` with a single property,
- * `releaseType`.
- */
- (error: any, recommendation: Callback.Recommendation): void;
+ interface Recommendation extends Options.WhatBump.Result {
+ /**
+ * `releaseType` is a `string`: Possible values: `major`, `minor` and `patch`,
+ * or `undefined` if `whatBump` does not return a valid `level` property, or
+ * the `level` property is not set by `whatBump`.
+ */
+ releaseType?: Recommendation.ReleaseType | undefined;
}

- }
-
- namespace Callback {
- /**
- * `recommendation` is an `object` with a single property, `releaseType`.
- *
- * `releaseType` is a `string`: Possible values: `major`, `minor` and `patch`,
- * or `undefined` if `whatBump` does not return a valid `level` property, or
- * the `level` property is not set by `whatBump`.
- */
* `releaseType` is a `string`: Possible values: `major`, `minor` and `patch`,
* or `undefined` if `whatBump` does not return a valid `level` property, or
* the `level` property is not set by `whatBump`.
*/
- interface Recommendation extends Options.WhatBump.Result {
- /**
- * `releaseType` is a `string`: Possible values: `major`, `minor` and `patch`,
Expand All @@ -84,204 +75,34 @@ index 9c397f71d8ac6f192c1ac4c55c298badc9b9aadf..ae65e4582541ba84748953e55a4062b0
- */
- releaseType?: Recommendation.ReleaseType | undefined;
- }
-
+ releaseType?: Recommendation.ReleaseType | undefined;
+ }

- namespace Recommendation {
- type ReleaseType = "major" | "minor" | "patch";
- }
+ namespace Recommendation {
+ type ReleaseType = "major" | "minor" | "patch";
+ type ReleaseType = 'major' | 'minor' | 'patch';
}
+ }
+
+ /**
+ * `options` is an object with the following properties:
+ * * `ignoreReverted`
+ * * `preset`
+ * * `config`
+ * * `whatBump`
+ */
+ interface Options {
+ /**
+ * If `true`, reverted commits will be ignored.
+ *
+ * @default
+ * true
+ */
+ ignoreReverted?: boolean | undefined;

/**
- * `options` is an object with the following properties:
- * * `ignoreReverted`
- * * `preset`
- * * `config`
- * * `whatBump`
+ * It's recommended to use a preset so you don't have to define everything
+ * yourself.
+ *
+ * The value is passed to [`conventional-changelog-preset-loader`](https://www.npmjs.com/package/conventional-changelog-preset-loader).
@@ -77,6 +51,10 @@ declare namespace conventionalRecommendedBump {
* * `preset`
* * `config`
* * `whatBump`
+ * * `tagPrefix`
+ * * `skipUnstable`
+ * * `lernaPackage`
+ * * `path`
*/
- interface Options {
- /**
- * If `true`, reverted commits will be ignored.
- *
- * @default
- * true
- */
- ignoreReverted?: boolean | undefined;
-
- /**
- * It's recommended to use a preset so you don't have to define everything
- * yourself.
- *
- * The value is passed to [`conventional-changelog-preset-loader`](https://www.npmjs.com/package/conventional-changelog-preset-loader).
- */
- preset?: string | undefined;
-
- /**
- * This should serve as default values for other arguments of
- * `conventional-recommended-bump` so you don't need to rewrite the same or
- * similar config across your projects.
- *
- * @remarks
- * `config` option will be overwritten by the value loaded by
- * `conventional-changelog-preset-loader` if the `preset` options is set.
- */
- config?: CoreOptions.Config<Commit, WriterContext> | undefined;
-
- /**
- * A function that takes parsed commits as an argument.
- *
- * ```
- * whatBump(commits) {};
- * ```
- *
- * `commits` is an array of all commits from last semver tag to `HEAD` as parsed
- * by `conventional-commits-parser`.
- *
- * This should return an object including but not limited to `level` and `reason`.
- * `level` is a `number` indicating what bump it should be and `reason` is the
- * reason of such release.
- */
- whatBump?: Options.WhatBump | undefined;
-
- /**
- * Specify a prefix for the git tag that will be taken into account during the
- * comparison.
- *
- * For instance if your version tag is prefixed by `version/` instead of `v` you
- * would specifying `--tagPrefix=version/` using the CLI, or `version/` as the
- * value of the `tagPrefix` option.
- */
- tagPrefix?: string | undefined;
-
- /**
- * If given, unstable tags (e.g. `x.x.x-alpha.1`, `x.x.x-rc.2`) will be skipped.
- */
- skipUnstable?: boolean | undefined;
-
- /**
- * Specify the name of a package in a [Lerna](https://lernajs.io/)-managed
- * repository. The package name will be used when fetching all changes to a
- * package since the last time that package was released.
- *
- * For instance if your project contained a package named
- * `conventional-changelog`, you could have only commits that have happened
- * since the last release of `conventional-changelog` was tagged by
- * specifying `--lernaPackage=conventional-changelog` using the CLI, or
- * `conventional-changelog` as the value of the `lernaPackage` option.
- */
- lernaPackage?: string | undefined;
-
- /**
- * Specify the path to only calculate with git commits related to the path.
- * If you want to calculate recommended bumps of packages in a Lerna-managed
- * repository, path should be use along with lernaPackage for each of the package.
- */
- path?: string | undefined;
- }
+ preset?: string | undefined;
+
+ /**
+ * This should serve as default values for other arguments of
+ * `conventional-recommended-bump` so you don't need to rewrite the same or
+ * similar config across your projects.
+ *
+ * @remarks
+ * `config` option will be overwritten by the value loaded by
+ * `conventional-changelog-preset-loader` if the `preset` options is set.
+ */
+ config?: CoreOptions.Config<Commit, WriterContext> | undefined;
+
+ /**
+ * A function that takes parsed commits as an argument.
+ *
+ * ```
+ * whatBump(commits) {};
+ * ```
+ *
+ * `commits` is an array of all commits from last semver tag to `HEAD` as parsed
+ * by `conventional-commits-parser`.
+ *
+ * This should return an object including but not limited to `level` and `reason`.
+ * `level` is a `number` indicating what bump it should be and `reason` is the
+ * reason of such release.
+ */
+ whatBump?: Options.WhatBump | undefined;
+
+ /**
+ * Specify a prefix for the git tag that will be taken into account during the
+ * comparison.
+ *
+ * For instance if your version tag is prefixed by `version/` instead of `v` you
+ * would specifying `--tagPrefix=version/` using the CLI, or `version/` as the
+ * value of the `tagPrefix` option.
+ */
+ tagPrefix?: string | undefined;
+
+ /**
+ * If given, unstable tags (e.g. `x.x.x-alpha.1`, `x.x.x-rc.2`) will be skipped.
+ */
+ skipUnstable?: boolean | undefined;
+
+ /**
+ * Specify the name of a package in a [Lerna](https://lernajs.io/)-managed
+ * repository. The package name will be used when fetching all changes to a
+ * package since the last time that package was released.
+ *
+ * For instance if your project contained a package named
+ * `conventional-changelog`, you could have only commits that have happened
+ * since the last release of `conventional-changelog` was tagged by
+ * specifying `--lernaPackage=conventional-changelog` using the CLI, or
+ * `conventional-changelog` as the value of the `lernaPackage` option.
+ */
+ lernaPackage?: string | undefined;
+
+ /**
+ * Specify the path to only calculate with git commits related to the path.
+ * If you want to calculate recommended bumps of packages in a Lerna-managed
+ * repository, path should be use along with lernaPackage for each of the package.
+ */
+ path?: string | undefined;
+ }

- namespace Options {
- type WhatBump = (commits: Commit[]) => WhatBump.Result;
+ namespace Options {
+ type WhatBump = (commits: Commit[]) => WhatBump.Result;

- namespace WhatBump {
- interface Result {
- level?: number | undefined;
- reason?: string | undefined;
- }
- }
+ namespace WhatBump {
+ interface Result {
+ level?: number | undefined;
+ reason?: string | undefined;
+ }
interface Options {
/**
@@ -170,7 +148,7 @@ declare namespace conventionalRecommendedBump {
}
+ }
}

type Callback = conventionalRecommendedBump.Callback;
-type Callback = conventionalRecommendedBump.Callback;
+type Recommendation = conventionalRecommendedBump.Recommendation;
type Options = conventionalRecommendedBump.Options;

export = conventionalRecommendedBump;
4 changes: 2 additions & 2 deletions src/commands/bump-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { readPackageJson, writePackageJson } from '#lib/package-json-parser';
import { doActionAndLog, getReleaseType } from '#lib/utils';
import { isNullishOrEmpty } from '@sapphire/utilities';
import type { Options } from 'commander';
import type { Callback as ConventionalChangelogCallback } from 'conventional-recommended-bump';
import type { Recommendation } from 'conventional-recommended-bump';
import { join } from 'node:path';
import Semver from 'semver';

export function bumpVersion(options: Options, releaseType: ConventionalChangelogCallback.Recommendation.ReleaseType) {
export function bumpVersion(options: Options, releaseType: Recommendation.ReleaseType) {
return doActionAndLog('Bumping version in package.json', async () => {
const packageJsonPath = join(packageCwd, 'package.json');
const packageJsonContent = await readPackageJson(packageJsonPath);
Expand Down
8 changes: 3 additions & 5 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Result } from '@sapphire/result';
import { isFunction, isNullishOrEmpty, isThenable, type Awaitable } from '@sapphire/utilities';
import { cyan, green, red } from 'colorette';
import type { Options } from 'commander';
import type { Callback as ConventionalChangelogCallback } from 'conventional-recommended-bump';
import type { Recommendation } from 'conventional-recommended-bump';
import { load } from 'js-yaml';
import { execSync } from 'node:child_process';
import type { PathLike } from 'node:fs';
Expand Down Expand Up @@ -115,7 +115,5 @@ export function resolveTagTemplate(options: Options, newVersion: string) {
}

/** Resolves the release-as prefix */
export const getReleaseType = (
options: Options,
changelogResolvedReleaseType: ConventionalChangelogCallback.Recommendation.ReleaseType
): ReleaseType => ((Boolean(options.preid) ? 'pre' : '') + changelogResolvedReleaseType) as ReleaseType;
export const getReleaseType = (options: Options, changelogResolvedReleaseType: Recommendation.ReleaseType): ReleaseType =>
((Boolean(options.preid) ? 'pre' : '') + changelogResolvedReleaseType) as ReleaseType;
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,12 @@ __metadata:

"@types/conventional-recommended-bump@patch:@types/conventional-recommended-bump@npm%3A6.1.1#./.yarn/patches/@types-conventional-recommended-bump-npm-6.1.1-1c00ca9397.patch::locator=%40favware%2Fcliff-jumper%40workspace%3A.":
version: 6.1.1
resolution: "@types/conventional-recommended-bump@patch:@types/conventional-recommended-bump@npm%3A6.1.1#./.yarn/patches/@types-conventional-recommended-bump-npm-6.1.1-1c00ca9397.patch::version=6.1.1&hash=30e0ed&locator=%40favware%2Fcliff-jumper%40workspace%3A."
resolution: "@types/conventional-recommended-bump@patch:@types/conventional-recommended-bump@npm%3A6.1.1#./.yarn/patches/@types-conventional-recommended-bump-npm-6.1.1-1c00ca9397.patch::version=6.1.1&hash=ea038d&locator=%40favware%2Fcliff-jumper%40workspace%3A."
dependencies:
"@types/conventional-changelog-core": "*"
"@types/conventional-changelog-writer": "*"
"@types/conventional-commits-parser": "*"
checksum: 1d17cecd0dece83ae5f746847455d3392e3940efac067275dddad156cc04d26dfc3dac68c79bf69c6ec9f18924f7ff9283277e060006f3f470f20067450f0b9e
checksum: 0ae040203a86a6cf2069aa9af8eb9608796c709e24988ad3d6c2be738e3229f3ca9633c71c513b76d7d353e8579c3a253ed373e7990b37be827785eeb907a0d3
languageName: node
linkType: hard

Expand Down

0 comments on commit e81e9bf

Please sign in to comment.