Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump semver from 7.2.2 to 7.3.2 #1546

Merged
merged 2 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@jsii/dotnet-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@types/node": "^10.17.19",
"@types/semver": "^7.1.0",
"jsii-build-tools": "^0.0.0",
"semver": "^7.2.2",
"semver": "^7.3.2",
"typescript": "~3.8.3"
}
}
37 changes: 25 additions & 12 deletions packages/jsii-pacmak/lib/targets/version-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Comparator, Range } from 'semver';
* @see https://cwiki.apache.org/confluence/display/MAVENOLD/Dependency+Mediation+and+Conflict+Resolution
*/
export function toMavenVersionRange(semverRange: string, suffix?: string): string {
return toBracketNotation(semverRange, suffix);
return toBracketNotation(semverRange, suffix, { semver: false });
}

/**
Expand All @@ -34,41 +34,45 @@ export function toPythonVersionRange(semverRange: string): string {
return range.set.map(
set => set.map(
comp => {
const versionId = comp.semver.raw?.replace(/-0$/, '') ?? '0.0.0';
switch (comp.operator) {
case '':
// With ^0.0.0, somehow we get a left entry with an empty operator and value, we'll fix this up
return comp.value === '' ? '>=0.0.0' : `==${versionId}`;
case '=':
return `==${comp.semver.raw}`;
return `==${versionId}`;
default: // >, >=, <, <= are all valid expressions
return `${comp.operator}${comp.semver.raw}`;
return `${comp.operator}${versionId}`;
}
}
).join(', ')
).join(', ');
}

function toBracketNotation(semverRange: string, suffix?: string): string {
function toBracketNotation(semverRange: string, suffix?: string, { semver = true }: { semver?: boolean } = {}): string {
const range = new Range(semverRange);
return range.set.map(set => {
if (set.length === 1) {
const version = set[0].semver.raw;
switch (set[0].operator || '=') {
// "[version]" => means exactly version
case '=': return `[${addSuffix(set[0].semver.raw)}]`;
case '=': return `[${addSuffix(version)}]`;
// "(version,]" => means greater than version
case '>': return `(${addSuffix(set[0].semver.raw)},]`;
case '>': return `(${addSuffix(version)},]`;
// "[version,]" => means greater than or equal to that version
case '>=': return `[${addSuffix(set[0].semver.raw)},]`;
case '>=': return `[${addSuffix(version)},]`;
// "[,version)" => means less than version
case '<': return `[,${addSuffix(set[0].semver.raw)})`;
case '<': return `[,${addSuffix(version, !semver)})`;
// "[,version]" => means less than or equal to version
case '<=': return `[,${addSuffix(set[0].semver.raw)}]`;
case '<=': return `[,${addSuffix(version)}]`;
}
} else if (set.length === 2) {
const nugetRange = toBracketRange(set[0], set[1]);
if (nugetRange) {
return nugetRange;
}
}
throw new Error(`Unsupported SemVer range set: ${set.map(comp => comp.value).join(', ')}`);
throw new Error(`Unsupported SemVer range set in ${semverRange}: ${set.map(comp => comp.value).join(', ')}`);
}).join(', ');

function toBracketRange(left: Comparator, right: Comparator): string | undefined {
Expand All @@ -77,17 +81,26 @@ function toBracketNotation(semverRange: string, suffix?: string): string {
[left, right] = [right, left];
}

// With ^0.0.0, somehow we get a left entry with an empty operator and value, we'll fix this up
if (left.operator === '' && left.value === '') {
left = new Comparator('>=0.0.0', left.options);
}

if (!left.operator.startsWith('>') || !right.operator.startsWith('<')) {
// We only support ranges defined like "> (or >=) left, < (or <=) right"
return undefined;
}

const leftBrace = left.operator.endsWith('=') ? '[' : '(';
const rightBrace = right.operator.endsWith('=') ? ']' : ')';
return `${leftBrace}${addSuffix(left.semver.raw)},${addSuffix(right.semver.raw)}${rightBrace}`;
return `${leftBrace}${addSuffix(left.semver.raw)},${addSuffix(right.semver.raw, right.operator === '<' && !semver)}${rightBrace}`;
}

function addSuffix(str: string) {
function addSuffix(str: string | undefined, trimDashZero = false) {
if (!str) { return ''; }
if (trimDashZero) {
str = str.replace(/-0$/, '');
}
return suffix ? `${str}${suffix}` : str;
}
}
2 changes: 1 addition & 1 deletion packages/jsii-pacmak/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"fs-extra": "^9.0.0",
"jsii-reflect": "^0.0.0",
"jsii-rosetta": "^0.0.0",
"semver": "^7.2.2",
"semver": "^7.3.2",
"spdx-license-list": "^6.1.0",
"xmlbuilder": "^15.1.1",
"yargs": "^15.3.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Amazon.JSII.Runtime" Version="[0.0.0,0.0.1)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId" Version="[0.0.0,0.0.1)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId" Version="[0.0.0,0.0.1-0)" />
</ItemGroup>
<PropertyGroup>
<NoWarn>0612,0618</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Amazon.JSII.Runtime" Version="[0.0.0,0.0.1)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BasePackageId" Version="[0.0.0,0.0.1)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId" Version="[0.0.0,0.0.1)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BasePackageId" Version="[0.0.0,0.0.1-0)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId" Version="[0.0.0,0.0.1-0)" />
</ItemGroup>
<PropertyGroup>
<NoWarn>0612,0618</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Amazon.JSII.Runtime" Version="[0.0.0,0.0.1)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BasePackageId" Version="[0.0.0,0.0.1)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId" Version="[0.0.0,0.0.1)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.LibPackageId" Version="[0.0.0-devpreview,0.0.1)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BasePackageId" Version="[0.0.0,0.0.1-0)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId" Version="[0.0.0,0.0.1-0)" />
<PackageReference Include="Amazon.JSII.Tests.CalculatorPackageId.LibPackageId" Version="[0.0.0-devpreview,0.0.1-0)" />
</ItemGroup>
<PropertyGroup>
<NoWarn>0612,0618</NoWarn>
Expand Down
8 changes: 4 additions & 4 deletions packages/jsii-pacmak/test/targets/version-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const examples: Record<string, { maven: string, nuget: string, python: string }>
},
'~1.2.3': {
maven: '[1.2.3,1.3.0)',
nuget: '[1.2.3,1.3.0)',
nuget: '[1.2.3,1.3.0-0)',
python: '>=1.2.3, <1.3.0',
},
'^1.2.3': {
maven: '[1.2.3,2.0.0)',
nuget: '[1.2.3,2.0.0)',
nuget: '[1.2.3,2.0.0-0)',
python: '>=1.2.3, <2.0.0',
},

Expand All @@ -26,12 +26,12 @@ const examples: Record<string, { maven: string, nuget: string, python: string }>
},
'~0.1.2': {
maven: '[0.1.2,0.2.0)',
nuget: '[0.1.2,0.2.0)',
nuget: '[0.1.2,0.2.0-0)',
python: '>=0.1.2, <0.2.0',
},
'^0.1.2': {
maven: '[0.1.2,0.2.0)',
nuget: '[0.1.2,0.2.0)',
nuget: '[0.1.2,0.2.0-0)',
python: '>=0.1.2, <0.2.0',
},

Expand Down
2 changes: 1 addition & 1 deletion packages/jsii/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"deep-equal": "^2.0.2",
"fs-extra": "^9.0.0",
"log4js": "^6.2.0",
"semver": "^7.2.2",
"semver": "^7.3.2",
"semver-intersect": "^1.4.0",
"sort-json": "^2.0.0",
"spdx-license-list": "^6.1.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7931,10 +7931,10 @@ [email protected], semver@^6.0.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.2.2:
version "7.2.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.2.2.tgz#d01432d74ed3010a20ffaf909d63a691520521cd"
integrity sha512-Zo84u6o2PebMSK3zjJ6Zp5wi8VnQZnEaCP13Ul/lt1ANsLACxnJxq4EEm1PY94/por1Hm9+7xpIswdS5AkieMA==
semver@^7.3.2:
version "7.3.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==

serialize-javascript@^2.1.2:
version "2.1.2"
Expand Down