Skip to content

Commit 65e958b

Browse files
committed
feat: enhancements to npm package migrate script
- downloading silently, but show errors - ignore npm lifecycle scripts on publish - add note on permissions issues - recommending to use ` | tee` to write output to separate log file
1 parent 8127914 commit 65e958b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/migrate-npm-packages-between-github-instances.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/bin/bash
22

3-
# Usage: ./migrate-npm-packages-between-github-instances.sh <source-org> <source-host> <target-org> <target-host>
3+
# Usage: ./migrate-npm-packages-between-github-instances.sh <source-org> <source-host> <target-org> <target-host> | tee output.log
44
#
55
#
66
# Prereqs:
77
# 1. [gh cli](https://cli.github.com) installed
88
# 2. Set the source GitHub PAT env var: `export GH_SOURCE_PAT=ghp_abc` (must have at least `read:packages`, `read:org` scope)
99
# 3. Set the target GitHub PAT env var: `export GH_TARGET_PAT=ghp_xyz` (must have at least `write:packages`, `read:org` scope)
1010
#
11-
# Example: ./migrate-npm-packages-between-github-instances.sh joshjohanning-org github.com joshjohanning-emu github.com
11+
# Example: ./migrate-npm-packages-between-github-instances.sh joshjohanning-org github.com joshjohanning-emu github.com | tee output.log
1212
#
1313
# Notes:
1414
# - Mapping the npm package to a repo is optional.
@@ -74,14 +74,15 @@ echo "$packages" | while IFS= read -r response; do
7474
fi
7575

7676
# download
77-
curl -H "Authorization: token $GH_SOURCE_PAT" -L -o $package_name-$version.tgz $url
77+
curl -sS -H "Authorization: token $GH_SOURCE_PAT" -L -o $package_name-$version.tgz $url
7878

7979
# untar
8080
mkdir -p ./$package_name-$version
81+
# if you run into permissions issue, add a `sudo` here
8182
tar xzf $package_name-$version.tgz -C $package_name-$version
8283
cd $package_name-$version/package
8384
perl -pi -e "s/$SOURCE_ORG/$TARGET_ORG/ig" package.json
84-
npm publish --userconfig $temp_dir/.npmrc || echo "skipped package due to failure: $package_name-$version.tgz" >> ./failed-packages.txt
85+
npm publish --ignore-scripts --userconfig $temp_dir/.npmrc || echo "skipped package due to failure: $package_name-$version.tgz" >> ./failed-packages.txt
8586
cd ./../../
8687

8788
done

0 commit comments

Comments
 (0)