diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index dccd180707..87cef33162 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -27,3 +27,6 @@ jobs: - name: Lint run: npm run lint + + - name: Verify Publish Configurations + run: ./scripts/lint-publish-configs.sh diff --git a/scripts/lint-publish-configs.sh b/scripts/lint-publish-configs.sh new file mode 100755 index 0000000000..b6f23c15dd --- /dev/null +++ b/scripts/lint-publish-configs.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +PACKAGE_JSON_PATHS=$(find packages/* -type f -name package.json -not -path "*/node_modules/*") +exitCode=0 + +while IFS= read -r PACKAGE_JSON_PATH; do + PACKAGE_NAME=$(<"${PACKAGE_JSON_PATH}" jq .name) + PACKAGE_IS_PRIVATE=$(<"${PACKAGE_JSON_PATH}" jq .private) + + if [[ "${PACKAGE_IS_PRIVATE}" == "true" ]]; then + continue + fi + + PACKAGE_HAS_PUBLISH_CONFIG=$(<"${PACKAGE_JSON_PATH}" jq '.publishConfig != null') + + if [[ "${PACKAGE_HAS_PUBLISH_CONFIG}" == "false" ]]; then + echo "${PACKAGE_NAME} is missing publish config" + exitCode=1 + fi +done <<< "${PACKAGE_JSON_PATHS}" + +exit "${exitCode}"