diff --git a/addon/ng2/commands/generate.ts b/addon/ng2/commands/generate.ts index 3a5bbf177353..3c01409d2cf2 100644 --- a/addon/ng2/commands/generate.ts +++ b/addon/ng2/commands/generate.ts @@ -2,7 +2,9 @@ import * as EmberGenerateCommand from 'ember-cli/lib/commands/generate'; import * as fs from 'fs'; import * as path from 'path'; import * as SilentError from 'silent-error'; - +var chalk = require('chalk'); +import * as Blueprint from 'ember-cli/lib/models/blueprint'; +var EOL = require('os').EOL; const GenerateCommand = EmberGenerateCommand.extend({ name: 'generate', @@ -15,10 +17,28 @@ const GenerateCommand = EmberGenerateCommand.extend({ // map the blueprint name to allow for aliases rawArgs[0] = mapBlueprintName(rawArgs[0]); - if (!fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) { + if (rawArgs[0] !== '--help' && + !fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) { SilentError.debugOrThrow('angular-cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`); } - + + // Override default help to hide ember blueprints + EmberGenerateCommand.prototype.printDetailedHelp = function (options) { + var blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints')); + var blueprints = blueprintList + .filter(bp => bp.indexOf('-test') === -1) + .filter(bp => bp !== 'ng2') + .map(bp => Blueprint.load(path.join(__dirname, '..', 'blueprints', bp))); + + var output = ''; + blueprints + .forEach(function (bp) { + output += bp.printBasicHelp(false) + EOL; + }); + this.ui.writeLine(chalk.cyan(' Available blueprints')); + this.ui.writeLine(output); + }; + return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments); } });