diff --git a/package.json b/package.json index 7438ac386c..a00de44e4b 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "gulp-template": "^3.0.0", "gulp-traceur": "0.16.*", "gulp-webserver": "^0.8.7", + "js-yaml": "^3.2.7", "karma": "^0.12.23", "karma-chrome-launcher": "^0.1.4", "karma-cli": "^0.0.4", diff --git a/scripts/publish/pub_publish.sh b/scripts/publish/pub_publish.sh new file mode 100755 index 0000000000..f0bb91a388 --- /dev/null +++ b/scripts/publish/pub_publish.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Publishes Angular 2 packages to pub. + +set -ex +shopt -s extglob + +ROOT_DIR=$(cd $(dirname $0)/../..; pwd) +cd $ROOT_DIR + +gulp clean +gulp build/packages.dart +gulp build/analyze.dart + +PKG_DIR=$ROOT_DIR/dist/pub +rm -fr $PKG_DIR +FILES='!(e2e_test|pubspec.lock)' + +function publishModule { + NAME=$1 + PUBLISH_DIR=$PKG_DIR/$NAME + rm -fr $PUBLISH_DIR + mkdir -p $PUBLISH_DIR + + cp -RP $ROOT_DIR/dist/dart/$NAME/$FILES $PUBLISH_DIR + + node scripts/publish/pubspec_cleaner.js --pubspec-file=$PUBLISH_DIR/pubspec.yaml + + (cd $PUBLISH_DIR && pub publish) +} + +publishModule angular2 +publishModule benchpress diff --git a/scripts/publish/pubspec_cleaner.js b/scripts/publish/pubspec_cleaner.js new file mode 100644 index 0000000000..7768712f34 --- /dev/null +++ b/scripts/publish/pubspec_cleaner.js @@ -0,0 +1,18 @@ +// Cleans up pubspec.yaml files prior to publishing +// Usage: node pubspec_cleaner.js --pubspec-file=PATH_TO_PUBSPEC_YAML + +fs = require('fs'); +yaml = require('js-yaml'); +yargs = require('yargs'); + +var pubspecFileOpt = 'pubspec-file'; +var pubspecFile = yargs + .demand([pubspecFileOpt]) + .argv[pubspecFileOpt]; + +var doc = yaml.safeLoad(fs.readFileSync(pubspecFile, 'utf8')); + +// Pub does not allow publishing with dependency_overrides +delete doc['dependency_overrides']; + +fs.writeFileSync(pubspecFile, yaml.safeDump(doc));