From 8e2d5f9ccbc7d4f2d7fa7dd6623bfa29e7bcb6f0 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Thu, 17 Sep 2026 16:29:53 +0000 Subject: [PATCH] Revert "refactor(@angular/cli): import markdown files directly for command descriptions" This reverts commit 3d7f081dbc6cc0c25740bab70d49f21c7d178c3c. --- .../cli/src/command-builder/command-module.ts | 46 +++++++++---------- packages/angular/cli/src/commands/add/cli.ts | 5 +- .../angular/cli/src/commands/analytics/cli.ts | 6 +-- .../cli/src/commands/analytics/info/cli.ts | 1 + .../src/commands/analytics/settings/cli.ts | 2 + .../angular/cli/src/commands/build/cli.ts | 6 +-- .../cli/src/commands/cache/clean/cli.ts | 1 + .../angular/cli/src/commands/cache/cli.ts | 6 +-- .../cli/src/commands/cache/info/cli.ts | 1 + .../cli/src/commands/cache/settings/cli.ts | 2 + .../cli/src/commands/completion/cli.ts | 7 ++- .../angular/cli/src/commands/config/cli.ts | 6 +-- .../angular/cli/src/commands/deploy/cli.ts | 6 +-- packages/angular/cli/src/commands/e2e/cli.ts | 1 + .../cli/src/commands/extract-i18n/cli.ts | 1 + .../angular/cli/src/commands/generate/cli.ts | 1 + packages/angular/cli/src/commands/lint/cli.ts | 6 +-- .../cli/src/commands/make-this-awesome/cli.ts | 1 + packages/angular/cli/src/commands/mcp/cli.ts | 1 + packages/angular/cli/src/commands/new/cli.ts | 6 +-- packages/angular/cli/src/commands/run/cli.ts | 6 +-- .../angular/cli/src/commands/serve/cli.ts | 1 + packages/angular/cli/src/commands/test/cli.ts | 6 +-- .../angular/cli/src/commands/update/cli.ts | 5 +- .../angular/cli/src/commands/version/cli.ts | 1 + packages/angular/cli/src/typings.d.ts | 12 ----- .../cli/src/utilities/markdown-loader.ts | 35 -------------- 27 files changed, 59 insertions(+), 119 deletions(-) delete mode 100644 packages/angular/cli/src/typings.d.ts delete mode 100644 packages/angular/cli/src/utilities/markdown-loader.ts diff --git a/packages/angular/cli/src/command-builder/command-module.ts b/packages/angular/cli/src/command-builder/command-module.ts index 35e0d4f8201d..ae0eb82f0cb5 100644 --- a/packages/angular/cli/src/command-builder/command-module.ts +++ b/packages/angular/cli/src/command-builder/command-module.ts @@ -7,6 +7,8 @@ */ import { schema } from '@angular-devkit/core'; +import { readFileSync } from 'node:fs'; +import { join, posix, relative } from 'node:path'; import type { ArgumentsCamelCase, Argv, CommandModule as YargsCommandModule } from 'yargs'; import { Parser as yargsParser } from 'yargs/helpers'; import { getAnalyticsUserId } from '../analytics/analytics'; @@ -18,7 +20,6 @@ import { AngularWorkspace } from '../utilities/config'; import { memoize } from '../utilities/memoize'; import { CommandContext, CommandScope, Options, OtherOptions } from './definitions'; import { Option, addSchemaOptionsToCommand } from './utilities/json-schema'; -import '../utilities/markdown-loader'; export { CommandScope }; export type { CommandContext, Options, OtherOptions }; @@ -30,11 +31,8 @@ export interface CommandModuleImplementation extends Omit< /** Scope in which the command can be executed in. */ scope: CommandScope; - /** Long description for the command in JSON help text. */ - longDescription?: string; - - /** Relative path to the long description file for the command in JSON help text. */ - longDescriptionRelativePath?: string; + /** Path used to load the long description for the command in JSON help text. */ + longDescriptionPath?: string; /** Object declaring the options the command accepts, or a function accepting and returning a yargs instance. */ builder(argv: Argv): Promise> | Argv; @@ -52,8 +50,7 @@ export interface FullDescribe { export abstract class CommandModule implements CommandModuleImplementation { abstract readonly command: string; abstract readonly describe: string | false; - readonly longDescription?: string; - readonly longDescriptionRelativePath?: string; + abstract readonly longDescriptionPath?: string; protected readonly shouldReportAnalytics: boolean = true; readonly scope: CommandScope = CommandScope.Both; @@ -71,22 +68,23 @@ export abstract class CommandModule implements CommandModuleI * `false` will result in a hidden command. */ public get fullDescribe(): FullDescribe | false { - if (this.describe === false) { - return false; - } - - const description: FullDescribe = { - describe: this.describe, - }; - - if (this.longDescription) { - description.longDescription = this.longDescription.replace(/\r\n/g, '\n'); - description.longDescriptionRelativePath = - this.longDescriptionRelativePath ?? - `@angular/cli/src/commands/${this.commandName}/long-description.md`; - } - - return description; + return this.describe === false + ? false + : { + describe: this.describe, + ...(this.longDescriptionPath + ? { + longDescriptionRelativePath: relative( + join(__dirname, '../../../../'), + this.longDescriptionPath, + ).replace(/\\/g, posix.sep), + longDescription: readFileSync(this.longDescriptionPath, 'utf8').replace( + /\r\n/g, + '\n', + ), + } + : {}), + }; } protected get commandName(): string { diff --git a/packages/angular/cli/src/commands/add/cli.ts b/packages/angular/cli/src/commands/add/cli.ts index fb352f70edfd..bc95f33ff8e7 100644 --- a/packages/angular/cli/src/commands/add/cli.ts +++ b/packages/angular/cli/src/commands/add/cli.ts @@ -29,9 +29,6 @@ import { NgAddSaveDependency, PackageManifest, PackageMetadata } from '../../pac import { assertIsError } from '../../utilities/error'; import { isTTY } from '../../utilities/tty'; import { VERSION } from '../../utilities/version'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; class CommandError extends Error {} @@ -103,7 +100,7 @@ export default class AddCommandModule { command = 'add '; describe = 'Adds support for an external library to your project.'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); protected override allowPrivateSchematics = true; private readonly schematicName = 'ng-add'; private rootRequire = createRequire(this.context.root + '/'); diff --git a/packages/angular/cli/src/commands/analytics/cli.ts b/packages/angular/cli/src/commands/analytics/cli.ts index 9639cbab50e6..da56a2a00460 100644 --- a/packages/angular/cli/src/commands/analytics/cli.ts +++ b/packages/angular/cli/src/commands/analytics/cli.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.dev/license */ +import { join } from 'node:path'; import { Argv } from 'yargs'; import { CommandModule, @@ -17,9 +18,6 @@ import { demandCommandFailureMessage, } from '../../command-builder/utilities/command'; import { AnalyticsInfoCommandModule } from './info/cli'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; import { AnalyticsDisableModule, AnalyticsEnableModule, @@ -32,7 +30,7 @@ export default class AnalyticsCommandModule { command = 'analytics'; describe = 'Configures the gathering of Angular CLI usage metrics.'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); builder(localYargs: Argv): Argv { const subcommands = [ diff --git a/packages/angular/cli/src/commands/analytics/info/cli.ts b/packages/angular/cli/src/commands/analytics/info/cli.ts index 93b34fd06716..e4434d35baee 100644 --- a/packages/angular/cli/src/commands/analytics/info/cli.ts +++ b/packages/angular/cli/src/commands/analytics/info/cli.ts @@ -20,6 +20,7 @@ export class AnalyticsInfoCommandModule { command = 'info'; describe = 'Prints analytics gathering and reporting configuration in the console.'; + longDescriptionPath?: string; builder(localYargs: Argv): Argv { return localYargs.strict(); diff --git a/packages/angular/cli/src/commands/analytics/settings/cli.ts b/packages/angular/cli/src/commands/analytics/settings/cli.ts index 24105de2b060..16f07b353d1a 100644 --- a/packages/angular/cli/src/commands/analytics/settings/cli.ts +++ b/packages/angular/cli/src/commands/analytics/settings/cli.ts @@ -26,6 +26,8 @@ abstract class AnalyticsSettingModule extends CommandModule implements CommandModuleImplementation { + longDescriptionPath?: string; + builder(localYargs: Argv): Argv { return localYargs .option('global', { diff --git a/packages/angular/cli/src/commands/build/cli.ts b/packages/angular/cli/src/commands/build/cli.ts index 031e31b5140f..365420ca3734 100644 --- a/packages/angular/cli/src/commands/build/cli.ts +++ b/packages/angular/cli/src/commands/build/cli.ts @@ -6,12 +6,10 @@ * found in the LICENSE file at https://angular.dev/license */ +import { join } from 'node:path'; import { ArchitectCommandModule } from '../../command-builder/architect-command-module'; import { CommandModuleImplementation } from '../../command-builder/command-module'; import { RootCommands } from '../command-config'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; export default class BuildCommandModule extends ArchitectCommandModule @@ -22,5 +20,5 @@ export default class BuildCommandModule aliases = RootCommands['build'].aliases; describe = 'Compiles an Angular application or library into an output directory named dist/ at the given output path.'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); } diff --git a/packages/angular/cli/src/commands/cache/clean/cli.ts b/packages/angular/cli/src/commands/cache/clean/cli.ts index 492699271b54..a115b686b7e0 100644 --- a/packages/angular/cli/src/commands/cache/clean/cli.ts +++ b/packages/angular/cli/src/commands/cache/clean/cli.ts @@ -18,6 +18,7 @@ import { getCacheConfig } from '../utilities'; export class CacheCleanModule extends CommandModule implements CommandModuleImplementation { command = 'clean'; describe = 'Deletes persistent disk cache from disk.'; + longDescriptionPath: string | undefined; override scope = CommandScope.In; builder(localYargs: Argv): Argv { diff --git a/packages/angular/cli/src/commands/cache/cli.ts b/packages/angular/cli/src/commands/cache/cli.ts index 25140041ae0e..dad144b034b3 100644 --- a/packages/angular/cli/src/commands/cache/cli.ts +++ b/packages/angular/cli/src/commands/cache/cli.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.dev/license */ +import { join } from 'node:path'; import { Argv } from 'yargs'; import { CommandModule, @@ -19,9 +20,6 @@ import { } from '../../command-builder/utilities/command'; import { CacheCleanModule } from './clean/cli'; import { CacheInfoCommandModule } from './info/cli'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; import { CacheDisableModule, CacheEnableModule } from './settings/cli'; export default class CacheCommandModule @@ -30,7 +28,7 @@ export default class CacheCommandModule { command = 'cache'; describe = 'Configure persistent disk cache and retrieve cache statistics.'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); override scope = CommandScope.In; builder(localYargs: Argv): Argv { diff --git a/packages/angular/cli/src/commands/cache/info/cli.ts b/packages/angular/cli/src/commands/cache/info/cli.ts index 6fd2df0414c7..f4278d52db74 100644 --- a/packages/angular/cli/src/commands/cache/info/cli.ts +++ b/packages/angular/cli/src/commands/cache/info/cli.ts @@ -21,6 +21,7 @@ import { getCacheConfig } from '../utilities'; export class CacheInfoCommandModule extends CommandModule implements CommandModuleImplementation { command = 'info'; describe = 'Prints persistent disk cache configuration and statistics in the console.'; + longDescriptionPath?: string | undefined; override scope = CommandScope.In; builder(localYargs: Argv): Argv { diff --git a/packages/angular/cli/src/commands/cache/settings/cli.ts b/packages/angular/cli/src/commands/cache/settings/cli.ts index 5de2d5496475..9a4f654f7ac7 100644 --- a/packages/angular/cli/src/commands/cache/settings/cli.ts +++ b/packages/angular/cli/src/commands/cache/settings/cli.ts @@ -18,6 +18,7 @@ export class CacheDisableModule extends CommandModule implements CommandModuleIm command = 'disable'; aliases = 'off'; describe = 'Disables persistent disk cache for all projects in the workspace.'; + longDescriptionPath: string | undefined; override scope = CommandScope.In; builder(localYargs: Argv): Argv { @@ -33,6 +34,7 @@ export class CacheEnableModule extends CommandModule implements CommandModuleImp command = 'enable'; aliases = 'on'; describe = 'Enables disk cache for all projects in the workspace.'; + longDescriptionPath: string | undefined; override scope = CommandScope.In; builder(localYargs: Argv): Argv { diff --git a/packages/angular/cli/src/commands/completion/cli.ts b/packages/angular/cli/src/commands/completion/cli.ts index ab81ce5636d8..3fc9dccdc703 100644 --- a/packages/angular/cli/src/commands/completion/cli.ts +++ b/packages/angular/cli/src/commands/completion/cli.ts @@ -6,15 +6,13 @@ * found in the LICENSE file at https://angular.dev/license */ +import { join } from 'node:path'; import { Argv } from 'yargs'; import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module'; import { addCommandModuleToYargs } from '../../command-builder/utilities/command'; import { colors } from '../../utilities/color'; import { hasGlobalCliInstall, initializeAutocomplete } from '../../utilities/completion'; import { assertIsError } from '../../utilities/error'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; export default class CompletionCommandModule extends CommandModule @@ -22,7 +20,7 @@ export default class CompletionCommandModule { command = 'completion'; describe = 'Set up Angular CLI autocompletion for your terminal.'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); builder(localYargs: Argv): Argv { addCommandModuleToYargs(CompletionScriptCommandModule, this.context); @@ -66,6 +64,7 @@ Appended \`source <(ng completion script)\` to \`${rcFile}\`. Restart your termi class CompletionScriptCommandModule extends CommandModule implements CommandModuleImplementation { command = 'script'; describe = 'Generate a bash and zsh real-time type-ahead autocompletion script.'; + longDescriptionPath = undefined; builder(localYargs: Argv): Argv { return localYargs; diff --git a/packages/angular/cli/src/commands/config/cli.ts b/packages/angular/cli/src/commands/config/cli.ts index f339fd9bb1ba..06b253b9a42d 100644 --- a/packages/angular/cli/src/commands/config/cli.ts +++ b/packages/angular/cli/src/commands/config/cli.ts @@ -8,6 +8,7 @@ import { JsonValue } from '@angular-devkit/core'; import { randomUUID } from 'node:crypto'; +import { join } from 'node:path'; import { Argv } from 'yargs'; import { CommandModule, @@ -17,9 +18,6 @@ import { } from '../../command-builder/command-module'; import { getWorkspaceRaw, validateWorkspace } from '../../utilities/config'; import { JSONFile, parseJson } from '../../utilities/json-file'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; interface ConfigCommandArgs { 'json-path'?: string; @@ -34,7 +32,7 @@ export default class ConfigCommandModule command = 'config [json-path] [value]'; describe = 'Retrieves or sets Angular configuration values in the angular.json file for the workspace.'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); builder(localYargs: Argv): Argv { return localYargs diff --git a/packages/angular/cli/src/commands/deploy/cli.ts b/packages/angular/cli/src/commands/deploy/cli.ts index 28317cff1ee1..947dc90af2d4 100644 --- a/packages/angular/cli/src/commands/deploy/cli.ts +++ b/packages/angular/cli/src/commands/deploy/cli.ts @@ -6,12 +6,10 @@ * found in the LICENSE file at https://angular.dev/license */ +import { join } from 'node:path'; import { MissingTargetChoice } from '../../command-builder/architect-base-command-module'; import { ArchitectCommandModule } from '../../command-builder/architect-command-module'; import { CommandModuleImplementation } from '../../command-builder/command-module'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; export default class DeployCommandModule extends ArchitectCommandModule @@ -39,7 +37,7 @@ export default class DeployCommandModule multiTarget = false; command = 'deploy [project]'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); describe = 'Invokes the deploy builder for a specified project or for the default project in the workspace.'; } diff --git a/packages/angular/cli/src/commands/e2e/cli.ts b/packages/angular/cli/src/commands/e2e/cli.ts index 9d63a8d96fb4..85d9aab173a0 100644 --- a/packages/angular/cli/src/commands/e2e/cli.ts +++ b/packages/angular/cli/src/commands/e2e/cli.ts @@ -42,4 +42,5 @@ export default class E2eCommandModule command = 'e2e [project]'; aliases = RootCommands['e2e'].aliases; describe = 'Builds and serves an Angular application, then runs end-to-end tests.'; + longDescriptionPath?: string; } diff --git a/packages/angular/cli/src/commands/extract-i18n/cli.ts b/packages/angular/cli/src/commands/extract-i18n/cli.ts index 09b3df343403..4f3dea2d8e7e 100644 --- a/packages/angular/cli/src/commands/extract-i18n/cli.ts +++ b/packages/angular/cli/src/commands/extract-i18n/cli.ts @@ -19,6 +19,7 @@ export default class ExtractI18nCommandModule multiTarget = false; command = 'extract-i18n [project]'; describe = 'Extracts i18n messages from source code.'; + longDescriptionPath?: string | undefined; override async findDefaultBuilderName( project: workspaces.ProjectDefinition, diff --git a/packages/angular/cli/src/commands/generate/cli.ts b/packages/angular/cli/src/commands/generate/cli.ts index 8f605e03a18b..4be29c3eaea0 100644 --- a/packages/angular/cli/src/commands/generate/cli.ts +++ b/packages/angular/cli/src/commands/generate/cli.ts @@ -38,6 +38,7 @@ export default class GenerateCommandModule command = 'generate'; aliases = RootCommands['generate'].aliases; describe = 'Generates and/or modifies files based on a schematic.'; + longDescriptionPath?: string | undefined; override async builder(argv: Argv): Promise> { let localYargs = (await super.builder(argv)).command({ diff --git a/packages/angular/cli/src/commands/lint/cli.ts b/packages/angular/cli/src/commands/lint/cli.ts index 3fdd38fc169c..9510dd7afe53 100644 --- a/packages/angular/cli/src/commands/lint/cli.ts +++ b/packages/angular/cli/src/commands/lint/cli.ts @@ -6,12 +6,10 @@ * found in the LICENSE file at https://angular.dev/license */ +import { join } from 'node:path'; import { MissingTargetChoice } from '../../command-builder/architect-base-command-module'; import { ArchitectCommandModule } from '../../command-builder/architect-command-module'; import { CommandModuleImplementation } from '../../command-builder/command-module'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; export default class LintCommandModule extends ArchitectCommandModule @@ -26,6 +24,6 @@ export default class LintCommandModule multiTarget = true; command = 'lint [project]'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); describe = 'Runs linting tools on Angular application code in a given project folder.'; } diff --git a/packages/angular/cli/src/commands/make-this-awesome/cli.ts b/packages/angular/cli/src/commands/make-this-awesome/cli.ts index 8e36447f1f3a..6a17c5614b94 100644 --- a/packages/angular/cli/src/commands/make-this-awesome/cli.ts +++ b/packages/angular/cli/src/commands/make-this-awesome/cli.ts @@ -17,6 +17,7 @@ export default class AwesomeCommandModule command = 'make-this-awesome'; describe = false as const; deprecated = false; + longDescriptionPath?: string | undefined; builder(localYargs: Argv): Argv { return localYargs; diff --git a/packages/angular/cli/src/commands/mcp/cli.ts b/packages/angular/cli/src/commands/mcp/cli.ts index cbc94499a9ca..a379022e8f5e 100644 --- a/packages/angular/cli/src/commands/mcp/cli.ts +++ b/packages/angular/cli/src/commands/mcp/cli.ts @@ -35,6 +35,7 @@ For more information and documentation, visit: https://angular.dev/ai/mcp export default class McpCommandModule extends CommandModule implements CommandModuleImplementation { command = 'mcp'; describe = false as const; + longDescriptionPath = undefined; builder(localYargs: Argv): Argv { return localYargs diff --git a/packages/angular/cli/src/commands/new/cli.ts b/packages/angular/cli/src/commands/new/cli.ts index c47f3c63153b..6e6545e66421 100644 --- a/packages/angular/cli/src/commands/new/cli.ts +++ b/packages/angular/cli/src/commands/new/cli.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.dev/license */ +import { join } from 'node:path'; import { Argv } from 'yargs'; import { CommandModuleImplementation, @@ -20,9 +21,6 @@ import { } from '../../command-builder/schematics-command-module'; import { VERSION } from '../../utilities/version'; import { RootCommands } from '../command-config'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; interface NewCommandArgs extends SchematicsCommandArgs { collection?: string; @@ -39,7 +37,7 @@ export default class NewCommandModule command = 'new [name]'; aliases = RootCommands['new'].aliases; describe = 'Creates a new Angular workspace.'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); override async builder(argv: Argv): Promise> { const localYargs = (await super.builder(argv)).option('collection', { diff --git a/packages/angular/cli/src/commands/run/cli.ts b/packages/angular/cli/src/commands/run/cli.ts index 774f811aa2a5..aa12cd0158f7 100644 --- a/packages/angular/cli/src/commands/run/cli.ts +++ b/packages/angular/cli/src/commands/run/cli.ts @@ -7,6 +7,7 @@ */ import { Target } from '@angular-devkit/architect'; +import { join } from 'node:path'; import { Argv } from 'yargs'; import { ArchitectBaseCommandModule } from '../../command-builder/architect-base-command-module'; import { @@ -16,9 +17,6 @@ import { Options, OtherOptions, } from '../../command-builder/command-module'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; export interface RunCommandArgs { target: string; @@ -33,7 +31,7 @@ export default class RunCommandModule command = 'run '; describe = 'Runs an Architect target with an optional custom builder configuration defined in your project.'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); async builder(argv: Argv): Promise> { const { jsonHelp, getYargsCompletions, help } = this.context.args.options; diff --git a/packages/angular/cli/src/commands/serve/cli.ts b/packages/angular/cli/src/commands/serve/cli.ts index 6448c48b9484..3b38fa122acd 100644 --- a/packages/angular/cli/src/commands/serve/cli.ts +++ b/packages/angular/cli/src/commands/serve/cli.ts @@ -18,4 +18,5 @@ export default class ServeCommandModule command = 'serve [project]'; aliases = RootCommands['serve'].aliases; describe = 'Builds and serves your application, rebuilding on file changes.'; + longDescriptionPath?: string | undefined; } diff --git a/packages/angular/cli/src/commands/test/cli.ts b/packages/angular/cli/src/commands/test/cli.ts index f9dcaaf92c8c..600e9f41f517 100644 --- a/packages/angular/cli/src/commands/test/cli.ts +++ b/packages/angular/cli/src/commands/test/cli.ts @@ -6,12 +6,10 @@ * found in the LICENSE file at https://angular.dev/license */ +import { join } from 'node:path'; import { ArchitectCommandModule } from '../../command-builder/architect-command-module'; import { CommandModuleImplementation } from '../../command-builder/command-module'; import { RootCommands } from '../command-config'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; export default class TestCommandModule extends ArchitectCommandModule @@ -21,5 +19,5 @@ export default class TestCommandModule command = 'test [project]'; aliases = RootCommands['test'].aliases; describe = 'Runs unit tests in a project.'; - override longDescription = longDescription; + longDescriptionPath = join(__dirname, 'long-description.md'); } diff --git a/packages/angular/cli/src/commands/update/cli.ts b/packages/angular/cli/src/commands/update/cli.ts index 6418bfc13ce4..005df998b501 100644 --- a/packages/angular/cli/src/commands/update/cli.ts +++ b/packages/angular/cli/src/commands/update/cli.ts @@ -24,9 +24,6 @@ import type { InstalledPackage, PackageManager, PackageManifest } from '../../pa import { colors } from '../../utilities/color'; import { disableVersionCheck } from '../../utilities/environment-options'; import { assertIsError } from '../../utilities/error'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore strict-deps: Markdown files are asset dependencies bundled/loaded at runtime -import longDescription from './long-description.md'; import { UpdatePlan, applyUpdatePlan, @@ -66,7 +63,7 @@ export default class UpdateCommandModule extends CommandModule { return localYargs diff --git a/packages/angular/cli/src/commands/version/cli.ts b/packages/angular/cli/src/commands/version/cli.ts index 1a79b8b76eef..205f0bc7e55e 100644 --- a/packages/angular/cli/src/commands/version/cli.ts +++ b/packages/angular/cli/src/commands/version/cli.ts @@ -37,6 +37,7 @@ export default class VersionCommandModule command = 'version'; aliases = RootCommands['version'].aliases; describe = 'Outputs Angular CLI version.'; + longDescriptionPath?: string | undefined; /** * Builds the command-line options for the `ng version` command. diff --git a/packages/angular/cli/src/typings.d.ts b/packages/angular/cli/src/typings.d.ts deleted file mode 100644 index 12e7de03c204..000000000000 --- a/packages/angular/cli/src/typings.d.ts +++ /dev/null @@ -1,12 +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.dev/license - */ - -declare module '*/long-description.md' { - const content: string; - export default content; -} diff --git a/packages/angular/cli/src/utilities/markdown-loader.ts b/packages/angular/cli/src/utilities/markdown-loader.ts deleted file mode 100644 index 3a70a5eaae1c..000000000000 --- a/packages/angular/cli/src/utilities/markdown-loader.ts +++ /dev/null @@ -1,35 +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.dev/license - */ - -import { readFileSync } from 'node:fs'; - -const LONG_DESCRIPTION_REGEXP = /[/\\]long-description\.md$/; - -function isCommandLongDescription(filePath: string | undefined): boolean { - return !!filePath && LONG_DESCRIPTION_REGEXP.test(filePath); -} - -// Register markdown extension hook for CommonJS execution -if (typeof require !== 'undefined' && require.extensions) { - const originalMdExtension = require.extensions['.md']; - require.extensions['.md'] = (module, filename) => { - if (isCommandLongDescription(filename)) { - module.exports = readFileSync(filename, 'utf8'); - - return; - } - - if (originalMdExtension) { - originalMdExtension(module, filename); - } else { - const err = new Error(`Cannot find module '${filename}'`); - (err as NodeJS.ErrnoException).code = 'MODULE_NOT_FOUND'; - throw err; - } - }; -}