extracted config, updated based on feedback

This commit is contained in:
Leo Lee (DEVDIV) 2015-02-03 10:24:06 -08:00
Родитель 4bdbae5f55
Коммит 628ae67a96
3 изменённых файлов: 35 добавлений и 29 удалений

7
src/build_config.json Normal file
Просмотреть файл

@ -0,0 +1,7 @@
{
"src": ".",
"compiledGulp": "../build",
"bin": "../build/src",
"tools": "../build/tools",
"copPath": "../tools/internal/TSStyleCop.js"
}

Просмотреть файл

@ -2,7 +2,8 @@
var exec = require("child_process").exec,
fs = require("fs"),
path = require('path'),
gulp = require("gulp");
gulp = require("gulp"),
buildConfig = require('./build_config.json');
gulp.on("task_not_found", function (err) {
console.error("\n---Please run 'gulp prep' to prepare project\n");
@ -10,20 +11,22 @@ gulp.on("task_not_found", function (err) {
/* compile the gulp-compile.ts file into JS */
gulp.task("prep", ["install"], function (callback) {
exec("tsc gulpmain.ts --outdir ../bin --module commonjs", { cwd: "." }, callback);
exec("tsc gulpmain.ts --outdir " + buildConfig.compiledGulp + " --module commonjs", { cwd: "." }, callback);
});
/* install gulp in root folder */
gulp.task("install", function (callback) {
var modules = ["del", "gulp", "typescript", "ncp", "q"];
for (var i in modules)
{
for (var i in modules){
exec("npm install " + modules[i], { cwd: ".." });
}
callback();
});
var gulpMain = "../bin/src/gulpmain.js";
////////////////// to add additional gulp tasks, add gulpfile in folder and reference it below
// for example: require('./src/compile/gulpfile');
///////////////////////
var gulpMain = path.join(buildConfig.bin, "gulpmain.js");
if (fs.existsSync(gulpMain)) {
require(gulpMain);
}

Просмотреть файл

@ -7,34 +7,30 @@ var gulp = require("gulp");
var del = require("del");
var path = require("path");
var exec = require("child_process").exec;
import dtsUtil = require("../tools/tsdefinition-util");
import stylecopUtil = require("../tools/stylecop-util");
import tsUtil = require("./taco-cli/compile/typescript-util");
import dtsUtil = require("../tools/tsdefinition-util");
var compilerPath = {
src: ".", // gulp task compiles all source under "taco-cli" source folder
bin: "../bin/src",
tools: "../bin/tools"
};
var copFile = path.join(compilerPath.src, "../tools/internal/TSStyleCop.js");
////////////////// to add additional gulp tasks, add gulpfile in folder and reference it below
// for example: require('./src/compile/gulpfile');
///////////////////////
var buildConfig = require("../../src/build_config.json");
/* Default task for building /src folder into /bin */
gulp.task("default", ["rebuild"]);
gulp.task("default", ["build"]);
/* Compiles the typescript files in the project, for fast iterative use */
gulp.task("compile", function (callback: Function): void {
var tsCompiler = new tsUtil.TypeScriptServices();
console.log("compilerPath.src: " + path.resolve(compilerPath.src));
console.log("compilerPath.bin: " + path.resolve(compilerPath.bin));
tsCompiler.compileDirectory(compilerPath.src, compilerPath.bin, callback);
console.log("buildConfig.src: " + path.resolve(buildConfig.src));
console.log("buildConfig.bin: " + path.resolve(buildConfig.bin));
tsCompiler.compileDirectory(buildConfig.src, buildConfig.bin, callback);
});
/* compile + copy */
gulp.task("build", ["compile"], function (callback: Function): void {
gulp.run("copy");
});
/* full clean build */
gulp.task("build", ["clean"], function (callback: Function): void {
gulp.task("rebuild", ["clean"], function (callback: Function): void {
gulp.run("compile");
gulp.run("copy");
});
@ -43,7 +39,7 @@ gulp.task("build", ["clean"], function (callback: Function): void {
gulp.task("run-stylecop", ["clean-build"], function (callback: Function): void {
if (fs.existsSync("copFile")) {
var styleCop = new stylecopUtil.StyleCopUtil();
styleCop.runCop(compilerPath.src, copFile, callback);
styleCop.runCop(buildConfig.src, buildConfig.copFile, callback);
} else {
callback();
}
@ -51,13 +47,13 @@ gulp.task("run-stylecop", ["clean-build"], function (callback: Function): void {
/* Cleans up the bin location, will have to call "gulp prep" again */
gulp.task("clean", function (callback: Function): void {
del([compilerPath.bin + "/../**"], { force: true }, callback);
del([buildConfig.bin + "/../**"], { force: true }, callback);
});
/* copy package.json files from source to bin */
/* copy package.json and resources.json files from source to bin */
gulp.task("copy", function (callback: Function): void {
gulp.src(path.join(compilerPath.src, "/**/package.json")).pipe(gulp.dest(compilerPath.bin));
gulp.src(path.join(compilerPath.src, "/**/resources.json")).pipe(gulp.dest(compilerPath.bin));
gulp.src(path.join(buildConfig.src, "/**/package.json")).pipe(gulp.dest(buildConfig.bin));
gulp.src(path.join(buildConfig.src, "/**/resources.json")).pipe(gulp.dest(buildConfig.bin));
});
/* auto-generate taco-utils.d.ts*/
@ -65,8 +61,8 @@ gulp.task("generate-dts", function (cb: Function): void {
var tacoUtils: string = "taco-utils";
dtsUtil.DefinitionServices.generateTSExportDefinition(
tacoUtils,
path.join(compilerPath.src, tacoUtils),
path.join(compilerPath.src, "typings"),
path.join(buildConfig.src, tacoUtils),
path.join(buildConfig.src, "typings"),
"TacoUtility",
tacoUtils);
cb();