diff --git a/.vscode/launch.json b/.vscode/launch.json index 7b479d873..5d8f12ea1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -216,7 +216,7 @@ { "type": "node", "request": "launch", - "name": "Launch Generate Template with aliases no name", + "name": "Launch Generate Template with aliases g t -g", "cwd": "${workspaceRoot}/output", "program": "${workspaceRoot}/bin/execute.js", "console": "externalTerminal", @@ -224,7 +224,25 @@ "args": [ "g", "t", + "-g" ], + }, + { + "type": "node", + "request": "launch", + "name": "Launch Generate Template with all aliases", + "cwd": "${workspaceRoot}/output", + "program": "${workspaceRoot}/bin/execute.js", + "console": "externalTerminal", + "preLaunchTask": "build", + "args": [ + "g", + "t", + "-n=alianato", + "-f=angular", + "-t=igx-ts", + "-s=false", + ] } ] } \ No newline at end of file diff --git a/lib/cli.ts b/lib/cli.ts index ffc4c841b..a4fd2470b 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -21,7 +21,6 @@ export async function run(args = null) { newCommand.template = templateManager; newCommand.builder.framework.choices = templateManager.getFrameworkIds(); add.templateManager = templateManager; - generate.templateManager = templateManager; const yargsModule = args ? yargs(args) : yargs; diff --git a/lib/commands/generate.ts b/lib/commands/generate.ts index e916e0fc7..34a6fa463 100644 --- a/lib/commands/generate.ts +++ b/lib/commands/generate.ts @@ -1,8 +1,8 @@ import * as path from "path"; import { Util } from "../Util"; -import { ProjectConfig } from "./../ProjectConfig"; import { TemplateManager } from "../TemplateManager"; import { utimes } from "fs-extra"; +import { default as config } from "./config"; const command = { // tslint:disable:object-literal-sort-keys @@ -16,31 +16,32 @@ const command = { command: "template [name] [framework] [type] [skip-config]", aliases: ["t"], desc: "Generates custom template", - builder: (yargs) => yargs - .options({ - name: { - describe: "Template name.", - aliases: ["n"], - default: "custom-template", - type: "string" - }, - framework: { - describe: "Framework name.", - aliases: ["f"], - default: "jquery", - type: "string" - }, - type: { - describe: "Framework type.", - aliases: ["t"], - default: "js", - type: "string" - }, - "skip-config": { - describe: "Skips adding to the config.", - type: "boolean" - } - }), + builder: { + name: { + describe: "Template name.", + alias: "n", + default: "custom-template", + type: "string" + }, + framework: { + describe: "Framework name.", + alias: "f", + default: "jquery", + type: "string" + }, + type: { + describe: "Framework type.", + alias: "t", + default: "js", + type: "string" + }, + "skip-config": { + describe: "Skips adding to the config.", + alias: "s", + default: false, + type: "boolean" + } + }, handler: command.template }) // at least one command is required @@ -82,11 +83,12 @@ const command = { Util.log(`Project Name: ${argv.name}, framework ${argv.framework}, type ${argv.type}`); const promise = Util.processTemplates(templatesFolder, outDir, { "$(name)": argv.name, "$(framework)": argv.framework, "$(type)": argv.type, __name__: argv.name }, null); promise.then((res) => { - if(res){ - if (ProjectConfig.hasLocalConfig()) - return Util.error("There is already an existing project.", "red"); + if (res) { + if (argv.skipConfig == false) { + config.addHandler({ property: "customTemplates", value: "parth:" + outDir, global: true }); + } } - else{ + else { return Util.log("Project creation failed!"); } }).catch((err) => {