Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
incorporate feedback comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anselm94 committed Apr 25, 2023
1 parent 48313a6 commit a5ea1cf
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .changeset/curvy-gorillas-smoke.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@shopify/shopify-api': patch
---

replace `semver` with `compare-versions` lib to reduce dependency on nodejs builtin-libs
Replace `semver` with `compare-versions` lib to reduce dependency on nodejs builtin-libs
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Config} from 'jest';
import {compare as semver} from 'compare-versions';
import {compare} from 'compare-versions';

const projects = [
'./lib/__tests__/jest_projects/library.jest.config.ts',
Expand All @@ -11,7 +11,7 @@ const projects = [

// eslint-disable-next-line no-warning-comments
// TODO Make all projects permanent after support for version 14 is dropped
if (semver(process.version, '15.0.0', '>=')) {
if (compare(process.version, '15.0.0', '>=')) {
projects.push(
'./lib/__tests__/jest_projects/adapters.cf-worker.jest.config.ts',
);
Expand Down
4 changes: 2 additions & 2 deletions lib/__tests__/test-helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as jose from 'jose';
import {compare as semver} from 'compare-versions';
import {compare} from 'compare-versions';

import {shopifyApi, Shopify} from '..';
import {LATEST_API_VERSION, LogSeverity} from '../types';
Expand Down Expand Up @@ -165,7 +165,7 @@ export function testIfLibraryVersionIsAtLeast(
testFn: jest.ProvidesCallback,
) {
describe(`when library version is at least ${version}`, () => {
if (semver(SHOPIFY_API_LIBRARY_VERSION, version, '>=')) {
if (compare(SHOPIFY_API_LIBRARY_VERSION, version, '>=')) {
test(testName, testFn);
} else {
test.skip(`- '${testName}' requires library version ${version} or higher`, () => {});
Expand Down
4 changes: 2 additions & 2 deletions lib/logger/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {compare as semver} from 'compare-versions';
import {compare} from 'compare-versions';

import {LogSeverity} from '../types';
import {ConfigInterface} from '../base-types';
Expand Down Expand Up @@ -29,7 +29,7 @@ export type ShopifyLogger = ReturnType<typeof logger>;

function deprecated(logFunction: LoggerFunction) {
return function (version: string, message: string): void {
if (semver(SHOPIFY_API_LIBRARY_VERSION, version, '>=')) {
if (compare(SHOPIFY_API_LIBRARY_VERSION, version, '>=')) {
throw new FeatureDeprecatedError(
`Feature was deprecated in version ${version}`,
);
Expand Down
4 changes: 2 additions & 2 deletions lib/setup-jest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {compare as semver} from 'compare-versions';
import {compare} from 'compare-versions';

import '../adapters/mock';
import {mockTestRequests} from '../adapters/mock/mock_test_requests';
Expand Down Expand Up @@ -131,7 +131,7 @@ expect.extend({
return {
message: () =>
`Found deprecation limited to version ${version}, please update or remove it.`,
pass: semver(SHOPIFY_API_LIBRARY_VERSION, version, '<'),
pass: compare(SHOPIFY_API_LIBRARY_VERSION, version, '<'),
};
},
});
4 changes: 2 additions & 2 deletions lib/utils/versioned-codeblocks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {compare as semver} from 'compare-versions';
import {compare} from 'compare-versions';

import {SHOPIFY_API_LIBRARY_VERSION} from '../version';

export function enableCodeAfterVersion(version: string, fn: () => void): void {
if (semver(SHOPIFY_API_LIBRARY_VERSION, version, '>=')) {
if (compare(SHOPIFY_API_LIBRARY_VERSION, version, '>=')) {
fn();
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
},
"dependencies": {
"@shopify/network": "^3.2.1",
"compare-versions": "^6.0.0-rc.1",
"compare-versions": "^5.0.3",
"jose": "^4.9.1",
"node-fetch": "^2.6.1",
"tslib": "^2.0.3",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2526,10 +2526,10 @@ commondir@^1.0.1:
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==

compare-versions@^6.0.0-rc.1:
version "6.0.0-rc.1"
resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-6.0.0-rc.1.tgz#93e6beb8767c2375333ee168fa64c28b75ace2c6"
integrity sha512-cFhkjbGY1jLFWIV7KegECbfuyYPxSGvgGkdkfM+ibboQDoPwg2FRHm5BSNTOApiauRBzJIQH7qvOJs2sW5ueKQ==
compare-versions@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-5.0.3.tgz#a9b34fea217472650ef4a2651d905f42c28ebfd7"
integrity sha512-4UZlZP8Z99MGEY+Ovg/uJxJuvoXuN4M6B3hKaiackiHrgzQFEe3diJi1mf1PNHbFujM7FvLrK2bpgIaImbtZ1A==

component-emitter@^1.3.0:
version "1.3.0"
Expand Down

0 comments on commit a5ea1cf

Please sign in to comment.