diff --git a/gulpfile.js b/gulpfile.js index 5ccd8e37b2..6cf274f2a2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -508,9 +508,67 @@ gulp.task('test.transpiler.unittest', function() { // ----------------- // orchestrated targets +// Pure Dart packages only contain Dart code and conform to pub package layout. +// These packages need no transpilation. All code is copied over to `dist` +// unmodified and directory structure is preserved. +// +// This task also fixes relative `dependency_overrides` paths in `pubspec.yaml` +// files. +gulp.task('build/pure-packages.dart', function() { + var through2 = require('through2'); + var yaml = require('js-yaml'); + var originalPrefix = '../../dist/dart/'; + + return gulp + .src([ + 'modules_dart/**/*.dart', + 'modules_dart/**/pubspec.yaml', + ]) + .pipe(through2.obj(function(file, enc, done) { + if (file.path.endsWith('pubspec.yaml')) { + // Pure packages specify dependency_overrides relative to + // `modules_dart`, so they have to walk up and into `dist`. + // + // Example: + // + // dependency_overrides: + // angular2: + // path: ../../dist/dart/angular2 + // + // When we copy a pure package into `dist` the relative path + // must be updated. The code below replaces paths accordingly. + // So the example above is turned into: + // + // dependency_overrides: + // angular2: + // path: ../angular2 + // + var pubspec = yaml.safeLoad(file.contents.toString()); + var overrides = pubspec['dependency_overrides']; + if (overrides) { + Object.keys(overrides).forEach(function(pkg) { + var overridePath = overrides[pkg]['path']; + if (overridePath.startsWith(originalPrefix)) { + overrides[pkg]['path'] = overridePath.replace(originalPrefix, '../'); + } + }); + file.contents = new Buffer(yaml.safeDump(pubspec)); + } + } + this.push(file); + done(); + })) + .pipe(gulp.dest('dist/dart')); +}); + // Builds all Dart packages, but does not compile them gulp.task('build/packages.dart', function(done) { - runSequence('build/tree.dart', 'build/format.dart', done); + runSequence( + 'build/tree.dart', + // Run after 'build/tree.dart' because broccoli clears the dist/dart folder + 'build/pure-packages.dart', + 'build/format.dart', + done); }); // Builds and compiles all Dart packages diff --git a/modules/angular2/src/analysis/analyzer_plugin/plugin.dart b/modules_dart/analysis_plugin/lib/plugin.dart similarity index 100% rename from modules/angular2/src/analysis/analyzer_plugin/plugin.dart rename to modules_dart/analysis_plugin/lib/plugin.dart diff --git a/modules_dart/analysis_plugin/pubspec.yaml b/modules_dart/analysis_plugin/pubspec.yaml new file mode 100644 index 0000000000..4c29d5f029 --- /dev/null +++ b/modules_dart/analysis_plugin/pubspec.yaml @@ -0,0 +1,11 @@ +name: angular2_analysis_plugin +version: 0.0.0 +description: Dart analyzer plugin for Angular 2 +environment: + sdk: '>=1.9.0-dev.8.0' +dependencies: + angular2: '0.0.0' + analyzer: '^0.24.4' +dependency_overrides: + angular2: + path: ../../dist/dart/angular2 diff --git a/modules/angular2/src/analysis/server_plugin/plugin.dart b/modules_dart/analysis_server/lib/plugin.dart similarity index 100% rename from modules/angular2/src/analysis/server_plugin/plugin.dart rename to modules_dart/analysis_server/lib/plugin.dart diff --git a/modules_dart/analysis_server/pubspec.yaml b/modules_dart/analysis_server/pubspec.yaml new file mode 100644 index 0000000000..185dfeaecb --- /dev/null +++ b/modules_dart/analysis_server/pubspec.yaml @@ -0,0 +1,7 @@ +name: angular2_analysis_server +version: 0.0.0 +description: Dart analyzer server plugin for Angular 2 +environment: + sdk: '>=1.9.0-dev.8.0' +dependencies: + analyzer: '^0.24.4' diff --git a/scripts/publish/pubspec_cleaner.js b/scripts/publish/pubspec_cleaner.js index 7768712f34..6491a70361 100644 --- a/scripts/publish/pubspec_cleaner.js +++ b/scripts/publish/pubspec_cleaner.js @@ -15,4 +15,16 @@ var doc = yaml.safeLoad(fs.readFileSync(pubspecFile, 'utf8')); // Pub does not allow publishing with dependency_overrides delete doc['dependency_overrides']; +// Overwrite temporary values with real values +delete doc['version']; +delete doc['authors']; +delete doc['homepage'] + +var BASE_PACKAGE_JSON = require('../../package.json'); +doc['version'] = BASE_PACKAGE_JSON.version; +doc['homepage'] = BASE_PACKAGE_JSON.homepage; +doc['authors'] = Object.keys(BASE_PACKAGE_JSON.contributors).map(function(name) { + return name + ' <' + BASE_PACKAGE_JSON.contributors[name] + '>'; +}); + fs.writeFileSync(pubspecFile, yaml.safeDump(doc));