diff --git a/addon/ng2/blueprints/service/files/__path__/__name__.service.spec.ts b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts similarity index 100% rename from addon/ng2/blueprints/service/files/__path__/__name__.service.spec.ts rename to addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts diff --git a/addon/ng2/blueprints/service/files/__path__/__name__.service.ts b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts similarity index 100% rename from addon/ng2/blueprints/service/files/__path__/__name__.service.ts rename to addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts diff --git a/addon/ng2/blueprints/service/files/__path__/index.ts b/addon/ng2/blueprints/route-test/service/files/__path__/index.ts similarity index 100% rename from addon/ng2/blueprints/service/files/__path__/index.ts rename to addon/ng2/blueprints/route-test/service/files/__path__/index.ts diff --git a/addon/ng2/blueprints/route-test/service/files/__path__/index.ts~HEAD b/addon/ng2/blueprints/route-test/service/files/__path__/index.ts~HEAD new file mode 100644 index 000000000000..78b9dc378f5e --- /dev/null +++ b/addon/ng2/blueprints/route-test/service/files/__path__/index.ts~HEAD @@ -0,0 +1 @@ +export {<%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service'; diff --git a/addon/ng2/blueprints/service/index.js b/addon/ng2/blueprints/route-test/service/index.js similarity index 100% rename from addon/ng2/blueprints/service/index.js rename to addon/ng2/blueprints/route-test/service/index.js diff --git a/addon/ng2/commands/generate.ts b/addon/ng2/commands/generate.ts index 80b34ceca9b7..72521ed84571 100644 --- a/addon/ng2/commands/generate.ts +++ b/addon/ng2/commands/generate.ts @@ -10,13 +10,15 @@ const GenerateCommand = EmberGenerateCommand.extend({ name: 'generate', beforeRun: function(rawArgs) { + this.ui.writeLine(chalk.green(`The raw arguments are now ${rawArgs}`)); + this.ui.writeLine(chalk.green(`The current path is ${process.cwd()}`)); if (!rawArgs.length) { return; } // map the blueprint name to allow for aliases rawArgs[0] = mapBlueprintName(rawArgs[0]); - + this.ui.writeLine(chalk.green(`The blueprint is now ${rawArgs[0]}`)); if (rawArgs[0] !== '--help' && !fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) { SilentError.debugOrThrow('angular-cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`); @@ -38,7 +40,7 @@ const GenerateCommand = EmberGenerateCommand.extend({ this.ui.writeLine(chalk.cyan(' Available blueprints')); this.ui.writeLine(output); }; - + this.ui.writeLine(chalk.green(`The raw arguments are now ${arguments}`)); return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments); } }); diff --git a/addon/ng2/commands/new.ts b/addon/ng2/commands/new.ts index 685e4e3e1124..6a2ebbd2d53c 100644 --- a/addon/ng2/commands/new.ts +++ b/addon/ng2/commands/new.ts @@ -1,3 +1,5 @@ +/// + import * as chalk from 'chalk'; import * as Command from 'ember-cli/lib/models/command'; import * as Project from 'ember-cli/lib/models/project'; diff --git a/addon/ng2/commands/newFromJSON.ts b/addon/ng2/commands/newFromJSON.ts new file mode 100644 index 000000000000..8b52509f7d1a --- /dev/null +++ b/addon/ng2/commands/newFromJSON.ts @@ -0,0 +1,411 @@ +/// + +<<<<<<< HEAD +import * as Command from 'ember-cli/lib/models/command'; +import * as SilentError from 'silent-error'; +import { execSync, exec } from 'child_process'; +import * as Promise from 'ember-cli/lib/ext/promise'; +import * as chalk from 'chalk'; +import * as fs from 'fs'; +import * as fse from 'fs-extra'; +======= +import * as chalk from 'chalk'; +import * as Command from 'ember-cli/lib/models/command'; +import * as Project from 'ember-cli/lib/models/project'; +import * as SilentError from 'silent-error'; +>>>>>>> adf21fb09196c21234f6129fc7c9b36cb55d44b0 +import * as validProjectName from 'ember-cli/lib/utilities/valid-project-name'; +import * as GenerateCommand from './generate'; +import {NgAppStructure} from '../models/newFromJSON.model'; + +const normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option'); +<<<<<<< HEAD +const fsReadFile = Promise.denodeify(fs.readFile); +const fsWriteFile = Promise.denodeify(fs.writeFile); +const fsReadDir = Promise.denodeify(fs.readdir); +const fsCopy = Promise.denodeify(fse.copy); +const fileStats = Promise.denodeify(fs.stat); +const execPromise = Promise.denodeify(exec); + +======= +const fs = require('fs'); +const exec = require('child_process').execSync; +const async = require('async'); +const NewCommand = require('./new'); +const InitCommand = require('./init'); + +const projectJSON: NgAppStructure = JSON.parse(fs.readFileSync('ng-project.json', 'utf8')); +let generatedItemCount: number = 0; +>>>>>>> adf21fb09196c21234f6129fc7c9b36cb55d44b0 + +const NewFromJSONCommand = Command.extend({ + name: 'newfromjson', + works: 'outsideProject', + + availableOptions: [ +<<<<<<< HEAD + ], + + run: function (commandOptions, rawArgs) { + + let projectJSON: NgAppStructure; + + const ui = this.ui; + const chDir = process.chdir; + const execOptions = { + cwd: process.cwd(), + maxBuffer: 2000 * 1024, + stdio: [0, 1, 2] + }; +======= + { name: 'dry-run', type: Boolean, default: false, aliases: ['d'] }, + { name: 'verbose', type: Boolean, default: false, aliases: ['v'] }, + { name: 'blueprint', type: String, default: 'ng2', aliases: ['b'] }, + { name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] }, + { name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] }, + { name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] }, + { name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] }, + { name: 'directory', type: String, aliases: ['dir'] }, + { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, + { name: 'style', type: String, default: 'css' }, + { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, + { name: 'mobile', type: Boolean, default: false } + ], + + run: function (commandOptions, rawArgs) { + + if (!projectJSON) { + return Promise.reject(new SilentError( + `The "ng ${this.name}" command requires a ng-project.json file. ` + + `For more details, use "ng help".`)); + } + + this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); + + const packageName = projectJSON.package.name; + const packageOptions = { + 'blueprint': projectJSON.package.blueprint || commandOptions.blueprint || undefined, + 'dryRun': projectJSON.package.dryRun || commandOptions.dryRun, + 'directory': projectJSON.package.directory || commandOptions.directory || undefined, + 'verbose': projectJSON.package.verbose || commandOptions.verbose, + 'skipNpm': projectJSON.package.skipNpm || commandOptions.skipNpm, + 'skipGit': projectJSON.package.skipGit || commandOptions.skipGit + } +>>>>>>> adf21fb09196c21234f6129fc7c9b36cb55d44b0 + const commandAliases = { + 'classes': 'cl', + 'components': 'c', + 'directives': 'd', + 'enums': 'e', + 'pipes': 'p', + 'routes': 'r', + 'services': 's' + }; +<<<<<<< HEAD + + const createAndStepIntoDirectory = + new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); + + let checkForExisting = (path: string) => { + return fileStats(path); + }; + + let checkForPackage = (packageName: string) => { + return checkForExisting(`${packageName}/angular-cli.json`) + }; + + let checkForItem = (typeOfItem: string, itemName: string) => { + return checkForExisting(`${typeOfItem}/${itemName}`) + }; + + let newPackage = (packageObject: { + name: string, blueprint?: string, dryRun?: boolean, verbose?: boolean, skipNpm?: boolean, skipGit?: boolean, directory?: string, flat?: boolean, default?: boolean, lazy?: boolean, skipRouterGeneration?: boolean, route?: string + }) => { + return checkForPackage(packageObject.name) + .then(() => { + let msg = `${packageObject.name} already exists, changing directories.` + ui.writeLine(chalk.yellow(msg)); + Promise.resolve(); + }) + .catch(() => { + let commandString = execCommandString('package', packageObject); + //return execSync(commandString, execOptions); + //p_list.push({ process: packageChildProcess, content: "" }); + return execPromise(commandString, execOptions); + }) + }; + + let generateItem = (typeOfItem: string, itemObject: { + name: string, blueprint?: string, dryRun?: boolean, verbose?: boolean, skipNpm?: boolean, skipGit?: boolean, directory?: string, flat?: boolean, default?: boolean, lazy?: boolean, skipRouterGeneration?: boolean, route?: string + }) => { + let itemObjectName = itemObject.lazy === false ? itemObject.name : `+${itemObject.name}`; + return checkForItem(typeOfItem, itemObjectName) + .then(() => { + let msg = `${itemObject.name} already exists, moving on.`; + ui.writeLine(chalk.yellow(msg)); + Promise.resolve(); + }) + .catch(() => { + let commandString = execCommandString(typeOfItem, itemObject); + //return execSync(commandString, execOptions); + return execPromise(commandString, execOptions); + }); + }; + const itemTypes = ['routes', 'components', 'pipes', 'services', 'directives', 'classes', 'enums']; + + return getJSONFile() + .then(newProject) + .then(changeToProjectDirectory) + .then(makeItemDirectories) + .then(generateProjectItems) + .then(ui.writeLine(chalk.blue(`This should only happen when I'm finished.`))) + .catch((err) => { + ui.writeLine(chalk.red(`This command requires a file named ng-project.json`)); + }); + + function getJSONFile() { + return fsReadFile('ng-project.json', 'utf8') + .then((data: string) => { + projectJSON = JSON.parse(data); + }) + } + + function newProject() { + return newPackage(projectJSON.package) + .then(() => { + ui.writeLine(chalk.green(`${projectJSON.package.name} project complete.`)); + }); + } + + function changeToProjectDirectory() { + return (() => { + chDir(`${projectJSON.package.name}/src/app`) + ui.writeLine(chalk.cyan(`Now in "${projectJSON.package.name}/src/app"...`)); + })(); + } + + function createProjectDirectories(directoryName: string) { + return createAndStepIntoDirectory + .run({ + directoryName: directoryName, + dryRun: projectJSON.package.dryRun + }) + } + + function createEachItem(typeOfItem: string, item: {}) { + return generateItem(typeOfItem, item) + //.then(() => { + // ui.writeLine(chalk.green(`${item.name} has been created`)); + //}); + } + + function makeItemDirectories() { + return itemTypes.forEach((type: string) => { + if (projectJSON[type] && projectJSON[type].length) { + return createProjectDirectories(type) + .then((dirName: string) => { + chDir('..'); + ui.writeLine(chalk.cyan(`Now in "${process.cwd()}"...`)); + }) + .catch(() => { + ui.writeLine(chalk.magenta(`Directory "${type}" already exists.`)); + Promise.resolve(); + }); + } + else { return; } + }); + } + + function generateProjectItems() { + return itemTypes.forEach((type: string) => { + let items: {}[] = projectJSON[type] && projectJSON[type].length ? projectJSON[type] : null; + + if (!!items) { + return items.forEach((item) => { + return generateItem(type, item) + .then(() => { + ui.writeLine(chalk.green(`${item.name} has been created`)); + }) + .catch((err) => { + ui.writeLine(chalk.red(`${item.name} creation has failed with ${err.message}`)); + }); + }); + } + else { return; } + }); + } + + function execCommandString(property: string, objectToCreate: { + name: string, blueprint?: string, dryRun?: boolean, verbose?: boolean, skipNpm?: boolean, skipGit?: boolean, directory?: string, flat?: boolean, default?: boolean, lazy?: boolean, skipRouterGeneration?: boolean, route?: string + }) { + let commandstring = property === 'package' ? `ng new ${objectToCreate.name}` : `ng generate ${commandAliases[property]} /${property}/${objectToCreate.name}`; + if (objectToCreate.dryRun) { commandstring += ' --dry-run'; } + if (objectToCreate.verbose) { commandstring += ' --verbose'; } + if (objectToCreate.skipNpm) { commandstring += ' --skip-npm'; } + if (objectToCreate.skipGit) { commandstring += ' --skip-git'; } + if (objectToCreate.directory) { commandstring += ` --directory=${objectToCreate.directory}`; } + if (objectToCreate.blueprint) { commandstring += ` --blueprint=${objectToCreate.blueprint}`; } + if (objectToCreate.flat) { commandstring += ' --flat'; } + if (objectToCreate.default) { commandstring += ' --default'; } + if (objectToCreate.skipRouterGeneration) { commandstring += ' --skip-router-generation'; } + if (objectToCreate.lazy === false) { commandstring += ' --lazy=false'; } + if (objectToCreate.route) { commandstring += ` --route=${objectToCreate.route}`; } + + return commandstring; + } +======= + const createAndStepIntoDirectory = + new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); + + let executeCommand = ( + data: { + command: string, + options?: {} + }) => { + let child = exec(data.command, data.options); + }; + + let generatePackage = (options: {}) => { + let commandstring = `ng new ${options.name}`; + if (options.dryRun) { + commandstring += ' --dry-run'; + } + if (options.verbose) { + commandstring += ' --verbose'; + } + if (options.skipNpm) { + commandstring += ' --skip-npm'; + } + if (options.skipGit) { + commandstring += ' --skip-git'; + } + if (options.directory) { + commandstring += ` --directory=${options.directory}`; + } + if (options.blueprint) { + commandstring += ` --blueprint=${options.blueprint}`; + } + let packageGenerator = executeCommand({ + command: commandstring, + options: { + cwd: process.cwd(), + maxBuffer: 2000 * 1024, + stdio: [0, 1, 2] + } + }) + } + + let generateItems = ( + data: { + projectJSONProperty: string[], + directoryName: string + }) => { + + this.ui.writeLine(chalk.red(`The current directory is ${process.cwd()}`)); + data.projectJSONProperty.forEach((item: {}, index: number) => { + this.ui.writeLine(chalk.green(`The ${data.directoryName} name is ${item.name}`)); + let commandstring = `ng generate ${commandAliases[data.directoryName]} /${data.directoryName}/${item.name}`; + if (item.flat) { + commandstring += ' --flat'; + } + if (item.default) { + commandstring += ' --default'; + } + if (item.skipRouterGeneration) { + commandstring += ' --skip-router-generation'; + } + if (item.lazy === false) { + commandstring += ' --lazy=false'; + } + if (item.route) { + commandstring += ` --route=${item.route}`; + } + let itemGenerator = executeCommand( + { + command: commandstring, + options: { + cwd: process.cwd(), + maxBuffer: 2000 * 1024, + stdio: [0, 1, 2] + } + }); + }); + }; + const generateItemsFromJSON = (obj: NgAppStructure) => { + let itemsToGenerateExist = false; + for (let prop in obj) { + let objProp = obj[prop]; + if (prop !== 'package' && objProp.length > 0) { + itemsToGenerateExist = true; + createAndStepIntoDirectory + .run({ + directoryName: prop, + dryRun: commandOptions.dryRun + }) + .then((dirName: string) => { + this.ui.writeLine(chalk.green(`The ${prop} name is ${dirName}`)); + generateItems( + { + projectJSONProperty: objProp, + directoryName: prop + }); + }) + .catch(() => { + generateItems( + { + projectJSONProperty: objProp, + directoryName: prop + }); + }); + } + } + if (!itemsToGenerateExist) { + return; + } + } + + if (packageOptions) { + if (packageOptions.dryRun) { + commandOptions.dryRun = true; + } + + if (packageOptions.blueprint) { + commandOptions.blueprint = packageOptions.blueprint; + } + + if (packageOptions.directory) { + commandOptions.directory = packageOptions.directory; + } + } + + this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); + this.ui.writeLine(chalk.red(`The packageName is ${packageName}`)); + if (!packageName) { + return Promise.reject(new SilentError( + `The "ng ${this.name}" command requires a name argument to be specified. ` + + `For more details, use "ng help".`)); + } + + commandOptions.name = packageName; + if (commandOptions.dryRun) { + commandOptions.skipGit = true; + } + + commandOptions.blueprint = normalizeBlueprint(commandOptions.blueprint); + + const runCommand = (options: {}, ngAppObj:NgAppStructure, callback) => { + generatePackage(options); + process.chdir(`${packageName}/src/app`); + generateItemsFromJSON(ngAppObj); + callback('Items Generated!'); + } + + return runCommand(commandOptions, projectJSON, (result: string) => { + this.ui.writeLine(chalk.green(result)); + }); +>>>>>>> adf21fb09196c21234f6129fc7c9b36cb55d44b0 + } +}); + +module.exports = NewFromJSONCommand; +module.exports.overrideCore = true; diff --git a/addon/ng2/commands/newFromJSON.ts~RF6db2f6c.TMP b/addon/ng2/commands/newFromJSON.ts~RF6db2f6c.TMP new file mode 100644 index 000000000000..b82e7e8e94e9 --- /dev/null +++ b/addon/ng2/commands/newFromJSON.ts~RF6db2f6c.TMP @@ -0,0 +1,204 @@ +/// + +import * as Command from 'ember-cli/lib/models/command'; +import * as SilentError from 'silent-error'; +import { execSync, exec } from 'child_process'; +import * as Promise from 'ember-cli/lib/ext/promise'; +import * as chalk from 'chalk'; +import * as fs from 'fs'; +import * as fse from 'fs-extra'; +import * as validProjectName from 'ember-cli/lib/utilities/valid-project-name'; +import * as GenerateCommand from './generate'; +import {NgAppStructure} from '../models/newFromJSON.model'; + +const normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option'); +const fsReadFile = Promise.denodeify(fs.readFile); +const fsWriteFile = Promise.denodeify(fs.writeFile); +const fsReadDir = Promise.denodeify(fs.readdir); +const fsCopy = Promise.denodeify(fse.copy); +const fileStats = Promise.denodeify(fs.stat); +const execPromise = Promise.denodeify(exec); + + +const NewFromJSONCommand = Command.extend({ + name: 'newfromjson', + works: 'outsideProject', + + availableOptions: [ + ], + + run: function (commandOptions, rawArgs) { + + let projectJSON: NgAppStructure; + + const ui = this.ui; + const chDir = process.chdir; + const execOptions = { + cwd: process.cwd(), + maxBuffer: 2000 * 1024, + stdio: [0, 1, 2] + }; + const commandAliases = { + 'classes': 'cl', + 'components': 'c', + 'directives': 'd', + 'enums': 'e', + 'pipes': 'p', + 'routes': 'r', + 'services': 's' + }; + + const createAndStepIntoDirectory = + new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); + + let checkForExisting = (path: string) => { + return fileStats(path); + }; + + let checkForPackage = (packageName: string) => { + return checkForExisting(`${packageName}/angular-cli.json`) + }; + + let checkForItem = (typeOfItem: string, itemName: string) => { + return checkForExisting(`${typeOfItem}/${itemName}`) + }; + + let newPackage = (packageObject: { + name: string, blueprint?: string, dryRun?: boolean, verbose?: boolean, skipNpm?: boolean, skipGit?: boolean, directory?: string, flat?: boolean, default?: boolean, lazy?: boolean, skipRouterGeneration?: boolean, route?: string + }) => { + return checkForPackage(packageObject.name) + .then(() => { + let msg = `${packageObject.name} already exists, changing directories.` + ui.writeLine(chalk.yellow(msg)); + Promise.resolve(); + }) + .catch(() => { + let commandString = execCommandString('package', packageObject); + //return execSync(commandString, execOptions); + //p_list.push({ process: packageChildProcess, content: "" }); + return execPromise(commandString, execOptions); + }) + }; + + let generateItem = (typeOfItem: string, itemObject: { + name: string, blueprint?: string, dryRun?: boolean, verbose?: boolean, skipNpm?: boolean, skipGit?: boolean, directory?: string, flat?: boolean, default?: boolean, lazy?: boolean, skipRouterGeneration?: boolean, route?: string + }) => { + let itemObjectName = itemObject.lazy === false ? itemObject.name : `+${itemObject.name}`; + return checkForItem(typeOfItem, itemObjectName) + .then(() => { + let msg = `${itemObject.name} already exists, moving on.`; + ui.writeLine(chalk.yellow(msg)); + Promise.resolve(); + }) + .catch(() => { + let commandString = execCommandString(typeOfItem, itemObject); + //return execSync(commandString, execOptions); + return execPromise(commandString, execOptions); + }); + }; + const itemTypes = ['routes', 'components', 'pipes', 'services', 'directives', 'classes', 'enums']; + + return getJSONFile() + .then(newProject) + .then(changeToProjectDirectory) + .then(makeItemDirectories) + .then(generateProjectItems) + .catch((err) => { + ui.writeLine(chalk.red(`This command requires a file named ng-project.json`)); + }); + + function getJSONFile() { + return fsReadFile('ng-project.json', 'utf8') + .then((data: string) => { + projectJSON = JSON.parse(data); + }) + } + + function newProject() { + return newPackage(projectJSON.package) + .then(() => { + ui.writeLine(chalk.green(`${projectJSON.package.name} project complete.`)); + }); + } + + function changeToProjectDirectory() { + return (() => { + chDir(`${projectJSON.package.name}/src/app`) + ui.writeLine(chalk.cyan(`Now in "${projectJSON.package.name}/src/app"...`)); + })(); + } + + function createProjectDirectories(directoryName: string) { + return createAndStepIntoDirectory + .run({ + directoryName: directoryName, + dryRun: projectJSON.package.dryRun + }) + } + + function createEachItem(typeOfItem: string, item: {}) { + return generateItem(typeOfItem, item) + //.then(() => { + // ui.writeLine(chalk.green(`${item.name} has been created`)); + //}); + } + + function makeItemDirectories() { + return itemTypes.forEach((type: string) => { + if (projectJSON[type] && projectJSON[type].length) { + return createProjectDirectories(type) + .then((dirName: string) => { + chDir('..'); + ui.writeLine(chalk.cyan(`Now in "${process.cwd()}"...`)); + }) + .catch(() => { + ui.writeLine(chalk.magenta(`Directory "${type}" already exists.`)); + Promise.resolve(); + }); + } + else { return; } + }); + } + + function generateProjectItems() { + itemTypes.forEach((type: string) => { + let items: {}[] = projectJSON[type] && projectJSON[type].length ? projectJSON[type] : null; + + if (!!items) { + items.forEach((item) => { + return createEachItem(type, item) + .then(() => { + ui.writeLine(chalk.green(`${item.name} has been created`)); + }) + .catch((err) => { + ui.writeLine(chalk.red(`${item.name} creation has failed with ${err.message}`)); + }); + }); + } + else { return; } + }); + } + + function execCommandString(property: string, objectToCreate: { + name: string, blueprint?: string, dryRun?: boolean, verbose?: boolean, skipNpm?: boolean, skipGit?: boolean, directory?: string, flat?: boolean, default?: boolean, lazy?: boolean, skipRouterGeneration?: boolean, route?: string + }) { + let commandstring = property === 'package' ? `ng new ${objectToCreate.name}` : `ng generate ${commandAliases[property]} /${property}/${objectToCreate.name}`; + if (objectToCreate.dryRun) { commandstring += ' --dry-run'; } + if (objectToCreate.verbose) { commandstring += ' --verbose'; } + if (objectToCreate.skipNpm) { commandstring += ' --skip-npm'; } + if (objectToCreate.skipGit) { commandstring += ' --skip-git'; } + if (objectToCreate.directory) { commandstring += ` --directory=${objectToCreate.directory}`; } + if (objectToCreate.blueprint) { commandstring += ` --blueprint=${objectToCreate.blueprint}`; } + if (objectToCreate.flat) { commandstring += ' --flat'; } + if (objectToCreate.default) { commandstring += ' --default'; } + if (objectToCreate.skipRouterGeneration) { commandstring += ' --skip-router-generation'; } + if (objectToCreate.lazy === false) { commandstring += ' --lazy=false'; } + if (objectToCreate.route) { commandstring += ` --route=${objectToCreate.route}`; } + + return commandstring; + } + } +}); + +module.exports = NewFromJSONCommand; +module.exports.overrideCore = true; diff --git a/addon/ng2/index.js b/addon/ng2/index.js index cb5a3b548acc..d3cc062e15bd 100644 --- a/addon/ng2/index.js +++ b/addon/ng2/index.js @@ -13,6 +13,7 @@ module.exports = { includedCommands: function () { return { 'new': require('./commands/new'), + 'newfromjson': require('./commands/newFromJSON'), 'generate': require('./commands/generate'), 'init': require('./commands/init'), 'test': require('./commands/test'), diff --git a/addon/ng2/models/newFromJSON.model.ts b/addon/ng2/models/newFromJSON.model.ts new file mode 100644 index 000000000000..387caeb00831 --- /dev/null +++ b/addon/ng2/models/newFromJSON.model.ts @@ -0,0 +1,44 @@ +export interface NgAppStructure extends JSON{ + package: { + name: string, + blueprint?: string, + dryRun?: boolean, + verbose?: boolean, + skipNpm?: boolean, + skipGit?: boolean, + directory?: string + }, + routes?: { + name: string, + flat?: boolean, + default?: boolean, + lazy?: boolean, + skipRouterGeneration?: boolean, + route?: string + }[], + components?: { + name: string, + flat?: boolean, + route?: string + }[], + pipes?: { + name: string, + flat?: boolean + }[], + services?: { + name: string, + flat?: boolean + }[], + directives?: { + name: string, + flat?: boolean + }[], + classes?: { + name: string, + flat?: boolean + }[], + enums?: { + name: string, + flat?: boolean + }[] +} \ No newline at end of file diff --git a/package.json b/package.json index 2e40130cc93a..1375980de33c 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "symlink-or-copy": "^1.0.3", "systemjs-builder": "0.15.17", "typescript": "^1.8.10", - "typings": "^0.8.1" + "typings": "^1.0.4" }, "ember-addon": { "paths": [ diff --git a/typings.json b/typings.json index e9093d1857fc..e179ebc5b89a 100644 --- a/typings.json +++ b/typings.json @@ -3,7 +3,7 @@ "devDependencies": { "chalk": "github:typings/typed-chalk#a7e422c5455e70292e5675a727d43a7b05fc3e58" }, - "ambientDevDependencies": { + "globalDevDependencies": { "assertion-error": "github:DefinitelyTyped/DefinitelyTyped/assertion-error/assertion-error.d.ts#800a7047cf275cc9f695cbd116748cd408a09d6d", "chai": "github:DefinitelyTyped/DefinitelyTyped/chai/chai.d.ts#9c25433c84251bfe72bf0030a95edbbb2c81c9d5", "glob": "github:DefinitelyTyped/DefinitelyTyped/glob/glob.d.ts#a14d724826174d1669d4df04c80f4838b7e71fdf", @@ -12,5 +12,8 @@ "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#8cf8164641be73e8f1e652c2a5b967c7210b6729", "shelljs": "github:DefinitelyTyped/DefinitelyTyped/shelljs/shelljs.d.ts#ce14ae27a020194da3d35aa3468ca1e9e5296316", "through": "github:DefinitelyTyped/DefinitelyTyped/through/through.d.ts#4ffee4a839f36d4f13ea7b0bc03ed2ca853e79d5" + }, + "globalDependencies": { + "ember": "registry:dt/ember#1.11.3+20160317120654" } }