@komaci/cli 264.4.0 → 266.3.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.
@@ -2,6 +2,13 @@ import { run } from './lib/run.js';
2
2
  export default {
3
3
  name: 'analyze',
4
4
  alias: 'a',
5
+ description: 'Run the Komaci static analyzer over one or more LWC bundle directories and print diagnostics. ' +
6
+ 'Exits with code 1 if any diagnostics are reported.',
7
+ usage: 'yarn komaci analyze <paths...> [options]',
8
+ examples: [
9
+ 'yarn komaci analyze sandbox/modules/c/komaciAction',
10
+ 'yarn komaci analyze "sandbox/modules/*/*" --raw',
11
+ ],
5
12
  options: [
6
13
  {
7
14
  name: 'paths',
@@ -10,18 +17,21 @@ export default {
10
17
  type: String,
11
18
  required: true,
12
19
  defaultOption: true,
20
+ description: 'One or more LWC bundle directories. Glob patterns are supported.',
13
21
  },
14
22
  {
15
23
  name: 'bundleType',
16
24
  alias: 't',
17
25
  type: String,
18
26
  defaultValue: 'internal',
27
+ description: 'Bundle type passed to @lwc/metadata (e.g. "internal", "platform").',
19
28
  },
20
29
  {
21
30
  name: 'raw',
22
31
  alias: 'r',
23
32
  type: Boolean,
24
33
  defaultValue: false,
34
+ description: 'Print the raw diagnostic JSON instead of formatted, source-annotated output.',
25
35
  },
26
36
  ],
27
37
  run,
@@ -2,6 +2,17 @@ import { run } from './lib/run.js';
2
2
  export default {
3
3
  name: 'modgen',
4
4
  alias: 'm',
5
+ description: 'Generate a Komaci module (ADG) from one or more LWC bundle directories. ' +
6
+ 'Each path must point to a component folder nested under a namespace folder ' +
7
+ '(e.g. ".../c/myComponent"); the namespace is derived from the parent directory.',
8
+ usage: 'yarn komaci modgen <paths...> [options]\n' +
9
+ ' Note: place <paths...> before --only/-o, since --only accepts multiple values\n' +
10
+ ' and will otherwise greedily consume the path as one of its values.',
11
+ examples: [
12
+ 'yarn komaci modgen sandbox/modules/c/komaciAction',
13
+ 'yarn komaci modgen sandbox/modules/c/komaciAction --only lwc',
14
+ 'yarn komaci modgen sandbox/modules/lightning/*',
15
+ ],
5
16
  options: [
6
17
  {
7
18
  name: 'paths',
@@ -10,6 +21,7 @@ export default {
10
21
  type: String,
11
22
  required: true,
12
23
  defaultOption: true,
24
+ description: 'One or more LWC bundle directories. Glob patterns are supported.',
13
25
  },
14
26
  {
15
27
  name: 'only',
@@ -17,41 +29,48 @@ export default {
17
29
  type: String,
18
30
  multiple: true,
19
31
  defaultValue: ['mod', 'lwc', 'doc'],
32
+ description: 'Limit which sections to print: "mod" (Komaci module / ADG), "lwc" (LWC metadata), "doc" (Komaci document).',
20
33
  },
21
34
  {
22
35
  name: 'disableKomaci',
23
36
  alias: 'd',
24
37
  type: Boolean,
38
+ description: 'Disable Komaci processing during metadata collection.',
25
39
  },
26
40
  {
27
41
  name: 'bundleType',
28
42
  alias: 't',
29
43
  type: String,
30
44
  defaultValue: 'internal',
45
+ description: 'Bundle type passed to @lwc/metadata (e.g. "internal", "platform").',
31
46
  },
32
47
  {
33
48
  name: 'json',
34
49
  alias: 'j',
35
50
  type: Boolean,
36
51
  defaultValue: false,
52
+ description: 'Print metadata/doc sections as JSON instead of pretty-printed objects.',
37
53
  },
38
54
  {
39
55
  name: 'raw',
40
56
  alias: 'r',
41
57
  type: Boolean,
42
58
  defaultValue: false,
59
+ description: 'Suppress section headers in the output. Useful for piping to other tools.',
43
60
  },
44
61
  {
45
62
  name: 'withExceptions',
46
63
  alias: 'e',
47
64
  type: Boolean,
48
65
  defaultValue: false,
66
+ description: 'Run the alternate generation path that surfaces exceptions instead of producing error ADGs.',
49
67
  },
50
68
  {
51
69
  name: 'luvioMetadata',
52
70
  alias: 'l',
53
71
  type: Boolean,
54
72
  defaultValue: false,
73
+ description: 'Include Luvio GraphQL metadata in the generator input.',
55
74
  },
56
75
  ],
57
76
  run,
package/build/index.js CHANGED
@@ -1,16 +1,48 @@
1
1
  import commandLineArgs from 'command-line-args';
2
2
  import { modgen, analyze } from './cmds/index.js';
3
3
  import { commander } from './lib/commander.js';
4
+ import { findCommand, printCommandHelp, printTopLevelHelp } from './lib/help.js';
4
5
  import logger from './lib/log.js';
5
6
  const { error } = logger;
7
+ const commands = [modgen, analyze];
8
+ const rawArgs = process.argv.slice(2);
9
+ const helpRequest = parseHelpRequest(rawArgs);
10
+ if (helpRequest) {
11
+ if (helpRequest.commandName) {
12
+ const cmd = findCommand(commands, helpRequest.commandName);
13
+ if (cmd) {
14
+ printCommandHelp(cmd);
15
+ process.exit(0);
16
+ }
17
+ error(`No command "${helpRequest.commandName}" found`);
18
+ printTopLevelHelp(commands);
19
+ process.exit(1);
20
+ }
21
+ printTopLevelHelp(commands);
22
+ process.exit(0);
23
+ }
6
24
  const optionDefinitions = [{ name: 'command', defaultOption: true }];
7
25
  const mainCommand = commandLineArgs(optionDefinitions, { stopAtFirstUnknown: true });
8
26
  const { command, _unknown: argv = [] } = mainCommand;
9
- if (!commander(command, argv, [modgen, analyze])) {
27
+ if (!commander(command, argv, commands)) {
10
28
  error(`No command "${command}" found`);
29
+ printTopLevelHelp(commands);
11
30
  process.exit(1);
12
31
  }
13
32
  else {
14
33
  process.exit(0);
15
34
  }
35
+ /**
36
+ * Detect any of: `help`, `help <cmd>`, `--help`, `--help <cmd>`, `-h`, `-h <cmd>`.
37
+ * Returns null when the user did not request help.
38
+ */
39
+ function parseHelpRequest(argv) {
40
+ if (argv.length === 0)
41
+ return null;
42
+ const [first, second] = argv;
43
+ if (first === 'help' || first === '--help' || first === '-h') {
44
+ return { commandName: second };
45
+ }
46
+ return null;
47
+ }
16
48
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import type { CommandLineOptions } from 'command-line-args';
2
+ import type { Command } from '../types.js';
3
+ declare type AnyCommand = Command<CommandLineOptions>;
4
+ export declare function printTopLevelHelp(commands: AnyCommand[]): void;
5
+ export declare function printCommandHelp(cmd: AnyCommand): void;
6
+ export declare function findCommand(commands: AnyCommand[], target: string): AnyCommand | undefined;
7
+ export {};
8
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1,77 @@
1
+ import chalk from 'chalk';
2
+ import logger from './log.js';
3
+ const { bold, cyan, dim } = chalk;
4
+ const { log } = logger;
5
+ export function printTopLevelHelp(commands) {
6
+ const lines = [];
7
+ lines.push(bold('komaci') + ' — CLI utility for the Komaci ESM generator and static analyzer.');
8
+ lines.push('');
9
+ lines.push(bold('Usage:'));
10
+ lines.push(' yarn komaci <command> [options]');
11
+ lines.push(' yarn komaci help [command]');
12
+ lines.push('');
13
+ lines.push(bold('Commands:'));
14
+ const nameWidth = Math.max(...commands.map((c) => formatCommandLabel(c).length));
15
+ for (const cmd of commands) {
16
+ const label = formatCommandLabel(cmd).padEnd(nameWidth);
17
+ const desc = cmd.description ?? '';
18
+ lines.push(` ${cyan(label)} ${desc}`);
19
+ }
20
+ lines.push('');
21
+ lines.push(`Run ${cyan('yarn komaci help <command>')} for detailed usage of a specific command.`);
22
+ log(lines.join('\n'));
23
+ }
24
+ export function printCommandHelp(cmd) {
25
+ const lines = [];
26
+ lines.push(bold(`komaci ${cmd.name}`) + (cmd.alias ? dim(` (alias: ${cmd.alias})`) : ''));
27
+ if (cmd.description) {
28
+ lines.push('');
29
+ lines.push(cmd.description);
30
+ }
31
+ lines.push('');
32
+ lines.push(bold('Usage:'));
33
+ lines.push(` ${cmd.usage ?? `yarn komaci ${cmd.name} [options] <paths...>`}`);
34
+ if (cmd.options.length > 0) {
35
+ lines.push('');
36
+ lines.push(bold('Options:'));
37
+ const rows = cmd.options.map((opt) => [formatOptionLabel(opt), formatOptionDescription(opt)]);
38
+ const labelWidth = Math.max(...rows.map(([label]) => label.length));
39
+ for (const [label, desc] of rows) {
40
+ lines.push(` ${cyan(label.padEnd(labelWidth))} ${desc}`);
41
+ }
42
+ }
43
+ if (cmd.examples && cmd.examples.length > 0) {
44
+ lines.push('');
45
+ lines.push(bold('Examples:'));
46
+ for (const example of cmd.examples) {
47
+ lines.push(` ${example}`);
48
+ }
49
+ }
50
+ log(lines.join('\n'));
51
+ }
52
+ function formatCommandLabel(cmd) {
53
+ return cmd.alias ? `${cmd.name}, ${cmd.alias}` : cmd.name;
54
+ }
55
+ function formatOptionLabel(opt) {
56
+ const flag = opt.alias ? `-${opt.alias}, --${opt.name}` : ` --${opt.name}`;
57
+ const valueHint = opt.type === Boolean ? '' : opt.multiple ? ' <values...>' : ' <value>';
58
+ return `${flag}${valueHint}`;
59
+ }
60
+ function formatOptionDescription(opt) {
61
+ const parts = [];
62
+ if (opt.description)
63
+ parts.push(opt.description);
64
+ if (opt.defaultOption)
65
+ parts.push(dim('(default positional argument)'));
66
+ if (opt.defaultValue !== undefined) {
67
+ const formatted = Array.isArray(opt.defaultValue)
68
+ ? `[${opt.defaultValue.join(', ')}]`
69
+ : String(opt.defaultValue);
70
+ parts.push(dim(`(default: ${formatted})`));
71
+ }
72
+ return parts.join(' ');
73
+ }
74
+ export function findCommand(commands, target) {
75
+ return commands.find(({ name, alias }) => target === name || target === alias);
76
+ }
77
+ //# sourceMappingURL=help.js.map
package/build/types.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import type { CommandLineOptions, OptionDefinition } from 'command-line-args';
2
+ export declare type CommandOptionDefinition = OptionDefinition & {
3
+ description?: string;
4
+ };
2
5
  export declare type Command<T extends CommandLineOptions> = {
3
6
  name: string;
4
7
  alias?: string;
8
+ description?: string;
9
+ usage?: string;
10
+ examples?: string[];
5
11
  run: (cmdOptions: T) => void;
6
- options: OptionDefinition[];
12
+ options: CommandOptionDefinition[];
7
13
  };
8
14
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@komaci/cli",
3
- "version": "264.4.0",
3
+ "version": "266.3.0",
4
4
  "description": "CLI utility that enables developers to use komaci from the command line.",
5
5
  "license": "MIT",
6
6
  "type": "module",