autorel 2.3.1 → 2.3.3

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.
@@ -0,0 +1,2 @@
1
+ import { Config } from '.';
2
+ export declare function autorel(args: Config): Promise<string | undefined>;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.autorel = void 0;
30
+ /* eslint-disable max-lines-per-function */
31
+ const convCom = __importStar(require("./conventionalcommits"));
32
+ const git = __importStar(require("./services/git"));
33
+ const npm = __importStar(require("./services/npm"));
34
+ const changelog_1 = require("./changelog");
35
+ const github = __importStar(require("./services/github"));
36
+ const logger_1 = __importDefault(require("./lib/logger"));
37
+ const updatePackageJsonVersion_1 = require("./updatePackageJsonVersion");
38
+ const colorette_1 = require("colorette");
39
+ const getPrereleaseChannel_1 = require("./getPrereleaseChannel");
40
+ const getTags_1 = require("./getTags");
41
+ const validateUseVersion_1 = require("./validateUseVersion");
42
+ const getNextTag_1 = require("./getNextTag");
43
+ const runUserReleaseScripts_1 = require("./runUserReleaseScripts");
44
+ const runUserPrereleaseScripts_1 = require("./runUserPrereleaseScripts");
45
+ async function autorel(args) {
46
+ const prereleaseChannel = (0, getPrereleaseChannel_1.getPrereleaseChannel)(args);
47
+ if (args.dryRun) {
48
+ logger_1.default.warn('Running in dry-run mode. No changes will be made.');
49
+ }
50
+ if (prereleaseChannel && !args.useVersion) {
51
+ const stmt = `Using prerelease channel: ${(0, colorette_1.bold)(prereleaseChannel)}`;
52
+ logger_1.default.info(!args.useVersion ? stmt : (0, colorette_1.strikethrough)(stmt));
53
+ }
54
+ else {
55
+ const stmt = 'This is a production release.';
56
+ logger_1.default.info(!args.useVersion ? stmt : (0, colorette_1.strikethrough)(stmt));
57
+ }
58
+ git.gitFetch();
59
+ const { highestTag, highestChannelTag, highestStableTag, tagFromWhichToFindCommits, } = (0, getTags_1.getTags)(prereleaseChannel);
60
+ const commits = git.getCommitsFromTag(tagFromWhichToFindCommits);
61
+ logger_1.default.info(`Found ${(0, colorette_1.bold)(commits.length.toString())} commit(s).`);
62
+ const parsedCommits = commits.map((commit) => convCom.parseConventionalCommit(commit.message, commit.hash))
63
+ .filter((commit) => !!commit);
64
+ const commitTypeMap = new Map(args.commitTypes.map((type) => [type.type, type]));
65
+ const releaseType = convCom.determineReleaseType(parsedCommits, commitTypeMap);
66
+ const releaseTypeStr = (releaseType === 'none' && (0, colorette_1.gray)('none'))
67
+ || (releaseType === 'major' && (0, colorette_1.redBright)('major'))
68
+ || (releaseType === 'minor' && (0, colorette_1.yellowBright)('minor'))
69
+ || (releaseType === 'patch' && (0, colorette_1.greenBright)('patch'));
70
+ logger_1.default.info(`The release type is: ${(0, colorette_1.bold)(String(releaseTypeStr))}`);
71
+ if (releaseType === 'none' && !args.useVersion) {
72
+ logger_1.default.info('No release is needed. Have a nice day (^_^)/');
73
+ return;
74
+ }
75
+ (0, validateUseVersion_1.validateUseVersion)(args.useVersion, releaseType);
76
+ const nextTag = (0, getNextTag_1.getNextTag)({
77
+ releaseType,
78
+ highestTag,
79
+ highestStableTag,
80
+ highestChannelTag,
81
+ useVersion: args.useVersion,
82
+ prereleaseChannel,
83
+ });
84
+ const changelog = (0, changelog_1.generateChangelog)(parsedCommits, commitTypeMap, args.breakingChangeTitle);
85
+ logger_1.default.info(`The next version is: ${(0, colorette_1.bold)(nextTag)}`);
86
+ logger_1.default.debug(`The changelog is:\n${changelog}`);
87
+ if (args.dryRun)
88
+ return;
89
+ (0, runUserPrereleaseScripts_1.runUserPreleaseScripts)(args);
90
+ git.createAndPushTag(nextTag);
91
+ const { owner, repository } = git.getRepo();
92
+ // publish to GitHub
93
+ if (!args.skipRelease) {
94
+ github.createRelease({
95
+ token: process.env.GITHUB_TOKEN,
96
+ owner,
97
+ repository,
98
+ tag: nextTag,
99
+ name: nextTag,
100
+ body: changelog,
101
+ });
102
+ }
103
+ // publish to npm
104
+ if (args.publish) {
105
+ (0, updatePackageJsonVersion_1.updatePackageJsonVersion)(nextTag);
106
+ npm.publishPackage(prereleaseChannel);
107
+ }
108
+ // set env variables
109
+ process.env.NEXT_VERSION = nextTag.replace('v', '');
110
+ process.env.NEXT_TAG = nextTag;
111
+ (0, runUserReleaseScripts_1.runUserReleaseScripts)(args);
112
+ return nextTag.replace('v', '');
113
+ }
114
+ exports.autorel = autorel;
115
+ //# sourceMappingURL=autorel.js.map
@@ -0,0 +1,9 @@
1
+ import { ReleaseType } from './semver';
2
+ export declare function getNextTag({ highestTag, highestStableTag, highestChannelTag, useVersion, prereleaseChannel, releaseType, }: {
3
+ highestTag: string | undefined;
4
+ highestStableTag: string | undefined;
5
+ highestChannelTag: string | undefined;
6
+ useVersion: string | undefined;
7
+ prereleaseChannel: string | undefined;
8
+ releaseType: ReleaseType;
9
+ }): string;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getNextTag = void 0;
27
+ const semver = __importStar(require("./semver"));
28
+ function getNextTag({ highestTag, highestStableTag, highestChannelTag, useVersion, prereleaseChannel, releaseType, }) {
29
+ return useVersion
30
+ ? `v${useVersion}`
31
+ : semver.toTag(semver.incrVer({
32
+ latestVer: semver.fromTag(highestTag || 'v0.0.0'),
33
+ latestStableVer: semver.fromTag(highestStableTag || 'v0.0.0'),
34
+ releaseType,
35
+ prereleaseChannel,
36
+ latestChannelVer: highestChannelTag ? semver.fromTag(highestChannelTag) ?? undefined : undefined,
37
+ }));
38
+ }
39
+ exports.getNextTag = getNextTag;
40
+ //# sourceMappingURL=getNextTag.js.map
@@ -0,0 +1,6 @@
1
+ export declare function getTags(prereleaseChannel?: string): {
2
+ highestTag: string | undefined;
3
+ highestStableTag: string | undefined;
4
+ highestChannelTag: string | undefined;
5
+ tagFromWhichToFindCommits: string | undefined;
6
+ };
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.getTags = void 0;
30
+ const git = __importStar(require("./services/git"));
31
+ const semver = __importStar(require("./semver"));
32
+ const logger_1 = __importDefault(require("./lib/logger"));
33
+ const colorette_1 = require("colorette");
34
+ function getTags(prereleaseChannel) {
35
+ const recentTags = git.getRecentTags();
36
+ const highestTag = semver.highestTag(recentTags);
37
+ const highestStableTag = semver.highestStableTag(recentTags);
38
+ const highestChannelTag = prereleaseChannel
39
+ ? semver.highestChannelTag(recentTags, prereleaseChannel)
40
+ : undefined;
41
+ // Determine the starting Git tag to compare against when generating
42
+ // release notes or changelogs (i.e. the point “since” which to find commits).
43
+ // If a pre-release channel is specified, and that channel has a tag, and
44
+ // it is higher than the stable tag, use that tag. Otherwise, use the stable tag.
45
+ const tagFromWhichToFindCommits = highestChannelTag
46
+ ? semver.highestTag([highestChannelTag, highestStableTag ?? 'v0.0.0'])
47
+ : highestStableTag;
48
+ !!highestChannelTag && logger_1.default.info(`The last pre-release channel version (${prereleaseChannel}) is: ${(0, colorette_1.bold)(highestChannelTag)}`);
49
+ logger_1.default.info(`The last stable/production version is: ${highestStableTag ? (0, colorette_1.bold)(highestStableTag) : (0, colorette_1.gray)('none')}`);
50
+ logger_1.default.info(`The current/highest version is: ${highestTag ? (0, colorette_1.bold)(highestTag) : (0, colorette_1.gray)('none')}`);
51
+ logger_1.default.info(`Fetching commits since ${tagFromWhichToFindCommits ?? 'the beginning of the repository'}...`);
52
+ return {
53
+ highestTag,
54
+ highestStableTag,
55
+ highestChannelTag,
56
+ tagFromWhichToFindCommits,
57
+ };
58
+ }
59
+ exports.getTags = getTags;
60
+ //# sourceMappingURL=getTags.js.map
package/dist/index.d.ts CHANGED
@@ -20,6 +20,6 @@ export type Config = {
20
20
  commitTypes: CommitType[];
21
21
  branches: ReleaseBranch[];
22
22
  };
23
- export declare function autorel(args: Config): Promise<string | undefined>;
24
23
  export * from './defaults';
25
24
  export * from './config';
25
+ export * from './autorel';
package/dist/index.js CHANGED
@@ -10,147 +10,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
15
  };
28
- var __importDefault = (this && this.__importDefault) || function (mod) {
29
- return (mod && mod.__esModule) ? mod : { "default": mod };
30
- };
31
16
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.autorel = void 0;
33
- /* eslint-disable max-lines-per-function */
34
- const semver = __importStar(require("./semver"));
35
- const convCom = __importStar(require("./conventionalcommits"));
36
- const git = __importStar(require("./services/git"));
37
- const npm = __importStar(require("./services/npm"));
38
- const changelog_1 = require("./changelog");
39
- const github = __importStar(require("./services/github"));
40
- const logger_1 = __importDefault(require("./lib/logger"));
41
- const updatePackageJsonVersion_1 = require("./updatePackageJsonVersion");
42
- const sh_1 = require("./services/sh");
43
- const colorette_1 = require("colorette");
44
- const getPrereleaseChannel_1 = require("./getPrereleaseChannel");
45
- async function autorel(args) {
46
- const prereleaseChannel = (0, getPrereleaseChannel_1.getPrereleaseChannel)(args);
47
- if (args.dryRun) {
48
- logger_1.default.warn('Running in dry-run mode. No changes will be made.');
49
- }
50
- if (prereleaseChannel && !args.useVersion) {
51
- const stmt = `Using prerelease channel: ${(0, colorette_1.bold)(prereleaseChannel)}`;
52
- logger_1.default.info(!args.useVersion ? stmt : (0, colorette_1.strikethrough)(stmt));
53
- }
54
- else {
55
- const stmt = 'This is a production release.';
56
- logger_1.default.info(!args.useVersion ? stmt : (0, colorette_1.strikethrough)(stmt));
57
- }
58
- const commitTypeMap = new Map(args.commitTypes.map((type) => [type.type, type]));
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)
65
- : undefined;
66
- // Determine the starting Git tag to compare against when generating
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')}`);
74
- logger_1.default.info(`Fetching commits since ${tagFromWhichToFindCommits ?? 'the beginning of the repository'}...`);
75
- const commits = git.getCommitsFromTag(tagFromWhichToFindCommits);
76
- logger_1.default.info(`Found ${(0, colorette_1.bold)(commits.length.toString())} commit(s).`);
77
- const parsedCommits = commits.map((commit) => convCom.parseConventionalCommit(commit.message, commit.hash))
78
- .filter((commit) => !!commit);
79
- const releaseType = convCom.determineReleaseType(parsedCommits, commitTypeMap);
80
- const releaseTypeStr = (releaseType === 'none' && (0, colorette_1.gray)('none'))
81
- || (releaseType === 'major' && (0, colorette_1.redBright)('major'))
82
- || (releaseType === 'minor' && (0, colorette_1.yellowBright)('minor'))
83
- || (releaseType === 'patch' && (0, colorette_1.greenBright)('patch'));
84
- logger_1.default.info(`The release type is: ${(0, colorette_1.bold)(String(releaseTypeStr))}`);
85
- if (releaseType === 'none' && !args.useVersion) {
86
- logger_1.default.info('No release is needed. Have a nice day (^_^)/');
87
- return;
88
- }
89
- // Validate useVersion & log warnings
90
- if (args.useVersion) {
91
- if (/^v(.+)$/.test(args.useVersion))
92
- throw new Error('useVersion should not start with a "v".');
93
- if (!semver.isValidTag(args.useVersion))
94
- throw new Error('useVersion must be a valid SemVer version');
95
- if (releaseType === 'none') {
96
- logger_1.default.warn(`We didn't find any commmits that would create a release, but you have set 'useVersion', which will force a release as: ${(0, colorette_1.bold)(args.useVersion)}.`);
97
- }
98
- else {
99
- logger_1.default.warn(`The next version was explicitly set by useVersion to be: ${(0, colorette_1.bold)(args.useVersion)}.`);
100
- }
101
- }
102
- const nextTag = args.useVersion
103
- ? `v${args.useVersion}`
104
- : semver.toTag(semver.incrVer({
105
- latestVer: semver.fromTag(latestTag || 'v0.0.0'),
106
- latestStableVer: semver.fromTag(lastStableTag || 'v0.0.0'),
107
- releaseType,
108
- prereleaseChannel,
109
- latestChannelVer: lastChannelTag ? semver.fromTag(lastChannelTag) ?? undefined : undefined,
110
- }));
111
- const changelog = (0, changelog_1.generateChangelog)(parsedCommits, commitTypeMap, args.breakingChangeTitle);
112
- logger_1.default.info(`The next version is: ${(0, colorette_1.bold)(nextTag)}`);
113
- logger_1.default.debug(`The changelog is:\n${changelog}`);
114
- if (args.dryRun)
115
- return;
116
- if (args.preRun) {
117
- logger_1.default.info('Running pre-release bash script...');
118
- (0, sh_1.bash)(args.preRun);
119
- }
120
- git.createAndPushTag(nextTag);
121
- const { owner, repository } = git.getRepo();
122
- !args.skipRelease && github.createRelease({
123
- token: process.env.GITHUB_TOKEN,
124
- owner,
125
- repository,
126
- tag: nextTag,
127
- name: nextTag,
128
- body: changelog,
129
- });
130
- // publish to npm
131
- if (args.publish) {
132
- (0, updatePackageJsonVersion_1.updatePackageJsonVersion)(nextTag);
133
- npm.publishPackage(prereleaseChannel);
134
- }
135
- process.env.NEXT_VERSION = nextTag.replace('v', '');
136
- process.env.NEXT_TAG = nextTag;
137
- // run post-release bash script
138
- if (args.run) {
139
- logger_1.default.info('Running post-release bash script...');
140
- (0, sh_1.bash)(args.run);
141
- }
142
- else if (args.runScript) {
143
- // TODO: delete this block in the next major version
144
- logger_1.default.warn('----------------------------');
145
- logger_1.default.warn('🚨 The "runScript" option is deprecated. Please use "run" instead. 🚨');
146
- logger_1.default.warn('🚨 The "runScript" option will be removed in the next major version. 🚨');
147
- logger_1.default.warn('----------------------------');
148
- logger_1.default.info('Running post-release bash script...');
149
- (0, sh_1.bash)(args.runScript);
150
- }
151
- return nextTag.replace('v', '');
152
- }
153
- exports.autorel = autorel;
154
17
  __exportStar(require("./defaults"), exports);
155
18
  __exportStar(require("./config"), exports);
19
+ __exportStar(require("./autorel"), exports);
156
20
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import { Config } from '.';
2
+ export declare function runUserPreleaseScripts(args: Config): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runUserPreleaseScripts = void 0;
7
+ const logger_1 = __importDefault(require("./lib/logger"));
8
+ const sh_1 = require("./services/sh");
9
+ function runUserPreleaseScripts(args) {
10
+ if (args.dryRun)
11
+ return;
12
+ if (!args.preRun)
13
+ return;
14
+ logger_1.default.info('Running pre-release bash script...');
15
+ (0, sh_1.bash)(args.preRun);
16
+ }
17
+ exports.runUserPreleaseScripts = runUserPreleaseScripts;
18
+ //# sourceMappingURL=runUserPrereleaseScripts.js.map
@@ -0,0 +1,2 @@
1
+ import { Config } from '.';
2
+ export declare function runUserReleaseScripts(args: Config): void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runUserReleaseScripts = void 0;
7
+ const logger_1 = __importDefault(require("./lib/logger"));
8
+ const sh_1 = require("./services/sh");
9
+ function runUserReleaseScripts(args) {
10
+ if (args.dryRun)
11
+ return;
12
+ if (args.run) {
13
+ logger_1.default.info('Running post-release bash script...');
14
+ (0, sh_1.bash)(args.run);
15
+ }
16
+ else if (args.runScript) {
17
+ // TODO: delete this block in the next major version
18
+ logger_1.default.warn('----------------------------');
19
+ logger_1.default.warn('🚨 The "runScript" option is deprecated. Please use "run" instead. 🚨');
20
+ logger_1.default.warn('🚨 The "runScript" option will be removed in the next major version. 🚨');
21
+ logger_1.default.warn('----------------------------');
22
+ logger_1.default.info('Running post-release bash script...');
23
+ (0, sh_1.bash)(args.runScript);
24
+ }
25
+ }
26
+ exports.runUserReleaseScripts = runUserReleaseScripts;
27
+ //# sourceMappingURL=runUserReleaseScripts.js.map
@@ -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,12 @@ 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
+ export declare function deleteTagFromLocalAndRemote(tag: string): void;
8
+ /**
9
+ * Returns the most recent 100 tags in the repository loosely sorted by version
10
+ * (does not take into account pre-release tags).
11
+ */
12
+ export declare function getRecentTags(): string[];
8
13
  export declare function getRepo(): {
9
14
  owner: string;
10
15
  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.deleteTagFromLocalAndRemote = 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,20 @@ function createAndPushTag(tag) {
11
11
  (0, sh_1.$) `git push origin ${tag}`;
12
12
  }
13
13
  exports.createAndPushTag = createAndPushTag;
14
- function getLatestTags() {
14
+ function deleteTagFromLocalAndRemote(tag) {
15
+ (0, sh_1.$) `git tag -d ${tag}`;
16
+ (0, sh_1.$) `git push origin :refs/tags/${tag}`;
17
+ }
18
+ exports.deleteTagFromLocalAndRemote = deleteTagFromLocalAndRemote;
19
+ /**
20
+ * Returns the most recent 100 tags in the repository loosely sorted by version
21
+ * (does not take into account pre-release tags).
22
+ */
23
+ function getRecentTags() {
15
24
  const tags = (0, sh_1.$) `git tag --sort=-v:refname | head -n 100`;
16
25
  return tags.split('\n').filter((tag) => tag.trim() !== '');
17
26
  }
18
- exports.getLatestTags = getLatestTags;
27
+ exports.getRecentTags = getRecentTags;
19
28
  function getRepo() {
20
29
  if (process.env.GITHUB_REPOSITORY) {
21
30
  const [owner, repository] = process.env.GITHUB_REPOSITORY.split('/');
@@ -0,0 +1,2 @@
1
+ import { ReleaseType } from './semver';
2
+ export declare function validateUseVersion(useVersion: string | undefined, releaseType: ReleaseType): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validateUseVersion = void 0;
7
+ const colorette_1 = require("colorette");
8
+ const logger_1 = __importDefault(require("./lib/logger"));
9
+ const semver_1 = require("./semver");
10
+ function validateUseVersion(useVersion, releaseType) {
11
+ if (!useVersion)
12
+ return;
13
+ if (/^v(.+)$/.test(useVersion))
14
+ throw new Error('useVersion should not start with a "v".');
15
+ if (!(0, semver_1.isValidTag)(useVersion))
16
+ throw new Error('useVersion must be a valid SemVer version');
17
+ if (releaseType === 'none') {
18
+ logger_1.default.warn(`We didn't find any commmits that would create a release, but you have set 'useVersion', which will force a release as: ${(0, colorette_1.bold)(useVersion)}.`);
19
+ }
20
+ else {
21
+ logger_1.default.warn(`The next version was explicitly set by useVersion to be: ${(0, colorette_1.bold)(useVersion)}.`);
22
+ }
23
+ }
24
+ exports.validateUseVersion = validateUseVersion;
25
+ //# sourceMappingURL=validateUseVersion.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autorel",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
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)",