autorel 2.3.1 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -57,20 +57,22 @@ async function autorel(args) {
57
57
  }
58
58
  const commitTypeMap = new Map(args.commitTypes.map((type) => [type.type, type]));
59
59
  git.gitFetch();
60
- const latestTags = git.getLatestTags();
61
- const latestTag = semver.latestTag(latestTags);
62
- const lastStableTag = semver.latestStableTag(latestTags);
63
- const lastChannelTag = prereleaseChannel
64
- ? semver.latestChannelTag(latestTags, prereleaseChannel)
60
+ const recentTags = git.getRecentTags();
61
+ const highestTag = semver.highestTag(recentTags);
62
+ const highestStableTag = semver.highestStableTag(recentTags);
63
+ const highestChannelTag = prereleaseChannel
64
+ ? semver.highestChannelTag(recentTags, prereleaseChannel)
65
65
  : undefined;
66
66
  // Determine the starting Git tag to compare against when generating
67
67
  // release notes or changelogs (i.e. the point “since” which to find commits).
68
- // If a pre-release channel is specified and a last channel tag exists,
69
- // use the last channel tag. Otherwise, use the last stable tag.
70
- const tagFromWhichToFindCommits = lastChannelTag ?? lastStableTag;
71
- !!lastChannelTag && logger_1.default.info(`The last pre-release channel version (${prereleaseChannel}) is: ${(0, colorette_1.bold)(lastChannelTag)}`);
72
- logger_1.default.info(`The last stable/production version is: ${lastStableTag ? (0, colorette_1.bold)(lastStableTag) : (0, colorette_1.gray)('none')}`);
73
- logger_1.default.info(`The current/highest version is: ${latestTag ? (0, colorette_1.bold)(latestTag) : (0, colorette_1.gray)('none')}`);
68
+ // If a pre-release channel is specified, and that channel has a tag, and
69
+ // it is higher than the stable tag, use that tag. Otherwise, use the stable tag.
70
+ const tagFromWhichToFindCommits = highestChannelTag
71
+ ? semver.highestTag([highestChannelTag, highestStableTag ?? 'v0.0.0'])
72
+ : highestStableTag;
73
+ !!highestChannelTag && logger_1.default.info(`The last pre-release channel version (${prereleaseChannel}) is: ${(0, colorette_1.bold)(highestChannelTag)}`);
74
+ logger_1.default.info(`The last stable/production version is: ${highestStableTag ? (0, colorette_1.bold)(highestStableTag) : (0, colorette_1.gray)('none')}`);
75
+ logger_1.default.info(`The current/highest version is: ${highestTag ? (0, colorette_1.bold)(highestTag) : (0, colorette_1.gray)('none')}`);
74
76
  logger_1.default.info(`Fetching commits since ${tagFromWhichToFindCommits ?? 'the beginning of the repository'}...`);
75
77
  const commits = git.getCommitsFromTag(tagFromWhichToFindCommits);
76
78
  logger_1.default.info(`Found ${(0, colorette_1.bold)(commits.length.toString())} commit(s).`);
@@ -102,11 +104,11 @@ async function autorel(args) {
102
104
  const nextTag = args.useVersion
103
105
  ? `v${args.useVersion}`
104
106
  : semver.toTag(semver.incrVer({
105
- latestVer: semver.fromTag(latestTag || 'v0.0.0'),
106
- latestStableVer: semver.fromTag(lastStableTag || 'v0.0.0'),
107
+ latestVer: semver.fromTag(highestTag || 'v0.0.0'),
108
+ latestStableVer: semver.fromTag(highestStableTag || 'v0.0.0'),
107
109
  releaseType,
108
110
  prereleaseChannel,
109
- latestChannelVer: lastChannelTag ? semver.fromTag(lastChannelTag) ?? undefined : undefined,
111
+ latestChannelVer: highestChannelTag ? semver.fromTag(highestChannelTag) ?? undefined : undefined,
110
112
  }));
111
113
  const changelog = (0, changelog_1.generateChangelog)(parsedCommits, commitTypeMap, args.breakingChangeTitle);
112
114
  logger_1.default.info(`The next version is: ${(0, colorette_1.bold)(nextTag)}`);
@@ -11,9 +11,18 @@ export declare function compareVersions(version1: SemVer, version2: SemVer): num
11
11
  * Returns the highest version of two SemVer objects (nomalized).
12
12
  */
13
13
  export declare function highestVersion(version1: SemVer, version2: SemVer): SemVer;
14
- export declare function latestTag(tags: string[]): string | undefined;
15
- export declare function latestChannelTag(tags: string[], channel: string): string | undefined;
16
- export declare function latestStableTag(tags: string[]): string | undefined;
14
+ /**
15
+ * Returns the tag with the highest version.
16
+ */
17
+ export declare function highestTag(tags: string[]): string | undefined;
18
+ /**
19
+ * Returns the tag with the highest version for a specific channel.
20
+ */
21
+ export declare function highestChannelTag(tags: string[], channel: string): string | undefined;
22
+ /**
23
+ * Returns the tag with the highest version that does not have a channel.
24
+ */
25
+ export declare function highestStableTag(tags: string[]): string | undefined;
17
26
  /**
18
27
  * Returns the raw tag string with the highest version.
19
28
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.highest = exports.latestStableTag = exports.latestChannelTag = exports.latestTag = exports.highestVersion = exports.compareVersions = void 0;
3
+ exports.highest = exports.highestStableTag = exports.highestChannelTag = exports.highestTag = exports.highestVersion = exports.compareVersions = void 0;
4
4
  const parse_1 = require("./parse");
5
5
  /**
6
6
  * Compares two versions and returns:
@@ -52,29 +52,38 @@ function highestVersion(version1, version2) {
52
52
  return (0, parse_1.normalizeVer)(comparison > 0 ? version1 : version2);
53
53
  }
54
54
  exports.highestVersion = highestVersion;
55
- function latestTag(tags) {
55
+ /**
56
+ * Returns the tag with the highest version.
57
+ */
58
+ function highestTag(tags) {
56
59
  const parsed = (0, parse_1.parseTags)(tags);
57
60
  if (parsed.length === 0)
58
61
  return undefined;
59
62
  return highest(parsed).raw;
60
63
  }
61
- exports.latestTag = latestTag;
62
- function latestChannelTag(tags, channel) {
64
+ exports.highestTag = highestTag;
65
+ /**
66
+ * Returns the tag with the highest version for a specific channel.
67
+ */
68
+ function highestChannelTag(tags, channel) {
63
69
  const parsed = (0, parse_1.parseTags)(tags)
64
70
  .filter((entry) => entry.version.channel === channel);
65
71
  if (parsed.length === 0)
66
72
  return undefined;
67
73
  return highest(parsed).raw;
68
74
  }
69
- exports.latestChannelTag = latestChannelTag;
70
- function latestStableTag(tags) {
75
+ exports.highestChannelTag = highestChannelTag;
76
+ /**
77
+ * Returns the tag with the highest version that does not have a channel.
78
+ */
79
+ function highestStableTag(tags) {
71
80
  const parsed = (0, parse_1.parseTags)(tags)
72
81
  .filter((entry) => !entry.version.channel);
73
82
  if (parsed.length === 0)
74
83
  return undefined;
75
84
  return highest(parsed).raw;
76
85
  }
77
- exports.latestStableTag = latestStableTag;
86
+ exports.highestStableTag = highestStableTag;
78
87
  /**
79
88
  * Returns the raw tag string with the highest version.
80
89
  */
@@ -4,7 +4,11 @@ export type Commit = {
4
4
  };
5
5
  export declare function gitFetch(): void;
6
6
  export declare function createAndPushTag(tag: string): void;
7
- export declare function getLatestTags(): string[];
7
+ /**
8
+ * Returns the most recent 100 tags in the repository loosely sorted by version
9
+ * (does not take into account pre-release tags).
10
+ */
11
+ export declare function getRecentTags(): string[];
8
12
  export declare function getRepo(): {
9
13
  owner: string;
10
14
  repository: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCurrentBranch = exports.getCommitsFromTag = exports.getRepo = exports.getLatestTags = exports.createAndPushTag = exports.gitFetch = void 0;
3
+ exports.getCurrentBranch = exports.getCommitsFromTag = exports.getRepo = exports.getRecentTags = exports.createAndPushTag = exports.gitFetch = void 0;
4
4
  const sh_1 = require("./sh");
5
5
  function gitFetch() {
6
6
  (0, sh_1.$) `git fetch`;
@@ -11,11 +11,15 @@ function createAndPushTag(tag) {
11
11
  (0, sh_1.$) `git push origin ${tag}`;
12
12
  }
13
13
  exports.createAndPushTag = createAndPushTag;
14
- function getLatestTags() {
14
+ /**
15
+ * Returns the most recent 100 tags in the repository loosely sorted by version
16
+ * (does not take into account pre-release tags).
17
+ */
18
+ function getRecentTags() {
15
19
  const tags = (0, sh_1.$) `git tag --sort=-v:refname | head -n 100`;
16
20
  return tags.split('\n').filter((tag) => tag.trim() !== '');
17
21
  }
18
- exports.getLatestTags = getLatestTags;
22
+ exports.getRecentTags = getRecentTags;
19
23
  function getRepo() {
20
24
  if (process.env.GITHUB_REPOSITORY) {
21
25
  const [owner, repository] = process.env.GITHUB_REPOSITORY.split('/');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autorel",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Automate semantic releases based on conventional commits. Similar to semantic-release but much simpler.",
5
5
  "license": "MIT",
6
6
  "author": "Marc H. Weiner <mhweiner234@gmail.com> (https://mhweiner.com)",