aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src/prepublish_checks.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-19 01:00:39 +0800
committerFabio Berger <me@fabioberger.com>2018-06-19 05:08:33 +0800
commit3e64b3da398a90e6ddfc287ebf28ec780b64b56f (patch)
treec1788d98471b58f90d99fa8bedb1553725cec4b6 /packages/monorepo-scripts/src/prepublish_checks.ts
parent9a748c8bf1dfd1a090e3d44a4cbebb59bcedd5e6 (diff)
downloaddexon-0x-contracts-3e64b3da398a90e6ddfc287ebf28ec780b64b56f.tar.gz
dexon-0x-contracts-3e64b3da398a90e6ddfc287ebf28ec780b64b56f.tar.zst
dexon-0x-contracts-3e64b3da398a90e6ddfc287ebf28ec780b64b56f.zip
Use semver library instead of semverUtils
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