From cc8f1f955234920d45f70bdb2770d73947d9d455 Mon Sep 17 00:00:00 2001 From: Julie Ralph Date: Thu, 3 Dec 2015 17:26:18 -0800 Subject: [PATCH] feat(testing): package angular2_testing to prepare it for publishing Closes #5682 --- gulpfile.js | 51 +++++++++++++++------- modules_dart/angular2_testing/pubspec.yaml | 6 ++- scripts/publish/pub_publish.sh | 1 + scripts/publish/pubspec_cleaner.js | 5 +++ 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 24a0264c26..4787bdd1b7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -791,7 +791,7 @@ gulp.task('test.transpiler.unittest', // Make a temporary directory and symlink dartium from there (just for this command) // so that it can run. var dartiumTmpdir = path.join(os.tmpdir(), 'dartium' + new Date().getTime().toString()); -gulp.task('test.dart.angular2_testing/ci', ['!pubget.angular2_testing.dart'], function(done) { +gulp.task('test.dart.angular2_testing/ci', ['build/pubspec.dart'], function(done) { runSequence('test.dart.angular2_testing_symlink', 'test.dart.angular2_testing', sequenceComplete(done)); }); @@ -802,11 +802,8 @@ gulp.task( gulp.task('test.dart.angular2_testing', shell.task(['PATH=$PATH:' + dartiumTmpdir + ' pub run test -p dartium'], - {'cwd': 'modules_dart/angular2_testing'})); + {'cwd': 'dist/dart/angular2_testing'})); -gulp.task( - '!pubget.angular2_testing.dart', - pubget.dir(gulp, gulpPlugins, {dir: 'modules_dart/angular2_testing', command: DART_SDK.PUB})); // ----------------- // Pre-test checks @@ -865,18 +862,42 @@ gulp.task('test.typings', // unmodified and directory structure is preserved. // // This task is expected to be run after build/tree.dart -gulp.task('build/pure-packages.dart', function() { - var yaml = require('js-yaml'); - - return gulp.src([ - 'modules_dart/transform/**/*', - '!modules_dart/transform/**/*.proto', - '!modules_dart/transform/pubspec.yaml', - '!modules_dart/transform/**/packages{,/**}', - ]) - .pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2'))); +gulp.task('build/pure-packages.dart', function(done) { + runSequence('build/pure-packages.dart/standalone', 'build/pure-packages.dart/license', + 'build/pure-packages.dart/angular2', sequenceComplete(done)); }); + +gulp.task('build/pure-packages.dart/standalone', function() { + return gulp.src([ + 'modules_dart/**/*', + '!modules_dart/**/*.proto', + '!modules_dart/**/packages{,/**}', + '!modules_dart/payload{,/**}', + '!modules_dart/transform{,/**}', + ]) + .pipe(gulp.dest(CONFIG.dest.dart)); +}); + +gulp.task('build/pure-packages.dart/license', + function() { + return gulp.src(['LICENSE']) + .pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2_testing'))); + }) + + + gulp.task('build/pure-packages.dart/angular2', function() { + var yaml = require('js-yaml'); + + return gulp.src([ + 'modules_dart/transform/**/*', + '!modules_dart/transform/**/*.proto', + '!modules_dart/transform/pubspec.yaml', + '!modules_dart/transform/**/packages{,/**}', + ]) + .pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2'))); + }); + // Builds all Dart packages, but does not compile them gulp.task('build/packages.dart', function(done) { runSequence('lint_protos.dart', 'build/tree.dart', 'build/pure-packages.dart', diff --git a/modules_dart/angular2_testing/pubspec.yaml b/modules_dart/angular2_testing/pubspec.yaml index ab50ff00b6..312442b0e7 100644 --- a/modules_dart/angular2_testing/pubspec.yaml +++ b/modules_dart/angular2_testing/pubspec.yaml @@ -1,9 +1,13 @@ name: angular2_testing +description: 'Helpers to run unit tests for angular2 components and injectables.' +version: 0.0.0 environment: sdk: '>=1.10.0 <2.0.0' dependencies: +# This will be overridden by scripts/publish/pubspec_cleaner +# to point to the current version of Angular2. angular2: - path: ../../dist/dart/angular2 + path: '../angular2' dev_dependencies: test: '^0.12.6' transformers: diff --git a/scripts/publish/pub_publish.sh b/scripts/publish/pub_publish.sh index 627d7851cf..3a8b2ef1db 100755 --- a/scripts/publish/pub_publish.sh +++ b/scripts/publish/pub_publish.sh @@ -37,3 +37,4 @@ publishModule angular2 publishModule benchpress publishModule benchmarks publishModule angular2_material +publishModule angular2_testing diff --git a/scripts/publish/pubspec_cleaner.js b/scripts/publish/pubspec_cleaner.js index 165f120e86..13c417a4b8 100644 --- a/scripts/publish/pubspec_cleaner.js +++ b/scripts/publish/pubspec_cleaner.js @@ -27,4 +27,9 @@ doc['authors'] = Object.keys(BASE_PACKAGE_JSON.contributors).map(function(name) return BASE_PACKAGE_JSON.contributors[name]; }); +if (doc['dependencies'] && doc['dependencies']['angular2']) { + delete doc['dependencies']['angular2']; + doc['dependencies']['angular2'] = BASE_PACKAGE_JSON.version; +} + fs.writeFileSync(pubspecFile, yaml.safeDump(doc));