diff --git a/packages/@angular/cli/ember-cli/lib/cli/index.js b/packages/@angular/cli/ember-cli/lib/cli/index.js index d5eaac6678..281c4a5a84 100644 --- a/packages/@angular/cli/ember-cli/lib/cli/index.js +++ b/packages/@angular/cli/ember-cli/lib/cli/index.js @@ -3,8 +3,6 @@ var path = require('path'); // Main entry point var Project = require('../models/project'); -var commands = require('../commands'); -var tasks = require('../tasks'); var CLI = require('./cli'); var debug = require('debug')('ember-cli:cli/index'); @@ -40,9 +38,9 @@ module.exports = function(options) { var project = Project.projectOrnullProject(ui, cli); var environment = { - tasks: tasks, + tasks: { }, cliArgs: options.cliArgs, - commands: commands, + commands: { }, project: project, settings: defaultUpdateCheckerOptions }; diff --git a/packages/@angular/cli/ember-cli/lib/commands.js b/packages/@angular/cli/ember-cli/lib/commands.js deleted file mode 100644 index 801330451d..0000000000 --- a/packages/@angular/cli/ember-cli/lib/commands.js +++ /dev/null @@ -1,2 +0,0 @@ - -module.exports = { 'Unknown': require('./commands/unknown') }; diff --git a/packages/@angular/cli/ember-cli/lib/commands/generate.js b/packages/@angular/cli/ember-cli/lib/commands/generate.js deleted file mode 100644 index 021d6030d4..0000000000 --- a/packages/@angular/cli/ember-cli/lib/commands/generate.js +++ /dev/null @@ -1,160 +0,0 @@ -'use strict'; - -var chalk = require('chalk'); -var Command = require('../models/command'); -var Promise = require('../ext/promise'); -var Blueprint = require('../models/blueprint'); -var mergeBlueprintOptions = require('../utilities/merge-blueprint-options'); -var merge = require('lodash/merge'); -var reject = require('lodash/reject'); -var EOL = require('os').EOL; -var SilentError = require('silent-error'); - -module.exports = Command.extend({ - name: 'generate', - description: 'Generates new code from blueprints.', - aliases: ['g'], - works: 'insideProject', - - availableOptions: [ - { name: 'dry-run', - type: Boolean, - default: false, - aliases: ['d'], - description: 'Run through without making any changes.' - }, - { - name: 'verbose', - type: Boolean, - default: false, - aliases: ['v'], - description: 'Adds more details to output logging.' - } - ], - - anonymousOptions: [ - '' - ], - - beforeRun: mergeBlueprintOptions, - - run: function(commandOptions, rawArgs) { - var blueprintName = rawArgs[0]; - - if (!blueprintName) { - return Promise.reject(new SilentError('The `ng generate` command requires a ' + - 'blueprint name to be specified. ' + - 'For more details, use `ng help`.')); - } - var Task = this.tasks.GenerateFromBlueprint; - var task = new Task({ - ui: this.ui, - project: this.project, - testing: this.testing, - settings: this.settings - }); - - var taskArgs = { - args: rawArgs - }; - - if (this.settings && this.settings.usePods && !commandOptions.classic) { - commandOptions.pod = false; - } - - var taskOptions = merge(taskArgs, commandOptions || {}); - - if (this.project.initializeAddons) { - this.project.initializeAddons(); - } - - return task.run(taskOptions); - }, - - printDetailedHelp: function(options) { - this.ui.writeLine(this.getAllBlueprints(options)); - }, - - addAdditionalJsonForHelp: function(json, options) { - json.availableBlueprints = this.getAllBlueprints(options).filter(x => x.name !== 'ng'); - }, - - getAllBlueprints: function(options) { - var lookupPaths = this.project.blueprintLookupPaths(); - var blueprintList = Blueprint.list({ paths: lookupPaths }); - - var output = ''; - - var singleBlueprintName; - if (options.rawArgs) { - singleBlueprintName = options.rawArgs[0]; - } - - if (!singleBlueprintName && !options.json) { - output += EOL + ' Available blueprints:' + EOL; - } - - var collectionsJson = []; - - blueprintList.forEach(function(collection) { - var result = this.getPackageBlueprints(collection, options, singleBlueprintName); - if (options.json) { - var collectionJson = {}; - collectionJson[collection.source] = result; - collectionsJson.push(collectionJson); - } else { - output += result; - } - }, this); - - if (singleBlueprintName && !output && !options.json) { - output = chalk.yellow('The \'' + singleBlueprintName + - '\' blueprint does not exist in this project.') + EOL; - } - - if (options.json) { - return collectionsJson; - } else { - return output; - } - }, - - getPackageBlueprints: function(collection, options, singleBlueprintName) { - var verbose = options.verbose; - var blueprints = collection.blueprints; - - if (!verbose) { - blueprints = reject(blueprints, 'overridden'); - } - - var output = ''; - var blueprintsJson = []; - - blueprints.forEach(function(blueprint) { - if (blueprint.name === 'ng') { - // Skip - return; - } - var singleMatch = singleBlueprintName === blueprint.name; - if (singleMatch) { - verbose = true; - } - if (!singleBlueprintName || singleMatch) { - // this may add default keys for printing - blueprint.availableOptions.forEach(this.normalizeOption); - - if (options.json) { - blueprintsJson.push(blueprint.getJson(verbose)); - } else { - output += blueprint.printBasicHelp(verbose) + EOL; - } - } - }, this); - - if (options.json) { - return blueprintsJson; - } else { - return output; - } - } -}); diff --git a/packages/@angular/cli/ember-cli/lib/tasks.js b/packages/@angular/cli/ember-cli/lib/tasks.js deleted file mode 100644 index 2278db9733..0000000000 --- a/packages/@angular/cli/ember-cli/lib/tasks.js +++ /dev/null @@ -1,8 +0,0 @@ - -module.exports = { - DestroyFromBlueprint: require('./tasks/destroy-from-blueprint'), - GenerateFromBlueprint: require('./tasks/generate-from-blueprint'), - InstallBlueprint: require('./tasks/install-blueprint'), - NpmInstall: require('./tasks/npm-install'), - NpmTask: require('./tasks/npm-task'), -}; diff --git a/packages/@angular/cli/ember-cli/lib/tasks/destroy-from-blueprint.js b/packages/@angular/cli/ember-cli/lib/tasks/destroy-from-blueprint.js deleted file mode 100644 index bc50961b25..0000000000 --- a/packages/@angular/cli/ember-cli/lib/tasks/destroy-from-blueprint.js +++ /dev/null @@ -1,9 +0,0 @@ -/*jshint quotmark: false*/ - -'use strict'; - -var Generate = require('./generate-from-blueprint'); - -module.exports = Generate.extend({ - blueprintFunction: 'uninstall' -}); diff --git a/packages/@angular/cli/ember-cli/lib/tasks/generate-from-blueprint.js b/packages/@angular/cli/ember-cli/lib/tasks/generate-from-blueprint.js deleted file mode 100644 index fe7f2b93e8..0000000000 --- a/packages/@angular/cli/ember-cli/lib/tasks/generate-from-blueprint.js +++ /dev/null @@ -1,95 +0,0 @@ -/*jshint quotmark: false*/ - -'use strict'; - -var Promise = require('../ext/promise'); -var Blueprint = require('../models/blueprint'); -var Task = require('../models/task'); -var parseOptions = require('../utilities/parse-options'); -var merge = require('lodash/merge'); - -module.exports = Task.extend({ - blueprintFunction: 'install', - - run: function(options) { - var self = this; - var name = options.args[0]; - var noAddonBlueprint = ['mixin', 'blueprint-test']; - - var mainBlueprint = this.lookupBlueprint(name, options.ignoreMissingMain); - var testBlueprint = this.lookupBlueprint(name + '-test', true); - // lookup custom addon blueprint - var addonBlueprint = this.lookupBlueprint(name + '-addon', true); - // otherwise, use default addon-import - - if (noAddonBlueprint.indexOf(name) < 0 && !addonBlueprint && (mainBlueprint && mainBlueprint.supportsAddon()) && options.args[1]) { - addonBlueprint = this.lookupBlueprint('addon-import', true); - } - - if (options.ignoreMissingMain && !mainBlueprint) { - return Promise.resolve(); - } - - if (options.dummy) { - // don't install test or addon reexport for dummy - if (this.project.isEmberCLIAddon()) { - testBlueprint = null; - addonBlueprint = null; - } - } - - var entity = { - name: options.args[1], - options: parseOptions(options.args.slice(2)) - }; - - var blueprintOptions = { - target: this.project.root, - entity: entity, - ui: this.ui, - project: this.project, - settings: this.settings, - testing: this.testing, - taskOptions: options, - originBlueprintName: name - }; - - blueprintOptions = merge(blueprintOptions, options || {}); - - return mainBlueprint[this.blueprintFunction](blueprintOptions) - .then(function() { - if (!testBlueprint) { return; } - - if (testBlueprint.locals === Blueprint.prototype.locals) { - testBlueprint.locals = function(options) { - return mainBlueprint.locals(options); - }; - } - - var testBlueprintOptions = merge({} , blueprintOptions, { installingTest: true }); - - return testBlueprint[self.blueprintFunction](testBlueprintOptions); - }) - .then(function() { - if (!addonBlueprint || name.match(/-addon/)) { return; } - if (!this.project.isEmberCLIAddon() && blueprintOptions.inRepoAddon === null) { return; } - - if (addonBlueprint.locals === Blueprint.prototype.locals) { - addonBlueprint.locals = function(options) { - return mainBlueprint.locals(options); - }; - } - - var addonBlueprintOptions = merge({}, blueprintOptions, { installingAddon: true }); - - return addonBlueprint[self.blueprintFunction](addonBlueprintOptions); - }.bind(this)); - }, - - lookupBlueprint: function(name, ignoreMissing) { - return Blueprint.lookup(name, { - paths: this.project.blueprintLookupPaths(), - ignoreMissing: ignoreMissing - }); - } -}); diff --git a/packages/@angular/cli/tasks/init.ts b/packages/@angular/cli/tasks/init.ts index 1bd981a8bb..6fed349aa0 100644 --- a/packages/@angular/cli/tasks/init.ts +++ b/packages/@angular/cli/tasks/init.ts @@ -6,10 +6,10 @@ import {checkYarnOrCNPM} from '../utilities/check-package-manager'; import {CliConfig} from '../models/config'; const Task = require('../ember-cli/lib/models/task'); -const Promise = require('../ember-cli/lib/ext/promise'); const SilentError = require('silent-error'); const normalizeBlueprint = require('../ember-cli/lib/utilities/normalize-blueprint-option'); const GitInit = require('../tasks/git-init'); +const InstallBlueprint = require('../ember-cli/lib/tasks/install-blueprint'); export default Task.extend({ @@ -18,7 +18,7 @@ export default Task.extend({ commandOptions.skipInstall = true; } - const installBlueprint = new this.tasks.InstallBlueprint({ + const installBlueprint = new InstallBlueprint({ ui: this.ui, project: this.project });