From 729e38af1944f582203270242646607eeb82a6bc Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Tue, 10 Feb 2015 15:18:16 -0800 Subject: [PATCH] feat(build): add npm publish script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also fixes gulpfile: - `runSequence` needs to be called with `done` callback - `es5build` should only run when the task executes… --- gulpfile.js | 77 ++++++++++++++++++++------------ modules/angular2/README.md | 5 +++ modules/angular2/package.json | 27 +++++------ modules/angular2/pubspec.yaml | 15 +++---- modules/rtts_assert/package.json | 23 +++------- package.json | 30 ++++++++----- scripts/publish/npm_publish.sh | 24 ++++++++++ tools/build/es5build.js | 2 +- tools/build/pubspec.js | 3 ++ 9 files changed, 123 insertions(+), 83 deletions(-) create mode 100755 scripts/publish/npm_publish.sh diff --git a/gulpfile.js b/gulpfile.js index d0c90cdbef..d1a68cd852 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -253,16 +253,19 @@ gulp.task('build/transpile.js.dev.es6', transpile(gulp, gulpPlugins, { srcFolderInsertion: CONFIG.srcFolderInsertion.js })); -gulp.task('build/transpile.js.dev.es5', es5build({ - src: CONFIG.dest.js.dev.es6, - dest: CONFIG.dest.js.dev.es5, - modules: 'instantiate' -})); +gulp.task('build/transpile.js.dev.es5', function() { + return es5build({ + src: CONFIG.dest.js.dev.es6, + dest: CONFIG.dest.js.dev.es5, + modules: 'instantiate' + }); +}); -gulp.task('build/transpile.js.dev', function() { - return runSequence( +gulp.task('build/transpile.js.dev', function(done) { + runSequence( 'build/transpile.js.dev.es6', - 'build/transpile.js.dev.es5' + 'build/transpile.js.dev.es5', + done ); }); @@ -275,16 +278,19 @@ gulp.task('build/transpile.js.prod.es6', transpile(gulp, gulpPlugins, { srcFolderInsertion: CONFIG.srcFolderInsertion.js })); -gulp.task('build/transpile.js.prod.es5', es5build({ - src: CONFIG.dest.js.prod.es6, - dest: CONFIG.dest.js.prod.es5, - modules: 'instantiate' -})); +gulp.task('build/transpile.js.prod.es5', function() { + return es5build({ + src: CONFIG.dest.js.prod.es6, + dest: CONFIG.dest.js.prod.es5, + modules: 'instantiate' + }); +}); -gulp.task('build/transpile.js.prod', function() { - return runSequence( +gulp.task('build/transpile.js.prod', function(done) { + runSequence( 'build/transpile.js.prod.es6', - 'build/transpile.js.prod.es5' + 'build/transpile.js.prod.es5', + done ); }); @@ -344,11 +350,19 @@ gulp.task('build/html.dart', html(gulp, gulpPlugins, { gulp.task('build/copy.js.dev', function() { return gulp.src(CONFIG.copy.js) + .pipe(gulpPlugins.template({ + 'channel': 'dev', + 'packageJson': require('./package.json') + })) .pipe(gulp.dest(CONFIG.dest.js.dev.es6)); }); gulp.task('build/copy.js.prod', function() { return gulp.src(CONFIG.copy.js) + .pipe(gulpPlugins.template({ + 'channel': 'prod', + 'packageJson': require('./package.json') + })) .pipe(gulp.dest(CONFIG.dest.js.prod.es6)); }); @@ -522,40 +536,45 @@ gulp.task('ci', function(done) { runSequence( 'test.transpiler.unittest', 'test.js/ci', - 'test.dart/ci' + 'test.dart/ci', + done ); }); // ----------------- // orchestrated targets -gulp.task('build.dart', function() { - return runSequence( +gulp.task('build.dart', function(done) { + runSequence( ['build/deps.js.dart2js', 'build/transpile.dart', 'build/html.dart'], 'build/pubspec.dart', 'build/multicopy.dart', 'build/pubbuild.dart', 'build/analyze.dart', - 'build/format.dart' + 'build/format.dart', + done ); }); -gulp.task('build.js.dev', function() { - return runSequence( +gulp.task('build.js.dev', function(done) { + runSequence( ['build/deps.js.dev', 'build/transpile.js.dev', 'build/html.js.dev', 'build/copy.js.dev'], - 'build/multicopy.js.dev' + 'build/multicopy.js.dev', + done ); }); -gulp.task('build.js.prod', function() { - return runSequence( +gulp.task('build.js.prod', function(done) { + runSequence( ['build/deps.js.prod', 'build/transpile.js.prod', 'build/html.js.prod', 'build/copy.js.prod'], - 'build/multicopy.js.prod' + 'build/multicopy.js.prod', + done ); }); -gulp.task('build.cjs', function() { - return runSequence( - ['build/transpile/tools.cjs', 'build/transpile/e2eTest.cjs'] +gulp.task('build.cjs', function(done) { + runSequence( + ['build/transpile/tools.cjs', 'build/transpile/e2eTest.cjs'], + done ); }); diff --git a/modules/angular2/README.md b/modules/angular2/README.md index 511b8a4be5..495ab16cbe 100644 --- a/modules/angular2/README.md +++ b/modules/angular2/README.md @@ -3,6 +3,11 @@ Angular2 The sources for this package are in the main [Angular2](https://github.com/angular/angular) repo. Please file issues and pull requests against that repo. This is the repository for the upcoming 2.0 version. If you're looking for the current official version of Angular you should go to [angular/angular.js](https://github.com/angular/angular.js) +Angular2 has 2 versions: + +1. a development version that includes runtime type assertions: See `ng2dev` npm tag +2. a production version that does not include runtime type assertions: See `ng2prod` npm tag + All sources are in ES6 format and have the suffix `.es6`. They don't depend on any runtime and can be used by any modern ES6 -> ES5 transpiler. diff --git a/modules/angular2/package.json b/modules/angular2/package.json index 5cc5e374da..0c57045f27 100644 --- a/modules/angular2/package.json +++ b/modules/angular2/package.json @@ -1,23 +1,16 @@ { - "name": "angular2", - "version": "2.0.0-alpha.1", + "name": "angular", + "version": "<%= packageJson.version %>.<%= channel %>", "description": "Angular 2 - a web framework for modern web apps", - "homepage": "https://github.com/angular/angular", - "bugs": "https://github.com/angular/angular/issues", - "contributors": { - "Alex Eagle": "alexeagle@google.com", - "Chirayu Krishnappa": "chirayu@google.com", - "Jeff Cross": "crossj@google.com", - "Misko Hevery": "misko@google.com", - "Rado Kirov": "radokirov@google.com", - "Tobias Bosch": "tbosch@google.com", - "Victor Savkin": "vsavkin@google.com", - "Yegor Jbanov": "yjbanov@google.com" - }, - "license": "Apache-2.0", + "homepage": "<%= packageJson.homepage %>", + "bugs": "<%= packageJson.bugs %>", + "contributors": <%= JSON.stringify(packageJson.contributors) %>, + "license": "<%= packageJson.license %>", "dependencies": { - "zone": "0.4.*", - "rtts-assert": "2.0.0-alpha.1" + <% if (channel==='dev') { %> + "ng-rtts-assert": "<%= packageJson.version %>", + <% } %> + "zone.js": "0.4.*" }, "devDependencies": { "yargs": "2.3.*", diff --git a/modules/angular2/pubspec.yaml b/modules/angular2/pubspec.yaml index 0475e6b9c3..adf53cb0d7 100644 --- a/modules/angular2/pubspec.yaml +++ b/modules/angular2/pubspec.yaml @@ -1,16 +1,11 @@ name: angular2 -version: 2.0.0-alpha.1 +version: <%= packageJson.version %> authors: -- Alex Eagle -- Chirayu Krishnappa -- Jeff Cross -- Misko Hevery -- Rado Kirov -- Tobias Bosch -- Victor Savkin -- Yegor Jbanov +<%= Object.keys(packageJson.contributors).map(function(name) { + return '- '+name+' <'+packageJson.contributors[name]+'>'; +}).join('\n') %> description: Angular 2 for Dart - a web framework for modern web apps -homepage: https://github.com/angular/angular +homepage: <%= packageJson.homepage %> environment: sdk: '>=1.4.0' dependencies: diff --git a/modules/rtts_assert/package.json b/modules/rtts_assert/package.json index c5460b8744..15224df9b5 100644 --- a/modules/rtts_assert/package.json +++ b/modules/rtts_assert/package.json @@ -1,20 +1,11 @@ { - "name": "rtts-assert", - "version": "2.0.0-alpha.1", - "description": "A type assertion library for Traceur.", - "homepage": "https://github.com/angular/angular", - "bugs": "https://github.com/angular/angular/issues", - "contributors": { - "Alex Eagle": "alexeagle@google.com", - "Chirayu Krishnappa": "chirayu@google.com", - "Jeff Cross": "crossj@google.com", - "Misko Hevery": "misko@google.com", - "Rado Kirov": "radokirov@google.com", - "Tobias Bosch": "tbosch@google.com", - "Victor Savkin": "vsavkin@google.com", - "Yegor Jbanov": "yjbanov@google.com" - }, - "license": "Apache-2.0", + "name": "ng-rtts-assert", + "version": "<%= packageJson.version %>", + "description": "A run-time type assertion library for JavaScript", + "homepage": "<%= packageJson.homepage %>", + "bugs": "<%= packageJson.bugs %>", + "contributors": <%= JSON.stringify(packageJson.contributors) %>, + "license": "<%= packageJson.license %>", "devDependencies": { "yargs": "2.3.*", "gulp-sourcemaps": "1.3.*", diff --git a/package.json b/package.json index dc45085667..4ecfd1c850 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,27 @@ { "name": "angular", - "version": "0.0.0", - "description": "Angular", + "version": "2.0.0-alpha.5", + "description": "Angular 2 - a web framework for modern web apps", + "homepage": "https://github.com/angular/angular", + "bugs": "https://github.com/angular/angular/issues", + "contributors": { + "Alex Eagle": "alexeagle@google.com", + "Chirayu Krishnappa": "chirayu@google.com", + "Jeff Cross": "crossj@google.com", + "Misko Hevery": "misko@google.com", + "Rado Kirov": "radokirov@google.com", + "Tobias Bosch": "tbosch@google.com", + "Victor Savkin": "vsavkin@google.com", + "Yegor Jbanov": "yjbanov@google.com" + }, + "license": "Apache-2.0", "repository": { "type": "git", "url": "https://github.com/angular/angular.git" }, - "bugs": "https://github.com/angular/angular/issues", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "author": "Tobias Bosch ", - "license": "Apache-2.0", "dependencies": { "es6-module-loader": "^0.9.2", "systemjs": "^0.9.1", @@ -22,9 +32,6 @@ "node-uuid": "1.4.x" }, "devDependencies": { - "yargs": "2.3.*", - "gulp-sourcemaps": "1.3.*", - "gulp-traceur": "0.16.*", "angular": "1.3.5", "bower": "^1.3.12", "canonical-path": "0.0.2", @@ -36,11 +43,13 @@ "gulp": "^3.8.8", "gulp-changed": "^1.0.0", "gulp-connect": "~1.0.5", - "gulp-ejs": "^0.3.1", "gulp-jasmine": "^1.0.1", "gulp-load-plugins": "^0.7.1", "gulp-rename": "^1.2.0", "gulp-shell": "^0.2.10", + "gulp-sourcemaps": "1.3.*", + "gulp-template": "^3.0.0", + "gulp-traceur": "0.16.*", "gulp-webserver": "^0.8.7", "karma": "^0.12.23", "karma-chrome-launcher": "^0.1.4", @@ -55,6 +64,7 @@ "q": "^1.0.1", "run-sequence": "^0.3.6", "sprintf-js": "1.0.*", - "through2": "^0.6.1" + "through2": "^0.6.1", + "yargs": "2.3.*" } } diff --git a/scripts/publish/npm_publish.sh b/scripts/publish/npm_publish.sh new file mode 100755 index 0000000000..9398816ee9 --- /dev/null +++ b/scripts/publish/npm_publish.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -ex + +ROOT_DIR=$(cd $(dirname $0)/../..; pwd) +cd $ROOT_DIR +gulp clean +gulp build.js.prod build.js.dev + +function angular { + CHANNEL=$1 + cd $ROOT_DIR/dist/js/$CHANNEL/es6/angular2 + rm -fr test + npm publish ./ --tag "ng2$CHANNEL" +} + +function rttsAssert { + cd $ROOT_DIR/dist/js/prod/es6/rtts_assert + rm -fr test + npm publish ./ +} + +rttsAssert +angular dev +angular prod diff --git a/tools/build/es5build.js b/tools/build/es5build.js index 3956867856..b16f9d9e7a 100755 --- a/tools/build/es5build.js +++ b/tools/build/es5build.js @@ -47,7 +47,7 @@ if (!module.parent) { function run(config) { var src = ['!node_modules', '!node_modules/**', './**/*.es6']; - gulp.src(src, {cwd: config.src}) + return gulp.src(src, {cwd: config.src}) .pipe(rename(function(file) { file.extname = file.extname.replace('.es6', '.js'); })) diff --git a/tools/build/pubspec.js b/tools/build/pubspec.js index b96b4f9802..cd450a93e9 100644 --- a/tools/build/pubspec.js +++ b/tools/build/pubspec.js @@ -9,6 +9,9 @@ module.exports = function(gulp, plugins, config) { var files = []; var pubSpecCopy = util.streamToPromise(gulp.src(config.src) .pipe(plugins.changed(config.dest)) // Only forward files that changed. + .pipe(plugins.template({ + 'packageJson': require('../../package.json') + })) .pipe(through2.obj(function(file, enc, done) { files.push(path.resolve(process.cwd(), config.dest, file.relative)); this.push(file);