From 8623a1dc3df852d1c3fd7b53ec700f1a4e8a3b86 Mon Sep 17 00:00:00 2001 From: Carl Menezes Date: Thu, 21 Mar 2024 09:23:56 +1300 Subject: [PATCH] chore: [DX-2725] update browser bundle versions in docs (#1608) --- .github/scripts/update-docs-link.sh | 59 ++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/.github/scripts/update-docs-link.sh b/.github/scripts/update-docs-link.sh index 6e02020b05..d91c9eb8d0 100755 --- a/.github/scripts/update-docs-link.sh +++ b/.github/scripts/update-docs-link.sh @@ -3,7 +3,7 @@ set -e set -x -if [ -z "VERSION" ] +if [ -z "$VERSION" ] then echo "VERSION is not set" exit 1 @@ -24,4 +24,61 @@ fi else sed -i -E "s/SDK_VERSION = '.*'/SDK_VERSION = '$VERSION'/g;" $FILE fi + + # Update versions in the browserBundle docs (https://docs.immutable.com/docs/x/sdks/typescript/#browser-bundle) + FILE=docs/main/sdks/_typescript.mdx + major=$(awk '{ + split($0, a, "."); + print a[1]; + }' <<< $VERSION) + minor=$(awk '{ + split($0, a, "."); + print a[2]; + }' <<< $VERSION) + patch=$(awk '{ + split($0, a, "."); + print a[3]; + }' <<< $VERSION) + echo "major: $major minor: $minor patch: $patch" + + # On Mac OS, sed requires an empty string as an argument to -i to avoid creating a backup file + # sed -i '' -E ... + # vs on Linux: + # sed -i -E ... + + if [ "$(uname)" == "Darwin" ]; then + # Be careful modifying the regexs below. + # They have been adapted from the numbered capture group version on the semver website: + # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string + # If you do modify them, please update the regex101 links in the comments to reflect the changes. + + # See https://regex101.com/r/FBpHw4/1 for a breakdown of the regex matches + sed -i '' -E "s/sdk@(0|[1-9]\d*)\`/sdk@$major\`/g;" $FILE + + # See https://regex101.com/r/jZeWrd/1 for a breakdown of the regex matches + sed -i '' -E "s/sdk@(0|[1-9]\d*)\.(0|[1-9]\d*)\`/sdk@$major.$minor\`/g;" $FILE + + # See https://regex101.com/r/2RWnGP/1 for a breakdown of the regex matches + sed -i '' -E "s/sdk@(0|[1-9]\d*)\.(0|[1-9]\d*)\.(.*)\`/sdk@$VERSION\`/g;" $FILE + + # See https://regex101.com/r/Gep6h6/1 for a breakdown of the regex matches + sed -i '' -E "s/e\.g\. (0|[1-9]\d*)\.(0|[1-9]\d*)\.(.*)\)/e.g. $VERSION\)/g;" $FILE + else + # Be careful modifying the regexs below. + # They have been adapted from the numbered capture group version on the semver website: + # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string + # If you do modify them, please update the regex101 links in the comments to reflect the changes. + + # See https://regex101.com/r/FBpHw4/1 for a breakdown of the regex matches + sed -i -E "s/sdk@(0|[1-9]\d*)\`/sdk@$major\`/g;" $FILE + + # See https://regex101.com/r/jZeWrd/1 for a breakdown of the regex matches + sed -i -E "s/sdk@(0|[1-9]\d*)\.(0|[1-9]\d*)\`/sdk@$major.$minor\`/g;" $FILE + + # See https://regex101.com/r/2RWnGP/1 for a breakdown of the regex matches + sed -i -E "s/sdk@(0|[1-9]\d*)\.(0|[1-9]\d*)\.(.*)\`/sdk@$VERSION\`/g;" $FILE + + # See https://regex101.com/r/Gep6h6/1 for a breakdown of the regex matches + sed -i -E "s/e\.g\. (0|[1-9]\d*)\.(0|[1-9]\d*)\.(.*)\)/e.g. $VERSION\)/g;" $FILE + fi )