relizy 0.2.7 → 0.2.8

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.mjs CHANGED
@@ -5,7 +5,7 @@ import process from 'node:process';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { printBanner, logger } from '@maz-ui/node';
7
7
  import { Command } from 'commander';
8
- import { W as isInCI, X as getCIName, b as bump, c as changelog, e as publish, a as providerRelease, r as release } from './shared/relizy.6FWq4lmP.mjs';
8
+ import { W as isInCI, X as getCIName, b as bump, c as changelog, e as publish, a as providerRelease, r as release } from './shared/relizy.DwP99Z7x.mjs';
9
9
  import 'changelogen';
10
10
  import 'fast-glob';
11
11
  import '@inquirer/prompts';
package/dist/index.d.mts CHANGED
@@ -223,12 +223,14 @@ declare function getLastTag({ logLevel, cwd }: {
223
223
  }): Promise<string>;
224
224
  declare function getLastRepoTag(options?: {
225
225
  onlyStable?: boolean;
226
+ currentVersion?: string;
226
227
  logLevel?: LogLevel;
227
228
  cwd?: string;
228
229
  }): Promise<string | null>;
229
- declare function getLastPackageTag({ packageName, onlyStable, logLevel, cwd, }: {
230
+ declare function getLastPackageTag({ packageName, onlyStable, currentVersion, logLevel, cwd, }: {
230
231
  packageName: string;
231
232
  onlyStable?: boolean;
233
+ currentVersion?: string;
232
234
  logLevel?: LogLevel;
233
235
  cwd?: string;
234
236
  }): Promise<string | null>;
@@ -334,6 +336,48 @@ declare function getBumpedIndependentPackages({ packages, dryRun, }: {
334
336
  packages: PackageBase[];
335
337
  dryRun: boolean;
336
338
  }): PackageBase[];
339
+ /**
340
+ * Determines if prerelease tags should be filtered out when searching for tags.
341
+ * Returns true when the current version is stable AND we're not graduating to stable.
342
+ *
343
+ * This prevents beta/prerelease tags from being used as the base for stable version bumps.
344
+ *
345
+ * @example
346
+ * shouldFilterPrereleaseTags('4.1.1', false) // true - stable version, not graduating
347
+ * shouldFilterPrereleaseTags('4.1.1-beta.0', true) // false - graduating to stable
348
+ * shouldFilterPrereleaseTags('4.1.1-beta.0', false) // false - prerelease version
349
+ */
350
+ declare function shouldFilterPrereleaseTags(currentVersion: string, graduating: boolean): boolean;
351
+ /**
352
+ * Extracts a semantic version from a git tag.
353
+ * Supports multiple tag formats:
354
+ * - v1.2.3 → 1.2.3
355
+ * - 1.2.3 → 1.2.3
356
+ * - package-name@1.2.3 → 1.2.3
357
+ * - v1.2.3-beta.0 → 1.2.3-beta.0
358
+ *
359
+ * @param tag - The git tag to extract version from
360
+ * @param packageName - Optional package name for independent mode tags (e.g., "pkg-name@1.2.3")
361
+ * @returns The extracted version string or null if invalid
362
+ */
363
+ declare function extractVersionFromTag(tag: string, packageName?: string): string | null;
364
+ /**
365
+ * Checks if a tag's version is compatible with the current version.
366
+ * A tag is compatible if its major version is less than or equal to the current major version.
367
+ *
368
+ * This prevents accidentally using tags from future major versions (e.g., v5.0.0-beta.0)
369
+ * when bumping a current stable version (e.g., 4.1.1 → 4.1.2).
370
+ *
371
+ * @param tagVersion - The semantic version extracted from the tag
372
+ * @param currentVersion - The current package version
373
+ * @returns true if the tag version's major is <= current major version
374
+ *
375
+ * @example
376
+ * isTagVersionCompatibleWithCurrent('4.1.1', '4.1.0') // true - same major
377
+ * isTagVersionCompatibleWithCurrent('5.0.0-beta.0', '4.1.1') // false - newer major
378
+ * isTagVersionCompatibleWithCurrent('3.9.9', '4.1.1') // true - older major
379
+ */
380
+ declare function isTagVersionCompatibleWithCurrent(tagVersion: string, currentVersion: string): boolean;
337
381
 
338
382
  type VersionMode = 'unified' | 'independent' | 'selective';
339
383
  type GitProvider = 'github' | 'gitlab';
@@ -935,5 +979,5 @@ declare function publish(options?: Partial<PublishOptions>): Promise<{
935
979
 
936
980
  declare function release(options?: Partial<ReleaseOptions>): Promise<void>;
937
981
 
938
- export { bump, changelog, checkGitStatusIfDirty, confirmBump, createCommitAndTags, createGitlabRelease, defineConfig, detectGitProvider, detectPackageManager, determinePublishTag, determineReleaseType, determineSemverChange, executeBuildCmd, executeFormatCmd, executeHook, expandPackagesToBumpWithDependents, extractVersionFromPackageTag, fetchGitTags, generateChangelog, getAuthCommand, getBumpedIndependentPackages, getBumpedPackageIndependently, getCIName, getCurrentGitBranch, getCurrentGitRef, getDefaultConfig, getDependentsOf, getFirstCommit, getGitStatus, getIndependentTag, getLastPackageTag, getLastRepoTag, getLastStableTag, getLastTag, getPackageCommits, getPackageDependencies, getPackageNewVersion, getPackages, getPackagesOrBumpedPackages, getPackagesToPublishInIndependentMode, getPackagesToPublishInSelectiveMode, getPreid, getRootPackage, github, gitlab, hasLernaJson, isBumpedPackage, isChangedPreid, isGraduating, isGraduatingToStableBetweenVersion, isInCI, isPrerelease, isPrereleaseReleaseType, isStableReleaseType, loadRelizyConfig, parseGitRemoteUrl, providerRelease, providerReleaseSafetyCheck, publish, publishPackage, publishSafetyCheck, pushCommitAndTags, readPackageJson, readPackages, release, resolveTags, topologicalSort, updateLernaVersion, writeChangelogToFile, writeVersion };
982
+ export { bump, changelog, checkGitStatusIfDirty, confirmBump, createCommitAndTags, createGitlabRelease, defineConfig, detectGitProvider, detectPackageManager, determinePublishTag, determineReleaseType, determineSemverChange, executeBuildCmd, executeFormatCmd, executeHook, expandPackagesToBumpWithDependents, extractVersionFromPackageTag, extractVersionFromTag, fetchGitTags, generateChangelog, getAuthCommand, getBumpedIndependentPackages, getBumpedPackageIndependently, getCIName, getCurrentGitBranch, getCurrentGitRef, getDefaultConfig, getDependentsOf, getFirstCommit, getGitStatus, getIndependentTag, getLastPackageTag, getLastRepoTag, getLastStableTag, getLastTag, getPackageCommits, getPackageDependencies, getPackageNewVersion, getPackages, getPackagesOrBumpedPackages, getPackagesToPublishInIndependentMode, getPackagesToPublishInSelectiveMode, getPreid, getRootPackage, github, gitlab, hasLernaJson, isBumpedPackage, isChangedPreid, isGraduating, isGraduatingToStableBetweenVersion, isInCI, isPrerelease, isPrereleaseReleaseType, isStableReleaseType, isTagVersionCompatibleWithCurrent, loadRelizyConfig, parseGitRemoteUrl, providerRelease, providerReleaseSafetyCheck, publish, publishPackage, publishSafetyCheck, pushCommitAndTags, readPackageJson, readPackages, release, resolveTags, shouldFilterPrereleaseTags, topologicalSort, updateLernaVersion, writeChangelogToFile, writeVersion };
939
983
  export type { BumpConfig, BumpOptions, BumpResult, BumpResultFalsy, BumpResultTruthy, ChangelogConfig, ChangelogOptions, ConfigType, GitProvider, GitlabRelease, GitlabReleaseResponse, HookConfig, HookStep, HookType, MonorepoConfig, PackageBase, PackageManager, PostedRelease, ProviderReleaseOptions, PublishConfig, PublishOptions, PublishResponse, ReadPackage, ReleaseConfig, ReleaseOptions, RelizyConfig, RepoConfig, ResolvedConfig, ResolvedRelizyConfig, ResolvedTags, RootPackage, Step, TemplatesConfig, VersionMode };
package/dist/index.d.ts CHANGED
@@ -223,12 +223,14 @@ declare function getLastTag({ logLevel, cwd }: {
223
223
  }): Promise<string>;
224
224
  declare function getLastRepoTag(options?: {
225
225
  onlyStable?: boolean;
226
+ currentVersion?: string;
226
227
  logLevel?: LogLevel;
227
228
  cwd?: string;
228
229
  }): Promise<string | null>;
229
- declare function getLastPackageTag({ packageName, onlyStable, logLevel, cwd, }: {
230
+ declare function getLastPackageTag({ packageName, onlyStable, currentVersion, logLevel, cwd, }: {
230
231
  packageName: string;
231
232
  onlyStable?: boolean;
233
+ currentVersion?: string;
232
234
  logLevel?: LogLevel;
233
235
  cwd?: string;
234
236
  }): Promise<string | null>;
@@ -334,6 +336,48 @@ declare function getBumpedIndependentPackages({ packages, dryRun, }: {
334
336
  packages: PackageBase[];
335
337
  dryRun: boolean;
336
338
  }): PackageBase[];
339
+ /**
340
+ * Determines if prerelease tags should be filtered out when searching for tags.
341
+ * Returns true when the current version is stable AND we're not graduating to stable.
342
+ *
343
+ * This prevents beta/prerelease tags from being used as the base for stable version bumps.
344
+ *
345
+ * @example
346
+ * shouldFilterPrereleaseTags('4.1.1', false) // true - stable version, not graduating
347
+ * shouldFilterPrereleaseTags('4.1.1-beta.0', true) // false - graduating to stable
348
+ * shouldFilterPrereleaseTags('4.1.1-beta.0', false) // false - prerelease version
349
+ */
350
+ declare function shouldFilterPrereleaseTags(currentVersion: string, graduating: boolean): boolean;
351
+ /**
352
+ * Extracts a semantic version from a git tag.
353
+ * Supports multiple tag formats:
354
+ * - v1.2.3 → 1.2.3
355
+ * - 1.2.3 → 1.2.3
356
+ * - package-name@1.2.3 → 1.2.3
357
+ * - v1.2.3-beta.0 → 1.2.3-beta.0
358
+ *
359
+ * @param tag - The git tag to extract version from
360
+ * @param packageName - Optional package name for independent mode tags (e.g., "pkg-name@1.2.3")
361
+ * @returns The extracted version string or null if invalid
362
+ */
363
+ declare function extractVersionFromTag(tag: string, packageName?: string): string | null;
364
+ /**
365
+ * Checks if a tag's version is compatible with the current version.
366
+ * A tag is compatible if its major version is less than or equal to the current major version.
367
+ *
368
+ * This prevents accidentally using tags from future major versions (e.g., v5.0.0-beta.0)
369
+ * when bumping a current stable version (e.g., 4.1.1 → 4.1.2).
370
+ *
371
+ * @param tagVersion - The semantic version extracted from the tag
372
+ * @param currentVersion - The current package version
373
+ * @returns true if the tag version's major is <= current major version
374
+ *
375
+ * @example
376
+ * isTagVersionCompatibleWithCurrent('4.1.1', '4.1.0') // true - same major
377
+ * isTagVersionCompatibleWithCurrent('5.0.0-beta.0', '4.1.1') // false - newer major
378
+ * isTagVersionCompatibleWithCurrent('3.9.9', '4.1.1') // true - older major
379
+ */
380
+ declare function isTagVersionCompatibleWithCurrent(tagVersion: string, currentVersion: string): boolean;
337
381
 
338
382
  type VersionMode = 'unified' | 'independent' | 'selective';
339
383
  type GitProvider = 'github' | 'gitlab';
@@ -935,5 +979,5 @@ declare function publish(options?: Partial<PublishOptions>): Promise<{
935
979
 
936
980
  declare function release(options?: Partial<ReleaseOptions>): Promise<void>;
937
981
 
938
- export { bump, changelog, checkGitStatusIfDirty, confirmBump, createCommitAndTags, createGitlabRelease, defineConfig, detectGitProvider, detectPackageManager, determinePublishTag, determineReleaseType, determineSemverChange, executeBuildCmd, executeFormatCmd, executeHook, expandPackagesToBumpWithDependents, extractVersionFromPackageTag, fetchGitTags, generateChangelog, getAuthCommand, getBumpedIndependentPackages, getBumpedPackageIndependently, getCIName, getCurrentGitBranch, getCurrentGitRef, getDefaultConfig, getDependentsOf, getFirstCommit, getGitStatus, getIndependentTag, getLastPackageTag, getLastRepoTag, getLastStableTag, getLastTag, getPackageCommits, getPackageDependencies, getPackageNewVersion, getPackages, getPackagesOrBumpedPackages, getPackagesToPublishInIndependentMode, getPackagesToPublishInSelectiveMode, getPreid, getRootPackage, github, gitlab, hasLernaJson, isBumpedPackage, isChangedPreid, isGraduating, isGraduatingToStableBetweenVersion, isInCI, isPrerelease, isPrereleaseReleaseType, isStableReleaseType, loadRelizyConfig, parseGitRemoteUrl, providerRelease, providerReleaseSafetyCheck, publish, publishPackage, publishSafetyCheck, pushCommitAndTags, readPackageJson, readPackages, release, resolveTags, topologicalSort, updateLernaVersion, writeChangelogToFile, writeVersion };
982
+ export { bump, changelog, checkGitStatusIfDirty, confirmBump, createCommitAndTags, createGitlabRelease, defineConfig, detectGitProvider, detectPackageManager, determinePublishTag, determineReleaseType, determineSemverChange, executeBuildCmd, executeFormatCmd, executeHook, expandPackagesToBumpWithDependents, extractVersionFromPackageTag, extractVersionFromTag, fetchGitTags, generateChangelog, getAuthCommand, getBumpedIndependentPackages, getBumpedPackageIndependently, getCIName, getCurrentGitBranch, getCurrentGitRef, getDefaultConfig, getDependentsOf, getFirstCommit, getGitStatus, getIndependentTag, getLastPackageTag, getLastRepoTag, getLastStableTag, getLastTag, getPackageCommits, getPackageDependencies, getPackageNewVersion, getPackages, getPackagesOrBumpedPackages, getPackagesToPublishInIndependentMode, getPackagesToPublishInSelectiveMode, getPreid, getRootPackage, github, gitlab, hasLernaJson, isBumpedPackage, isChangedPreid, isGraduating, isGraduatingToStableBetweenVersion, isInCI, isPrerelease, isPrereleaseReleaseType, isStableReleaseType, isTagVersionCompatibleWithCurrent, loadRelizyConfig, parseGitRemoteUrl, providerRelease, providerReleaseSafetyCheck, publish, publishPackage, publishSafetyCheck, pushCommitAndTags, readPackageJson, readPackages, release, resolveTags, shouldFilterPrereleaseTags, topologicalSort, updateLernaVersion, writeChangelogToFile, writeVersion };
939
983
  export type { BumpConfig, BumpOptions, BumpResult, BumpResultFalsy, BumpResultTruthy, ChangelogConfig, ChangelogOptions, ConfigType, GitProvider, GitlabRelease, GitlabReleaseResponse, HookConfig, HookStep, HookType, MonorepoConfig, PackageBase, PackageManager, PostedRelease, ProviderReleaseOptions, PublishConfig, PublishOptions, PublishResponse, ReadPackage, ReleaseConfig, ReleaseOptions, RelizyConfig, RepoConfig, ResolvedConfig, ResolvedRelizyConfig, ResolvedTags, RootPackage, Step, TemplatesConfig, VersionMode };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { b as bump, c as changelog, n as checkGitStatusIfDirty, ae as confirmBump, u as createCommitAndTags, B as createGitlabRelease, h as defineConfig, q as detectGitProvider, D as detectPackageManager, E as determinePublishTag, a2 as determineReleaseType, a1 as determineSemverChange, Z as executeBuildCmd, Y as executeFormatCmd, V as executeHook, k as expandPackagesToBumpWithDependents, a6 as extractVersionFromPackageTag, o as fetchGitTags, g as generateChangelog, H as getAuthCommand, af as getBumpedIndependentPackages, ad as getBumpedPackageIndependently, X as getCIName, y as getCurrentGitBranch, z as getCurrentGitRef, f as getDefaultConfig, j as getDependentsOf, x as getFirstCommit, m as getGitStatus, P as getIndependentTag, T as getLastPackageTag, S as getLastRepoTag, Q as getLastStableTag, R as getLastTag, N as getPackageCommits, i as getPackageDependencies, a4 as getPackageNewVersion, M as getPackages, $ as getPackagesOrBumpedPackages, G as getPackagesToPublishInIndependentMode, F as getPackagesToPublishInSelectiveMode, ab as getPreid, K as getRootPackage, A as github, C as gitlab, O as hasLernaJson, _ as isBumpedPackage, ac as isChangedPreid, aa as isGraduating, a0 as isGraduatingToStableBetweenVersion, W as isInCI, a7 as isPrerelease, a9 as isPrereleaseReleaseType, a8 as isStableReleaseType, l as loadRelizyConfig, s as parseGitRemoteUrl, a as providerRelease, p as providerReleaseSafetyCheck, e as publish, I as publishPackage, d as publishSafetyCheck, v as pushCommitAndTags, J as readPackageJson, L as readPackages, r as release, U as resolveTags, t as topologicalSort, a5 as updateLernaVersion, w as writeChangelogToFile, a3 as writeVersion } from './shared/relizy.6FWq4lmP.mjs';
1
+ export { b as bump, c as changelog, n as checkGitStatusIfDirty, ae as confirmBump, u as createCommitAndTags, B as createGitlabRelease, h as defineConfig, q as detectGitProvider, D as detectPackageManager, E as determinePublishTag, a2 as determineReleaseType, a1 as determineSemverChange, Z as executeBuildCmd, Y as executeFormatCmd, V as executeHook, k as expandPackagesToBumpWithDependents, a6 as extractVersionFromPackageTag, ah as extractVersionFromTag, o as fetchGitTags, g as generateChangelog, H as getAuthCommand, af as getBumpedIndependentPackages, ad as getBumpedPackageIndependently, X as getCIName, y as getCurrentGitBranch, z as getCurrentGitRef, f as getDefaultConfig, j as getDependentsOf, x as getFirstCommit, m as getGitStatus, P as getIndependentTag, T as getLastPackageTag, S as getLastRepoTag, Q as getLastStableTag, R as getLastTag, N as getPackageCommits, i as getPackageDependencies, a4 as getPackageNewVersion, M as getPackages, $ as getPackagesOrBumpedPackages, G as getPackagesToPublishInIndependentMode, F as getPackagesToPublishInSelectiveMode, ab as getPreid, K as getRootPackage, A as github, C as gitlab, O as hasLernaJson, _ as isBumpedPackage, ac as isChangedPreid, aa as isGraduating, a0 as isGraduatingToStableBetweenVersion, W as isInCI, a7 as isPrerelease, a9 as isPrereleaseReleaseType, a8 as isStableReleaseType, ai as isTagVersionCompatibleWithCurrent, l as loadRelizyConfig, s as parseGitRemoteUrl, a as providerRelease, p as providerReleaseSafetyCheck, e as publish, I as publishPackage, d as publishSafetyCheck, v as pushCommitAndTags, J as readPackageJson, L as readPackages, r as release, U as resolveTags, ag as shouldFilterPrereleaseTags, t as topologicalSort, a5 as updateLernaVersion, w as writeChangelogToFile, a3 as writeVersion } from './shared/relizy.DwP99Z7x.mjs';
2
2
  import '@maz-ui/node';
3
3
  import 'node:fs';
4
4
  import 'node:path';
@@ -216,7 +216,7 @@ function readPackages({
216
216
  const patternsSet = new Set(patterns);
217
217
  if (!patterns)
218
218
  patternsSet.add(".");
219
- logger.debug(`Read package.json files from patterns: ${patternsSet.values()}`);
219
+ logger.debug(`Read package.json files from patterns: ${[...patternsSet].join(", ")}`);
220
220
  for (const pattern of patternsSet) {
221
221
  try {
222
222
  const matches = fastGlob.sync(pattern, {
@@ -2095,6 +2095,40 @@ function getBumpedIndependentPackages({
2095
2095
  }
2096
2096
  return bumpedPackages;
2097
2097
  }
2098
+ function shouldFilterPrereleaseTags(currentVersion, graduating) {
2099
+ return !isPrerelease(currentVersion) && !graduating;
2100
+ }
2101
+ function extractVersionFromTag(tag, packageName) {
2102
+ if (!tag) {
2103
+ return null;
2104
+ }
2105
+ if (packageName) {
2106
+ const prefix = `${packageName}@`;
2107
+ if (tag.startsWith(prefix)) {
2108
+ return tag.slice(prefix.length);
2109
+ }
2110
+ }
2111
+ const atIndex = tag.lastIndexOf("@");
2112
+ if (atIndex !== -1) {
2113
+ return tag.slice(atIndex + 1);
2114
+ }
2115
+ if (tag.startsWith("v") && /^v\d/.test(tag)) {
2116
+ return tag.slice(1);
2117
+ }
2118
+ if (/^\d+\.\d+\.\d+/.test(tag)) {
2119
+ return tag;
2120
+ }
2121
+ return null;
2122
+ }
2123
+ function isTagVersionCompatibleWithCurrent(tagVersion, currentVersion) {
2124
+ try {
2125
+ const tagMajor = semver.major(tagVersion);
2126
+ const currentMajor = semver.major(currentVersion);
2127
+ return tagMajor <= currentMajor;
2128
+ } catch {
2129
+ return false;
2130
+ }
2131
+ }
2098
2132
 
2099
2133
  function getIndependentTag({ version, name }) {
2100
2134
  return `${name}@${version}`;
@@ -2126,18 +2160,131 @@ async function getLastTag({ logLevel, cwd }) {
2126
2160
  logger.debug("Last tag:", lastTag || "No tags found");
2127
2161
  return lastTag;
2128
2162
  }
2163
+ async function getAllRecentRepoTags(options) {
2164
+ const limit = options?.limit;
2165
+ try {
2166
+ const { stdout } = await execPromise(
2167
+ `git tag --sort=-creatordate | head -n ${limit}`,
2168
+ {
2169
+ logLevel: options?.logLevel,
2170
+ noStderr: true,
2171
+ noStdout: true,
2172
+ noSuccess: true,
2173
+ cwd: options?.cwd
2174
+ }
2175
+ );
2176
+ const tags = stdout.trim().split("\n").filter((tag) => tag.length > 0);
2177
+ logger.debug(`Retrieved ${tags.length} recent repo tags`);
2178
+ return tags;
2179
+ } catch {
2180
+ return [];
2181
+ }
2182
+ }
2183
+ async function getAllRecentPackageTags({
2184
+ packageName,
2185
+ limit = 50,
2186
+ logLevel,
2187
+ cwd
2188
+ }) {
2189
+ try {
2190
+ const escapedPackageName = packageName.replace(/[@/]/g, "\\$&");
2191
+ const { stdout } = await execPromise(
2192
+ `git tag --sort=-creatordate | grep -E '^${escapedPackageName}@' | head -n ${limit}`,
2193
+ {
2194
+ logLevel,
2195
+ noStderr: true,
2196
+ noStdout: true,
2197
+ noSuccess: true,
2198
+ cwd
2199
+ }
2200
+ );
2201
+ const tags = stdout.trim().split("\n").filter((tag) => tag.length > 0);
2202
+ logger.debug(`Retrieved ${tags.length} recent tags for package ${packageName}`);
2203
+ return tags;
2204
+ } catch {
2205
+ return [];
2206
+ }
2207
+ }
2208
+ function filterCompatibleTags({
2209
+ tags,
2210
+ currentVersion,
2211
+ onlyStable,
2212
+ packageName
2213
+ }) {
2214
+ const filtered = tags.filter((tag) => {
2215
+ const tagVersion = extractVersionFromTag(tag, packageName);
2216
+ if (!tagVersion) {
2217
+ logger.debug(`Skipping tag ${tag}: cannot extract version`);
2218
+ return false;
2219
+ }
2220
+ if (onlyStable && isPrerelease(tagVersion)) {
2221
+ logger.debug(`Skipping tag ${tag}: prerelease version ${tagVersion} (onlyStable=${onlyStable})`);
2222
+ return false;
2223
+ }
2224
+ if (!isTagVersionCompatibleWithCurrent(tagVersion, currentVersion)) {
2225
+ logger.debug(`Skipping tag ${tag}: version ${tagVersion} has higher major than current ${currentVersion}`);
2226
+ return false;
2227
+ }
2228
+ logger.debug(`Tag ${tag} with version ${tagVersion} is compatible`);
2229
+ return true;
2230
+ });
2231
+ logger.debug(`Filtered ${tags.length} tags down to ${filtered.length} compatible tags`);
2232
+ return filtered;
2233
+ }
2129
2234
  function getLastRepoTag(options) {
2235
+ if (options?.currentVersion) {
2236
+ return getLastRepoTagWithFiltering({
2237
+ currentVersion: options.currentVersion,
2238
+ onlyStable: options.onlyStable ?? false,
2239
+ logLevel: options.logLevel,
2240
+ cwd: options.cwd
2241
+ });
2242
+ }
2130
2243
  if (options?.onlyStable) {
2131
2244
  return getLastStableTag({ logLevel: options?.logLevel, cwd: options?.cwd });
2132
2245
  }
2133
2246
  return getLastTag({ logLevel: options?.logLevel, cwd: options?.cwd });
2134
2247
  }
2248
+ async function getLastRepoTagWithFiltering({
2249
+ currentVersion,
2250
+ onlyStable,
2251
+ logLevel,
2252
+ cwd
2253
+ }) {
2254
+ const recentTags = await getAllRecentRepoTags({ limit: 50, logLevel, cwd });
2255
+ if (recentTags.length === 0) {
2256
+ logger.debug("No tags found in repository");
2257
+ return null;
2258
+ }
2259
+ const compatibleTags = filterCompatibleTags({
2260
+ tags: recentTags,
2261
+ currentVersion,
2262
+ onlyStable
2263
+ });
2264
+ if (compatibleTags.length === 0) {
2265
+ logger.debug("No compatible tags found");
2266
+ return null;
2267
+ }
2268
+ const lastTag = compatibleTags[0];
2269
+ logger.debug(`Last compatible repo tag: ${lastTag}`);
2270
+ return lastTag;
2271
+ }
2135
2272
  async function getLastPackageTag({
2136
2273
  packageName,
2137
2274
  onlyStable,
2275
+ currentVersion,
2138
2276
  logLevel,
2139
2277
  cwd
2140
2278
  }) {
2279
+ if (currentVersion) {
2280
+ return getLastPackageTagWithFiltering({
2281
+ packageName,
2282
+ currentVersion,
2283
+ onlyStable: onlyStable ?? false,
2284
+ logLevel,
2285
+ cwd
2286
+ });
2287
+ }
2141
2288
  try {
2142
2289
  const escapedPackageName = packageName.replace(/[@/]/g, "\\$&");
2143
2290
  let grepPattern;
@@ -2162,16 +2309,52 @@ async function getLastPackageTag({
2162
2309
  return null;
2163
2310
  }
2164
2311
  }
2312
+ async function getLastPackageTagWithFiltering({
2313
+ packageName,
2314
+ currentVersion,
2315
+ onlyStable,
2316
+ logLevel,
2317
+ cwd
2318
+ }) {
2319
+ const recentTags = await getAllRecentPackageTags({
2320
+ packageName,
2321
+ limit: 50,
2322
+ logLevel,
2323
+ cwd
2324
+ });
2325
+ if (recentTags.length === 0) {
2326
+ logger.debug(`No tags found for package ${packageName}`);
2327
+ return null;
2328
+ }
2329
+ const compatibleTags = filterCompatibleTags({
2330
+ tags: recentTags,
2331
+ currentVersion,
2332
+ onlyStable,
2333
+ packageName
2334
+ });
2335
+ if (compatibleTags.length === 0) {
2336
+ logger.debug(`No compatible tags found for package ${packageName}`);
2337
+ return null;
2338
+ }
2339
+ const lastTag = compatibleTags[0];
2340
+ logger.debug(`Last compatible package tag for ${packageName}: ${lastTag}`);
2341
+ return lastTag;
2342
+ }
2165
2343
  async function resolveFromTagIndependent({
2166
2344
  cwd,
2167
2345
  packageName,
2346
+ currentVersion,
2168
2347
  graduating,
2169
2348
  logLevel
2170
2349
  }) {
2350
+ const filterPrereleases = shouldFilterPrereleaseTags(currentVersion, graduating);
2351
+ const onlyStable = graduating || filterPrereleases;
2171
2352
  const lastPackageTag = await getLastPackageTag({
2172
2353
  packageName,
2173
- onlyStable: graduating,
2174
- logLevel
2354
+ currentVersion,
2355
+ onlyStable,
2356
+ logLevel,
2357
+ cwd
2175
2358
  });
2176
2359
  if (!lastPackageTag) {
2177
2360
  return getFirstCommit(cwd);
@@ -2180,10 +2363,18 @@ async function resolveFromTagIndependent({
2180
2363
  }
2181
2364
  async function resolveFromTagUnified({
2182
2365
  config,
2366
+ currentVersion,
2183
2367
  graduating,
2184
2368
  logLevel
2185
2369
  }) {
2186
- const from = await getLastRepoTag({ onlyStable: graduating, logLevel }) || getFirstCommit(config.cwd);
2370
+ const filterPrereleases = shouldFilterPrereleaseTags(currentVersion, graduating);
2371
+ const onlyStable = graduating || filterPrereleases;
2372
+ const from = await getLastRepoTag({
2373
+ currentVersion,
2374
+ onlyStable,
2375
+ logLevel,
2376
+ cwd: config.cwd
2377
+ }) || getFirstCommit(config.cwd);
2187
2378
  return from;
2188
2379
  }
2189
2380
  async function resolveFromTag({
@@ -2191,6 +2382,7 @@ async function resolveFromTag({
2191
2382
  versionMode,
2192
2383
  step,
2193
2384
  packageName,
2385
+ currentVersion,
2194
2386
  graduating,
2195
2387
  logLevel
2196
2388
  }) {
@@ -2202,12 +2394,14 @@ async function resolveFromTag({
2202
2394
  from = await resolveFromTagIndependent({
2203
2395
  cwd: config.cwd,
2204
2396
  packageName,
2397
+ currentVersion,
2205
2398
  graduating,
2206
2399
  logLevel
2207
2400
  });
2208
2401
  } else {
2209
2402
  from = await resolveFromTagUnified({
2210
2403
  config,
2404
+ currentVersion,
2211
2405
  graduating,
2212
2406
  logLevel
2213
2407
  });
@@ -2256,6 +2450,7 @@ async function resolveTags({
2256
2450
  versionMode,
2257
2451
  step,
2258
2452
  packageName: pkg.name,
2453
+ currentVersion: pkg.version,
2259
2454
  graduating,
2260
2455
  logLevel
2261
2456
  });
@@ -3443,4 +3638,4 @@ Git provider: ${provider}`);
3443
3638
  }
3444
3639
  }
3445
3640
 
3446
- export { getPackagesOrBumpedPackages as $, github as A, createGitlabRelease as B, gitlab as C, detectPackageManager as D, determinePublishTag as E, getPackagesToPublishInSelectiveMode as F, getPackagesToPublishInIndependentMode as G, getAuthCommand as H, publishPackage as I, readPackageJson as J, getRootPackage as K, readPackages as L, getPackages as M, getPackageCommits as N, hasLernaJson as O, getIndependentTag as P, getLastStableTag as Q, getLastTag as R, getLastRepoTag as S, getLastPackageTag as T, resolveTags as U, executeHook as V, isInCI as W, getCIName as X, executeFormatCmd as Y, executeBuildCmd as Z, isBumpedPackage as _, providerRelease as a, isGraduatingToStableBetweenVersion as a0, determineSemverChange as a1, determineReleaseType as a2, writeVersion as a3, getPackageNewVersion as a4, updateLernaVersion as a5, extractVersionFromPackageTag as a6, isPrerelease as a7, isStableReleaseType as a8, isPrereleaseReleaseType as a9, isGraduating as aa, getPreid as ab, isChangedPreid as ac, getBumpedPackageIndependently as ad, confirmBump as ae, getBumpedIndependentPackages as af, bump as b, changelog as c, publishSafetyCheck as d, publish as e, getDefaultConfig as f, generateChangelog as g, defineConfig as h, getPackageDependencies as i, getDependentsOf as j, expandPackagesToBumpWithDependents as k, loadRelizyConfig as l, getGitStatus as m, checkGitStatusIfDirty as n, fetchGitTags as o, providerReleaseSafetyCheck as p, detectGitProvider as q, release as r, parseGitRemoteUrl as s, topologicalSort as t, createCommitAndTags as u, pushCommitAndTags as v, writeChangelogToFile as w, getFirstCommit as x, getCurrentGitBranch as y, getCurrentGitRef as z };
3641
+ export { getPackagesOrBumpedPackages as $, github as A, createGitlabRelease as B, gitlab as C, detectPackageManager as D, determinePublishTag as E, getPackagesToPublishInSelectiveMode as F, getPackagesToPublishInIndependentMode as G, getAuthCommand as H, publishPackage as I, readPackageJson as J, getRootPackage as K, readPackages as L, getPackages as M, getPackageCommits as N, hasLernaJson as O, getIndependentTag as P, getLastStableTag as Q, getLastTag as R, getLastRepoTag as S, getLastPackageTag as T, resolveTags as U, executeHook as V, isInCI as W, getCIName as X, executeFormatCmd as Y, executeBuildCmd as Z, isBumpedPackage as _, providerRelease as a, isGraduatingToStableBetweenVersion as a0, determineSemverChange as a1, determineReleaseType as a2, writeVersion as a3, getPackageNewVersion as a4, updateLernaVersion as a5, extractVersionFromPackageTag as a6, isPrerelease as a7, isStableReleaseType as a8, isPrereleaseReleaseType as a9, isGraduating as aa, getPreid as ab, isChangedPreid as ac, getBumpedPackageIndependently as ad, confirmBump as ae, getBumpedIndependentPackages as af, shouldFilterPrereleaseTags as ag, extractVersionFromTag as ah, isTagVersionCompatibleWithCurrent as ai, bump as b, changelog as c, publishSafetyCheck as d, publish as e, getDefaultConfig as f, generateChangelog as g, defineConfig as h, getPackageDependencies as i, getDependentsOf as j, expandPackagesToBumpWithDependents as k, loadRelizyConfig as l, getGitStatus as m, checkGitStatusIfDirty as n, fetchGitTags as o, providerReleaseSafetyCheck as p, detectGitProvider as q, release as r, parseGitRemoteUrl as s, topologicalSort as t, createCommitAndTags as u, pushCommitAndTags as v, writeChangelogToFile as w, getFirstCommit as x, getCurrentGitBranch as y, getCurrentGitRef as z };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "relizy",
3
3
  "type": "module",
4
- "version": "0.2.7",
4
+ "version": "0.2.8",
5
5
  "description": "Changelogen adapter for monorepo management with unified and independent versioning",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",