From b4594bac334982b3f152021f70b1b1e8db3e243f Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Wed, 22 Feb 2017 17:20:17 -0800 Subject: [PATCH] fix(@angular/cli): add more description --- packages/@angular/cli/commands/build.ts | 99 +++++++++-------- packages/@angular/cli/commands/completion.ts | 26 ++++- packages/@angular/cli/commands/e2e.ts | 105 ++++++++++-------- packages/@angular/cli/commands/eject.ts | 6 +- packages/@angular/cli/commands/get.ts | 7 +- packages/@angular/cli/commands/lint.ts | 27 ++++- packages/@angular/cli/commands/new.ts | 3 +- packages/@angular/cli/commands/serve.ts | 109 ++++++++++++------- packages/@angular/cli/commands/set.ts | 10 +- packages/@angular/cli/commands/xi18n.ts | 3 +- 10 files changed, 249 insertions(+), 146 deletions(-) diff --git a/packages/@angular/cli/commands/build.ts b/packages/@angular/cli/commands/build.ts index f204f03aad4d..bdb1cdaf00e5 100644 --- a/packages/@angular/cli/commands/build.ts +++ b/packages/@angular/cli/commands/build.ts @@ -24,78 +24,81 @@ export const baseBuildCommandOptions: any = [ description: 'Defines the build environment.' }, { - name: 'output-path', - type: 'Path', - aliases: ['op'], - description: 'Path where output will be placed.' + name: 'output-path', + type: 'Path', + aliases: ['op'], + description: 'Path where output will be placed.' }, { - name: 'aot', - type: Boolean, - description: 'Build using Ahead of Time compilation.' + name: 'aot', + type: Boolean, + description: 'Build using Ahead of Time compilation.' }, { - name: 'sourcemap', - type: Boolean, - aliases: ['sm', 'sourcemaps'], - description: 'Output sourcemaps.' + name: 'sourcemap', + type: Boolean, + aliases: ['sm', 'sourcemaps'], + description: 'Output sourcemaps.' }, { - name: 'vendor-chunk', - type: Boolean, - default: true, - aliases: ['vc'], - description: 'Use a separate bundle containing only vendor libraries.' + name: 'vendor-chunk', + type: Boolean, + default: true, + aliases: ['vc'], + description: 'Use a separate bundle containing only vendor libraries.' }, { - name: 'base-href', - type: String, - aliases: ['bh'], - description: 'Base url for the application being built.' + name: 'base-href', + type: String, + aliases: ['bh'], + description: 'Base url for the application being built.' }, { - name: 'deploy-url', - type: String, - aliases: ['d'], - description: 'URL where files will be deployed.' + name: 'deploy-url', + type: String, + aliases: ['d'], + description: 'URL where files will be deployed.' }, { - name: 'verbose', - type: Boolean, - default: false, - aliases: ['v'], - description: 'Adds more details to output logging.' + name: 'verbose', + type: Boolean, + default: false, + aliases: ['v'], + description: 'Adds more details to output logging.' }, { - name: 'progress', - type: Boolean, - default: true, - aliases: ['pr'], - description: 'Log progress to the console while building.' + name: 'progress', + type: Boolean, + default: true, + aliases: ['pr'], + description: 'Log progress to the console while building.' }, { - name: 'i18n-file', - type: String + name: 'i18n-file', + type: String, + description: 'Localization file to use for i18n.' }, { - name: 'i18n-format', - type: String + name: 'i18n-format', + type: String, + description: 'Format of the localization file specified with --i18n-file.' }, { - name: 'locale', - type: String + name: 'locale', + type: String, + description: 'Locale to use for i18n.' }, { - name: 'extract-css', - type: Boolean, - aliases: ['ec'], - description: 'Extract css from global styles onto css files instead of js ones.' + name: 'extract-css', + type: Boolean, + aliases: ['ec'], + description: 'Extract css from global styles onto css files instead of js ones.' }, { - name: 'watch', - type: Boolean, default: false, - aliases: ['w'], - description: 'Run build when files change.' + name: 'watch', + type: Boolean, default: false, + aliases: ['w'], + description: 'Run build when files change.' }, { name: 'output-hashing', diff --git a/packages/@angular/cli/commands/completion.ts b/packages/@angular/cli/commands/completion.ts index 891fd4cb9e39..5e14954474a8 100644 --- a/packages/@angular/cli/commands/completion.ts +++ b/packages/@angular/cli/commands/completion.ts @@ -36,7 +36,7 @@ export interface CompletionCommandOptions { all?: boolean; bash?: boolean; zsh?: boolean; -}; +} const commandsToIgnore = [ 'destroy', @@ -51,9 +51,27 @@ const CompletionCommand = Command.extend({ description: 'Adds autocomplete functionality to `ng` commands and subcommands.', works: 'everywhere', availableOptions: [ - { name: 'all', type: Boolean, default: true, aliases: ['a'] }, - { name: 'bash', type: Boolean, default: false, aliases: ['b'] }, - { name: 'zsh', type: Boolean, default: false, aliases: ['z'] } + { + name: 'all', + type: Boolean, + default: true, + aliases: ['a'], + description: 'Generate a completion script compatible with both bash and zsh.' + }, + { + name: 'bash', + type: Boolean, + default: false, + aliases: ['b'] + description: 'Generate a completion script for bash.' + }, + { + name: 'zsh', + type: Boolean, + default: false, + aliases: ['z'] + description: 'Generate a completion script for zsh.' + } ], run: function (commandOptions: CompletionCommandOptions) { diff --git a/packages/@angular/cli/commands/e2e.ts b/packages/@angular/cli/commands/e2e.ts index a40ce1a163ff..a937814e98d8 100644 --- a/packages/@angular/cli/commands/e2e.ts +++ b/packages/@angular/cli/commands/e2e.ts @@ -21,54 +21,63 @@ const E2eCommand = Command.extend({ aliases: ['e'], description: 'Run e2e tests in existing project.', works: 'insideProject', - availableOptions: overrideOptions( - baseServeCommandOptions.concat([ - { - name: 'config', - type: String, - aliases: ['c'], - description: oneLine`Use a specific config file. - Defaults to the protractor config file in angular-cli.json.` - }, - { - name: 'specs', - type: Array, - default: [], - aliases: ['sp'], - description: oneLine`Override specs in the protractor config. - Can send in multiple specs by repeating flag (ng e2e --specs=spec1.ts --specs=spec2.ts).` - }, - { - name: 'element-explorer', - type: Boolean, - default: false, - aliases: ['ee'], - description: 'Start Protractor\'s Element Explorer for debugging.' - }, - { - name: 'webdriver-update', - type: Boolean, - default: true, - aliases: ['wu'], - description: 'Try to update webdriver.' - }, - { - name: 'serve', - type: Boolean, - default: true, - aliases: ['s'], - description: oneLine`Compile and Serve the app. - All non-reload related serve options are also available (e.g. --port=4400).` - } - ]), [ - { name: 'port', default: 0 }, - { - name: 'watch', - default: false, - description: 'Run build when files change.' - }, - ] - ), + availableOptions: overrideOptions([ + ...baseServeCommandOptions, + { + name: 'config', + type: String, + aliases: ['c'], + description: oneLine` + Use a specific config file. + Defaults to the protractor config file in angular-cli.json. + ` + }, + { + name: 'specs', + type: Array, + default: [], + aliases: ['sp'], + description: oneLine` + Override specs in the protractor config. + Can send in multiple specs by repeating flag (ng e2e --specs=spec1.ts --specs=spec2.ts). + ` + }, + { + name: 'element-explorer', + type: Boolean, + default: false, + aliases: ['ee'], + description: 'Start Protractor\'s Element Explorer for debugging.' + }, + { + name: 'webdriver-update', + type: Boolean, + default: true, + aliases: ['wu'], + description: 'Try to update webdriver.' + }, + { + name: 'serve', + type: Boolean, + default: true, + aliases: ['s'], + description: oneLine` + Compile and Serve the app. + All non-reload related serve options are also available (e.g. --port=4400). + ` + } + ], [ + { + name: 'port', + default: 0, + description: 'The port to use to serve the application.' + }, + { + name: 'watch', + default: false, + description: 'Run build when files change.' + }, + ]), run: function (commandOptions: E2eTaskOptions) { const E2eTask = require('../tasks/e2e').E2eTask; this.project.ngConfig = this.project.ngConfig || CliConfig.fromProject(); diff --git a/packages/@angular/cli/commands/eject.ts b/packages/@angular/cli/commands/eject.ts index c681a96d840e..016cfd564977 100644 --- a/packages/@angular/cli/commands/eject.ts +++ b/packages/@angular/cli/commands/eject.ts @@ -6,7 +6,11 @@ const Command = require('../ember-cli/lib/models/command'); // defaults for BuildOptions export const baseEjectCommandOptions: any = [ ...baseBuildCommandOptions, - { name: 'force', 'type': Boolean }, + { + name: 'force', + type: Boolean, + description: 'Overwrite any webpack.config.js and npm scripts already existing.' + }, { name: 'app', type: String, diff --git a/packages/@angular/cli/commands/get.ts b/packages/@angular/cli/commands/get.ts index 04e9af4df4d2..ee0bca96ab35 100644 --- a/packages/@angular/cli/commands/get.ts +++ b/packages/@angular/cli/commands/get.ts @@ -15,7 +15,12 @@ const GetCommand = Command.extend({ works: 'everywhere', availableOptions: [ - { name: 'global', type: Boolean, 'default': false } + { + name: 'global', + type: Boolean, + 'default': false, + description: 'Get the value in the global configuration (in your home directory).' + } ], run: function (commandOptions: GetOptions, rawArgs: string[]): Promise { diff --git a/packages/@angular/cli/commands/lint.ts b/packages/@angular/cli/commands/lint.ts index db7b44c378a6..1a40c51158c7 100644 --- a/packages/@angular/cli/commands/lint.ts +++ b/packages/@angular/cli/commands/lint.ts @@ -1,5 +1,8 @@ +import {oneLine} from 'common-tags'; + const Command = require('../ember-cli/lib/models/command'); + export interface LintCommandOptions { fix?: boolean; format?: string; @@ -12,9 +15,27 @@ export default Command.extend({ description: 'Lints code in existing project.', works: 'insideProject', availableOptions: [ - { name: 'fix', type: Boolean, default: false }, - { name: 'force', type: Boolean, default: false }, - { name: 'format', alias: 't', type: String, default: 'prose' } + { + name: 'fix', + type: Boolean, + default: false, + description: 'Fixes linting errors (may overwrite linted files).' + }, + { + name: 'force', + type: Boolean, + default: false, + description: 'Succeeds even if there was linting errors.' + }, + { + name: 'format', + alias: 't', + type: String, + default: 'prose', + description: oneLine` + Output format (prose, json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist). + ` + } ], run: function (commandOptions: LintCommandOptions) { const LintTask = require('../tasks/lint').default; diff --git a/packages/@angular/cli/commands/new.ts b/packages/@angular/cli/commands/new.ts index 1cafc8952566..2b8df9dddced 100644 --- a/packages/@angular/cli/commands/new.ts +++ b/packages/@angular/cli/commands/new.ts @@ -71,7 +71,8 @@ const NewCommand = Command.extend({ name: 'skip-commit', type: Boolean, default: false, - aliases: ['sc'] + aliases: ['sc'], + description: 'Skip committing the first commit to git.' }, { name: 'directory', diff --git a/packages/@angular/cli/commands/serve.ts b/packages/@angular/cli/commands/serve.ts index f944d56d8dc3..01254c523145 100644 --- a/packages/@angular/cli/commands/serve.ts +++ b/packages/@angular/cli/commands/serve.ts @@ -29,43 +29,78 @@ export interface ServeTaskOptions extends BuildOptions { } // Expose options unrelated to live-reload to other commands that need to run serve -export const baseServeCommandOptions: any = overrideOptions( - baseBuildCommandOptions.concat([ - { name: 'port', type: Number, default: defaultPort, aliases: ['p'] }, - { - name: 'host', - type: String, - default: defaultHost, - aliases: ['H'], - description: `Listens only on ${defaultHost} by default.` - }, - { name: 'proxy-config', type: 'Path', aliases: ['pc'] }, - { name: 'ssl', type: Boolean, default: defaultSsl }, - { name: 'ssl-key', type: String, default: defaultSslKey }, - { name: 'ssl-cert', type: String, default: defaultSslCert }, - { - name: 'open', - type: Boolean, - default: false, - aliases: ['o'], - description: 'Opens the url in default browser.', - }, - { name: 'live-reload', type: Boolean, default: true, aliases: ['lr'] }, - { - name: 'live-reload-client', - type: String, - description: 'Specify the URL that the live reload browser client will use.' - }, - { - name: 'hmr', - type: Boolean, - default: false, - description: 'Enable hot module replacement.', - } - ]), [ - { name: 'watch', default: true } - ] -); +export const baseServeCommandOptions: any = overrideOptions([ + ...baseBuildCommandOptions, + { + name: 'port', + type: Number, + default: defaultPort, + aliases: ['p'], + description: 'Port to listen to for serving.' + }, + { + name: 'host', + type: String, + default: defaultHost, + aliases: ['H'], + description: `Listens only on ${defaultHost} by default.` + }, + { + name: 'proxy-config', + type: 'Path', + aliases: ['pc'], + description: 'Proxy configuration file.' + }, + { + name: 'ssl', + type: Boolean, + default: defaultSsl, + description: 'Serve using HTTPS.' + }, + { + name: 'ssl-key', + type: String, + default: defaultSslKey, + description: 'SSL key to use for serving HTTPS.' + }, + { + name: 'ssl-cert', + type: String, + default: defaultSslCert, + description: 'SSL certificate to use for serving HTTPS.' + }, + { + name: 'open', + type: Boolean, + default: false, + aliases: ['o'], + description: 'Opens the url in default browser.', + }, + { + name: 'live-reload', + type: Boolean, + default: true, + aliases: ['lr'], + description: 'Whether to reload the page on change, using live-reload.' + }, + { + name: 'live-reload-client', + type: String, + description: 'Specify the URL that the live reload browser client will use.' + }, + { + name: 'hmr', + type: Boolean, + default: false, + description: 'Enable hot module replacement.', + } +], [ + { + name: 'watch', + default: true, + description: 'Rebuild on change.' + } +]); const ServeCommand = Command.extend({ name: 'serve', diff --git a/packages/@angular/cli/commands/set.ts b/packages/@angular/cli/commands/set.ts index 52a38f0c3637..c37e706aaf1a 100644 --- a/packages/@angular/cli/commands/set.ts +++ b/packages/@angular/cli/commands/set.ts @@ -1,4 +1,4 @@ -import {CliConfig} from '../models/config'; +\import {CliConfig} from '../models/config'; const SilentError = require('silent-error'); const Command = require('../ember-cli/lib/models/command'); @@ -15,7 +15,13 @@ const SetCommand = Command.extend({ works: 'everywhere', availableOptions: [ - { name: 'global', type: Boolean, 'default': false, aliases: ['g'] }, + { + name: 'global', + type: Boolean, + 'default': false, + aliases: ['g'], + description: 'Set the value in the global configuration rather than in your project\'s.' + }, ], asBoolean: function (raw: string): boolean { diff --git a/packages/@angular/cli/commands/xi18n.ts b/packages/@angular/cli/commands/xi18n.ts index 67ee147bd23a..5cce122fdbd4 100644 --- a/packages/@angular/cli/commands/xi18n.ts +++ b/packages/@angular/cli/commands/xi18n.ts @@ -15,7 +15,8 @@ const Xi18nCommand = Command.extend({ name: 'i18n-format', type: String, default: 'xlf', - aliases: ['f', {'xmb': 'xmb'}, {'xlf': 'xlf'}, {'xliff': 'xlf'}] + aliases: ['f', {'xmb': 'xmb'}, {'xlf': 'xlf'}, {'xliff': 'xlf'}], + description: 'Output format for the generated file.' }, { name: 'output-path',