-
-
Save trentm/23591b5bde546a0f2f4b5b057b9d3ad9 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
if [ "$TRACE" != "" ]; then | |
export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' | |
set -o xtrace | |
fi | |
set -o errexit | |
set -o pipefail | |
# ---- support functions | |
function warn { | |
echo "$(basename $0): warn: $*" >&2 | |
} | |
function fatal { | |
echo "$(basename $0): error: $*" >&2 | |
exit 1 | |
} | |
# ---- main | |
pjs=$(json -f package.json workspaces | json -ga | xargs -n1 -I% sh -c "ls %/package.json") | |
# pjs=$(ls packages/*/package.json) # play with subset for dev | |
olddirs="" | |
for pj in $pjs; do | |
echo "# $pj" | |
currdir=$(dirname $pj) | |
parentdir=$(dirname $currdir) | |
currbase=$(basename $currdir) | |
pkgname=$(json -f $pj name) | |
if ! [[ "$pkgname" =~ ^@opentelemetry/ ]]; then | |
fatal "unexpected pkgname: $pkgname" | |
fi | |
expectedbase=${pkgname#@opentelemetry/} | |
expecteddir="$parentdir/$expectedbase" | |
# update pj.repository, etc. | |
json -I -f $pj \ | |
-e "this.repository={type:'git',url:'https://github.com/open-telemetry/opentelemetry-js-contrib.git',directory:'$expecteddir'}" \ | |
-e "this.homepage='https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/$expecteddir#readme'" | |
# move to expected new basedir (matching the package name base) | |
if [[ "$currbase" != "$expectedbase" ]]; then | |
olddirs="$olddirs | |
$currdir" | |
echo git mv $currdir $expecteddir | |
git mv $currdir $expecteddir | |
sed -i.bak -e "s/$currbase/$expectedbase/g" \ | |
.github/component_owners.yml \ | |
.github/component-label-map.yml \ | |
release-please-config.json \ | |
.release-please-manifest.json \ | |
metapackages/auto-instrumentations-web/README.md \ | |
metapackages/auto-instrumentations-node/README.md \ | |
package-lock.json | |
# fatal "$currdir -> $expecteddir" | |
fi | |
done | |
echo "" | |
echo "# olddirs (also written to olddirs.txt)" | |
echo "$olddirs" | sed '/^[[:space:]]*$/d' >olddirs.txt | |
echo "$olddirs" | |
# Follow up tasks: | |
# - manually update the few hits from this: | |
# rg -f olddirs.txt -- $(git ls-files) | |
# - update the repo labels if necessary? test-utils? cassandra-driver? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment