зеркало из https://github.com/microsoft/TACO.git
comments
This commit is contained in:
Родитель
480a373207
Коммит
2ade068252
|
@ -9,9 +9,13 @@ import tacoUtility = require("taco-utils");
|
|||
*
|
||||
* Command class handling passthroughs to CordovaCLI
|
||||
*/
|
||||
class Cordova extends tacoUtility.Commands.Command {
|
||||
class Cordova extends tacoUtility.Commands.Command {
|
||||
|
||||
/**
|
||||
* Handles direct routing to Cordova CLI
|
||||
*/
|
||||
public run(): void {
|
||||
cordova.cli(this.cliArgs); //call into Cordova CLI
|
||||
cordova.cli(this.cliArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,10 @@ import level = logger.Level;
|
|||
* handles "Taco Create"
|
||||
*/
|
||||
class Create extends cordovaCommand {
|
||||
/**
|
||||
* Sample only, shows processing specific taco commands, and passing remaining ones to Cordova CLI
|
||||
*/
|
||||
run() {
|
||||
console.log("create!!!");
|
||||
var knownOpts: any = {
|
||||
"template": String
|
||||
};
|
||||
|
@ -28,9 +30,9 @@ class Create extends cordovaCommand {
|
|||
//sample getting args specific to taco
|
||||
logger.logNewLine("Creating new project using template : " + args.template, level.Success);
|
||||
|
||||
//sample routing remaining args to Cordova
|
||||
//sample routing remaining args to Cordova, stripped out template
|
||||
this.cliArgs = args.argv.remain;
|
||||
super.run();
|
||||
super.run(); //take this out if we don't need to route to Cordova CLI
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ class Help extends tacoUtility.Commands.Command {
|
|||
private charsToDescription: number = 35;
|
||||
private maxRight = 70;
|
||||
|
||||
/**
|
||||
* entry point for printing helper
|
||||
*/
|
||||
run() {
|
||||
this.printHeader();
|
||||
if (this.cliArgs.length == 0) {
|
||||
|
@ -29,14 +32,24 @@ class Help extends tacoUtility.Commands.Command {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* prints out Microsoft header
|
||||
*/
|
||||
public printHeader(): void {
|
||||
logger.logNewLine("\n=================================================================", level.Normal);
|
||||
}
|
||||
|
||||
/**
|
||||
* prints out general usage of all support TACO commands
|
||||
*/
|
||||
public printGeneralUsage(): void {
|
||||
console.log("General Help!!");
|
||||
logger.logNewLine("\nGeneral Usage", level.Normal);
|
||||
}
|
||||
|
||||
/**
|
||||
* prints out specific usage, i.e. TACO help create
|
||||
* @param {string} command - TACO command being inquired
|
||||
*/
|
||||
public printCommandUsage(command: string): void {
|
||||
if (!commandsFactory.Listings || !commandsFactory.Listings[command]) {
|
||||
this.printGeneralUsage();
|
||||
|
@ -52,6 +65,11 @@ class Help extends tacoUtility.Commands.Command {
|
|||
this.printCommandTable(list.options, this.indent + this.indent);
|
||||
}
|
||||
|
||||
/**
|
||||
* helper function to print out [name --- description] pairs for args and options
|
||||
* @param {INameDescription[]} nameValuePairs - name-value pairs
|
||||
* @param {string} indentFromLeft - string to insert from left
|
||||
*/
|
||||
public printCommandTable(nameValuePairs: tacoUtility.Commands.INameDescription[], indentFromLeft: string) {
|
||||
nameValuePairs.forEach(nvp => {
|
||||
logger.log(indentFromLeft + nvp.name, level.Warn);
|
||||
|
|
|
@ -8,18 +8,32 @@ import commandsFactory = tacoUtility.Commands.CommandFactory;
|
|||
import fs = require("fs");
|
||||
import path = require("path");
|
||||
|
||||
/*
|
||||
* Taco
|
||||
*
|
||||
* Main Taco class
|
||||
*/
|
||||
class Taco {
|
||||
/**
|
||||
* @constructor, initialize all other config classes
|
||||
*/
|
||||
constructor() {
|
||||
var resourcePath: string = path.resolve("../resources");
|
||||
resourcesManager.init("en", resourcePath);
|
||||
commandsFactory.init("../cli/commands.json");
|
||||
}
|
||||
|
||||
/*
|
||||
* Invoke task to be run
|
||||
*/
|
||||
public run(): void {
|
||||
commandsFactory.runTask();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Entry point function called from node
|
||||
*/
|
||||
function start(): void {
|
||||
var taco = new Taco();
|
||||
taco.run();
|
||||
|
|
|
@ -44,7 +44,6 @@ export class TypeScriptServices {
|
|||
if (!fs.statSync(currentPath).isDirectory()) {
|
||||
/* push the typescript files */
|
||||
if (path.extname(currentPath) === ".ts" &&
|
||||
!currentPath.match("d.ts$") &&
|
||||
!currentPath.match("gulpfile.ts") &&
|
||||
!currentPath.match("gulpmain.ts")) {
|
||||
result.push(currentPath);
|
||||
|
|
|
@ -6,11 +6,18 @@ import fs = require("fs");
|
|||
var colors = require("colors");
|
||||
import path = require ("path");
|
||||
|
||||
module TacoUtility {
|
||||
module TacoUtility {
|
||||
export module Logger {
|
||||
/**
|
||||
* Warning levels
|
||||
*/
|
||||
export enum Level { Warn, Error, Link, Normal, Success, NormalBold };
|
||||
export function colorize(msg: string, level: Level): string {
|
||||
//not yet possible to combine themes yet so still need to wrap this: https://github.com/Marak/colors.js/issues/72
|
||||
|
||||
/**
|
||||
* returns colorized string
|
||||
* wrapping "colors" module because not yet possible to combine themes, i.e. ["yellow", "bold"]: https://github.com/Marak/colors.js/issues/72
|
||||
*/
|
||||
export function colorize(msg: string, level: Level): string {
|
||||
colors.setTheme({
|
||||
error: "red",
|
||||
warn: "yellow",
|
||||
|
@ -34,8 +41,7 @@ module TacoUtility {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* log
|
||||
*/
|
||||
export function log(msg: string, level: Level): void {
|
||||
msg = colorize(msg, level);
|
||||
|
@ -69,6 +75,9 @@ module TacoUtility {
|
|||
options: INameDescription[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Base command class, all other commands inherit from this
|
||||
*/
|
||||
export class Command {
|
||||
info: ICommandInfo;
|
||||
cliArgs: string[];
|
||||
|
@ -81,11 +90,17 @@ module TacoUtility {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory to create new Commands classes
|
||||
*/
|
||||
export class CommandFactory {
|
||||
public static Listings: any;
|
||||
private static Instance: Command;
|
||||
|
||||
// initialize with json file containing commands
|
||||
/**
|
||||
* Factory to create new Commands classes
|
||||
* initialize with json file containing commands
|
||||
*/
|
||||
public static init(commandsInfoPath: string) {
|
||||
commandsInfoPath = path.resolve(commandsInfoPath);
|
||||
if (!fs.existsSync(commandsInfoPath)) {
|
||||
|
@ -95,7 +110,9 @@ module TacoUtility {
|
|||
CommandFactory.Listings = require(commandsInfoPath);
|
||||
}
|
||||
|
||||
// get specific task object, given task name
|
||||
/**
|
||||
* get specific task object, given task name
|
||||
*/
|
||||
public static getTask(name: string): Command {
|
||||
if (!name || !CommandFactory.Listings) {
|
||||
throw new Error("Cannot find command listing file");
|
||||
|
@ -116,6 +133,9 @@ module TacoUtility {
|
|||
return CommandFactory.Instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* run specific task, based on what's fed to the CLI
|
||||
*/
|
||||
public static runTask() {
|
||||
var input: string = process.argv[2];
|
||||
var command: Command = null;
|
||||
|
|
Загрузка…
Ссылка в новой задаче