From c231859f29d119a57a72b9ad084e1e322911dfd8 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 31 Oct 2022 10:53:27 -0700 Subject: [PATCH 1/6] Squashed commit of the following: commit b5c85475747f5149c2c52731f2cb9d174687f9fa Author: Tyler Butler Date: Fri Oct 28 11:54:51 2022 -0700 further relax version handling for prerelease/dev versions commit 39df103685f8c277e2ae88add90f46e34571b868 Author: Tyler Butler Date: Fri Oct 28 10:03:48 2022 -0700 build: Fix dependency ranges in published packages --- .../templates/include-set-package-version.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/pipelines/templates/include-set-package-version.yml b/tools/pipelines/templates/include-set-package-version.yml index 680a91037834..21529036b340 100644 --- a/tools/pipelines/templates/include-set-package-version.yml +++ b/tools/pipelines/templates/include-set-package-version.yml @@ -86,27 +86,25 @@ steps: echo VERSION_PATCH=$VERSION_PATCH echo VERSION_INCLUDE_INTERNAL_VERSIONS=$VERSION_INCLUDE_INTERNAL_VERSIONS - # Generate the build version + # Generate the build version. Sets the environment variables version, codeVersion, and isLatest. + # These are referenced in following steps prefixed by this task name. E.g. SetVersion.version flub generate buildVersion - task: Bash@3 displayName: Update Package Version env: VERSION_RELEASE: $(release) + RELEASE_GROUP: ${{ parameters.tagName }} inputs: targetType: 'inline' workingDirectory: ${{ parameters.buildDirectory }} script: | echo SETVERSION_VERSION=$SETVERSION_VERSION echo SETVERSION_CODEVERSION=$SETVERSION_CODEVERSION + echo RELEASE_GROUP=$RELEASE_GROUP if [ -f "lerna.json" ]; then - if [ "$VERSION_RELEASE" = "release" ]; then - # no need to run anything here, as the version in the package should be correct - npx lerna exec "if [ \`npm -s run env echo '\$npm_package_version'\` != '$(SetVersion.version)' ]; then ( exit 1 ) fi" - exit $? - fi - npx lerna version $(SetVersion.version) --no-git-tag-version --no-push --yes --exact + flub bump $RELEASE_GROUP --exact $(SetVersion.version) -xv else npm version $(SetVersion.version) --no-git-tag-version -f --allow-same-version fi From 3077a92095970b6871922a69580e719aa41fc2c5 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 31 Oct 2022 10:59:06 -0700 Subject: [PATCH 2/6] Squashed commit of the following: commit 777d75311ff446697ce7b4016d1509c55a74bda1 Merge: 0b8bdcc4e7 e900a5858c Author: Tyler Butler Date: Mon Oct 31 10:57:21 2022 -0700 Merge branch 'pipeline/fix-ranges' of https://github.com/microsoft/FluidFramework into pipeline/fix-ranges commit 0b8bdcc4e725100878e3c7709606bab1075c6277 Merge: b5c8547574 e08c825da4 Author: Tyler Butler Date: Mon Oct 31 10:55:41 2022 -0700 Merge branch 'main' into pipeline/fix-ranges commit e900a5858c901072bb11bbcacea15074d7360da9 Author: Tyler Butler Date: Fri Oct 28 11:54:51 2022 -0700 fix(version-tools): Accept prerelease/dev versions for range bumps commit 84b8fa04a98d46f0e330685d8dfabca7e2109e79 Merge: da04d419e4 562240e9e5 Author: Tyler Butler Date: Fri Oct 28 15:39:57 2022 -0700 Merge branch 'main' into pipeline/fix-ranges commit da04d419e41cd510818c167e6a0b40b9171e11e5 Author: Tyler Butler Date: Fri Oct 28 15:36:39 2022 -0700 debugging commit 29791d04927ec627255d82d44adba713d6a41996 Author: Tyler Butler Date: Fri Oct 28 10:03:48 2022 -0700 build: Fix dependency ranges in published packages commit b5c85475747f5149c2c52731f2cb9d174687f9fa Author: Tyler Butler Date: Fri Oct 28 11:54:51 2022 -0700 further relax version handling for prerelease/dev versions commit 39df103685f8c277e2ae88add90f46e34571b868 Author: Tyler Butler Date: Fri Oct 28 10:03:48 2022 -0700 build: Fix dependency ranges in published packages --- .../version-tools/src/internalVersionScheme.ts | 12 +++++++----- .../src/test/internalVersionScheme.test.ts | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/build-tools/packages/version-tools/src/internalVersionScheme.ts b/build-tools/packages/version-tools/src/internalVersionScheme.ts index eba5ce025663..a25f19e7b8e3 100644 --- a/build-tools/packages/version-tools/src/internalVersionScheme.ts +++ b/build-tools/packages/version-tools/src/internalVersionScheme.ts @@ -250,7 +250,7 @@ export function isInternalVersionRange(range: string, allowAnyPrereleaseId = fal return false; } - return isInternalVersionScheme(minVer, false, allowAnyPrereleaseId); + return isInternalVersionScheme(minVer, allowAnyPrereleaseId, allowAnyPrereleaseId); } /** @@ -265,10 +265,12 @@ export function bumpInternalVersion( version: semver.SemVer | string, bumpType: VersionBumpTypeExtended, ): semver.SemVer { - validateVersionScheme(version); - const [pubVer, intVer, prereleaseId] = fromInternalScheme(version, false, true); + validateVersionScheme(version, true, undefined); + const [pubVer, intVer, prereleaseId] = fromInternalScheme(version, true, true); + console.log(intVer.version); const newIntVer = bumpType === "current" ? intVer : intVer.inc(bumpType); - return toInternalScheme(pubVer, newIntVer, false, prereleaseId); + console.log(newIntVer.version); + return toInternalScheme(pubVer, newIntVer, true, prereleaseId); } /** @@ -290,7 +292,7 @@ export function getVersionRange( version: semver.SemVer | string, maxAutomaticBump: "minor" | "patch" | "~" | "^", ): string { - validateVersionScheme(version, false, undefined); + validateVersionScheme(version, true, undefined); const lowVersion = version; let highVersion: semver.SemVer; diff --git a/build-tools/packages/version-tools/src/test/internalVersionScheme.test.ts b/build-tools/packages/version-tools/src/test/internalVersionScheme.test.ts index 70ad42887ae4..c8b8a32a2d96 100644 --- a/build-tools/packages/version-tools/src/test/internalVersionScheme.test.ts +++ b/build-tools/packages/version-tools/src/test/internalVersionScheme.test.ts @@ -243,6 +243,20 @@ describe("internalScheme", () => { assert.isFalse(semver.satisfies(`2.0.0-internal.3.1.0`, range)); }); + it("caret ^ dependency equivalent for prerelease/dev versions", () => { + const input = `2.0.0-dev.1.2.3.12345`; + const expected = `>=2.0.0-dev.1.2.3.12345 <2.0.0-dev.2.0.0`; + const range = getVersionRange(input, "^"); + assert.strictEqual(range, expected); + }); + + it("tilde ~ dependency equivalent for prerelease/dev versions", () => { + const input = `2.0.0-dev.1.2.3.12345`; + const expected = `>=2.0.0-dev.1.2.3.12345 <2.0.0-dev.1.3.0`; + const range = getVersionRange(input, "~"); + assert.strictEqual(range, expected); + }); + /** * Builds that are produced from dev builds or other non-release builds don't have the "internal" prerelease * identifier intentionally to ensure they don't satisfy the caret/tilde-equivalent semver ranges we provide to From 70293ba153b5556b1a873b5fce0e74eabe00dc59 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 31 Oct 2022 11:03:34 -0700 Subject: [PATCH 3/6] Revert "Squashed commit of the following:" This reverts commit c231859f29d119a57a72b9ad084e1e322911dfd8. --- .../templates/include-set-package-version.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/pipelines/templates/include-set-package-version.yml b/tools/pipelines/templates/include-set-package-version.yml index 21529036b340..680a91037834 100644 --- a/tools/pipelines/templates/include-set-package-version.yml +++ b/tools/pipelines/templates/include-set-package-version.yml @@ -86,25 +86,27 @@ steps: echo VERSION_PATCH=$VERSION_PATCH echo VERSION_INCLUDE_INTERNAL_VERSIONS=$VERSION_INCLUDE_INTERNAL_VERSIONS - # Generate the build version. Sets the environment variables version, codeVersion, and isLatest. - # These are referenced in following steps prefixed by this task name. E.g. SetVersion.version + # Generate the build version flub generate buildVersion - task: Bash@3 displayName: Update Package Version env: VERSION_RELEASE: $(release) - RELEASE_GROUP: ${{ parameters.tagName }} inputs: targetType: 'inline' workingDirectory: ${{ parameters.buildDirectory }} script: | echo SETVERSION_VERSION=$SETVERSION_VERSION echo SETVERSION_CODEVERSION=$SETVERSION_CODEVERSION - echo RELEASE_GROUP=$RELEASE_GROUP if [ -f "lerna.json" ]; then - flub bump $RELEASE_GROUP --exact $(SetVersion.version) -xv + if [ "$VERSION_RELEASE" = "release" ]; then + # no need to run anything here, as the version in the package should be correct + npx lerna exec "if [ \`npm -s run env echo '\$npm_package_version'\` != '$(SetVersion.version)' ]; then ( exit 1 ) fi" + exit $? + fi + npx lerna version $(SetVersion.version) --no-git-tag-version --no-push --yes --exact else npm version $(SetVersion.version) --no-git-tag-version -f --allow-same-version fi From 0ad20f8bfd58d247a03ade38fe680c3e41eb301b Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 31 Oct 2022 11:04:34 -0700 Subject: [PATCH 4/6] Apply suggestions from code review --- build-tools/packages/version-tools/src/internalVersionScheme.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-tools/packages/version-tools/src/internalVersionScheme.ts b/build-tools/packages/version-tools/src/internalVersionScheme.ts index a25f19e7b8e3..861e7e2e80b7 100644 --- a/build-tools/packages/version-tools/src/internalVersionScheme.ts +++ b/build-tools/packages/version-tools/src/internalVersionScheme.ts @@ -267,9 +267,7 @@ export function bumpInternalVersion( ): semver.SemVer { validateVersionScheme(version, true, undefined); const [pubVer, intVer, prereleaseId] = fromInternalScheme(version, true, true); - console.log(intVer.version); const newIntVer = bumpType === "current" ? intVer : intVer.inc(bumpType); - console.log(newIntVer.version); return toInternalScheme(pubVer, newIntVer, true, prereleaseId); } From d6662f1f80dd912650a099b94c915a040fe5eaec Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 31 Oct 2022 12:09:46 -0700 Subject: [PATCH 5/6] Update build-tools/packages/version-tools/src/internalVersionScheme.ts --- .../packages/version-tools/src/internalVersionScheme.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-tools/packages/version-tools/src/internalVersionScheme.ts b/build-tools/packages/version-tools/src/internalVersionScheme.ts index 861e7e2e80b7..cc3163db9644 100644 --- a/build-tools/packages/version-tools/src/internalVersionScheme.ts +++ b/build-tools/packages/version-tools/src/internalVersionScheme.ts @@ -250,7 +250,8 @@ export function isInternalVersionRange(range: string, allowAnyPrereleaseId = fal return false; } - return isInternalVersionScheme(minVer, allowAnyPrereleaseId, allowAnyPrereleaseId); + // if allowAnyPrereleaseId === true, then allowPrereleases is implied to be true + return isInternalVersionScheme(minVer, /* allowPrereleases */ allowAnyPrereleaseId, allowAnyPrereleaseId); } /** From e67406a7131f20f230e4dbd35a71252b27c104bb Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Mon, 31 Oct 2022 12:17:37 -0700 Subject: [PATCH 6/6] formatting --- .../packages/version-tools/src/internalVersionScheme.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-tools/packages/version-tools/src/internalVersionScheme.ts b/build-tools/packages/version-tools/src/internalVersionScheme.ts index cc3163db9644..6707acb682e9 100644 --- a/build-tools/packages/version-tools/src/internalVersionScheme.ts +++ b/build-tools/packages/version-tools/src/internalVersionScheme.ts @@ -251,7 +251,11 @@ export function isInternalVersionRange(range: string, allowAnyPrereleaseId = fal } // if allowAnyPrereleaseId === true, then allowPrereleases is implied to be true - return isInternalVersionScheme(minVer, /* allowPrereleases */ allowAnyPrereleaseId, allowAnyPrereleaseId); + return isInternalVersionScheme( + minVer, + /* allowPrereleases */ allowAnyPrereleaseId, + allowAnyPrereleaseId, + ); } /**