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/semver.js DELETED
@@ -1,212 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.incrVer = exports.lastChannelVerTooLarge = exports.lastChannelVerNotSameChannel = exports.stableVerNotValid = exports.outOfOrderErr = exports.isValidVersion = exports.isValidTag = exports.incrMajor = exports.incrMinor = exports.incrPatch = exports.incrByType = exports.highestVersion = exports.rootVersion = exports.compareVersions = exports.normalize = exports.isVerPrerelease = exports.fromTag = exports.toTag = void 0;
4
- function toTag(version) {
5
- let versionString = `${version.major}.${version.minor}.${version.patch}`;
6
- if (version.channel) {
7
- versionString += `-${version.channel}`;
8
- if (version.build) {
9
- versionString += `.${version.build}`;
10
- }
11
- }
12
- return `v${versionString}`;
13
- }
14
- exports.toTag = toTag;
15
- function fromTag(tag) {
16
- const semverRegex = /^v(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<channel>[0-9a-zA-Z-]+)(?:\.(?<build>[0-9a-zA-Z-]+))?)?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
17
- const match = tag.match(semverRegex);
18
- if (!match || !match.groups) {
19
- return null;
20
- }
21
- const { major, minor, patch, channel, build } = match.groups;
22
- return {
23
- major: parseInt(major, 10),
24
- minor: parseInt(minor, 10),
25
- patch: parseInt(patch, 10),
26
- ...(channel ? { channel } : {}),
27
- ...(build ? { build: parseInt(build, 10) } : {}),
28
- };
29
- }
30
- exports.fromTag = fromTag;
31
- function isVerPrerelease(version) {
32
- return !!version.channel;
33
- }
34
- exports.isVerPrerelease = isVerPrerelease;
35
- function normalize(version) {
36
- return {
37
- major: version.major,
38
- minor: version.minor,
39
- patch: version.patch,
40
- ...(version.channel ? {
41
- channel: version.channel,
42
- build: version.build || 1,
43
- } : {}),
44
- };
45
- }
46
- exports.normalize = normalize;
47
- /**
48
- * Compares two versions and returns:
49
- * - 1 if version1 is greater than version2
50
- * - -1 if version1 is less than version2
51
- * - 0 if they are equal
52
- */
53
- function compareVersions(version1, version2) {
54
- const version1n = normalize(version1);
55
- const version2n = normalize(version2);
56
- if (version1n.major > version2n.major)
57
- return 1;
58
- if (version1n.major < version2n.major)
59
- return -1;
60
- if (version1n.minor > version2n.minor)
61
- return 1;
62
- if (version1n.minor < version2n.minor)
63
- return -1;
64
- if (version1n.patch > version2n.patch)
65
- return 1;
66
- if (version1n.patch < version2n.patch)
67
- return -1;
68
- if (!version1n.channel && !!version2n.channel)
69
- return 1;
70
- if (!!version1n.channel && !version2n.channel)
71
- return -1;
72
- if (!version1n.build && !!version2n.build)
73
- return 1;
74
- if (!!version1n.build && !version2n.build)
75
- return -1;
76
- // compare channel
77
- if (version1n.channel && version2n.channel) {
78
- if (version1n.channel > version2n.channel)
79
- return 1;
80
- if (version1n.channel < version2n.channel)
81
- return -1;
82
- // compare build
83
- if (version1n.build && version2n.build) {
84
- if (version1n.build > version2n.build)
85
- return 1;
86
- if (version1n.build < version2n.build)
87
- return -1;
88
- }
89
- }
90
- return 0;
91
- }
92
- exports.compareVersions = compareVersions;
93
- function rootVersion(version) {
94
- return {
95
- major: version.major,
96
- minor: version.minor,
97
- patch: version.patch,
98
- };
99
- }
100
- exports.rootVersion = rootVersion;
101
- function highestVersion(version1, version2) {
102
- const comparison = compareVersions(version1, version2);
103
- return normalize(comparison > 0 ? version1 : version2);
104
- }
105
- exports.highestVersion = highestVersion;
106
- function incrByType(version, releaseType) {
107
- switch (releaseType) {
108
- case 'major':
109
- return incrMajor(version);
110
- case 'minor':
111
- return incrMinor(version);
112
- case 'patch':
113
- return incrPatch(version);
114
- default:
115
- return version;
116
- }
117
- }
118
- exports.incrByType = incrByType;
119
- function incrPatch(version) {
120
- return {
121
- ...version,
122
- major: version.major,
123
- minor: version.minor,
124
- patch: version.patch + 1,
125
- ...(version.build ? { build: 1 } : {}),
126
- };
127
- }
128
- exports.incrPatch = incrPatch;
129
- function incrMinor(version) {
130
- return {
131
- ...version,
132
- major: version.major,
133
- minor: version.minor + 1,
134
- patch: 0,
135
- ...(version.build ? { build: 1 } : {}),
136
- };
137
- }
138
- exports.incrMinor = incrMinor;
139
- function incrMajor(version) {
140
- return {
141
- ...version,
142
- major: version.major + 1,
143
- minor: 0,
144
- patch: 0,
145
- ...(version.build ? { build: 1 } : {}),
146
- };
147
- }
148
- exports.incrMajor = incrMajor;
149
- function isValidTag(ver) {
150
- return !!fromTag(ver);
151
- }
152
- exports.isValidTag = isValidTag;
153
- function isValidVersion(version) {
154
- return !!fromTag(toTag(version));
155
- }
156
- exports.isValidVersion = isValidVersion;
157
- exports.outOfOrderErr = 'The current/highest version cannot be less than the last stable/production version (following SemVer).'
158
- + '\n\nTo fix this, we recommend using the --use-version flag to specify the version you want to use.';
159
- exports.stableVerNotValid = 'The stable version cannot be a prerelease.';
160
- exports.lastChannelVerNotSameChannel = 'The last channel version must be a prerelease of the same channel.';
161
- exports.lastChannelVerTooLarge = 'The last channel version cannot be greater than the highest version.';
162
- /**
163
- * Increments the version based on the release type. The next version must
164
- * be greater than the highest/current version except for the following cases:
165
- * 1. The release type is 'none'.
166
- * 2. The highest version is a prerelease of a different channel. Even in this case,
167
- * the next version must be greater than the last stable/production version.
168
- *
169
- * Parameters:
170
- * - `highestVer` is typically the current version of the package and the
171
- * same as `lastStableVer` if the last release was a stable/production release.
172
- * - `lastStableVer` is the last stable/production release.
173
- * - `releaseType` is the type of release to make.
174
- * - `prereleaseChannel` is the name of the prerelease channel, if it's a prerelease.
175
- * - `lastChannelVer` is the last version of the package on the same channel.
176
- */
177
- function incrVer(input) {
178
- const { lastStableVer, highestVer, releaseType, prereleaseChannel, lastChannelVer } = input;
179
- if (releaseType === 'none')
180
- return highestVer;
181
- if (compareVersions(highestVer, lastStableVer) < 0)
182
- throw new Error(exports.outOfOrderErr);
183
- if (isVerPrerelease(lastStableVer))
184
- throw new Error(exports.stableVerNotValid);
185
- if (prereleaseChannel && lastChannelVer && compareVersions(lastChannelVer, highestVer) > 0)
186
- throw new Error(exports.lastChannelVerTooLarge);
187
- if (prereleaseChannel && lastChannelVer && prereleaseChannel !== lastChannelVer.channel)
188
- throw new Error(exports.lastChannelVerNotSameChannel);
189
- const isPrerelease = !!prereleaseChannel;
190
- const nextRootVer = highestVersion(incrByType(lastStableVer, releaseType), rootVersion(highestVer));
191
- if (isPrerelease) {
192
- const nextVer = {
193
- ...nextRootVer,
194
- channel: prereleaseChannel,
195
- build: 1,
196
- };
197
- if (!lastChannelVer || compareVersions(nextVer, lastChannelVer) > 0) {
198
- return nextVer;
199
- }
200
- else {
201
- return {
202
- ...lastChannelVer,
203
- build: (lastChannelVer.build || 0) + 1,
204
- };
205
- }
206
- }
207
- else {
208
- return nextRootVer;
209
- }
210
- }
211
- exports.incrVer = incrVer;
212
- //# sourceMappingURL=semver.js.map
File without changes
File without changes
File without changes