Vendored
+5
@@ -0,0 +1,5 @@
|
||||
interface AngularBuilderOptions {
|
||||
outputPath: string;
|
||||
dartSDK?: any;
|
||||
logs?: any;
|
||||
}
|
||||
@@ -7,7 +7,6 @@ var path = require('path');
|
||||
var printSlowTrees = require('broccoli-slow-trees');
|
||||
var Q = require('q');
|
||||
|
||||
|
||||
/**
|
||||
* BroccoliBuilder facade for all of our build pipelines.
|
||||
*/
|
||||
@@ -16,9 +15,9 @@ export class AngularBuilder {
|
||||
private browserDevBuilder: BroccoliBuilder;
|
||||
private browserProdBuilder: BroccoliBuilder;
|
||||
private dartBuilder: BroccoliBuilder;
|
||||
private outputPath: string;
|
||||
|
||||
|
||||
constructor(private outputPath: string) {}
|
||||
constructor(public options: AngularBuilderOptions) { this.outputPath = options.outputPath; }
|
||||
|
||||
|
||||
public rebuildBrowserDevTree(): Promise<BuildResult> {
|
||||
@@ -75,7 +74,12 @@ export class AngularBuilder {
|
||||
|
||||
|
||||
private makeDartBuilder(): BroccoliBuilder {
|
||||
let tree = makeDartTree(path.join(this.outputPath, 'dart'));
|
||||
let options = {
|
||||
outputPath: path.join(this.outputPath, 'dart'),
|
||||
dartSDK: this.options.dartSDK,
|
||||
logs: this.options.logs
|
||||
};
|
||||
let tree = makeDartTree(options);
|
||||
return new broccoli.Builder(tree);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/// <reference path="../typings/node/node.d.ts" />
|
||||
/// <reference path="../typings/fs-extra/fs-extra.d.ts" />
|
||||
import fse = require('fs-extra');
|
||||
import path = require('path');
|
||||
import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
function processToPromise(process) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
process.on('close', function(code) {
|
||||
if (code) {
|
||||
reject(code);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class DartFormatter implements DiffingBroccoliPlugin {
|
||||
private DARTFMT: string;
|
||||
private verbose: boolean;
|
||||
|
||||
constructor(public inputPath: string, public cachePath: string, options) {
|
||||
if (!options.dartSDK) throw new Error("Missing Dart SDK");
|
||||
this.DARTFMT = options.dartSDK.DARTFMT;
|
||||
this.verbose = options.logs.dartfmt;
|
||||
}
|
||||
|
||||
rebuild(treeDiff: DiffResult): Promise<any> {
|
||||
let args = ['-w'];
|
||||
treeDiff.changedPaths.forEach((changedFile) => {
|
||||
let sourcePath = path.join(this.inputPath, changedFile);
|
||||
let destPath = path.join(this.cachePath, changedFile);
|
||||
if (/\.dart$/.test(changedFile)) args.push(destPath);
|
||||
fse.copySync(sourcePath, destPath);
|
||||
});
|
||||
treeDiff.removedPaths.forEach((removedFile) => {
|
||||
let destPath = path.join(this.cachePath, removedFile);
|
||||
fse.removeSync(destPath);
|
||||
});
|
||||
return processToPromise(spawn(
|
||||
this.DARTFMT, args, {stdio: this.verbose ? 'inherit' : ['ignore', 'ignore', 'inherit']}));
|
||||
}
|
||||
}
|
||||
|
||||
export default wrapDiffingPlugin(DartFormatter);
|
||||
@@ -1,4 +1,5 @@
|
||||
/// <reference path="../../typings/node/node.d.ts" />
|
||||
/// <reference path="../angular_builder.d.ts" />
|
||||
'use strict';
|
||||
|
||||
import {MultiCopy} from './../multi_copy';
|
||||
@@ -11,6 +12,7 @@ var renderLodashTemplate = require('broccoli-lodash');
|
||||
var replace = require('broccoli-replace');
|
||||
var stew = require('broccoli-stew');
|
||||
import ts2dart from '../broccoli-ts2dart';
|
||||
import dartfmt from '../broccoli-dartfmt';
|
||||
|
||||
/**
|
||||
* A funnel starting at modules, including the given filters, and moving into the root.
|
||||
@@ -138,11 +140,12 @@ function getDocsTree() {
|
||||
return mergeTrees([licenses, mdTree, docs]);
|
||||
}
|
||||
|
||||
module.exports = function makeDartTree(destinationPath) {
|
||||
var sourceTree = mergeTrees([getSourceTree(), getHtmlSourcesTree()]);
|
||||
module.exports = function makeDartTree(options: AngularBuilderOptions) {
|
||||
var dartSources = dartfmt(getSourceTree(), {dartSDK: options.dartSDK, logs: options.logs});
|
||||
var sourceTree = mergeTrees([dartSources, getHtmlSourcesTree()]);
|
||||
sourceTree = fixDartFolderLayout(sourceTree);
|
||||
|
||||
var dartTree = mergeTrees([sourceTree, getTemplatedPubspecsTree(), getDocsTree()]);
|
||||
|
||||
return destCopy(dartTree, destinationPath);
|
||||
return destCopy(dartTree, options.outputPath);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user