Skip to content

Commit f783841

Browse files
committed
chore(packaging): pub publish script
1 parent f30e3e5 commit f783841

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"gulp-template": "^3.0.0",
5454
"gulp-traceur": "0.16.*",
5555
"gulp-webserver": "^0.8.7",
56+
"js-yaml": "^3.2.7",
5657
"karma": "^0.12.23",
5758
"karma-chrome-launcher": "^0.1.4",
5859
"karma-cli": "^0.0.4",

scripts/publish/pub_publish.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Publishes Angular 2 packages to pub.
4+
5+
set -ex
6+
shopt -s extglob
7+
8+
ROOT_DIR=$(cd $(dirname $0)/../..; pwd)
9+
cd $ROOT_DIR
10+
11+
gulp clean
12+
gulp build/packages.dart
13+
gulp build/analyze.dart
14+
15+
PKG_DIR=$ROOT_DIR/dist/pub
16+
rm -fr $PKG_DIR
17+
FILES='!(e2e_test|pubspec.lock)'
18+
19+
function publishModule {
20+
NAME=$1
21+
PUBLISH_DIR=$PKG_DIR/$NAME
22+
rm -fr $PUBLISH_DIR
23+
mkdir -p $PUBLISH_DIR
24+
25+
cp -RP $ROOT_DIR/dist/dart/$NAME/$FILES $PUBLISH_DIR
26+
27+
node scripts/publish/pubspec_cleaner.js --pubspec-file=$PUBLISH_DIR/pubspec.yaml
28+
29+
(cd $PUBLISH_DIR && pub publish)
30+
}
31+
32+
publishModule angular2
33+
publishModule benchpress

scripts/publish/pubspec_cleaner.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Cleans up pubspec.yaml files prior to publishing
2+
// Usage: node pubspec_cleaner.js --pubspec-file=PATH_TO_PUBSPEC_YAML
3+
4+
fs = require('fs');
5+
yaml = require('js-yaml');
6+
yargs = require('yargs');
7+
8+
var pubspecFileOpt = 'pubspec-file';
9+
var pubspecFile = yargs
10+
.demand([pubspecFileOpt])
11+
.argv[pubspecFileOpt];
12+
13+
var doc = yaml.safeLoad(fs.readFileSync(pubspecFile, 'utf8'));
14+
15+
// Pub does not allow publishing with dependency_overrides
16+
delete doc['dependency_overrides'];
17+
18+
fs.writeFileSync(pubspecFile, yaml.safeDump(doc));

0 commit comments

Comments
 (0)