diff --git a/src/gulp-compile.ts b/src/gulp-compile.ts index 74e54791..a5638b40 100644 --- a/src/gulp-compile.ts +++ b/src/gulp-compile.ts @@ -7,6 +7,7 @@ var exec = require("child_process").exec; import typescriptUtil = require("../tools/typescript-util"); import styleCopUtil = require("../tools/stylecop-util"); var del = require("del"); +var ncp = require("ncp"); var compilerPath = { src: "../../src", // gulp task compiles all source under "taco-cli" source folder @@ -18,9 +19,9 @@ var compilerPath = { /////////////////////// /* Default task for compiler - runs clean, compile, combine. */ -gulp.task("default", ["installBinDependencies", "styleCop"]); +gulp.task("default", ["installBinDependencies", "styleCop", "copyResources"]); -/* Compiles the typescript files in the project. */ +/* Compiles the typescript files in the project, for fast iterative use */ gulp.task("fast-compile", function (cb: Function): void { var tsUtil = new typescriptUtil.TacoUtils.TypescriptServices(); console.log("compilerPath.src: " + path.resolve(compilerPath.src)); @@ -28,6 +29,7 @@ gulp.task("fast-compile", function (cb: Function): void { tsUtil.compileDirectory(compilerPath.src, compilerPath.bin, cb); }); +/* full clean build */ gulp.task("compile", ["clean"], function (cb: Function): void { var tsUtil = new typescriptUtil.TacoUtils.TypescriptServices(); console.log("compilerPath.src: " + path.resolve(compilerPath.src)); @@ -60,6 +62,12 @@ gulp.task("copyPackageJSON", ["compile"], function (cb: Function): void { cb(); }); +/* copy package.json files from source to bin */ +gulp.task("copyResources", ["compile"], function (cb: Function): void { + ncp("../../src/taco-cli/resources", "../../bin/taco-cli/resources", {clobber: true}, cb) +}); + +/* with package.json files setup in Bin folder, call npm install */ gulp.task("installBinDependencies", ["copyPackageJSON"], function (cb: Function): void { exec("npm install", { cwd: "../../bin/taco-cli" }, cb); }); diff --git a/src/gulpfile.js b/src/gulpfile.js index 500d1c8b..0c984f1b 100644 --- a/src/gulpfile.js +++ b/src/gulpfile.js @@ -1,3 +1,4 @@ +/*starter gulpfile, bootstraps compiling gulp-compile.ts and runs it*/ var exec = require("child_process").exec, fs = require("fs"), path = require('path'), @@ -7,17 +8,17 @@ var exec = require("child_process").exec, gulp.task("default", ["runCompiledGulp"], function (cb) { console.log("************************************************************"); console.log("Prepared taco-cli project for first use....."); - console.log("Run 'gulp' in current folder or 'gulp --gulpfile gulp-compile.js' in ../build/src for subsequent builds"); + console.log("Run 'gulp' in current folder or 'gulp fast-compile --gulpfile gulp-compile.js' in ../build/src for incremental builds"); console.log("************************************************************\n\n"); }); -/* Runs style cop on the sources. */ +/* Runs the compiled gulp file */ gulp.task("runCompiledGulp", ["compileTSGulpFiles"], function (cb) { exec("gulp --gulpfile gulp-compile.js", { cwd: "../build/src" }, cb); }); -/* Runs style cop on the sources. */ -gulp.task("compileTSGulpFiles", ["installRootFolderGulp", "installRootFolderTypeScript", "installRootFolderDel"], function (cb) { +/* compile the gulp-compile.ts file into JS */ +gulp.task("compileTSGulpFiles", ["installRootFolderGulp", "installRootFolderTypeScript", "installRootFolderDel", "installRootFolderNcp"], function (cb) { exec("tsc gulp-compile.ts --outdir ../build --module commonjs", { cwd: "." }, cb); }); @@ -31,9 +32,14 @@ gulp.task("installRootFolderTypeScript", function (cb) { exec("npm install typescript", { cwd: ".." }, cb); }); -/* install typescript in root folder */ +/* install del in root folder */ gulp.task("installRootFolderDel", function (cb) { exec("npm install del", { cwd: ".." }, cb); }); +/* install del in root folder */ +gulp.task("installRootFolderNcp", function (cb) { + exec("npm install ncp", { cwd: ".." }, cb); +}); + module.exports = gulp; diff --git a/src/taco-cli/cli/taco.ts b/src/taco-cli/cli/taco.ts index b9b79f35..18898b09 100644 --- a/src/taco-cli/cli/taco.ts +++ b/src/taco-cli/cli/taco.ts @@ -10,55 +10,11 @@ import path = require("path"); class Taco { tacoResources: tacoUtility.Resources; constructor() { - this.tacoResources = new tacoUtility.Resources("abc"); + var resourcePath : string = path.resolve("../resources"); + this.tacoResources = new tacoUtility.Resources("en", resourcePath); } run(): void { console.log(this.tacoResources.getString("usage")); - var knownOpts = - { - 'verbose': Boolean - , 'version': Boolean - , 'help': Boolean - , 'silent': Boolean - , 'experimental': Boolean - , 'noregistry': Boolean - , 'shrinkwrap': Boolean - , 'usegit': Boolean - , 'copy-from': String - , 'link-to': path - , 'searchpath': String - , 'variable': Array - // Flags to be passed to `cordova build/run/emulate` - , 'debug': Boolean - , 'release': Boolean - , 'archs': String - , 'device': Boolean - , 'emulator': Boolean - , 'target': String - , 'browserify': Boolean - , 'nobuild': Boolean - }; - - var shortHands = - { - 'd': '--verbose' - , 'v': '--version' - , 'h': '--help' - , 'src': '--copy-from' - }; - - // If no inputArgs given, use process.argv. - var inputArguments: string[] = process.argv; - - var args = nopt.nopt(knownOpts, shortHands, inputArguments); - console.info(args); - - console.info("Number of command-line arguments - " + args.argv.remain.length); - - for (var i = 0; i < args.argv.remain.length; ++i) { - console.info(args.argv.remain[i]); - } - } } diff --git a/src/taco-cli/resources/en/resources.json b/src/taco-cli/resources/en/resources.json new file mode 100644 index 00000000..155f1a79 --- /dev/null +++ b/src/taco-cli/resources/en/resources.json @@ -0,0 +1,3 @@ +{ + "usage": "Usage: taco-cli command args" +} \ No newline at end of file diff --git a/src/taco-cli/resources/resources.json b/src/taco-cli/resources/resources.json deleted file mode 100644 index f90ccf41..00000000 --- a/src/taco-cli/resources/resources.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Usage": "Usage: taco-cli command args", -} \ No newline at end of file