Skip to content

Commit

Permalink
Disallow publishing packages with version 0.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rickycodes committed Feb 26, 2024
1 parent d5972c3 commit 1db74c1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ if [[ -z $PUBLISH_NPM_TAG ]]; then
exit 1
fi

CURRENT_PACKAGE_VERSION=$(jq --raw-output .version package.json)

if [[ "$CURRENT_PACKAGE_VERSION" = "0.0.0" ]]; then
echo "Notice: Invalid version: $CURRENT_PACKAGE_VERSION. aborting publish."
exit 0
fi

# check param, if it's set (monorepo) we check if it's published before proceeding
if [[ -n "$1" ]]; then
# check if module is published
PACKAGE_NAME=$(jq --raw-output .name package.json)
LATEST_PACKAGE_VERSION=$(npm view "$PACKAGE_NAME" dist-tags --workspaces false --json | jq --raw-output --arg tag "$PUBLISH_NPM_TAG" '.[$tag]' || echo "")
CURRENT_PACKAGE_VERSION=$(jq --raw-output .version package.json)

if [ "$LATEST_PACKAGE_VERSION" = "$CURRENT_PACKAGE_VERSION" ]; then
echo "Notice: This module is already published at $CURRENT_PACKAGE_VERSION. aborting publish."
Expand Down

0 comments on commit 1db74c1

Please sign in to comment.