From 03eee0545095ff958ac86cb5dfad44692ef018ae Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 8 Apr 2024 06:37:00 +0000 Subject: [PATCH] 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 --- packages/angular/cli/BUILD.bazel | 1 - packages/angular/cli/package.json | 1 - .../cli/src/commands/command-config.ts | 6 +- packages/angular/cli/src/commands/doc/cli.ts | 91 ------------------- 4 files changed, 1 insertion(+), 98 deletions(-) delete mode 100644 packages/angular/cli/src/commands/doc/cli.ts diff --git a/packages/angular/cli/BUILD.bazel b/packages/angular/cli/BUILD.bazel index c6d55809442d..a3b6da47908f 100644 --- a/packages/angular/cli/BUILD.bazel +++ b/packages/angular/cli/BUILD.bazel @@ -68,7 +68,6 @@ ts_library( "@npm//ini", "@npm//jsonc-parser", "@npm//npm-package-arg", - "@npm//open", "@npm//ora", "@npm//pacote", "@npm//semver", diff --git a/packages/angular/cli/package.json b/packages/angular/cli/package.json index 67da4e8b4214..af9fe979d37a 100644 --- a/packages/angular/cli/package.json +++ b/packages/angular/cli/package.json @@ -33,7 +33,6 @@ "jsonc-parser": "3.2.1", "npm-package-arg": "11.0.1", "npm-pick-manifest": "9.0.0", - "open": "8.4.2", "ora": "5.4.1", "pacote": "17.0.6", "resolve": "1.22.8", diff --git a/packages/angular/cli/src/commands/command-config.ts b/packages/angular/cli/src/commands/command-config.ts index f0cffb01b520..5190bd9968c8 100644 --- a/packages/angular/cli/src/commands/command-config.ts +++ b/packages/angular/cli/src/commands/command-config.ts @@ -16,7 +16,6 @@ export type CommandNames = | 'completion' | 'config' | 'deploy' - | 'doc' | 'e2e' | 'extract-i18n' | 'generate' @@ -60,10 +59,7 @@ export const RootCommands: Record< 'deploy': { factory: () => import('./deploy/cli'), }, - 'doc': { - factory: () => import('./doc/cli'), - aliases: ['d'], - }, + 'e2e': { factory: () => import('./e2e/cli'), aliases: ['e'], diff --git a/packages/angular/cli/src/commands/doc/cli.ts b/packages/angular/cli/src/commands/doc/cli.ts deleted file mode 100644 index d6f9d571248a..000000000000 --- a/packages/angular/cli/src/commands/doc/cli.ts +++ /dev/null @@ -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 - implements CommandModuleImplementation -{ - command = 'doc '; - 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 { - 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): Promise { - 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}`, - ); - } -}