@salesforce/plugin-command-reference 2.4.5 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +33 -17
  2. package/lib/commands/commandreference/generate.d.ts +14 -7
  3. package/lib/commands/commandreference/generate.js +105 -52
  4. package/lib/commands/commandreference/generate.js.map +1 -1
  5. package/lib/commands/jit/install.js +4 -7
  6. package/lib/commands/jit/install.js.map +1 -1
  7. package/lib/ditamap/base-ditamap.js +1 -0
  8. package/lib/ditamap/base-ditamap.js.map +1 -1
  9. package/lib/ditamap/cli-reference.js +1 -0
  10. package/lib/ditamap/cli-reference.js.map +1 -1
  11. package/lib/ditamap/command.d.ts +8 -5
  12. package/lib/ditamap/command.js +50 -53
  13. package/lib/ditamap/command.js.map +1 -1
  14. package/lib/ditamap/ditamap.d.ts +8 -8
  15. package/lib/ditamap/ditamap.js +10 -10
  16. package/lib/ditamap/ditamap.js.map +1 -1
  17. package/lib/ditamap/help-reference.js +1 -0
  18. package/lib/ditamap/help-reference.js.map +1 -1
  19. package/lib/ditamap/topic-commands.d.ts +2 -2
  20. package/lib/ditamap/topic-commands.js +1 -0
  21. package/lib/ditamap/topic-commands.js.map +1 -1
  22. package/lib/ditamap/topic-ditamap.js +1 -0
  23. package/lib/ditamap/topic-ditamap.js.map +1 -1
  24. package/lib/docs.d.ts +4 -5
  25. package/lib/docs.js +53 -65
  26. package/lib/docs.js.map +1 -1
  27. package/lib/utils.d.ts +81 -7
  28. package/lib/utils.js +4 -19
  29. package/lib/utils.js.map +1 -1
  30. package/messages/main.md +53 -0
  31. package/oclif.manifest.json +33 -13
  32. package/package.json +142 -42
  33. package/lib/ditamap/cli-reference-topic.d.ts +0 -5
  34. package/lib/ditamap/cli-reference-topic.js +0 -28
  35. package/lib/ditamap/cli-reference-topic.js.map +0 -1
  36. package/lib/ditamap/main-topic-intro.d.ts +0 -6
  37. package/lib/ditamap/main-topic-intro.js +0 -43
  38. package/lib/ditamap/main-topic-intro.js.map +0 -1
  39. package/messages/main.json +0 -9
  40. package/templates/cli_reference_topic.hbs +0 -25
  41. package/templates/main_topic_intro.hbs +0 -44
@@ -9,14 +9,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Command = void 0;
10
10
  const path_1 = require("path");
11
11
  const ts_types_1 = require("@salesforce/ts-types");
12
- const ejs = require("ejs");
13
12
  const utils_1 = require("../utils");
14
13
  const ditamap_1 = require("./ditamap");
15
14
  const getDefault = async (flag) => {
16
- if (typeof flag.default !== 'function') {
17
- return flag.default;
15
+ if (!flag) {
16
+ return '';
18
17
  }
19
- else if (typeof flag.default === 'function') {
18
+ if (typeof flag.default === 'function') {
20
19
  try {
21
20
  const help = await flag.default();
22
21
  return help || '';
@@ -26,92 +25,90 @@ const getDefault = async (flag) => {
26
25
  }
27
26
  }
28
27
  else {
29
- return '';
28
+ return flag.default;
30
29
  }
31
30
  };
32
31
  class Command extends ditamap_1.Ditamap {
33
32
  constructor(topic, subtopic, command, commandMeta = {}) {
34
33
  const commandWithUnderscores = (0, ts_types_1.ensureString)(command.id).replace(/:/g, '_');
35
34
  const filename = ditamap_1.Ditamap.file(`cli_reference_${commandWithUnderscores}`, 'xml');
36
- super(filename, {});
37
- for (const flag of Object.keys(command.flags)) {
38
- if (command.flags[flag].summary) {
39
- command.flags[flag].summary = ejs.render(command.flags[flag].summary, {
40
- command,
41
- config: { bin: commandMeta.binary },
42
- });
43
- }
44
- if (command.flags[flag].description) {
45
- command.flags[flag].description = ejs.render(command.flags[flag].description, {
46
- command,
47
- config: { bin: commandMeta.binary },
48
- });
49
- }
50
- }
35
+ super(filename, undefined);
51
36
  this.flags = (0, ts_types_1.ensureObject)(command.flags);
52
- const summary = (0, utils_1.punctuate)((0, ts_types_1.asString)(ejs.render(command.summary || '', { command, config: { bin: commandMeta.binary } })));
53
- const description = (0, ts_types_1.asString)(ejs.render(command.description || '', { command, config: { bin: commandMeta.binary } }));
37
+ this.commandMeta = commandMeta;
38
+ const summary = (0, utils_1.punctuate)(command.summary);
39
+ this.commandName = command.id.replace(/:/g, (0, ts_types_1.asString)(this.commandMeta.topicSeparator, ':'));
40
+ const description = command.description
41
+ ? (0, utils_1.replaceConfigVariables)(command.description, (0, ts_types_1.asString)(this.commandMeta.binary, 'unknown'), this.commandName)
42
+ : undefined;
54
43
  // Help are all the lines after the first line in the description. Before oclif, there was a 'help' property so continue to
55
44
  // support that.
56
45
  const help = this.formatParagraphs(description);
57
46
  let trailblazerCommunityUrl;
58
47
  let trailblazerCommunityName;
59
- if (commandMeta.trailblazerCommunityLink) {
60
- const community = (0, ts_types_1.ensureJsonMap)(commandMeta.trailblazerCommunityLink);
61
- trailblazerCommunityUrl = community.url;
62
- trailblazerCommunityName = community.name;
48
+ if (this.commandMeta.trailblazerCommunityLink) {
49
+ const community = this.commandMeta.trailblazerCommunityLink;
50
+ trailblazerCommunityUrl = community.url ?? 'unknown';
51
+ trailblazerCommunityName = community.name ?? 'unknown';
63
52
  }
64
- const commandName = (0, ts_types_1.asString)(command.id).replace(/:/g, (0, ts_types_1.asString)(commandMeta.topicSeparator));
65
- const examples = (command.examples || []).map((example) => {
66
- const parts = example.split('\n');
67
- const desc = parts.length > 1 ? parts[0] : null;
68
- const commands = parts.length > 1 ? parts.slice(1) : [parts[0]];
53
+ const examples = (command.examples ?? []).map((example) => {
54
+ let desc;
55
+ let commands;
56
+ if (typeof example === 'string') {
57
+ const parts = example.split('\n');
58
+ desc = parts.length > 1 ? parts[0] : null;
59
+ commands = parts.length > 1 ? parts.slice(1) : [parts[0]];
60
+ }
61
+ else {
62
+ desc = example.description;
63
+ commands = [example.command];
64
+ }
69
65
  return {
70
- description: desc,
71
- commands: commands.map((c) => {
72
- return c
73
- .replace(/<%= config.bin %>/g, (0, ts_types_1.asString)(commandMeta.binary))
74
- .replace(/<%= command.id %>/g, commandName);
75
- }),
66
+ description: (0, utils_1.replaceConfigVariables)(desc ?? '', (0, ts_types_1.asString)(this.commandMeta.binary, 'unknown'), this.commandName),
67
+ commands: commands.map((cmd) => (0, utils_1.replaceConfigVariables)(cmd, (0, ts_types_1.asString)(this.commandMeta.binary, 'unknown'), this.commandName)),
76
68
  };
77
69
  });
78
- const state = command.state || commandMeta.state;
79
- this.data = Object.assign(command, {
80
- name: commandName,
81
- binary: commandMeta.binary,
82
- topicSeparator: commandMeta.topicSeparator,
83
- commandWithUnderscores,
84
- examples,
70
+ const state = command.state ?? this.commandMeta.state;
71
+ const commandData = {
72
+ name: this.commandName,
85
73
  summary,
86
74
  description,
75
+ binary: 'binary' in commandMeta && typeof commandMeta.binary === 'string' ? commandMeta.binary : 'unknown',
76
+ commandWithUnderscores,
77
+ deprecated: command.deprecated ?? false,
78
+ examples,
87
79
  help,
80
+ isBetaCommand: state === 'beta',
88
81
  isClosedPilotCommand: state === 'closedPilot',
89
82
  isOpenPilotCommand: state === 'openPilot',
90
- isBetaCommand: state === 'beta',
91
- trailblazerCommunityUrl,
92
83
  trailblazerCommunityName,
93
- });
84
+ trailblazerCommunityUrl,
85
+ };
86
+ this.data = Object.assign(command, commandData);
94
87
  this.destination = (0, path_1.join)(ditamap_1.Ditamap.outputDir, topic, filename);
95
88
  }
96
89
  async getParametersForTemplate(flags) {
97
90
  const final = [];
98
91
  for (const [flagName, flag] of Object.entries(flags)) {
99
- if (flag.hidden)
92
+ if (!flag || flag.hidden)
100
93
  continue;
101
- const description = Array.isArray(flag.description) ? flag.description.join('\n') : flag.description || '';
102
- const entireDescription = flag.summary ? `${flag.summary}\n${description}` : description;
94
+ const description = (0, utils_1.replaceConfigVariables)(Array.isArray(flag?.description) ? flag?.description.join('\n') : flag?.description ?? '', (0, ts_types_1.asString)(this.commandMeta.binary, 'unknown'), this.commandName);
95
+ const entireDescription = flag.summary
96
+ ? `${(0, utils_1.replaceConfigVariables)(flag.summary, (0, ts_types_1.asString)(this.commandMeta.binary, 'unknown'), this.commandName)}\n${description}`
97
+ : description;
103
98
  const updated = Object.assign({}, flag, {
104
99
  name: flagName,
105
100
  description: this.formatParagraphs(entireDescription),
106
- optional: !flag.required,
107
- kind: flag.kind || flag.type,
108
- hasValue: flag.type !== 'boolean',
101
+ optional: !flag?.required,
102
+ kind: flag?.kind ?? flag?.type,
103
+ hasValue: flag?.type !== 'boolean',
104
+ // eslint-disable-next-line no-await-in-loop
109
105
  defaultFlagValue: await getDefault(flag),
110
106
  });
111
107
  final.push(updated);
112
108
  }
113
109
  return final;
114
110
  }
111
+ // eslint-disable-next-line class-methods-use-this
115
112
  getTemplateFileName() {
116
113
  return 'command.hbs';
117
114
  }
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/ditamap/command.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAA4B;AAC5B,mDAQ8B;AAC9B,2BAA2B;AAC3B,oCAAmD;AACnD,uCAAoC;AAapC,MAAM,UAAU,GAAG,KAAK,EAAE,IAAqB,EAAmB,EAAE;IAClE,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,EAAE;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC;KACrB;SAAM,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,EAAE;QAC7C,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,OAAO,IAAI,IAAI,EAAE,CAAC;SACnB;QAAC,MAAM;YACN,OAAO,EAAE,CAAC;SACX;KACF;SAAM;QACL,OAAO,EAAE,CAAC;KACX;AACH,CAAC,CAAC;AAEF,MAAa,OAAQ,SAAQ,iBAAO;IAGlC,YAAmB,KAAa,EAAE,QAAgB,EAAE,OAAqB,EAAE,cAAuB,EAAE;QAClG,MAAM,sBAAsB,GAAG,IAAA,uBAAY,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC3E,MAAM,QAAQ,GAAG,iBAAO,CAAC,IAAI,CAA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,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC,kBAAkB,EAAE,CAAC;IACpC,CAAC;CACF;AA3HD,0BA2HC"}
@@ -1,24 +1,23 @@
1
- import { JsonMap } from '@salesforce/ts-types';
1
+ import { DitamapData } from '../utils';
2
2
  export declare abstract class Ditamap {
3
3
  private filename;
4
- protected data: JsonMap;
4
+ protected data: DitamapData;
5
5
  static SUFFIX: string;
6
6
  static templatesDir: string;
7
7
  static outputDir: string;
8
8
  static cliVersion: string;
9
- static plugins: JsonMap;
9
+ static plugins: Record<string, string>;
10
10
  static pluginVersions: Array<{
11
11
  name: string;
12
12
  version: string;
13
13
  }>;
14
+ private static _suffix;
15
+ protected destination: string;
16
+ private readonly source;
17
+ constructor(filename: string, data: DitamapData);
14
18
  static get suffix(): string;
15
19
  static set suffix(suffix: string);
16
20
  static file(name: string, ext: string): string;
17
- private static _suffix;
18
- protected destination: string;
19
- private source;
20
- constructor(filename: string, data: JsonMap);
21
- abstract getTemplateFileName(): string;
22
21
  getFilename(): string;
23
22
  getOutputFilePath(): string;
24
23
  write(): Promise<void>;
@@ -31,4 +30,5 @@ export declare abstract class Ditamap {
31
30
  * @returns {object}
32
31
  */
33
32
  protected transformToDitamap(): Promise<string>;
33
+ abstract getTemplateFileName(): string;
34
34
  }
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Ditamap = void 0;
10
10
  const path_1 = require("path");
11
11
  const fs = require("fs/promises");
12
- const mkdirp = require("mkdirp");
13
12
  const debugCreator = require("debug");
14
13
  const hb = require("handlebars");
15
14
  const debug = debugCreator('commandreference');
@@ -26,14 +25,20 @@ hb.registerHelper('uniqueId', (...strings) => {
26
25
  /*
27
26
  * Returns true if the string should be formatted as code block in docs
28
27
  */
29
- // tslint:disable-next-line: no-any
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
29
  hb.registerHelper('isCodeBlock', function (val, options) {
31
- return val.indexOf('sf') === 0 || val.indexOf('sfdx') === 0 || val.indexOf('$') >= 0 || val.indexOf('>>') >= 0
30
+ return val.startsWith('sf') || val.startsWith('sfdx') || val.includes('$') || val.includes('>>')
32
31
  ? options.fn(this)
33
32
  : options.inverse(this);
34
33
  });
35
34
  hb.registerHelper('nextVersion', (value) => parseInt(value, 2) + 1);
36
35
  class Ditamap {
36
+ constructor(filename, data) {
37
+ this.filename = filename;
38
+ this.data = data;
39
+ this.source = (0, path_1.join)(Ditamap.templatesDir, this.getTemplateFileName());
40
+ this.destination = (0, path_1.join)(Ditamap.outputDir, filename);
41
+ }
37
42
  static get suffix() {
38
43
  return Ditamap._suffix;
39
44
  }
@@ -43,12 +48,6 @@ class Ditamap {
43
48
  static file(name, ext) {
44
49
  return Ditamap.suffix ? `${name}_${Ditamap.suffix}.${ext}` : `${name}.${ext}`;
45
50
  }
46
- constructor(filename, data) {
47
- this.filename = filename;
48
- this.data = data;
49
- this.source = (0, path_1.join)(Ditamap.templatesDir, this.getTemplateFileName());
50
- this.destination = (0, path_1.join)(Ditamap.outputDir, filename);
51
- }
52
51
  getFilename() {
53
52
  return this.filename;
54
53
  }
@@ -56,10 +55,11 @@ class Ditamap {
56
55
  return this.destination;
57
56
  }
58
57
  async write() {
59
- await mkdirp((0, path_1.dirname)(this.destination));
58
+ await fs.mkdir((0, path_1.dirname)(this.destination), { recursive: true });
60
59
  const output = await this.transformToDitamap();
61
60
  await fs.writeFile(this.destination, output);
62
61
  }
62
+ // eslint-disable-next-line class-methods-use-this
63
63
  formatParagraphs(textToFormat) {
64
64
  return textToFormat ? textToFormat.split('\n').filter((n) => n !== '') : [];
65
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ditamap.js","sourceRoot":"","sources":["../../src/ditamap/ditamap.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAAqC;AACrC,kCAAkC;AAClC,iCAAiC;AAEjC,sCAAsC;AACt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AC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,kDAAkD;IACxC,gBAAgB,CAAC,YAAqB;QAC9C,OAAO,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9E,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,kBAAkB;QAChC,KAAK,CAAC,cAAc,IAAI,CAAC,WAAW,SAAS,IAAI,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC3E,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;;AAvEH,0BA0EC;AAzEe,cAAM,GAAG,SAAS,CAAC;AAEnB,oBAAY,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC"}
@@ -16,6 +16,7 @@ class HelpReference extends ditamap_1.Ditamap {
16
16
  id: filename.replace('.xml', ''),
17
17
  });
18
18
  }
19
+ // eslint-disable-next-line class-methods-use-this
19
20
  getTemplateFileName() {
20
21
  return 'cli_reference_help.hbs';
21
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"help-reference.js","sourceRoot":"","sources":["../../src/ditamap/help-reference.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uCAAoC;AAEpC,MAAa,aAAc,SAAQ,iBAAO;IACxC;QACE,sCAAsC;QACtC,MAAM,QAAQ,GAAG,iBAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAC3D,KAAK,CAAC,QAAQ,EAAE;YACd,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACjC,CAAC,CAAC;IACL,CAAC;IAEM,mBAAmB;QACxB,OAAO,wBAAwB,CAAC;IAClC,CAAC;CACF;AAZD,sCAYC"}
1
+ {"version":3,"file":"help-reference.js","sourceRoot":"","sources":["../../src/ditamap/help-reference.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uCAAoC;AAEpC,MAAa,aAAc,SAAQ,iBAAO;IACxC;QACE,sCAAsC;QACtC,MAAM,QAAQ,GAAG,iBAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAC3D,KAAK,CAAC,QAAQ,EAAE;YACd,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACjC,CAAC,CAAC;IACL,CAAC;IAED,kDAAkD;IAC3C,mBAAmB;QACxB,OAAO,wBAAwB,CAAC;IAClC,CAAC;CACF;AAbD,sCAaC"}
@@ -1,6 +1,6 @@
1
- import { JsonMap } from '@salesforce/ts-types';
1
+ import { SfTopic } from '../utils';
2
2
  import { Ditamap } from './ditamap';
3
3
  export declare class TopicCommands extends Ditamap {
4
- constructor(topic: string, topicMeta: JsonMap);
4
+ constructor(topic: string, topicMeta: SfTopic);
5
5
  getTemplateFileName(): string;
6
6
  }
@@ -17,6 +17,7 @@ class TopicCommands extends ditamap_1.Ditamap {
17
17
  // Override destination to include topic and subtopic
18
18
  this.destination = (0, path_1.join)(ditamap_1.Ditamap.outputDir, topic, filename);
19
19
  }
20
+ // eslint-disable-next-line class-methods-use-this
20
21
  getTemplateFileName() {
21
22
  return 'cli_reference_topic_commands.hbs';
22
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"topic-commands.js","sourceRoot":"","sources":["../../src/ditamap/topic-commands.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAA4B;AAE5B,uCAAoC;AAEpC,MAAa,aAAc,SAAQ,iBAAO;IACxC,YAAmB,KAAa,EAAE,SAAkB;QAClD,MAAM,QAAQ,GAAG,iBAAO,CAAC,IAAI,CAAC,iBAAiB,KAAK,WAAW,EAAE,KAAK,CAAC,CAAC;QACxE,sCAAsC;QACtC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE3B,qDAAqD;QACrD,IAAI,CAAC,WAAW,GAAG,IAAA,WAAI,EAAC,iBAAO,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAEM,mBAAmB;QACxB,OAAO,kCAAkC,CAAC;IAC5C,CAAC;CACF;AAbD,sCAaC"}
1
+ {"version":3,"file":"topic-commands.js","sourceRoot":"","sources":["../../src/ditamap/topic-commands.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAA4B;AAE5B,uCAAoC;AAEpC,MAAa,aAAc,SAAQ,iBAAO;IACxC,YAAmB,KAAa,EAAE,SAAkB;QAClD,MAAM,QAAQ,GAAG,iBAAO,CAAC,IAAI,CAAC,iBAAiB,KAAK,WAAW,EAAE,KAAK,CAAC,CAAC;QACxE,sCAAsC;QACtC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE3B,qDAAqD;QACrD,IAAI,CAAC,WAAW,GAAG,IAAA,WAAI,EAAC,iBAAO,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAED,kDAAkD;IAC3C,mBAAmB;QACxB,OAAO,kCAAkC,CAAC;IAC5C,CAAC;CACF;AAdD,sCAcC"}
@@ -18,6 +18,7 @@ class TopicDitamap extends ditamap_1.Ditamap {
18
18
  // Override destination to include topic and subtopic
19
19
  this.destination = (0, path_1.join)(ditamap_1.Ditamap.outputDir, topic, filename);
20
20
  }
21
+ // eslint-disable-next-line class-methods-use-this
21
22
  getTemplateFileName() {
22
23
  return 'topic_ditamap.hbs';
23
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"topic-ditamap.js","sourceRoot":"","sources":["../../src/ditamap/topic-ditamap.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAA4B;AAC5B,uCAAoC;AAEpC,MAAa,YAAa,SAAQ,iBAAO;IACvC,YAAmB,KAAa,EAAE,UAAoB;QACpD,MAAM,QAAQ,GAAG,iBAAO,CAAC,IAAI,CAAC,iBAAiB,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;QACnE,sCAAsC;QACtC,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACnF,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAErC,qDAAqD;QACrD,IAAI,CAAC,WAAW,GAAG,IAAA,WAAI,EAAC,iBAAO,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAEM,mBAAmB;QACxB,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAdD,oCAcC"}
1
+ {"version":3,"file":"topic-ditamap.js","sourceRoot":"","sources":["../../src/ditamap/topic-ditamap.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAA4B;AAC5B,uCAAoC;AAEpC,MAAa,YAAa,SAAQ,iBAAO;IACvC,YAAmB,KAAa,EAAE,UAAoB;QACpD,MAAM,QAAQ,GAAG,iBAAO,CAAC,IAAI,CAAC,iBAAiB,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;QACnE,sCAAsC;QACtC,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACnF,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAErC,qDAAqD;QACrD,IAAI,CAAC,WAAW,GAAG,IAAA,WAAI,EAAC,iBAAO,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAED,kDAAkD;IAC3C,mBAAmB;QACxB,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAfD,oCAeC"}
package/lib/docs.d.ts CHANGED
@@ -1,14 +1,13 @@
1
- import { Dictionary, JsonMap } from '@salesforce/ts-types';
2
- import { CommandClass } from './utils';
1
+ import { AnyJson } from '@salesforce/ts-types';
2
+ import { CliMeta, SfTopics, CommandClass } from './utils';
3
3
  export declare class Docs {
4
4
  private outputDir;
5
- private plugins;
6
5
  private hidden;
7
6
  private topicMeta;
8
7
  private cliMeta;
9
- constructor(outputDir: string, plugins: JsonMap, hidden: boolean, topicMeta: JsonMap, cliMeta: JsonMap);
8
+ constructor(outputDir: string, hidden: boolean, topicMeta: SfTopics, cliMeta: CliMeta);
10
9
  build(commands: CommandClass[]): Promise<void>;
11
- populateTopic(topic: string, subtopics: Dictionary<CommandClass | CommandClass[]>): Promise<any[]>;
10
+ populateTopic(topic: string, subtopics: Map<string, CommandClass[]>): Promise<AnyJson[]>;
12
11
  /**
13
12
  * Group all commands by the top level topic and then subtopic. e.g. force, analytics, evergreen, etc
14
13
  * then org, apex, etc within the force namespace.
package/lib/docs.js CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Docs = void 0;
10
- const mkdirp = require("mkdirp");
10
+ const fs = require("fs/promises");
11
11
  const ts_types_1 = require("@salesforce/ts-types");
12
12
  const chalk = require("chalk");
13
13
  const base_ditamap_1 = require("./ditamap/base-ditamap");
@@ -21,64 +21,58 @@ function emitNoTopicMetadataWarning(topic) {
21
21
  utils_1.events.emit('warning', `No metadata for topic ${chalk.bold(topic)}. That topic owner must add topic metadata in the oclif section in the package.json file within their plugin.`);
22
22
  }
23
23
  class Docs {
24
- constructor(outputDir, plugins, hidden, topicMeta, cliMeta) {
24
+ constructor(outputDir, hidden, topicMeta, cliMeta) {
25
25
  this.outputDir = outputDir;
26
- this.plugins = plugins;
27
26
  this.hidden = hidden;
28
27
  this.topicMeta = topicMeta;
29
28
  this.cliMeta = cliMeta;
30
29
  }
31
30
  async build(commands) {
32
31
  // Create if doesn't exist
33
- await mkdirp(this.outputDir);
32
+ await fs.mkdir(this.outputDir, { recursive: true });
34
33
  await this.populateTemplate(commands);
35
34
  }
36
35
  async populateTopic(topic, subtopics) {
37
- const topicMeta = (0, ts_types_1.ensureJsonMap)(this.topicMeta[topic], `No topic meta for ${topic} - add this topic to the oclif section of the package.json.`);
38
- let description = (0, ts_types_1.asString)(topicMeta.description);
36
+ const topicMeta = this.topicMeta.get(topic);
37
+ if (!topicMeta) {
38
+ throw new Error(`No topic meta for ${topic} - add this topic to the oclif section of the package.json.`);
39
+ }
40
+ let description = topicMeta.description;
39
41
  if (!description && !topicMeta.external) {
40
- description = (0, utils_1.punctuate)((0, ts_types_1.asString)(topicMeta.description));
42
+ // TODO: check why the same property is used again when it is already used above
43
+ description = (0, utils_1.punctuate)(topicMeta.description);
41
44
  if (!description) {
42
45
  utils_1.events.emit('warning', `No description for topic ${chalk.bold(topic)}. Skipping until topic owner adds topic metadata in the oclif section in the package.json file within their plugin.`);
43
- return;
46
+ return [];
44
47
  }
45
48
  }
46
49
  const subTopicNames = [];
47
50
  const commandIds = [];
48
- for (const subtopic of Object.keys(subtopics)) {
49
- const subtopicOrCommand = (0, ts_types_1.isArray)(subtopics[subtopic])
50
- ? Object.assign([], subtopics[subtopic])
51
- : Object.assign({}, subtopics[subtopic]);
51
+ for (const [subtopic, classes] of subtopics.entries()) {
52
52
  try {
53
- if (!(0, ts_types_1.isArray)(subtopicOrCommand)) {
54
- // If it is not subtopic (array) it is a command in the top-level topic
55
- const command = Object.assign({}, subtopicOrCommand);
56
- const commandMeta = this.resolveCommandMeta((0, ts_types_1.ensureString)(command.id), command, 1);
57
- await this.populateCommand(topic, null, command, commandMeta);
58
- commandIds.push(command.id);
59
- continue;
60
- }
61
- const subTopicsMeta = (0, ts_types_1.ensureJsonMap)(topicMeta.subtopics);
62
- if (!subTopicsMeta[subtopic]) {
63
- emitNoTopicMetadataWarning(`${topic}:${subtopic}`);
64
- continue;
65
- }
53
+ // const subTopicsMeta = topicMeta.subtopics;
54
+ // if (!subTopicsMeta?.get(subtopic)) {
55
+ // emitNoTopicMetadataWarning(`${topic}:${subtopic}`);
56
+ // continue;
57
+ // }
66
58
  subTopicNames.push(subtopic);
67
59
  // Commands within the sub topic
68
- for (const command of subtopicOrCommand) {
60
+ for (const command of classes) {
69
61
  const fullTopic = (0, ts_types_1.ensureString)(command.id).replace(/:\w+$/, '');
70
- const commandsInFullTopic = subtopicOrCommand.filter((cmd) => (0, ts_types_1.ensureString)(cmd.id).indexOf(fullTopic) === 0);
62
+ const commandsInFullTopic = classes.filter((cmd) => (0, ts_types_1.ensureString)(cmd.id).startsWith(fullTopic));
71
63
  const commandMeta = this.resolveCommandMeta((0, ts_types_1.ensureString)(command.id), command, commandsInFullTopic.length);
64
+ // eslint-disable-next-line no-await-in-loop
72
65
  await this.populateCommand(topic, subtopic, command, commandMeta);
73
66
  commandIds.push(command.id);
74
67
  }
75
68
  }
76
69
  catch (error) {
77
- if (error.name === 'UnexpectedValueTypeError') {
70
+ const err = error instanceof Error ? error : typeof error === 'string' ? new Error(error) : new Error('Unknown error');
71
+ if (err.name === 'UnexpectedValueTypeError') {
78
72
  emitNoTopicMetadataWarning(`${topic}:${subtopic}`);
79
73
  }
80
74
  else {
81
- utils_1.events.emit('warning', `Can't create topic for ${topic}:${subtopic}: ${error.message}\n`);
75
+ utils_1.events.emit('warning', `Can't create topic for ${topic}:${subtopic}: ${err.message}\n`);
82
76
  }
83
77
  }
84
78
  }
@@ -96,7 +90,8 @@ class Docs {
96
90
  * @returns The commands grouped by topics/subtopic/commands.
97
91
  */
98
92
  groupTopicsAndSubtopics(commands) {
99
- const topLevelTopics = {};
93
+ // const topLevelTopics: Dictionary<Dictionary<CommandClass | CommandClass[]>> = {};
94
+ const topLevelTopics = new Map();
100
95
  for (const command of commands) {
101
96
  if (command.hidden && !this.hidden) {
102
97
  continue;
@@ -104,39 +99,37 @@ class Docs {
104
99
  const commandParts = (0, ts_types_1.ensureString)(command.id).split(':');
105
100
  const topLevelTopic = commandParts[0];
106
101
  const plugin = command.plugin;
107
- if (plugin && this.plugins[plugin.name]) {
102
+ if (plugin) {
108
103
  // Also include the namespace on the commands so we don't need to do the split at other times in the code.
109
104
  command.topic = topLevelTopic;
110
- const topics = topLevelTopics[topLevelTopic] || {};
105
+ const existingTopicsForTopLevel = topLevelTopics.get(topLevelTopic) ?? new Map();
111
106
  if (commandParts.length === 1) {
112
107
  // This is a top-level topic that is also a command
113
- topics[commandParts[0]] = command;
108
+ const existingTarget = existingTopicsForTopLevel.get(commandParts[0]) ?? [];
109
+ existingTopicsForTopLevel.set(commandParts[0], [...existingTarget, command]);
114
110
  }
115
111
  else if (commandParts.length === 2) {
116
112
  // This is a command directly under the top-level topic
117
- topics[commandParts[1]] = command;
113
+ const existingTarget = existingTopicsForTopLevel.get(commandParts[1]) ?? [];
114
+ existingTopicsForTopLevel.set(commandParts[1], [...existingTarget, command]);
118
115
  }
119
116
  else {
120
117
  const subtopic = commandParts[1];
121
118
  try {
122
- const topicMeta = (0, ts_types_1.ensureJsonMap)(this.topicMeta[topLevelTopic]);
123
- const subTopicsMeta = (0, ts_types_1.ensureJsonMap)(topicMeta.subtopics);
124
- if (subTopicsMeta.hidden && !this.hidden) {
119
+ const topicMeta = this.topicMeta.get(topLevelTopic);
120
+ const subTopicsMeta = topicMeta?.subtopics?.get(subtopic);
121
+ if (subTopicsMeta?.hidden && !this.hidden) {
125
122
  continue;
126
123
  }
127
124
  }
128
- catch (e) { } // It means no meta so it isn't hidden, although it should always fail before here with no meta found
129
- command.subtopic = subtopic;
130
- const existingSubTopics = topics[subtopic];
131
- let subtopicCommands = [];
132
- if (existingSubTopics) {
133
- subtopicCommands = (0, ts_types_1.isArray)(existingSubTopics) ? existingSubTopics : [existingSubTopics];
125
+ catch (e) {
126
+ // It means no meta so it isn't hidden, although it should always fail before here with no meta found
134
127
  }
135
- (0, ts_types_1.ensureArray)(subtopicCommands);
136
- subtopicCommands.push(command);
137
- topics[subtopic] = subtopicCommands;
128
+ command.subtopic = subtopic;
129
+ const subtopicCommands = existingTopicsForTopLevel.get(subtopic) ?? [];
130
+ existingTopicsForTopLevel.set(subtopic, [...subtopicCommands, command]);
138
131
  }
139
- topLevelTopics[topLevelTopic] = topics;
132
+ topLevelTopics.set(topLevelTopic, existingTopicsForTopLevel);
140
133
  }
141
134
  }
142
135
  return topLevelTopics;
@@ -145,12 +138,11 @@ class Docs {
145
138
  const topicsAndSubtopics = this.groupTopicsAndSubtopics(commands);
146
139
  await new cli_reference_1.CLIReference().write();
147
140
  await new help_reference_1.HelpReference().write();
148
- const topics = Object.keys(topicsAndSubtopics);
149
141
  // Generate one base file with all top-level topics.
150
- await new base_ditamap_1.BaseDitamap(topics).write();
151
- for (const topic of topics) {
142
+ await new base_ditamap_1.BaseDitamap(Array.from(topicsAndSubtopics.keys())).write();
143
+ for (const [topic, subtopics] of topicsAndSubtopics.entries()) {
152
144
  utils_1.events.emit('topic', { topic });
153
- const subtopics = (0, ts_types_1.ensure)(topicsAndSubtopics[topic]);
145
+ // eslint-disable-next-line no-await-in-loop
154
146
  await this.populateTopic(topic, subtopics);
155
147
  }
156
148
  }
@@ -163,32 +155,28 @@ class Docs {
163
155
  let currentMeta;
164
156
  for (part of commandParts) {
165
157
  if (currentMeta) {
166
- const subtopics = (0, ts_types_1.ensureJsonMap)(currentMeta.subtopics);
167
- currentMeta = (0, ts_types_1.ensureJsonMap)(subtopics[part]);
158
+ const subtopics = currentMeta.subtopics;
159
+ currentMeta = subtopics?.get(part);
168
160
  }
169
161
  else {
170
- currentMeta = (0, ts_types_1.ensureJsonMap)(this.topicMeta[part]);
162
+ currentMeta = this.topicMeta.get(part);
171
163
  }
172
164
  // Collect all tiers of the meta, so the command will also pick up the topic state (isPilot, etc) if applicable
173
165
  Object.assign({}, commandMeta, currentMeta);
174
166
  }
175
167
  }
176
168
  catch (error) {
169
+ // @ts-expect-error: part may be undefined
177
170
  if (commandId.endsWith(part)) {
178
171
  // This means there wasn't meta information going all the way down to the command, which is ok.
179
172
  return commandMeta;
180
173
  }
181
- else {
182
- if (commandsInTopic !== 1) {
183
- utils_1.events.emit('warning', `subtopic "${part}" meta not found for command ${commandId}`);
184
- }
185
- else {
186
- // Since there is no command meta, just use the command description since that is what oclif does.
187
- if (!commandMeta.description) {
188
- commandMeta.description = command.description;
189
- commandMeta.longDescription = command.longDescription || (0, utils_1.punctuate)(command.description);
190
- }
191
- }
174
+ else if (commandsInTopic !== 1) {
175
+ utils_1.events.emit('warning', `subtopic "${part}" meta not found for command ${commandId}`);
176
+ }
177
+ else if (!commandMeta.description) {
178
+ commandMeta.description = command.description;
179
+ commandMeta.longDescription = (command.longDescription ? command.longDescription : (0, utils_1.punctuate)(command.description));
192
180
  }
193
181
  }
194
182
  return commandMeta;