mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 03:23:57 +08:00
refactor(@angular/cli): remove ng doc
command
This command lacked practical utility. BREAKING CHANGE: The `ng doc` command has been removed without a replacement. To perform searches, please visit www.angular.dev
This commit is contained in:
parent
6bd4f5f8d3
commit
03eee05450
@ -68,7 +68,6 @@ ts_library(
|
|||||||
"@npm//ini",
|
"@npm//ini",
|
||||||
"@npm//jsonc-parser",
|
"@npm//jsonc-parser",
|
||||||
"@npm//npm-package-arg",
|
"@npm//npm-package-arg",
|
||||||
"@npm//open",
|
|
||||||
"@npm//ora",
|
"@npm//ora",
|
||||||
"@npm//pacote",
|
"@npm//pacote",
|
||||||
"@npm//semver",
|
"@npm//semver",
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
"jsonc-parser": "3.2.1",
|
"jsonc-parser": "3.2.1",
|
||||||
"npm-package-arg": "11.0.1",
|
"npm-package-arg": "11.0.1",
|
||||||
"npm-pick-manifest": "9.0.0",
|
"npm-pick-manifest": "9.0.0",
|
||||||
"open": "8.4.2",
|
|
||||||
"ora": "5.4.1",
|
"ora": "5.4.1",
|
||||||
"pacote": "17.0.6",
|
"pacote": "17.0.6",
|
||||||
"resolve": "1.22.8",
|
"resolve": "1.22.8",
|
||||||
|
@ -16,7 +16,6 @@ export type CommandNames =
|
|||||||
| 'completion'
|
| 'completion'
|
||||||
| 'config'
|
| 'config'
|
||||||
| 'deploy'
|
| 'deploy'
|
||||||
| 'doc'
|
|
||||||
| 'e2e'
|
| 'e2e'
|
||||||
| 'extract-i18n'
|
| 'extract-i18n'
|
||||||
| 'generate'
|
| 'generate'
|
||||||
@ -60,10 +59,7 @@ export const RootCommands: Record<
|
|||||||
'deploy': {
|
'deploy': {
|
||||||
factory: () => import('./deploy/cli'),
|
factory: () => import('./deploy/cli'),
|
||||||
},
|
},
|
||||||
'doc': {
|
|
||||||
factory: () => import('./doc/cli'),
|
|
||||||
aliases: ['d'],
|
|
||||||
},
|
|
||||||
'e2e': {
|
'e2e': {
|
||||||
factory: () => import('./e2e/cli'),
|
factory: () => import('./e2e/cli'),
|
||||||
aliases: ['e'],
|
aliases: ['e'],
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright Google LLC All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by an MIT-style license that can be
|
|
||||||
* found in the LICENSE file at https://angular.io/license
|
|
||||||
*/
|
|
||||||
|
|
||||||
import open from 'open';
|
|
||||||
import { Argv } from 'yargs';
|
|
||||||
import {
|
|
||||||
CommandModule,
|
|
||||||
CommandModuleImplementation,
|
|
||||||
Options,
|
|
||||||
} from '../../command-builder/command-module';
|
|
||||||
import { RootCommands } from '../command-config';
|
|
||||||
|
|
||||||
interface DocCommandArgs {
|
|
||||||
keyword: string;
|
|
||||||
search?: boolean;
|
|
||||||
version?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class DocCommandModule
|
|
||||||
extends CommandModule<DocCommandArgs>
|
|
||||||
implements CommandModuleImplementation<DocCommandArgs>
|
|
||||||
{
|
|
||||||
command = 'doc <keyword>';
|
|
||||||
aliases = RootCommands['doc'].aliases;
|
|
||||||
describe =
|
|
||||||
'Opens the official Angular documentation (angular.io) in a browser, and searches for a given keyword.';
|
|
||||||
longDescriptionPath?: string;
|
|
||||||
|
|
||||||
builder(localYargs: Argv): Argv<DocCommandArgs> {
|
|
||||||
return localYargs
|
|
||||||
.positional('keyword', {
|
|
||||||
description: 'The keyword to search for, as provided in the search bar in angular.io.',
|
|
||||||
type: 'string',
|
|
||||||
demandOption: true,
|
|
||||||
})
|
|
||||||
.option('search', {
|
|
||||||
description: `Search all of angular.io. Otherwise, searches only API reference documentation.`,
|
|
||||||
alias: ['s'],
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
})
|
|
||||||
.option('version', {
|
|
||||||
description:
|
|
||||||
'The version of Angular to use for the documentation. ' +
|
|
||||||
'If not provided, the command uses your current Angular core version.',
|
|
||||||
type: 'string',
|
|
||||||
})
|
|
||||||
.strict();
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(options: Options<DocCommandArgs>): Promise<number | void> {
|
|
||||||
let domain = 'angular.io';
|
|
||||||
|
|
||||||
if (options.version) {
|
|
||||||
// version can either be a string containing "next"
|
|
||||||
if (options.version === 'next') {
|
|
||||||
domain = 'next.angular.io';
|
|
||||||
} else if (options.version === 'rc') {
|
|
||||||
domain = 'rc.angular.io';
|
|
||||||
// or a number where version must be a valid Angular version (i.e. not 0, 1 or 3)
|
|
||||||
} else if (!isNaN(+options.version) && ![0, 1, 3].includes(+options.version)) {
|
|
||||||
domain = `v${options.version}.angular.io`;
|
|
||||||
} else {
|
|
||||||
this.context.logger.error(
|
|
||||||
'Version should either be a number (2, 4, 5, 6...), "rc" or "next"',
|
|
||||||
);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// we try to get the current Angular version of the project
|
|
||||||
// and use it if we can find it
|
|
||||||
try {
|
|
||||||
/* eslint-disable-next-line import/no-extraneous-dependencies */
|
|
||||||
const currentNgVersion = (await import('@angular/core')).VERSION.major;
|
|
||||||
domain = `v${currentNgVersion}.angular.io`;
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
await open(
|
|
||||||
options.search
|
|
||||||
? `https://${domain}/docs?search=${options.keyword}`
|
|
||||||
: `https://${domain}/api?query=${options.keyword}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user