aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src/prepublish_checks.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/monorepo-scripts/src/prepublish_checks.ts')
-rw-r--r--packages/monorepo-scripts/src/prepublish_checks.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/packages/monorepo-scripts/src/prepublish_checks.ts b/packages/monorepo-scripts/src/prepublish_checks.ts
index 0bd3bb0c1..5848cea8d 100644
--- a/packages/monorepo-scripts/src/prepublish_checks.ts
+++ b/packages/monorepo-scripts/src/prepublish_checks.ts
@@ -2,12 +2,13 @@ import * as fs from 'fs';
import * as _ from 'lodash';
import * as path from 'path';
import { exec as execAsync } from 'promisify-child-process';
+import semver = require('semver');
+import semverSort = require('semver-sort');
import { constants } from './constants';
import { Changelog, PackageRegistryJson } from './types';
import { changelogUtils } from './utils/changelog_utils';
import { npmUtils } from './utils/npm_utils';
-import { semverUtils } from './utils/semver_utils';
import { utils } from './utils/utils';
async function prepublishChecksAsync(): Promise<void> {
@@ -63,7 +64,8 @@ async function checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(
continue; // noop for packages not yet published to NPM
}
const allVersionsIncludingUnpublished = npmUtils.getPreviouslyPublishedVersions(packageRegistryJsonIfExists);
- const latestNPMVersion = semverUtils.getLatestVersion(allVersionsIncludingUnpublished);
+ const sortedVersions = semverSort.desc(allVersionsIncludingUnpublished);
+ const latestNPMVersion = sortedVersions[0];
if (packageVersion !== latestNPMVersion) {
versionMismatches.push({
packageJsonVersion: packageVersion,
@@ -96,13 +98,13 @@ async function checkChangelogFormatAsync(updatedPublicLernaPackages: LernaPackag
if (!_.isEmpty(changelog)) {
const lastEntry = changelog[0];
const doesLastEntryHaveTimestamp = !_.isUndefined(lastEntry.timestamp);
- if (semverUtils.lessThan(lastEntry.version, currentVersion)) {
+ if (semver.lt(lastEntry.version, currentVersion)) {
changeLogInconsistencies.push({
packageJsonVersion: currentVersion,
changelogVersion: lastEntry.version,
packageName,
});
- } else if (semverUtils.greaterThan(lastEntry.version, currentVersion) && doesLastEntryHaveTimestamp) {
+ } else if (semver.gt(lastEntry.version, currentVersion) && doesLastEntryHaveTimestamp) {
// Remove incorrectly added timestamp
delete changelog[0].timestamp;
// Save updated CHANGELOG.json