Skip to content

Commit

Permalink
npmPublish script (#80)
Browse files Browse the repository at this point in the history
skips private packages and already published versions (ie, unchanged)
  • Loading branch information
giladgray authored Nov 11, 2016
1 parent e4419d3 commit 18870ea
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/landing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "blueprint-landing",
"version": "0.1.0",
"description": "Blueprint landing page",
"public": false,
"private": true,
"author": "Palantir Technologies",
"license": "Apache-2.0",
"keywords": [
Expand Down
37 changes: 37 additions & 0 deletions scripts/npmPublish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

cd $(dirname $0)/..
set -e

# ---------------------------------------------------------------------------------------------------------------------
# NPM pre publish

# https://circleci.com/docs/npm-login/
echo -e "$NPM_USER\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login

# ---------------------------------------------------------------------------------------------------------------------
# NPM publish

MODULES=$(ls packages)

for module in $MODULES; do
if [ -e "packages/$module/package.json" ]; then
IS_PRIVATE=$(echo "console.log(require('./packages/$module/package.json').private)" | node)
if [[ $IS_PRIVATE == "true" ]]; then
echo "Skipping private package @blueprintjs/$module"
continue
fi

TO_PUBLISH=$(echo "console.log(require('./packages/$module/package.json').version)" | node)
VERSIONS=$(npm info @blueprintjs/$module versions || echo "new_package")

# check for presence of this version in the list of all published versions
if [[ $VERSIONS == *"'$TO_PUBLISH'"* ]]; then
echo "Nothing to publish for @blueprintjs/$module@$TO_PUBLISH"
else
echo "Publishing @blueprintjs/$module@$TO_PUBLISH..."
# must set public access for scoped packages
npm publish packages/$module --access public
fi
fi
done

1 comment on commit 18870ea

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npmPublish script (#80)

Preview: docs Coverage: core | datetime

Please sign in to comment.