mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
feat(): Dartanalyzer running.
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
/.packages
|
||||
/packages
|
||||
/pubspec.lock
|
||||
/src/.pub
|
||||
/src/.packages
|
||||
/src/packages
|
||||
/src/pubspec.lock
|
||||
|
||||
|
||||
# IDEs
|
||||
|
||||
@@ -37,4 +37,4 @@ Here's a list of gotchas to keep in mind when writing TypeScript code that will
|
||||
* **Boolean expressions are required to be boolean.** There's no type coercion or truthiness concept in Dart. Code like this: `if (!aNumber) {}` must be refactored to be `if (aNumber != 0) {}`.
|
||||
* **Accessing any platform primitive must be done through a Facade.** For example, Promises or DOM manipulation. Facades are going to be provided on a need-to-have basis.
|
||||
* **Union types are a no-go.** Dart has them on its roadmap, but for now we must avoid them.
|
||||
* **Dart files cannot have the same name as a reserved keyword.** For example, `for.dart`, `switch.dart` or `class.dart` are all invalid names. Since the TypeScript files have the same name when transpiled to Dart, they also have the same restriction.
|
||||
* **Dart files cannot have the same name as a reserved keyword.** For example, `for.dart`, `switch.dart` or `class.dart` are all invalid names. Since the TypeScript files have the same name when transpiled to Dart, they also have the same restriction.
|
||||
|
||||
+43
-13
@@ -5,12 +5,17 @@ var path = require('path');
|
||||
require('ts-node/register');
|
||||
|
||||
const detect = require('./tools/build/dart').detect;
|
||||
|
||||
var mergeTrees = require('broccoli-merge-trees');
|
||||
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
|
||||
var BroccoliSass = require('broccoli-sass');
|
||||
var broccoliAutoprefixer = require('broccoli-autoprefixer');
|
||||
var BroccoliTs2Dart = require('./tools/broccoli/broccoli-ts2dart').default;
|
||||
var dartfmt = require('./tools/broccoli/broccoli-dartfmt').default;
|
||||
|
||||
const BroccoliTs2Dart = require('./tools/broccoli/broccoli-ts2dart').default;
|
||||
const BroccoliDestCopy = require('./tools/broccoli/broccoli-dest-copy').default;
|
||||
const BroccoliDartFmt = require('./tools/broccoli/broccoli-dartfmt').default;
|
||||
const BroccoliFunnel = require('broccoli-funnel');
|
||||
const BroccoliSource = require('broccoli-source');
|
||||
|
||||
var autoprefixerOptions = require('./build/autoprefixer-options');
|
||||
|
||||
@@ -31,17 +36,8 @@ module.exports = function(defaults) {
|
||||
|
||||
/** Gets the Dart tree - Transpile Dart files and format them afterward. */
|
||||
function getDartTree(root) {
|
||||
const ts2dart = new BroccoliTs2Dart('src/', {
|
||||
generateLibraryName: true,
|
||||
generateSourceMap: false,
|
||||
translateBuiltins: true,
|
||||
});
|
||||
|
||||
const dartSDK = detect();
|
||||
if (dartSDK) {
|
||||
// If Dart isn't found, detect() will throw an error.
|
||||
return dartfmt(ts2dart, { dartSDK });
|
||||
} else {
|
||||
if (!dartSDK) {
|
||||
console.warn('---------------------------------------');
|
||||
console.warn('You do not have the Dart SDK installed.');
|
||||
console.warn('In order to contribute to this repo, please refer to');
|
||||
@@ -50,6 +46,41 @@ function getDartTree(root) {
|
||||
console.warn('You can still build and serve the demo app without dart support.');
|
||||
return null;
|
||||
}
|
||||
|
||||
const ts2dart = new BroccoliTs2Dart(root, {
|
||||
generateLibraryName: true,
|
||||
generateSourceMap: false,
|
||||
translateBuiltins: true,
|
||||
});
|
||||
|
||||
const formatter = new BroccoliDartFmt(ts2dart, { dartSDK });
|
||||
|
||||
const dartSources = new BroccoliFunnel(root, {
|
||||
include: ['**/*.dart'],
|
||||
destDir: 'dart/web',
|
||||
});
|
||||
|
||||
const allDartFiles = mergeTrees([
|
||||
dartSources,
|
||||
formatter
|
||||
]);
|
||||
|
||||
//const pubSpecTree = new BroccoliFunnel('.', {
|
||||
// files: ['pubspec.yaml'],
|
||||
// //exclude: ['**/*'],
|
||||
// destDir: 'dart'
|
||||
//});
|
||||
const pubSpecTree = new BroccoliFunnel(new BroccoliSource.UnwatchedDir('.'), {
|
||||
files: ['pubspec.yaml'],
|
||||
destDir: 'dart',
|
||||
});
|
||||
|
||||
// Publishes the Dart files and pubspec inside a
|
||||
return mergeTrees([
|
||||
dartSources,
|
||||
pubSpecTree,
|
||||
new BroccoliDestCopy(formatter, 'dart/web'),
|
||||
]);
|
||||
}
|
||||
|
||||
/** Gets the tree for all of the components' CSS. */
|
||||
@@ -74,4 +105,3 @@ function getCssTree(folder) {
|
||||
}, []);
|
||||
return broccoliAutoprefixer(mergeTrees(componentCssTrees), autoprefixerOptions);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,10 @@
|
||||
"angular-cli": "0.0.*",
|
||||
"angular-cli-github-pages": "^0.2.0",
|
||||
"broccoli-autoprefixer": "^4.1.0",
|
||||
"broccoli-funnel": "^1.0.1",
|
||||
"broccoli-merge-trees": "^1.1.1",
|
||||
"broccoli-sass": "^0.7.0",
|
||||
"broccoli-source": "^1.1.0",
|
||||
"browserstacktunnel-wrapper": "^1.4.2",
|
||||
"ember-cli-inject-live-reload": "^1.3.0",
|
||||
"fs-extra": "^0.26.5",
|
||||
|
||||
@@ -11,22 +11,22 @@ import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-br
|
||||
* and tees a copy to the given path outside the tmp dir.
|
||||
*/
|
||||
class DestCopy implements DiffingBroccoliPlugin {
|
||||
constructor(private inputPath, private cachePath, private outputRoot: string) {}
|
||||
constructor(private inputPath, private cachePath: string, private outputRoot: string) {}
|
||||
|
||||
|
||||
rebuild(treeDiff: DiffResult) {
|
||||
treeDiff.addedPaths.concat(treeDiff.changedPaths)
|
||||
.forEach((changedFilePath) => {
|
||||
var destFilePath = path.join(this.outputRoot, changedFilePath);
|
||||
|
||||
var sourceFilePath = path.join(this.inputPath, changedFilePath);
|
||||
var destFilePath = path.join(this.cachePath, this.outputRoot, changedFilePath);
|
||||
var destDirPath = path.dirname(destFilePath);
|
||||
|
||||
fse.mkdirsSync(destDirPath);
|
||||
fse.copySync(path.join(this.inputPath, changedFilePath), destFilePath);
|
||||
fse.copySync(sourceFilePath, destFilePath);
|
||||
});
|
||||
|
||||
treeDiff.removedPaths.forEach((removedFilePath) => {
|
||||
var destFilePath = path.join(this.outputRoot, removedFilePath);
|
||||
|
||||
// TODO: what about obsolete directories? we are not cleaning those up yet
|
||||
fs.unlinkSync(destFilePath);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user