-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from replit/dstewart/chore/set-metadata-script
Adding a helpful script to automate some of the tedium around doing updates
- Loading branch information
Showing
1 changed file
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# set-metadata.sh | ||
# A script to help reduce easily avoidable merge conflicts during upgrades. | ||
# | ||
# Usage, presuming we are currently on our release 2.0.8, | ||
# tracking upstream 1.1.353 with the intent to bump to 1.1.354: | ||
# | ||
# $ scripts/set-metadata.sh them 1.1.353 # Revert to the last checkpoint | ||
# $ npm install # Regenerate lockfile | ||
# $ git merge --no-edit 1.1.354 # Sync to desired tag | ||
# $ scripts/set-metadata.sh us 2.0.9 # Reset metadata to next release | ||
# $ npm install # Regenerate lockfile | ||
|
||
die() { | ||
echo "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
modify_packages() { | ||
target="packages/pyright/package.json" | ||
while [ -n "$1" ]; do | ||
case "$1" in | ||
--name) | ||
name="$2"; shift 2 || die 'Missing name' | ||
;; | ||
--displayName) | ||
displayName="$2"; shift 2 || die 'Missing displayName' | ||
;; | ||
--description) | ||
description="$2"; shift 2 || die 'Missing description' | ||
;; | ||
--version) | ||
version="$2"; shift 2 || die 'Missing version' | ||
;; | ||
--author) | ||
author="$2"; shift 2 || die 'Missing author' | ||
;; | ||
--contributors) | ||
contributors_json="$2"; shift 2 || die 'Missing contributors' | ||
;; | ||
--publisher) | ||
publisher="$2"; shift 2 || die 'Missing publisher' | ||
;; | ||
*) | ||
die 'Unknown arguments: $@' | ||
break | ||
;; | ||
esac | ||
done | ||
|
||
contents="$( | ||
jq --indent 4 \ | ||
--arg name "$name" \ | ||
--arg displayName "$displayName" \ | ||
--arg description "$description" \ | ||
--arg version "$version" \ | ||
--arg author "$author" \ | ||
--argjson contributors "$contributors_json" \ | ||
--arg publisher "$publisher" \ | ||
'. | ||
| .name |= $name | ||
| .displayName |= $displayName | ||
| .description |= $description | ||
| .version |= $version | ||
| .author |= (.name |= $author) | ||
| .contributors |= (if $contributors == null then empty else $contributors end) | ||
| .publisher |= $publisher | ||
' \ | ||
< "$target" | ||
)" | ||
echo "$contents" > "$target" | ||
} | ||
|
||
main() { | ||
direction="$1"; shift || die 'Missing direction' | ||
version="$1"; shift || die 'Missing version' | ||
if [ "$direction" = them ]; then | ||
modify_packages \ | ||
--name "pyright" \ | ||
--displayName "Pyright" \ | ||
--description "Type checker for the Python language" \ | ||
--version "$version" \ | ||
--author "Microsoft Corporation" \ | ||
--contributors 'null' \ | ||
--publisher "Microsoft Corporation" | ||
elif [ "$direction" = us ]; then | ||
modify_packages \ | ||
--name "@replit/pyright-extended" \ | ||
--displayName "pyright-extended" \ | ||
--description "Extending pyright with yapf + ruff" \ | ||
--version "$version" \ | ||
--author "Replit" \ | ||
--contributors '[{"name":"Microsoft"}]' \ | ||
--publisher "Replit" | ||
fi | ||
} | ||
|
||
main "$@" |