Skip to content

Commit

Permalink
Skip package redownload in comparison script script, output diff to file
Browse files Browse the repository at this point in the history
  • Loading branch information
wadimw committed Dec 5, 2024
1 parent 93bb24d commit dbcc903
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/compare-package-contents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@ pnpm -r exec pnpm pack --pack-destination ../../packs/packs-local

# Download each package from npm as a tarball into the `packs/packs-npm` directory
# Ensure matching major version
mkdir -p packs/packs-npm
mkdir -p packs/packs-npm packs/diffs
for file in packs/packs-local/*.tgz; do
tar_name="$(basename "$file" .tgz)"
package_name="${tar_name%-*}" # strip version from tar file name
package_version="${tar_name##*-}" # strip package name from tar file name
package_version_major="${package_version%%.*}" # strip minor and patch version from package version

# Download the corresponding package from npm
npm pack "$package_name@$package_version_major" --pack-destination packs/packs-npm
if [ -f "$(ls packs/packs-npm/"$package_name"-[0-9]*)" ]; then
echo "Package $package_name already downloaded"
else
npm pack "$package_name@$package_version_major" --pack-destination packs/packs-npm
fi

echo "Comparing $package_name"

# Get contents of current package's tarballs excluding the `docs` directory
local_files=$(tar -tf packs/packs-local/"$package_name"-[0-9]* | sort | grep -v '^package/docs/')
npm_files=$(tar -tf packs/packs-npm/"$package_name"-[0-9]* | sort | grep -v '^package/docs/')

diff <(echo "$local_files") <(echo "$npm_files") || true
diff_output=$(diff <(echo "$local_files") <(echo "$npm_files")) || echo "$diff_output" > "packs/diffs/$package_name.diff"
done

0 comments on commit dbcc903

Please sign in to comment.