77 */
88
99import { schema } from '@angular-devkit/core' ;
10+ import { readFileSync } from 'node:fs' ;
11+ import { join , posix , relative } from 'node:path' ;
1012import type { ArgumentsCamelCase , Argv , CommandModule as YargsCommandModule } from 'yargs' ;
1113import { Parser as yargsParser } from 'yargs/helpers' ;
1214import { getAnalyticsUserId } from '../analytics/analytics' ;
@@ -18,7 +20,6 @@ import { AngularWorkspace } from '../utilities/config';
1820import { memoize } from '../utilities/memoize' ;
1921import { CommandContext , CommandScope , Options , OtherOptions } from './definitions' ;
2022import { Option , addSchemaOptionsToCommand } from './utilities/json-schema' ;
21- import '../utilities/markdown-loader' ;
2223
2324export { CommandScope } ;
2425export type { CommandContext , Options , OtherOptions } ;
@@ -30,11 +31,8 @@ export interface CommandModuleImplementation<T extends {} = {}> extends Omit<
3031 /** Scope in which the command can be executed in. */
3132 scope : CommandScope ;
3233
33- /** Long description for the command in JSON help text. */
34- longDescription ?: string ;
35-
36- /** Relative path to the long description file for the command in JSON help text. */
37- longDescriptionRelativePath ?: string ;
34+ /** Path used to load the long description for the command in JSON help text. */
35+ longDescriptionPath ?: string ;
3836
3937 /** Object declaring the options the command accepts, or a function accepting and returning a yargs instance. */
4038 builder ( argv : Argv ) : Promise < Argv < T > > | Argv < T > ;
@@ -52,8 +50,7 @@ export interface FullDescribe {
5250export abstract class CommandModule < T extends { } = { } > implements CommandModuleImplementation < T > {
5351 abstract readonly command : string ;
5452 abstract readonly describe : string | false ;
55- readonly longDescription ?: string ;
56- readonly longDescriptionRelativePath ?: string ;
53+ abstract readonly longDescriptionPath ?: string ;
5754 protected readonly shouldReportAnalytics : boolean = true ;
5855 readonly scope : CommandScope = CommandScope . Both ;
5956
@@ -71,22 +68,23 @@ export abstract class CommandModule<T extends {} = {}> implements CommandModuleI
7168 * `false` will result in a hidden command.
7269 */
7370 public get fullDescribe ( ) : FullDescribe | false {
74- if ( this . describe === false ) {
75- return false ;
76- }
77-
78- const description : FullDescribe = {
79- describe : this . describe ,
80- } ;
81-
82- if ( this . longDescription ) {
83- description . longDescription = this . longDescription . replace ( / \r \n / g, '\n' ) ;
84- description . longDescriptionRelativePath =
85- this . longDescriptionRelativePath ??
86- `@angular/cli/src/commands/${ this . commandName } /long-description.md` ;
87- }
88-
89- return description ;
71+ return this . describe === false
72+ ? false
73+ : {
74+ describe : this . describe ,
75+ ...( this . longDescriptionPath
76+ ? {
77+ longDescriptionRelativePath : relative (
78+ join ( __dirname , '../../../../' ) ,
79+ this . longDescriptionPath ,
80+ ) . replace ( / \\ / g, posix . sep ) ,
81+ longDescription : readFileSync ( this . longDescriptionPath , 'utf8' ) . replace (
82+ / \r \n / g,
83+ '\n' ,
84+ ) ,
85+ }
86+ : { } ) ,
87+ } ;
9088 }
9189
9290 protected get commandName ( ) : string {
0 commit comments