autorel 2.2.13 → 2.3.0-next.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/cli.js CHANGED
@@ -1,18 +1,14 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  const commander_1 = require("commander");
7
- const colors_1 = require("./lib/colors");
4
+ const colorette_1 = require("colorette");
8
5
  const _1 = require(".");
9
- const output_1 = __importDefault(require("./lib/output"));
10
6
  const config_1 = require("./config");
11
7
  // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
12
8
  const packageJson = require('../package.json');
13
9
  const program = new commander_1.Command();
14
10
  console.log('------------------------------');
15
- console.log(`${(0, colors_1.bold)('autorel')} ${(0, colors_1.grey)(`v${packageJson.version}`)}`);
11
+ console.log(`${(0, colorette_1.bold)((0, colorette_1.white)('autorel'))} ${(0, colorette_1.dim)(`v${packageJson.version}`)}`);
16
12
  console.log('------------------------------');
17
13
  program
18
14
  .version(packageJson.version, '-v, --version')
@@ -35,7 +31,6 @@ const cliOptions = {
35
31
  publish: options.publish,
36
32
  skipRelease: options.skipRelease,
37
33
  };
38
- output_1.default.debug(`CLI Options: ${JSON.stringify(cliOptions, null, 2)}`);
39
34
  // remove falsy values from the overrides
40
35
  if (cliOptions) {
41
36
  Object.keys(cliOptions).forEach((key) => (
@@ -43,6 +38,5 @@ if (cliOptions) {
43
38
  !cliOptions[key] && delete cliOptions[key]));
44
39
  }
45
40
  const config = (0, config_1.getConfig)(cliOptions);
46
- output_1.default.debug(`Config: ${JSON.stringify(config, null, 2)}`);
47
41
  (0, _1.autorel)(config);
48
42
  //# sourceMappingURL=cli.js.map
package/dist/config.js CHANGED
@@ -31,7 +31,7 @@ const fs = __importStar(require("node:fs"));
31
31
  const path = __importStar(require("node:path"));
32
32
  const yaml = __importStar(require("js-yaml"));
33
33
  const typura_1 = require("typura");
34
- const output_1 = __importDefault(require("./lib/output"));
34
+ const logger_1 = __importDefault(require("./lib/logger"));
35
35
  const defaults_1 = require("./defaults");
36
36
  const validateConfig = typura_1.predicates.object({
37
37
  dryRun: typura_1.predicates.optional(typura_1.predicates.boolean()),
@@ -62,37 +62,42 @@ function readAutorelYaml(filePath = '.autorel.yaml') {
62
62
  const absolutePath = path.resolve(filePath);
63
63
  // Check if the file exists
64
64
  if (!fs.existsSync(absolutePath)) {
65
- output_1.default.log('.autorel.yaml not found, using default configuration');
65
+ logger_1.default.info('.autorel.yaml not found, using default configuration');
66
66
  return {};
67
67
  }
68
68
  else {
69
- output_1.default.log('Using .autorel.yaml configuration');
69
+ logger_1.default.info('Using .autorel.yaml configuration');
70
70
  }
71
71
  const [readErr, fileContents] = (0, typura_1.toResult)(() => fs.readFileSync(absolutePath, 'utf8'));
72
72
  if (readErr) {
73
- output_1.default.error('Error reading .autorel.yaml file:');
73
+ logger_1.default.error('Error reading .autorel.yaml file:');
74
74
  throw readErr;
75
75
  }
76
76
  const [parseErr, parsedData] = (0, typura_1.toResult)(() => yaml.load(fileContents));
77
77
  if (parseErr) {
78
- output_1.default.error('Error parsing .autorel.yaml file:');
78
+ logger_1.default.error('Error parsing .autorel.yaml file:');
79
79
  throw parseErr;
80
80
  }
81
- const [validationErr] = (0, typura_1.toResult)(() => validateConfig(parsedData));
82
- if (validationErr instanceof typura_1.ValidationError) {
83
- output_1.default.error('Invalid configuration:');
84
- throw validationErr;
85
- }
86
81
  return parsedData;
87
82
  }
88
83
  function getConfig(overrides) {
89
84
  const yamlConfig = readAutorelYaml();
90
- output_1.default.debug(`Yaml: ${JSON.stringify(yamlConfig, null, 2)}`);
91
- return {
85
+ const mergedConfig = {
92
86
  ...defaults_1.defaultConfig,
93
87
  ...yamlConfig,
94
- ...overrides,
88
+ ...overrides ?? {},
95
89
  };
90
+ logger_1.default.debug('---\nConfig:');
91
+ logger_1.default.debug(`Default: ${JSON.stringify(defaults_1.defaultConfig, null, 2)}`);
92
+ logger_1.default.debug(`Yaml: ${JSON.stringify(yamlConfig, null, 2)}`);
93
+ logger_1.default.debug(`Overrides: ${JSON.stringify(overrides, null, 2)}`);
94
+ logger_1.default.debug('---');
95
+ const [validationErr] = (0, typura_1.toResult)(() => validateConfig(mergedConfig));
96
+ if (validationErr instanceof typura_1.ValidationError) {
97
+ logger_1.default.error('Invalid configuration:');
98
+ throw validationErr;
99
+ }
100
+ return mergedConfig;
96
101
  }
97
102
  exports.getConfig = getConfig;
98
103
  //# sourceMappingURL=config.js.map
@@ -1,35 +1,12 @@
1
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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.filterBreakingCommits = exports.groupCommits = exports.determineReleaseType = exports.parseConventionalCommit = void 0;
30
7
  const node_util_1 = require("node:util");
31
- const color = __importStar(require("./lib/colors"));
32
- const output_1 = __importDefault(require("./lib/output"));
8
+ const logger_1 = __importDefault(require("./lib/logger"));
9
+ const colorette_1 = require("colorette");
33
10
  // eslint-disable-next-line max-lines-per-function
34
11
  function parseConventionalCommit(commitMessage, hash) {
35
12
  const lines = commitMessage.split('\n');
@@ -84,17 +61,17 @@ function determineCommitReleaseType(commit, commitTypeMap) {
84
61
  }
85
62
  function determineReleaseType(commits, commitTypeMap) {
86
63
  const releaseTypes = commits.map((commit) => {
87
- output_1.default.debug('Analyzing commit:');
88
- output_1.default.debug((0, node_util_1.inspect)(commit, {
64
+ logger_1.default.debug('Analyzing commit:');
65
+ logger_1.default.debug((0, node_util_1.inspect)(commit, {
89
66
  depth: null,
90
67
  colors: false,
91
68
  }));
92
69
  const releaseType = determineCommitReleaseType(commit, commitTypeMap);
93
- const releaseTypeStr = (releaseType === 'none' && color.grey('none'))
94
- || (releaseType === 'major' && color.red('major'))
95
- || (releaseType === 'minor' && color.yellow('minor'))
96
- || (releaseType === 'patch' && color.green('patch'));
97
- output_1.default.debug(`Release type: ${releaseTypeStr}`);
70
+ const releaseTypeStr = (releaseType === 'none' && (0, colorette_1.dim)('none'))
71
+ || (releaseType === 'major' && (0, colorette_1.redBright)('major'))
72
+ || (releaseType === 'minor' && (0, colorette_1.yellowBright)('minor'))
73
+ || (releaseType === 'patch' && (0, colorette_1.greenBright)('patch'));
74
+ logger_1.default.debug(`Release type: ${releaseTypeStr}`);
98
75
  return releaseType;
99
76
  });
100
77
  if (releaseTypes.includes('major'))
@@ -0,0 +1,18 @@
1
+ import { Config } from '.';
2
+ /**
3
+ * Determines the prerelease channel to use for the current release.
4
+ *
5
+ * It follows this order of precedence:
6
+ * 1. Use `config.prereleaseChannel` if explicitly defined.
7
+ * 2. Otherwise, detect the current git branch and look for a matching entry
8
+ * in `config.branches` to infer the prerelease channel.
9
+ *
10
+ * Returns:
11
+ * - A string representing the prerelease channel (e.g. "alpha", "beta"), or
12
+ * - `undefined` if no channel is configured or matched.
13
+ *
14
+ * Throws:
15
+ * - If the current branch cannot be determined.
16
+ * - If `config.branches` is undefined or empty.
17
+ */
18
+ export declare function getPrereleaseChannel(config: Config): string | undefined;
@@ -0,0 +1,58 @@
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.getPrereleaseChannel = void 0;
27
+ const git = __importStar(require("./services/git"));
28
+ /**
29
+ * Determines the prerelease channel to use for the current release.
30
+ *
31
+ * It follows this order of precedence:
32
+ * 1. Use `config.prereleaseChannel` if explicitly defined.
33
+ * 2. Otherwise, detect the current git branch and look for a matching entry
34
+ * in `config.branches` to infer the prerelease channel.
35
+ *
36
+ * Returns:
37
+ * - A string representing the prerelease channel (e.g. "alpha", "beta"), or
38
+ * - `undefined` if no channel is configured or matched.
39
+ *
40
+ * Throws:
41
+ * - If the current branch cannot be determined.
42
+ * - If `config.branches` is undefined or empty.
43
+ */
44
+ function getPrereleaseChannel(config) {
45
+ if (config.prereleaseChannel)
46
+ return config.prereleaseChannel;
47
+ const branch = git.getCurrentBranch();
48
+ if (!branch)
49
+ throw new Error('Could not get the current branch. Please make sure you are in a git repository.');
50
+ if (!config.branches.length)
51
+ throw new Error('Branches are not defined in the configuration. See https://github.com/mhweiner/autorel?tab=readme-ov-file#configuration');
52
+ const matchingBranch = config.branches.find((b) => b.name === branch);
53
+ if (!matchingBranch)
54
+ return undefined;
55
+ return matchingBranch.prereleaseChannel || undefined;
56
+ }
57
+ exports.getPrereleaseChannel = getPrereleaseChannel;
58
+ //# sourceMappingURL=getPrereleaseChannel.js.map
package/dist/index.d.ts CHANGED
@@ -20,5 +20,4 @@ export type Config = {
20
20
  commitTypes: CommitType[];
21
21
  branches: ReleaseBranch[];
22
22
  };
23
- export declare function getPrereleaseChannel(config: Config): string | undefined;
24
23
  export declare function autorel(args: Config): Promise<string | undefined>;
package/dist/index.js CHANGED
@@ -26,110 +26,92 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.autorel = exports.getPrereleaseChannel = void 0;
29
+ exports.autorel = void 0;
30
30
  /* eslint-disable max-lines-per-function */
31
31
  const semver = __importStar(require("./semver"));
32
32
  const convCom = __importStar(require("./conventionalcommits"));
33
- const git = __importStar(require("./lib/git"));
34
- const npm = __importStar(require("./lib/npm"));
35
- const color = __importStar(require("./lib/colors"));
33
+ const git = __importStar(require("./services/git"));
34
+ const npm = __importStar(require("./services/npm"));
36
35
  const changelog_1 = require("./changelog");
37
36
  const github = __importStar(require("./services/github"));
38
- const output_1 = __importDefault(require("./lib/output"));
37
+ const logger_1 = __importDefault(require("./lib/logger"));
39
38
  const updatePackageJsonVersion_1 = require("./updatePackageJsonVersion");
40
- const sh_1 = require("./lib/sh");
41
- function getPrereleaseChannel(config) {
42
- if (config.prereleaseChannel)
43
- return config.prereleaseChannel;
44
- const branch = git.getCurrentBranch();
45
- if (!branch)
46
- throw new Error('Could not get the current branch. Please make sure you are in a git repository.');
47
- if (!config.branches || !config.branches.length)
48
- throw new Error('Branches are not defined in the configuration. See https://github.com/mhweiner/autorel?tab=readme-ov-file#configuration');
49
- const matchingBranch = config.branches.find((b) => b.name === branch);
50
- if (!matchingBranch)
51
- return undefined;
52
- return matchingBranch.prereleaseChannel || undefined;
53
- }
54
- exports.getPrereleaseChannel = getPrereleaseChannel;
39
+ const sh_1 = require("./services/sh");
40
+ const colorette_1 = require("colorette");
41
+ const getPrereleaseChannel_1 = require("./getPrereleaseChannel");
55
42
  async function autorel(args) {
56
- const prereleaseChannel = getPrereleaseChannel(args);
43
+ const prereleaseChannel = (0, getPrereleaseChannel_1.getPrereleaseChannel)(args);
57
44
  if (args.dryRun) {
58
- output_1.default.warn('Running in dry-run mode. No changes will be made.');
45
+ logger_1.default.warn('Running in dry-run mode. No changes will be made.');
59
46
  }
60
47
  if (prereleaseChannel && !args.useVersion) {
61
- const stmt = `Using prerelease channel: ${color.bold(prereleaseChannel)}`;
62
- output_1.default.log(!args.useVersion ? stmt : color.strikethrough(stmt));
48
+ const stmt = `Using prerelease channel: ${(0, colorette_1.bold)(prereleaseChannel)}`;
49
+ logger_1.default.info(!args.useVersion ? stmt : (0, colorette_1.strikethrough)(stmt));
63
50
  }
64
51
  else {
65
52
  const stmt = 'This is a production release.';
66
- output_1.default.log(!args.useVersion ? stmt : color.strikethrough(stmt));
53
+ logger_1.default.info(!args.useVersion ? stmt : (0, colorette_1.strikethrough)(stmt));
67
54
  }
68
55
  const commitTypeMap = new Map(args.commitTypes.map((type) => [type.type, type]));
69
- git.gitFetchTags(); // fetch latest tags from remote
70
- const lastChannelTag = prereleaseChannel ? git.getLastChannelTag(prereleaseChannel) : undefined;
71
- const lastStableTag = git.getLastStableTag();
72
- const highestTag = git.getHighestTag();
73
- // validate tags if they exist
74
- if (lastChannelTag && !semver.isValidTag(lastChannelTag))
75
- throw new Error(`Invalid last channel tag: ${lastChannelTag}`);
76
- if (lastStableTag && !semver.isValidTag(lastStableTag))
77
- throw new Error(`Invalid last stable tag: ${lastStableTag}`);
78
- if (highestTag && !semver.isValidTag(highestTag))
79
- throw new Error(`Invalid highest tag: ${highestTag}`);
80
- if (lastChannelTag && !highestTag)
81
- throw new Error('Last channel tag exists, but highest tag does not.');
82
- const tagFromWhichToFindCommits = prereleaseChannel && lastChannelTag
83
- ? semver.toTag(semver.highestVersion(semver.fromTag(lastChannelTag), semver.fromTag(lastStableTag ?? 'v0.0.0')))
84
- : lastStableTag;
85
- !!lastChannelTag && output_1.default.log(`The last pre-release channel version (${prereleaseChannel}) is: ${color.bold(lastChannelTag)}`);
86
- output_1.default.log(`The last stable/production version is: ${lastStableTag ? color.bold(lastStableTag) : color.grey('none')}`);
87
- output_1.default.log(`The current/highest version is: ${highestTag ? color.bold(highestTag) : color.grey('none')}`);
88
- output_1.default.log(`Fetching commits since ${tagFromWhichToFindCommits ?? 'the beginning of the repository'}...`);
56
+ git.gitFetch();
57
+ const latestTags = git.getLatestTags();
58
+ const latestTag = semver.latestTag(latestTags);
59
+ const lastStableTag = semver.latestStableTag(latestTags);
60
+ const lastChannelTag = prereleaseChannel
61
+ ? semver.latestChannelTag(latestTags, prereleaseChannel)
62
+ : undefined;
63
+ // Determine the starting Git tag to compare against when generating
64
+ // release notes or changelogs (i.e. the point “since” which to find commits).
65
+ // If a pre-release channel is specified and a last channel tag exists,
66
+ // use the last channel tag. Otherwise, use the last stable tag.
67
+ const tagFromWhichToFindCommits = lastChannelTag ?? lastStableTag;
68
+ !!lastChannelTag && logger_1.default.info(`The last pre-release channel version (${prereleaseChannel}) is: ${(0, colorette_1.bold)(lastChannelTag)}`);
69
+ logger_1.default.info(`The last stable/production version is: ${lastStableTag ? (0, colorette_1.bold)(lastStableTag) : (0, colorette_1.dim)('none')}`);
70
+ logger_1.default.info(`The current/highest version is: ${latestTag ? (0, colorette_1.bold)(latestTag) : (0, colorette_1.dim)('none')}`);
71
+ logger_1.default.info(`Fetching commits since ${tagFromWhichToFindCommits ?? 'the beginning of the repository'}...`);
89
72
  const commits = git.getCommitsFromTag(tagFromWhichToFindCommits);
90
- output_1.default.log(`Found ${color.bold(commits.length.toString())} commit(s).`);
73
+ logger_1.default.info(`Found ${(0, colorette_1.bold)(commits.length.toString())} commit(s).`);
91
74
  const parsedCommits = commits.map((commit) => convCom.parseConventionalCommit(commit.message, commit.hash))
92
75
  .filter((commit) => !!commit);
93
76
  const releaseType = convCom.determineReleaseType(parsedCommits, commitTypeMap);
94
- const releaseTypeStr = (releaseType === 'none' && color.grey('none'))
95
- || (releaseType === 'major' && color.red('major'))
96
- || (releaseType === 'minor' && color.yellow('minor'))
97
- || (releaseType === 'patch' && color.green('patch'));
98
- output_1.default.log(`The release type is: ${releaseTypeStr}`);
77
+ const releaseTypeStr = (releaseType === 'none' && (0, colorette_1.dim)('none'))
78
+ || (releaseType === 'major' && (0, colorette_1.redBright)('major'))
79
+ || (releaseType === 'minor' && (0, colorette_1.yellowBright)('minor'))
80
+ || (releaseType === 'patch' && (0, colorette_1.greenBright)('patch'));
81
+ logger_1.default.info(`The release type is: ${releaseTypeStr}`);
99
82
  if (releaseType === 'none' && !args.useVersion) {
100
- output_1.default.log('No release is needed. Have a nice day (^_^)/');
83
+ logger_1.default.info('No release is needed. Have a nice day (^_^)/');
101
84
  return;
102
85
  }
103
- let nextTagCalculated = '';
86
+ // Validate useVersion & log warnings
104
87
  if (args.useVersion) {
105
88
  if (/^v(.+)$/.test(args.useVersion))
106
89
  throw new Error('useVersion should not start with a "v".');
107
90
  if (!semver.isValidTag(args.useVersion))
108
91
  throw new Error('useVersion must be a valid SemVer version');
109
92
  if (releaseType === 'none') {
110
- output_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: ${color.bold(args.useVersion)}.`);
93
+ 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)}.`);
111
94
  }
112
95
  else {
113
- output_1.default.warn(`The next version was set by useVersion to be: ${color.bold(args.useVersion)}.`);
96
+ logger_1.default.warn(`The next version was explicitly set by useVersion to be: ${(0, colorette_1.bold)(args.useVersion)}.`);
114
97
  }
115
98
  }
116
- else {
117
- nextTagCalculated = semver.toTag(semver.incrVer({
118
- highestVer: semver.fromTag(highestTag || 'v0.0.0'),
119
- lastStableVer: semver.fromTag(lastStableTag || 'v0.0.0'),
99
+ const nextTag = args.useVersion
100
+ ? `v${args.useVersion}`
101
+ : semver.toTag(semver.incrVer({
102
+ latestVer: semver.fromTag(latestTag || 'v0.0.0'),
103
+ latestStableVer: semver.fromTag(lastStableTag || 'v0.0.0'),
120
104
  releaseType,
121
105
  prereleaseChannel,
122
- lastChannelVer: lastChannelTag ? semver.fromTag(lastChannelTag) ?? undefined : undefined,
106
+ latestChannelVer: lastChannelTag ? semver.fromTag(lastChannelTag) ?? undefined : undefined,
123
107
  }));
124
- output_1.default.log(`The next version is: ${color.bold(nextTagCalculated)}`);
125
- }
126
- const nextTag = args.useVersion ? `v${args.useVersion}` : nextTagCalculated;
127
108
  const changelog = (0, changelog_1.generateChangelog)(parsedCommits, commitTypeMap, args.breakingChangeTitle);
128
- output_1.default.debug(`The changelog is:\n${changelog}`);
109
+ logger_1.default.info(`The next version is: ${(0, colorette_1.bold)(nextTag)}`);
110
+ logger_1.default.debug(`The changelog is:\n${changelog}`);
129
111
  if (args.dryRun)
130
112
  return;
131
113
  if (args.preRun) {
132
- output_1.default.log('Running pre-release bash script...');
114
+ logger_1.default.info('Running pre-release bash script...');
133
115
  (0, sh_1.bash)(args.preRun);
134
116
  }
135
117
  git.createAndPushTag(nextTag);
@@ -151,16 +133,16 @@ async function autorel(args) {
151
133
  process.env.NEXT_TAG = nextTag;
152
134
  // run post-release bash script
153
135
  if (args.run) {
154
- output_1.default.log('Running post-release bash script...');
136
+ logger_1.default.info('Running post-release bash script...');
155
137
  (0, sh_1.bash)(args.run);
156
138
  }
157
139
  else if (args.runScript) {
158
140
  // TODO: delete this block in the next major version
159
- output_1.default.warn('----------------------------');
160
- output_1.default.warn('🚨 The "runScript" option is deprecated. Please use "run" instead. 🚨');
161
- output_1.default.warn('🚨 The "runScript" option will be removed in the next major version. 🚨');
162
- output_1.default.warn('----------------------------');
163
- output_1.default.log('Running post-release bash script...');
141
+ logger_1.default.warn('----------------------------');
142
+ logger_1.default.warn('🚨 The "runScript" option is deprecated. Please use "run" instead. 🚨');
143
+ logger_1.default.warn('🚨 The "runScript" option will be removed in the next major version. 🚨');
144
+ logger_1.default.warn('----------------------------');
145
+ logger_1.default.info('Running post-release bash script...');
164
146
  (0, sh_1.bash)(args.runScript);
165
147
  }
166
148
  return nextTag.replace('v', '');
@@ -1,9 +1,9 @@
1
- declare function log(message: string): void;
1
+ declare function info(message: string): void;
2
2
  declare function debug(message: string): void;
3
3
  declare function warn(message: string): void;
4
4
  declare function error(message: string): void;
5
5
  declare const _default: {
6
- log: typeof log;
6
+ info: typeof info;
7
7
  debug: typeof debug;
8
8
  warn: typeof warn;
9
9
  error: typeof error;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const colorette_1 = require("colorette");
4
+ const prefix = '[autorel] ';
5
+ function info(message) {
6
+ console.log(`${prefix}${message}`);
7
+ }
8
+ function debug(message) {
9
+ process.env.AUTOREL_DEBUG && info((0, colorette_1.gray)(message));
10
+ }
11
+ function warn(message) {
12
+ info((0, colorette_1.yellow)(`Warning: ${message}`));
13
+ }
14
+ function error(message) {
15
+ info((0, colorette_1.red)(`Error: ${message}`));
16
+ }
17
+ exports.default = {
18
+ info,
19
+ debug,
20
+ warn,
21
+ error,
22
+ };
23
+ //# sourceMappingURL=logger.js.map
@@ -1,5 +1,5 @@
1
- export declare const fakeLogger: {
2
- log: () => undefined;
1
+ export declare const mockLogger: {
2
+ info: () => undefined;
3
3
  debug: () => undefined;
4
4
  warn: () => undefined;
5
5
  error: () => undefined;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fakeLogger = void 0;
4
- exports.fakeLogger = {
5
- log: () => undefined,
3
+ exports.mockLogger = void 0;
4
+ exports.mockLogger = {
5
+ info: () => undefined,
6
6
  debug: () => undefined,
7
7
  warn: () => undefined,
8
8
  error: () => undefined,
9
9
  };
10
- //# sourceMappingURL=fakeLog.js.map
10
+ //# sourceMappingURL=mockLogger.js.map
@@ -0,0 +1,20 @@
1
+ import { VersionWithRaw } from './parse';
2
+ import { SemVer } from './types';
3
+ /**
4
+ * Compares two versions and returns:
5
+ * - 1 if version1 is greater than version2
6
+ * - -1 if version1 is less than version2
7
+ * - 0 if they are equal
8
+ */
9
+ export declare function compareVersions(version1: SemVer, version2: SemVer): number;
10
+ /**
11
+ * Returns the highest version of two SemVer objects (nomalized).
12
+ */
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;
17
+ /**
18
+ * Returns the raw tag string with the highest version.
19
+ */
20
+ export declare function highest(parsed: VersionWithRaw[]): VersionWithRaw;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.highest = exports.latestStableTag = exports.latestChannelTag = exports.latestTag = exports.highestVersion = exports.compareVersions = void 0;
4
+ const parse_1 = require("./parse");
5
+ /**
6
+ * Compares two versions and returns:
7
+ * - 1 if version1 is greater than version2
8
+ * - -1 if version1 is less than version2
9
+ * - 0 if they are equal
10
+ */
11
+ function compareVersions(version1, version2) {
12
+ const version1n = (0, parse_1.normalizeVer)(version1);
13
+ const version2n = (0, parse_1.normalizeVer)(version2);
14
+ if (version1n.major > version2n.major)
15
+ return 1;
16
+ if (version1n.major < version2n.major)
17
+ return -1;
18
+ if (version1n.minor > version2n.minor)
19
+ return 1;
20
+ if (version1n.minor < version2n.minor)
21
+ return -1;
22
+ if (version1n.patch > version2n.patch)
23
+ return 1;
24
+ if (version1n.patch < version2n.patch)
25
+ return -1;
26
+ if (!version1n.channel && !!version2n.channel)
27
+ return 1;
28
+ if (!!version1n.channel && !version2n.channel)
29
+ return -1;
30
+ // compare channel
31
+ if (version1n.channel && version2n.channel) {
32
+ if (version1n.channel > version2n.channel)
33
+ return 1;
34
+ if (version1n.channel < version2n.channel)
35
+ return -1;
36
+ // compare build
37
+ if (version1n.build && version2n.build) {
38
+ if (version1n.build > version2n.build)
39
+ return 1;
40
+ if (version1n.build < version2n.build)
41
+ return -1;
42
+ }
43
+ }
44
+ return 0;
45
+ }
46
+ exports.compareVersions = compareVersions;
47
+ /**
48
+ * Returns the highest version of two SemVer objects (nomalized).
49
+ */
50
+ function highestVersion(version1, version2) {
51
+ const comparison = compareVersions(version1, version2);
52
+ return (0, parse_1.normalizeVer)(comparison > 0 ? version1 : version2);
53
+ }
54
+ exports.highestVersion = highestVersion;
55
+ function latestTag(tags) {
56
+ const parsed = (0, parse_1.parseTags)(tags);
57
+ if (parsed.length === 0)
58
+ return undefined;
59
+ return highest(parsed).raw;
60
+ }
61
+ exports.latestTag = latestTag;
62
+ function latestChannelTag(tags, channel) {
63
+ const parsed = (0, parse_1.parseTags)(tags)
64
+ .filter((entry) => entry.version.channel === channel);
65
+ if (parsed.length === 0)
66
+ return undefined;
67
+ return highest(parsed).raw;
68
+ }
69
+ exports.latestChannelTag = latestChannelTag;
70
+ function latestStableTag(tags) {
71
+ const parsed = (0, parse_1.parseTags)(tags)
72
+ .filter((entry) => !entry.version.channel);
73
+ if (parsed.length === 0)
74
+ return undefined;
75
+ return highest(parsed).raw;
76
+ }
77
+ exports.latestStableTag = latestStableTag;
78
+ /**
79
+ * Returns the raw tag string with the highest version.
80
+ */
81
+ function highest(parsed) {
82
+ return parsed.reduce((a, b) => compareVersions(a.version, b.version) >= 0 ? a : b);
83
+ }
84
+ exports.highest = highest;
85
+ //# sourceMappingURL=compare.js.map
@@ -0,0 +1,7 @@
1
+ export declare const errors: {
2
+ noReleaseErr: string;
3
+ outOfOrderErr: string;
4
+ stableVerNotValid: string;
5
+ lastChannelVerNotSameChannel: string;
6
+ lastChannelVerTooLarge: string;
7
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.errors = void 0;
4
+ const noReleaseErr = 'Release type is set to "none"';
5
+ const outOfOrderErr = 'The latest version cannot be less than the last stable/production version (following SemVer).'
6
+ + '\n\nTo fix this, we recommend using the --use-version flag to specify the version you want to use.';
7
+ const stableVerNotValid = 'The stable version cannot be a prerelease.';
8
+ const lastChannelVerNotSameChannel = 'The last channel version must be a prerelease of the same channel.';
9
+ const lastChannelVerTooLarge = 'The latest channel version cannot be greater than the latest version.';
10
+ exports.errors = {
11
+ noReleaseErr,
12
+ outOfOrderErr,
13
+ stableVerNotValid,
14
+ lastChannelVerNotSameChannel,
15
+ lastChannelVerTooLarge,
16
+ };
17
+ //# sourceMappingURL=errors.js.map