Skip to content

Commit

Permalink
chore: [DX-2725] update browser bundle versions in docs (#1608)
Browse files Browse the repository at this point in the history
  • Loading branch information
carleeto authored Mar 20, 2024
1 parent b4d7517 commit 8623a1d
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion .github/scripts/update-docs-link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e
set -x

if [ -z "VERSION" ]
if [ -z "$VERSION" ]
then
echo "VERSION is not set"
exit 1
Expand All @@ -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
)

0 comments on commit 8623a1d

Please sign in to comment.