66 */
77
88import * as mkdirp from 'mkdirp' ;
9- import { Plugin } from '@oclif/config' ;
109import {
1110 asString ,
1211 Dictionary ,
@@ -23,7 +22,7 @@ import { CLIReference } from './ditamap/cli-reference';
2322import { Command } from './ditamap/command' ;
2423import { TopicCommands } from './ditamap/topic-commands' ;
2524import { TopicDitamap } from './ditamap/topic-ditamap' ;
26- import { events , punctuate } from './utils' ;
25+ import { CommandClass , events , punctuate } from './utils' ;
2726import { HelpReference } from './ditamap/help-reference' ;
2827
2928function emitNoTopicMetadataWarning ( topic : string ) : void {
@@ -44,14 +43,14 @@ export class Docs {
4443 private cliMeta : JsonMap
4544 ) { }
4645
47- public async build ( commands : JsonMap [ ] ) : Promise < void > {
46+ public async build ( commands : CommandClass [ ] ) : Promise < void > {
4847 // Create if doesn't exist
4948 await mkdirp ( this . outputDir ) ;
5049
5150 await this . populateTemplate ( commands ) ;
5251 }
5352
54- public async populateTopic ( topic : string , subtopics : Dictionary < Dictionary | Dictionary [ ] > ) : Promise < any [ ] > {
53+ public async populateTopic ( topic : string , subtopics : Dictionary < CommandClass | CommandClass [ ] > ) : Promise < any [ ] > {
5554 const topicMeta = ensureJsonMap (
5655 this . topicMeta [ topic ] ,
5756 `No topic meta for ${ topic } - add this topic to the oclif section of the package.json.`
@@ -127,8 +126,8 @@ export class Docs {
127126 * @param commands - The entire set of command data.
128127 * @returns The commands grouped by topics/subtopic/commands.
129128 */
130- private groupTopicsAndSubtopics ( commands : JsonMap [ ] ) {
131- const topLevelTopics : Dictionary < Dictionary < Dictionary | Dictionary [ ] > > = { } ;
129+ private groupTopicsAndSubtopics ( commands : CommandClass [ ] ) : Dictionary < Dictionary < CommandClass | CommandClass [ ] > > {
130+ const topLevelTopics : Dictionary < Dictionary < CommandClass | CommandClass [ ] > > = { } ;
132131
133132 for ( const command of commands ) {
134133 if ( command . hidden && ! this . hidden ) {
@@ -137,7 +136,7 @@ export class Docs {
137136 const commandParts = ensureString ( command . id ) . split ( ':' ) ;
138137 const topLevelTopic = commandParts [ 0 ] ;
139138
140- const plugin = command . plugin as unknown as Plugin ;
139+ const plugin = command . plugin ;
141140 if ( this . plugins [ plugin . name ] ) {
142141 // Also include the namespace on the commands so we don't need to do the split at other times in the code.
143142 command . topic = topLevelTopic ;
@@ -179,7 +178,7 @@ export class Docs {
179178 return topLevelTopics ;
180179 }
181180
182- private async populateTemplate ( commands : JsonMap [ ] ) {
181+ private async populateTemplate ( commands : CommandClass [ ] ) {
183182 const topicsAndSubtopics = this . groupTopicsAndSubtopics ( commands ) ;
184183
185184 await new CLIReference ( ) . write ( ) ;
@@ -234,7 +233,7 @@ export class Docs {
234233 return commandMeta ;
235234 }
236235
237- private async populateCommand ( topic : string , subtopic : string , command : Dictionary , commandMeta : JsonMap ) {
236+ private async populateCommand ( topic : string , subtopic : string , command : CommandClass , commandMeta : JsonMap ) {
238237 // If it is a hidden command - abort
239238 if ( command . hidden && ! this . hidden ) {
240239 return '' ;
0 commit comments