@yabasha/gex 1.0.0 → 1.0.1

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.
package/dist/cli.cjs CHANGED
@@ -164,9 +164,211 @@ function renderMarkdown(report) {
164
164
  return lines.join("\n");
165
165
  }
166
166
 
167
+ // src/report/html.ts
168
+ function table2(headers, rows) {
169
+ const headerHtml = `<tr>${headers.map((h) => `<th>${h}</th>`).join("")}</tr>`;
170
+ const bodyHtml = rows.map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join("")}</tr>`).join("");
171
+ return `<table><thead>${headerHtml}</thead><tbody>${bodyHtml}</tbody></table>`;
172
+ }
173
+ function escapeHtml(text) {
174
+ const htmlEntities = {
175
+ "&": "&amp;",
176
+ "<": "&lt;",
177
+ ">": "&gt;",
178
+ '"': "&quot;",
179
+ "'": "&#39;"
180
+ };
181
+ return text.replace(/[&<>"']/g, (char) => htmlEntities[char]);
182
+ }
183
+ function renderHtml(report) {
184
+ const hasProjectMeta = report.project_name || report.project_version || report.project_description || report.project_homepage || report.project_bugs;
185
+ return `<!DOCTYPE html>
186
+ <html lang="en">
187
+ <head>
188
+ <meta charset="UTF-8">
189
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
190
+ <title>GEX Report - ${report.project_name || "Dependency Audit"}</title>
191
+ <style>
192
+ body {
193
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
194
+ line-height: 1.6;
195
+ color: #333;
196
+ max-width: 1200px;
197
+ margin: 0 auto;
198
+ padding: 20px;
199
+ background-color: #f5f5f5;
200
+ }
201
+ .container {
202
+ background: white;
203
+ border-radius: 8px;
204
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
205
+ padding: 30px;
206
+ }
207
+ h1 {
208
+ color: #2c3e50;
209
+ border-bottom: 3px solid #3498db;
210
+ padding-bottom: 10px;
211
+ margin-top: 0;
212
+ }
213
+ h2 {
214
+ color: #34495e;
215
+ border-bottom: 2px solid #bdc3c7;
216
+ padding-bottom: 8px;
217
+ margin-top: 40px;
218
+ margin-bottom: 20px;
219
+ }
220
+ .metadata {
221
+ background: #ecf0f1;
222
+ border-radius: 6px;
223
+ padding: 20px;
224
+ margin-bottom: 20px;
225
+ }
226
+ .metadata dl {
227
+ margin: 0;
228
+ }
229
+ .metadata dt {
230
+ font-weight: bold;
231
+ color: #2c3e50;
232
+ margin-top: 10px;
233
+ }
234
+ .metadata dt:first-child {
235
+ margin-top: 0;
236
+ }
237
+ .metadata dd {
238
+ margin: 5px 0 0 20px;
239
+ color: #555;
240
+ }
241
+ .metadata dd a {
242
+ color: #3498db;
243
+ text-decoration: none;
244
+ }
245
+ .metadata dd a:hover {
246
+ text-decoration: underline;
247
+ }
248
+ table {
249
+ width: 100%;
250
+ border-collapse: collapse;
251
+ margin-bottom: 30px;
252
+ background: white;
253
+ border-radius: 6px;
254
+ overflow: hidden;
255
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
256
+ }
257
+ th {
258
+ background: #3498db;
259
+ color: white;
260
+ padding: 12px;
261
+ text-align: left;
262
+ font-weight: 600;
263
+ }
264
+ td {
265
+ padding: 12px;
266
+ border-bottom: 1px solid #ecf0f1;
267
+ font-family: 'SFMono-Regular', Consolas, monospace;
268
+ font-size: 14px;
269
+ }
270
+ tr:nth-child(even) {
271
+ background: #f8f9fa;
272
+ }
273
+ tr:hover {
274
+ background: #e8f4fd;
275
+ }
276
+ .footer {
277
+ text-align: center;
278
+ color: #7f8c8d;
279
+ font-size: 14px;
280
+ margin-top: 40px;
281
+ padding-top: 20px;
282
+ border-top: 1px solid #ecf0f1;
283
+ }
284
+ .footer strong {
285
+ color: #2c3e50;
286
+ }
287
+ .no-data {
288
+ text-align: center;
289
+ color: #7f8c8d;
290
+ font-style: italic;
291
+ padding: 40px;
292
+ }
293
+ .timestamp {
294
+ color: #95a5a6;
295
+ font-size: 14px;
296
+ margin-top: 10px;
297
+ }
298
+ </style>
299
+ </head>
300
+ <body>
301
+ <div class="container">
302
+ <h1>GEX Dependency Report</h1>
303
+
304
+ ${hasProjectMeta ? `
305
+ <section class="metadata">
306
+ <h2>Project Information</h2>
307
+ <dl>
308
+ ${report.project_name ? `<dt>Project Name</dt><dd>${escapeHtml(report.project_name)}</dd>` : ""}
309
+ ${report.project_version ? `<dt>Version</dt><dd>${escapeHtml(report.project_version)}</dd>` : ""}
310
+ ${report.project_description ? `<dt>Description</dt><dd>${escapeHtml(report.project_description)}</dd>` : ""}
311
+ ${report.project_homepage ? `<dt>Homepage</dt><dd><a href="${escapeHtml(report.project_homepage)}" target="_blank">${escapeHtml(report.project_homepage)}</a></dd>` : ""}
312
+ ${report.project_bugs ? `<dt>Bugs</dt><dd><a href="${escapeHtml(report.project_bugs)}" target="_blank">${escapeHtml(report.project_bugs)}</a></dd>` : ""}
313
+ <dt>Report Generated</dt><dd>${new Date(report.timestamp).toLocaleString()}</dd>
314
+ </dl>
315
+ </section>
316
+ ` : ""}
317
+
318
+ ${report.global_packages.length > 0 ? `
319
+ <section>
320
+ <h2>Global Packages <small>(${report.global_packages.length})</small></h2>
321
+ ${table2(
322
+ ["Name", "Version", "Path"],
323
+ report.global_packages.map((p) => [
324
+ escapeHtml(p.name),
325
+ escapeHtml(p.version || ""),
326
+ escapeHtml(p.resolved_path || "")
327
+ ])
328
+ )}
329
+ </section>
330
+ ` : '<section><h2>Global Packages</h2><div class="no-data">No global packages found</div></section>'}
331
+
332
+ ${report.local_dependencies.length > 0 ? `
333
+ <section>
334
+ <h2>Local Dependencies <small>(${report.local_dependencies.length})</small></h2>
335
+ ${table2(
336
+ ["Name", "Version", "Path"],
337
+ report.local_dependencies.map((p) => [
338
+ escapeHtml(p.name),
339
+ escapeHtml(p.version || ""),
340
+ escapeHtml(p.resolved_path || "")
341
+ ])
342
+ )}
343
+ </section>
344
+ ` : '<section><h2>Local Dependencies</h2><div class="no-data">No local dependencies found</div></section>'}
345
+
346
+ ${report.local_dev_dependencies.length > 0 ? `
347
+ <section>
348
+ <h2>Local Dev Dependencies <small>(${report.local_dev_dependencies.length})</small></h2>
349
+ ${table2(
350
+ ["Name", "Version", "Path"],
351
+ report.local_dev_dependencies.map((p) => [
352
+ escapeHtml(p.name),
353
+ escapeHtml(p.version || ""),
354
+ escapeHtml(p.resolved_path || "")
355
+ ])
356
+ )}
357
+ </section>
358
+ ` : '<section><h2>Local Dev Dependencies</h2><div class="no-data">No local dev dependencies found</div></section>'}
359
+
360
+ <footer class="footer">
361
+ <p>Generated by <strong>GEX v${escapeHtml(report.tool_version)}</strong> on ${new Date(report.timestamp).toLocaleString()}</p>
362
+ <p>Report format version: ${escapeHtml(report.report_version)}</p>
363
+ </footer>
364
+ </div>
365
+ </body>
366
+ </html>`;
367
+ }
368
+
167
369
  // src/cli/output.ts
168
370
  async function outputReport(report, format, outFile, markdownExtras) {
169
- const content = format === "json" ? renderJson(report) : renderMarkdown({ ...report, ...markdownExtras || {} });
371
+ const content = format === "json" ? renderJson(report) : format === "html" ? renderHtml({ ...report, ...markdownExtras || {} }) : renderMarkdown({ ...report, ...markdownExtras || {} });
170
372
  if (outFile) {
171
373
  const outDir = import_node_path.default.dirname(outFile);
172
374
  const { mkdir, writeFile } = await import("fs/promises");
@@ -414,8 +616,12 @@ async function produceReport(ctx, options) {
414
616
  function addCommonOptions(cmd, { allowOmitDev }) {
415
617
  cmd.option(
416
618
  "-f, --output-format <format>",
417
- "Output format: md or json",
418
- (val) => val === "md" ? "md" : "json",
619
+ "Output format: json, md, or html",
620
+ (val) => {
621
+ if (val === "md") return "md";
622
+ if (val === "html") return "html";
623
+ return "json";
624
+ },
419
625
  "json"
420
626
  ).option("-o, --out-file <path>", "Write report to file").option("--full-tree", "Include full npm ls tree (omit depth=0 default)", false);
421
627
  if (allowOmitDev) {
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/cli/commands.ts","../src/cli/install.ts","../src/cli/output.ts","../src/report/json.ts","../src/report/md.ts","../src/cli/parser.ts","../src/cli/report.ts","../src/npm.ts","../src/transform.ts","../src/cli/utils.ts"],"sourcesContent":["/**\n * @fileoverview Main CLI entry point for GEX dependency auditing tool\n */\n\nimport { createProgram } from './cli/commands.js'\n\n/**\n * Main CLI runner function\n *\n * @param argv - Command line arguments (defaults to process.argv)\n */\nexport async function run(argv = process.argv): Promise<void> {\n const program = await createProgram()\n await program.parseAsync(argv)\n}\n\nconst isMainModule = (() => {\n try {\n if (typeof require !== 'undefined' && typeof module !== 'undefined') {\n return (require as any).main === module\n }\n\n if (typeof import.meta !== 'undefined') {\n return import.meta.url === `file://${process.argv[1]}`\n }\n return false\n } catch {\n return false\n }\n})()\n\nif (isMainModule) {\n run().catch((error) => {\n console.error('CLI error:', error)\n process.exitCode = 1\n })\n}\n","/**\n * @fileoverview CLI command definitions and handlers\n */\n\nimport path from 'node:path'\n\nimport { Command } from 'commander'\n\nimport type { OutputFormat } from '../types.js'\n\nimport { installFromReport, printFromReport } from './install.js'\nimport { outputReport } from './output.js'\nimport { isMarkdownReportFile, loadReportFromFile } from './parser.js'\nimport { produceReport } from './report.js'\nimport { ASCII_BANNER, getToolVersion } from './utils.js'\n\n/**\n * Adds common options to a command\n *\n * @param cmd - Command to add options to\n * @param options - Configuration for which options to add\n * @returns Modified command\n */\nfunction addCommonOptions(cmd: Command, { allowOmitDev }: { allowOmitDev: boolean }): Command {\n cmd\n .option(\n '-f, --output-format <format>',\n 'Output format: md or json',\n (val) => (val === 'md' ? 'md' : 'json'),\n 'json',\n )\n .option('-o, --out-file <path>', 'Write report to file')\n .option('--full-tree', 'Include full npm ls tree (omit depth=0 default)', false)\n\n if (allowOmitDev) {\n cmd.option('--omit-dev', 'Exclude devDependencies (local only)', false)\n }\n\n return cmd\n}\n\n/**\n * Creates the local command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createLocalCommand(program: Command): Command {\n const localCmd = program\n .command('local', { isDefault: true })\n .description(\"Generate a report for the current project's dependencies\")\n\n addCommonOptions(localCmd, { allowOmitDev: true })\n\n localCmd.action(async (opts) => {\n const outputFormat = (opts.outputFormat ?? 'json') as OutputFormat\n const outFile = opts.outFile as string | undefined\n const fullTree = Boolean(opts.fullTree)\n const omitDev = Boolean(opts.omitDev)\n\n // Only set finalOutFile when explicitly provided via --out-file\n const finalOutFile = outFile\n\n const { report, markdownExtras } = await produceReport('local', {\n outputFormat,\n outFile: finalOutFile,\n fullTree,\n omitDev,\n })\n\n await outputReport(report, outputFormat, finalOutFile, markdownExtras)\n })\n\n return localCmd\n}\n\n/**\n * Creates the global command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createGlobalCommand(program: Command): Command {\n const globalCmd = program\n .command('global')\n .description('Generate a report of globally installed packages')\n\n addCommonOptions(globalCmd, { allowOmitDev: false })\n\n globalCmd.action(async (opts) => {\n const outputFormat = (opts.outputFormat ?? 'json') as OutputFormat\n const outFile = opts.outFile as string | undefined\n const fullTree = Boolean(opts.fullTree)\n\n // Only set finalOutFile when explicitly provided via --out-file\n const finalOutFile = outFile\n\n const { report, markdownExtras } = await produceReport('global', {\n outputFormat,\n outFile: finalOutFile,\n fullTree,\n })\n\n await outputReport(report, outputFormat, finalOutFile, markdownExtras)\n })\n\n return globalCmd\n}\n\n/**\n * Creates the read command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createReadCommand(program: Command): Command {\n const readCmd = program\n .command('read')\n .description(\n 'Read a previously generated report (JSON or Markdown) and either print package names or install them',\n )\n .argument('[report]', 'Path to report file (JSON or Markdown)', 'gex-report.json')\n .option('-r, --report <path>', 'Path to report file (JSON or Markdown)')\n .option('-p, --print', 'Print package names/versions from the report (default)', false)\n .option('-i, --install', 'Install packages from the report', false)\n\n readCmd.action(async (reportArg: string | undefined, opts: any) => {\n const chosen = (opts.report as string | undefined) || reportArg || 'gex-report.json'\n const reportPath = path.resolve(process.cwd(), chosen)\n\n try {\n const parsed = await loadReportFromFile(reportPath)\n\n const doInstall = Boolean(opts.install)\n const doPrint = Boolean(opts.print) || !doInstall\n\n if (doPrint) {\n printFromReport(parsed)\n }\n if (doInstall) {\n await installFromReport(parsed, process.cwd())\n }\n } catch (err: any) {\n const isMd = isMarkdownReportFile(reportPath)\n const hint = isMd\n ? 'Try generating a JSON report with: gex global -f json -o global.json, then: gex read global.json'\n : 'Specify a report path with: gex read <path-to-report.json>'\n console.error(`Failed to read report at ${reportPath}: ${err?.message || err}`)\n console.error(hint)\n process.exitCode = 1\n }\n })\n\n return readCmd\n}\n\n/**\n * Creates and configures the main CLI program\n *\n * @returns Configured Commander program\n */\nexport async function createProgram(): Promise<Command> {\n const program = new Command()\n .name('gex')\n .description('GEX: Dependency auditing and documentation for Node.js (local and global).')\n .version(await getToolVersion())\n\n program.addHelpText('beforeAll', `\\n${ASCII_BANNER}`)\n\n createLocalCommand(program)\n createGlobalCommand(program)\n createReadCommand(program)\n\n return program\n}\n","/**\n * @fileoverview Package installation utilities for CLI\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Lazily obtain a promisified execFile so tests can mock built-ins reliably.\n */\nasync function getExecFileAsync(): Promise<\n (\n command: string,\n args?: readonly string[] | null,\n options?: any,\n ) => Promise<{ stdout: string; stderr: string }>\n> {\n const { execFile } = await import('node:child_process')\n const { promisify } = await import('node:util')\n return promisify(execFile) as any\n}\n\n/**\n * Installs packages from a report to the local environment\n *\n * @param report - The report containing packages to install\n * @param cwd - Current working directory for installation\n * @throws {Error} If npm installation fails\n */\nexport async function installFromReport(report: Report, cwd: string): Promise<void> {\n const globalPkgs = report.global_packages.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n const localPkgs = report.local_dependencies.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n const devPkgs = report.local_dev_dependencies.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n\n if (globalPkgs.length === 0 && localPkgs.length === 0 && devPkgs.length === 0) {\n console.log('No packages to install from report.')\n return\n }\n\n // Acquire execFileAsync once per run to keep logs grouped, while still mockable in tests\n const execFileAsync = await getExecFileAsync()\n\n if (globalPkgs.length > 0) {\n console.log(`Installing global: ${globalPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', '-g', ...globalPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n\n if (localPkgs.length > 0) {\n console.log(`Installing local deps: ${localPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', ...localPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n\n if (devPkgs.length > 0) {\n console.log(`Installing local devDeps: ${devPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', '-D', ...devPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n}\n\n/**\n * Prints packages from a report to the console\n *\n * @param report - The report to print packages from\n */\nexport function printFromReport(report: Report): void {\n const lines: string[] = []\n\n if (report.global_packages.length > 0) {\n lines.push('Global Packages:')\n for (const p of report.global_packages) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (report.local_dependencies.length > 0) {\n if (lines.length) lines.push('')\n lines.push('Local Dependencies:')\n for (const p of report.local_dependencies) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (report.local_dev_dependencies.length > 0) {\n if (lines.length) lines.push('')\n lines.push('Local Dev Dependencies:')\n for (const p of report.local_dev_dependencies) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (lines.length === 0) {\n lines.push('(no packages found in report)')\n }\n\n console.log(lines.join('\\n'))\n}\n","/**\n * @fileoverview Report output utilities for CLI\n */\n\nimport path from 'node:path'\n\nimport { renderJson } from '../report/json.js'\nimport { renderMarkdown } from '../report/md.js'\nimport type { OutputFormat, Report } from '../types.js'\n\n/**\n * Outputs a report to console or file\n *\n * @param report - The report to output\n * @param format - Output format ('json' or 'md')\n * @param outFile - Optional file path to write to\n * @param markdownExtras - Additional metadata for markdown rendering\n */\nexport async function outputReport(\n report: Report,\n format: OutputFormat,\n outFile?: string,\n markdownExtras?: any,\n): Promise<void> {\n const content =\n format === 'json'\n ? renderJson(report)\n : renderMarkdown({ ...report, ...(markdownExtras || {}) })\n\n if (outFile) {\n const outDir = path.dirname(outFile)\n const { mkdir, writeFile } = await import('node:fs/promises')\n\n await mkdir(outDir, { recursive: true })\n await writeFile(outFile, content, 'utf8')\n\n console.log(`Wrote report to ${outFile}`)\n } else {\n console.log(content)\n }\n}\n","/**\n * @fileoverview JSON report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Renders a Report object as formatted JSON string\n *\n * @param report - Report object to render\n * @returns Pretty-printed JSON string with consistent package ordering\n *\n * @example\n * ```typescript\n * import { renderJson } from './report/json.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * global_packages: [],\n * local_dependencies: [{ name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }],\n * local_dev_dependencies: []\n * }\n *\n * const jsonOutput = renderJson(report)\n * console.log(jsonOutput) // Pretty-printed JSON\n * ```\n */\nexport function renderJson(report: Report): string {\n const r: Report = {\n ...report,\n global_packages: [...report.global_packages].sort((a, b) => a.name.localeCompare(b.name)),\n local_dependencies: [...report.local_dependencies].sort((a, b) => a.name.localeCompare(b.name)),\n local_dev_dependencies: [...report.local_dev_dependencies].sort((a, b) =>\n a.name.localeCompare(b.name),\n ),\n }\n return JSON.stringify(r, null, 2)\n}\n","/**\n * @fileoverview Markdown report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Creates a markdown table from headers and row data\n *\n * @param headers - Array of table header strings\n * @param rows - Array of row data (each row is array of strings)\n * @returns Formatted markdown table string\n */\nfunction table(headers: string[], rows: string[][]): string {\n const header = `| ${headers.join(' | ')} |`\n const sep = `| ${headers.map(() => '---').join(' | ')} |`\n const body = rows.map((r) => `| ${r.join(' | ')} |`).join('\\n')\n return [header, sep, body].filter(Boolean).join('\\n')\n}\n\n/**\n * Renders a Report object as formatted Markdown\n *\n * @param report - Report object with optional project metadata\n * @returns Formatted Markdown string with tables and sections\n *\n * @example\n * ```typescript\n * import { renderMarkdown } from './report/md.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * project_name: 'my-project',\n * global_packages: [],\n * local_dependencies: [\n * { name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }\n * ],\n * local_dev_dependencies: [],\n * project_description: 'My awesome project'\n * }\n *\n * const markdown = renderMarkdown(report)\n * console.log(markdown) // Formatted markdown with tables\n * ```\n */\nexport function renderMarkdown(\n report: Report & {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n },\n): string {\n const lines: string[] = []\n lines.push('# GEX Report')\n lines.push('')\n\n if (\n report.project_name ||\n report.project_version ||\n (report as any).project_description ||\n (report as any).project_homepage ||\n (report as any).project_bugs\n ) {\n lines.push('## Project Metadata')\n if (report.project_name) lines.push(`- Name: ${report.project_name}`)\n if (report.project_version) lines.push(`- Version: ${report.project_version}`)\n if ((report as any).project_description)\n lines.push(`- Description: ${(report as any).project_description}`)\n if ((report as any).project_homepage)\n lines.push(`- Homepage: ${(report as any).project_homepage}`)\n if ((report as any).project_bugs) lines.push(`- Bugs: ${(report as any).project_bugs}`)\n lines.push('')\n }\n\n if (report.global_packages.length > 0) {\n lines.push('## Global Packages')\n const rows = report.global_packages.map((p) => [p.name, p.version || '', p.resolved_path || ''])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n if (report.local_dependencies.length > 0) {\n lines.push('## Local Dependencies')\n const rows = report.local_dependencies.map((p) => [\n p.name,\n p.version || '',\n p.resolved_path || '',\n ])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n if (report.local_dev_dependencies.length > 0) {\n lines.push('## Local Dev Dependencies')\n const rows = report.local_dev_dependencies.map((p) => [\n p.name,\n p.version || '',\n p.resolved_path || '',\n ])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n lines.push('---')\n lines.push('_Generated by GEX_')\n\n return lines.join('\\n')\n}\n","/**\n * @fileoverview Report parsing utilities for CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport type { PackageInfo, Report } from '../types.js'\n\n/**\n * Checks if a file path indicates a markdown report\n */\nexport function isMarkdownReportFile(filePath: string): boolean {\n const ext = path.extname(filePath).toLowerCase()\n return ext === '.md' || ext === '.markdown'\n}\n\n/**\n * Parses a markdown table and extracts package information\n *\n * @param lines - Array of file lines\n * @param startIndex - Index where table starts\n * @returns Array of package information\n */\nfunction parseMarkdownPackagesTable(lines: string[], startIndex: number): PackageInfo[] {\n const rows: PackageInfo[] = []\n if (!lines[startIndex] || !lines[startIndex].trim().startsWith('|')) return rows\n\n let i = startIndex + 2\n while (i < lines.length && lines[i].trim().startsWith('|')) {\n const cols = lines[i]\n .split('|')\n .map((c) => c.trim())\n .filter((_, idx, arr) => !(idx === 0 || idx === arr.length - 1))\n\n const [name = '', version = '', resolved_path = ''] = cols\n if (name) rows.push({ name, version, resolved_path })\n i++\n }\n return rows\n}\n\n/**\n * Parses a markdown report and converts it to a Report object\n *\n * @param md - Markdown content to parse\n * @returns Parsed Report object\n */\nexport function parseMarkdownReport(md: string): Report {\n const lines = md.split(/\\r?\\n/)\n\n const findSection = (title: string) =>\n lines.findIndex((l) => l.trim().toLowerCase() === `## ${title}`.toLowerCase())\n\n const parseSection = (idx: number): PackageInfo[] => {\n if (idx < 0) return []\n\n let i = idx + 1\n while (i < lines.length && !lines[i].trim().startsWith('|')) i++\n return parseMarkdownPackagesTable(lines, i)\n }\n\n const global_packages = parseSection(findSection('Global Packages'))\n const local_dependencies = parseSection(findSection('Local Dependencies'))\n const local_dev_dependencies = parseSection(findSection('Local Dev Dependencies'))\n\n const report: Report = {\n report_version: '1.0',\n timestamp: new Date().toISOString(),\n tool_version: 'unknown',\n global_packages,\n local_dependencies,\n local_dev_dependencies,\n }\n return report\n}\n\n/**\n * Loads and parses a report file (JSON or Markdown)\n *\n * @param reportPath - Path to the report file\n * @returns Parsed Report object\n * @throws {Error} If file cannot be read or parsed\n */\nexport async function loadReportFromFile(reportPath: string): Promise<Report> {\n const raw = await readFile(reportPath, 'utf8')\n\n if (isMarkdownReportFile(reportPath) || raw.startsWith('# GEX Report')) {\n return parseMarkdownReport(raw)\n }\n\n return JSON.parse(raw) as Report\n}\n","/**\n * @fileoverview Report generation utilities for CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { npmLs, npmRootGlobal } from '../npm.js'\nimport { buildReportFromNpmTree } from '../transform.js'\nimport type { OutputFormat, Report } from '../types.js'\n\nimport { getToolVersion } from './utils.js'\n\n/**\n * Options for report generation\n */\nexport interface ReportOptions {\n outputFormat: OutputFormat\n outFile?: string\n fullTree?: boolean\n omitDev?: boolean\n cwd?: string\n}\n\n/**\n * Result of report generation including markdown extras\n */\nexport interface ReportResult {\n report: Report\n markdownExtras?: {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n }\n}\n\n/**\n * Produces a dependency report for local or global context\n *\n * @param ctx - Context for report generation ('local' or 'global')\n * @param options - Report generation options\n * @returns Report and optional markdown extras\n */\nexport async function produceReport(\n ctx: 'local' | 'global',\n options: ReportOptions,\n): Promise<ReportResult> {\n const toolVersion = await getToolVersion()\n const depth0 = !options.fullTree\n const cwd = options.cwd || process.cwd()\n\n const tree = await npmLs({\n global: ctx === 'global',\n omitDev: ctx === 'local' ? Boolean(options.omitDev) : false,\n depth0,\n cwd,\n })\n\n let project_description: string | undefined\n let project_homepage: string | undefined\n let project_bugs: string | undefined\n\n if (ctx === 'local') {\n try {\n const pkgRaw = await readFile(path.join(cwd, 'package.json'), 'utf8')\n const pkg = JSON.parse(pkgRaw)\n project_description = pkg.description\n project_homepage = pkg.homepage\n if (typeof pkg.bugs === 'string') project_bugs = pkg.bugs\n else if (pkg.bugs && typeof pkg.bugs.url === 'string') project_bugs = pkg.bugs.url\n } catch {\n // Ignore errors reading local package.json (e.g., file missing or invalid JSON)\n void 0\n }\n }\n\n const globalRoot = ctx === 'global' ? await npmRootGlobal().catch(() => undefined) : undefined\n\n const report = await buildReportFromNpmTree(tree, {\n context: ctx,\n includeTree: Boolean(options.fullTree),\n omitDev: Boolean(options.omitDev),\n cwd,\n toolVersion,\n globalRoot,\n })\n\n const markdownExtras = { project_description, project_homepage, project_bugs }\n return { report, markdownExtras }\n}\n","/**\n * @fileoverview npm command execution utilities for dependency analysis\n */\n\n/**\n * Lazily obtain a promisified execFile so tests can mock built-ins reliably.\n */\nasync function getExecFileAsync(): Promise<\n (\n command: string,\n args?: readonly string[] | null,\n options?: any,\n ) => Promise<{ stdout: string; stderr: string }>\n> {\n const { execFile } = await import('node:child_process')\n const { promisify } = await import('node:util')\n return promisify(execFile) as any\n}\n\n/**\n * Options for npm ls command execution\n */\nexport type NpmLsOptions = {\n /** Whether to list global packages */\n global?: boolean\n /** Whether to omit devDependencies */\n omitDev?: boolean\n /** Whether to use depth=0 for faster execution */\n depth0?: boolean\n /** Current working directory for command execution */\n cwd?: string\n}\n\n/**\n * Executes npm ls command and returns parsed dependency tree\n *\n * @param options - Configuration options for npm ls command\n * @returns Promise resolving to npm dependency tree object\n * @throws {Error} If npm command fails or output cannot be parsed\n *\n * @example\n * ```typescript\n * import { npmLs } from './npm.js'\n *\n * // Get local dependencies with devDependencies omitted\n * const tree = await npmLs({ omitDev: true, depth0: true })\n *\n * // Get global packages\n * const globalTree = await npmLs({ global: true })\n * ```\n */\nexport async function npmLs(options: NpmLsOptions = {}): Promise<any> {\n const args = ['ls', '--json']\n if (options.global) args.push('--global')\n if (options.omitDev) args.push('--omit=dev')\n if (options.depth0) args.push('--depth=0')\n\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', args, {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n if (stdout && stdout.trim()) return JSON.parse(stdout)\n return {}\n } catch (err: any) {\n const stdout = err?.stdout\n if (typeof stdout === 'string' && stdout.trim()) {\n try {\n return JSON.parse(stdout)\n } catch (parseErr) {\n if (process.env.DEBUG?.includes('gex')) {\n console.warn('npm ls stdout parse failed:', parseErr)\n }\n }\n }\n const stderr = err?.stderr\n const msg = (typeof stderr === 'string' && stderr.trim()) || err?.message || 'npm ls failed'\n throw new Error(`npm ls failed: ${msg}`)\n }\n}\n\n/**\n * Gets the global npm root directory path\n *\n * @returns Promise resolving to the global npm root path\n * @throws {Error} If npm root -g command fails\n *\n * @example\n * ```typescript\n * import { npmRootGlobal } from './npm.js'\n *\n * try {\n * const globalRoot = await npmRootGlobal()\n * console.log('Global npm root:', globalRoot)\n * } catch (error) {\n * console.error('Failed to get global root:', error.message)\n * }\n * ```\n */\nexport async function npmRootGlobal(): Promise<string> {\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', ['root', '-g'])\n return stdout.trim()\n } catch (err: any) {\n const stderr = err?.stderr\n const msg =\n (typeof stderr === 'string' && stderr.trim()) || err?.message || 'npm root -g failed'\n throw new Error(`npm root -g failed: ${msg}`)\n }\n}\n","/**\n * @fileoverview Data transformation utilities for converting npm tree data into reports\n */\n\nimport path from 'node:path'\nimport { readFile } from 'node:fs/promises'\n\nimport type { PackageInfo, Report } from './types.js'\n\n/**\n * Options for report generation and normalization\n */\nexport type NormalizeOptions = {\n /** Context for report generation ('local' or 'global') */\n context: 'local' | 'global'\n /** Whether to include the full npm dependency tree */\n includeTree?: boolean\n /** Whether to omit devDependencies (local context only) */\n omitDev?: boolean\n /** Current working directory */\n cwd?: string\n /** Tool version to include in report */\n toolVersion: string\n /** Global npm root directory path */\n globalRoot?: string\n}\n\n/**\n * Converts npm dependency object to array of package entries\n *\n * @param obj - npm dependency object from npm ls output\n * @returns Array of name/node pairs for packages\n */\nfunction toPkgArray(obj: Record<string, any> | undefined | null): { name: string; node: any }[] {\n if (!obj) return []\n return Object.keys(obj)\n .map((name) => ({ name, node: obj[name] }))\n .filter((p) => p && p.node)\n}\n\n/**\n * Builds a GEX report from npm ls tree output\n *\n * @param tree - Raw npm ls command output\n * @param opts - Report generation options\n * @returns Promise resolving to a formatted Report object\n *\n * @example\n * ```typescript\n * import { buildReportFromNpmTree } from './transform.js'\n * import { npmLs } from './npm.js'\n *\n * const tree = await npmLs({ depth0: true })\n * const report = await buildReportFromNpmTree(tree, {\n * context: 'local',\n * toolVersion: '0.3.2',\n * cwd: process.cwd()\n * })\n *\n * console.log(`Found ${report.local_dependencies.length} dependencies`)\n * ```\n */\nexport async function buildReportFromNpmTree(tree: any, opts: NormalizeOptions): Promise<Report> {\n const timestamp = new Date().toISOString()\n const report: Report = {\n report_version: '1.0',\n timestamp,\n tool_version: opts.toolVersion,\n global_packages: [],\n local_dependencies: [],\n local_dev_dependencies: [],\n }\n\n if (opts.context === 'local') {\n let pkgMeta: any = null\n try {\n const pkgJsonPath = path.join(opts.cwd || process.cwd(), 'package.json')\n const raw = await readFile(pkgJsonPath, 'utf8')\n pkgMeta = JSON.parse(raw)\n } catch {\n // Ignore errors reading/parsing package.json; fall back to undefined metadata\n void 0\n }\n if (pkgMeta?.name) report.project_name = pkgMeta.name\n if (pkgMeta?.version) report.project_version = pkgMeta.version\n\n const depsObj = tree?.dependencies as Record<string, any> | undefined\n const items = toPkgArray(depsObj)\n const devKeys = new Set(Object.keys((pkgMeta?.devDependencies as Record<string, string>) || {}))\n\n for (const { name, node } of items) {\n const version = (node && node.version) || ''\n const resolvedPath =\n (node && node.path) || path.join(opts.cwd || process.cwd(), 'node_modules', name)\n const pkg: PackageInfo = { name, version, resolved_path: resolvedPath }\n if (devKeys.has(name)) {\n report.local_dev_dependencies.push(pkg)\n } else {\n report.local_dependencies.push(pkg)\n }\n }\n\n report.local_dependencies.sort((a, b) => a.name.localeCompare(b.name))\n report.local_dev_dependencies.sort((a, b) => a.name.localeCompare(b.name))\n } else if (opts.context === 'global') {\n const depsObj = tree?.dependencies as Record<string, any> | undefined\n const items = toPkgArray(depsObj)\n\n for (const { name, node } of items) {\n const version = (node && node.version) || ''\n const resolvedPath = (node && node.path) || path.join(opts.globalRoot || '', name)\n const pkg: PackageInfo = { name, version, resolved_path: resolvedPath }\n report.global_packages.push(pkg)\n }\n\n report.global_packages.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n if (opts.includeTree) {\n report.tree = tree\n }\n\n return report\n}\n","/**\n * @fileoverview CLI utility functions for version handling and path resolution\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Gets the path to package.json for version resolution\n */\nexport function getPkgJsonPath(): string {\n try {\n const __filename = fileURLToPath((import.meta as any).url)\n const __dirnameLocal = path.dirname(__filename)\n return path.resolve(__dirnameLocal, '..', '..', 'package.json')\n } catch {\n const dir = typeof __dirname !== 'undefined' ? __dirname : process.cwd()\n return path.resolve(dir, '..', 'package.json')\n }\n}\n\n/**\n * Gets the current tool version from package.json\n */\nexport async function getToolVersion(): Promise<string> {\n try {\n const pkgPath = getPkgJsonPath()\n const raw = await readFile(pkgPath, 'utf8')\n const pkg = JSON.parse(raw)\n return pkg.version || '0.0.0'\n } catch {\n return '0.0.0'\n }\n}\n\n/**\n * ASCII banner for the CLI\n */\nexport const ASCII_BANNER = String.raw`\n ________ __\n / _____/ ____ _____/ |_ ____ ____\n/ \\ ___ / _ \\ / _ \\ __\\/ __ \\ / \\\n\\ \\_\\ ( <_> | <_> ) | \\ ___/| | \\\n \\______ /\\____/ \\____/|__| \\___ >___| /\n \\/ \\/ \\/\n GEX\n`\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,IAAAA,oBAAiB;AAEjB,uBAAwB;;;ACGxB,eAAe,mBAMb;AACA,QAAM,EAAE,SAAS,IAAI,MAAM,OAAO,eAAoB;AACtD,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,MAAW;AAC9C,SAAO,UAAU,QAAQ;AAC3B;AASA,eAAsB,kBAAkB,QAAgB,KAA4B;AAClF,QAAM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AAQ,MAAM,4BAA4B,UAAU,KAAK,KAAK,WAAW,GAAG,EAAE;AAC9E,cAAQ,MAAM,IAAI;AAClB,cAAQ,WAAW;AAAA,IACrB;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAOA,eAAsB,gBAAkC;AACtD,QAAM,UAAU,IAAI,yBAAQ,EACzB,KAAK,KAAK,EACV,YAAY,4EAA4E,EACxF,QAAQ,MAAM,eAAe,CAAC;AAEjC,UAAQ,YAAY,aAAa;AAAA,EAAK,YAAY,EAAE;AAEpD,qBAAmB,OAAO;AAC1B,sBAAoB,OAAO;AAC3B,oBAAkB,OAAO;AAEzB,SAAO;AACT;;;AD9KA,IAAAC,eAAA;AAWA,eAAsB,IAAI,OAAO,QAAQ,MAAqB;AAC5D,QAAM,UAAU,MAAM,cAAc;AACpC,QAAM,QAAQ,WAAW,IAAI;AAC/B;AAEA,IAAM,gBAAgB,MAAM;AAC1B,MAAI;AACF,QAAI,OAAO,YAAY,eAAe,OAAO,WAAW,aAAa;AACnE,aAAQ,QAAgB,SAAS;AAAA,IACnC;AAEA,QAAI,OAAOA,iBAAgB,aAAa;AACtC,aAAOA,aAAY,QAAQ,UAAU,QAAQ,KAAK,CAAC,CAAC;AAAA,IACtD;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF,GAAG;AAEH,IAAI,cAAc;AAChB,MAAI,EAAE,MAAM,CAAC,UAAU;AACrB,YAAQ,MAAM,cAAc,KAAK;AACjC,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["import_node_path","path","import_node_path","path","import_promises","import_node_path","getExecFileAsync","import_node_path","import_promises","path","import_promises","import_node_path","path","path","path","import_meta"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/cli/commands.ts","../src/cli/install.ts","../src/cli/output.ts","../src/report/json.ts","../src/report/md.ts","../src/report/html.ts","../src/cli/parser.ts","../src/cli/report.ts","../src/npm.ts","../src/transform.ts","../src/cli/utils.ts"],"sourcesContent":["/**\n * @fileoverview Main CLI entry point for GEX dependency auditing tool\n */\n\nimport { createProgram } from './cli/commands.js'\n\n/**\n * Main CLI runner function\n *\n * @param argv - Command line arguments (defaults to process.argv)\n */\nexport async function run(argv = process.argv): Promise<void> {\n const program = await createProgram()\n await program.parseAsync(argv)\n}\n\nconst isMainModule = (() => {\n try {\n if (typeof require !== 'undefined' && typeof module !== 'undefined') {\n return (require as any).main === module\n }\n\n if (typeof import.meta !== 'undefined') {\n return import.meta.url === `file://${process.argv[1]}`\n }\n return false\n } catch {\n return false\n }\n})()\n\nif (isMainModule) {\n run().catch((error) => {\n console.error('CLI error:', error)\n process.exitCode = 1\n })\n}\n","/**\n * @fileoverview CLI command definitions and handlers\n */\n\nimport path from 'node:path'\n\nimport { Command } from 'commander'\n\nimport type { OutputFormat } from '../types.js'\n\nimport { installFromReport, printFromReport } from './install.js'\nimport { outputReport } from './output.js'\nimport { isMarkdownReportFile, loadReportFromFile } from './parser.js'\nimport { produceReport } from './report.js'\nimport { ASCII_BANNER, getToolVersion } from './utils.js'\n\n/**\n * Adds common options to a command\n *\n * @param cmd - Command to add options to\n * @param options - Configuration for which options to add\n * @returns Modified command\n */\nfunction addCommonOptions(cmd: Command, { allowOmitDev }: { allowOmitDev: boolean }): Command {\n cmd\n .option(\n '-f, --output-format <format>',\n 'Output format: json, md, or html',\n (val) => {\n if (val === 'md') return 'md'\n if (val === 'html') return 'html'\n return 'json'\n },\n 'json',\n )\n .option('-o, --out-file <path>', 'Write report to file')\n .option('--full-tree', 'Include full npm ls tree (omit depth=0 default)', false)\n\n if (allowOmitDev) {\n cmd.option('--omit-dev', 'Exclude devDependencies (local only)', false)\n }\n\n return cmd\n}\n\n/**\n * Creates the local command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createLocalCommand(program: Command): Command {\n const localCmd = program\n .command('local', { isDefault: true })\n .description(\"Generate a report for the current project's dependencies\")\n\n addCommonOptions(localCmd, { allowOmitDev: true })\n\n localCmd.action(async (opts) => {\n const outputFormat = (opts.outputFormat ?? 'json') as OutputFormat\n const outFile = opts.outFile as string | undefined\n const fullTree = Boolean(opts.fullTree)\n const omitDev = Boolean(opts.omitDev)\n\n // Only set finalOutFile when explicitly provided via --out-file\n const finalOutFile = outFile\n\n const { report, markdownExtras } = await produceReport('local', {\n outputFormat,\n outFile: finalOutFile,\n fullTree,\n omitDev,\n })\n\n await outputReport(report, outputFormat, finalOutFile, markdownExtras)\n })\n\n return localCmd\n}\n\n/**\n * Creates the global command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createGlobalCommand(program: Command): Command {\n const globalCmd = program\n .command('global')\n .description('Generate a report of globally installed packages')\n\n addCommonOptions(globalCmd, { allowOmitDev: false })\n\n globalCmd.action(async (opts) => {\n const outputFormat = (opts.outputFormat ?? 'json') as OutputFormat\n const outFile = opts.outFile as string | undefined\n const fullTree = Boolean(opts.fullTree)\n\n // Only set finalOutFile when explicitly provided via --out-file\n const finalOutFile = outFile\n\n const { report, markdownExtras } = await produceReport('global', {\n outputFormat,\n outFile: finalOutFile,\n fullTree,\n })\n\n await outputReport(report, outputFormat, finalOutFile, markdownExtras)\n })\n\n return globalCmd\n}\n\n/**\n * Creates the read command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createReadCommand(program: Command): Command {\n const readCmd = program\n .command('read')\n .description(\n 'Read a previously generated report (JSON or Markdown) and either print package names or install them',\n )\n .argument('[report]', 'Path to report file (JSON or Markdown)', 'gex-report.json')\n .option('-r, --report <path>', 'Path to report file (JSON or Markdown)')\n .option('-p, --print', 'Print package names/versions from the report (default)', false)\n .option('-i, --install', 'Install packages from the report', false)\n\n readCmd.action(async (reportArg: string | undefined, opts: any) => {\n const chosen = (opts.report as string | undefined) || reportArg || 'gex-report.json'\n const reportPath = path.resolve(process.cwd(), chosen)\n\n try {\n const parsed = await loadReportFromFile(reportPath)\n\n const doInstall = Boolean(opts.install)\n const doPrint = Boolean(opts.print) || !doInstall\n\n if (doPrint) {\n printFromReport(parsed)\n }\n if (doInstall) {\n await installFromReport(parsed, process.cwd())\n }\n } catch (err: any) {\n const isMd = isMarkdownReportFile(reportPath)\n const hint = isMd\n ? 'Try generating a JSON report with: gex global -f json -o global.json, then: gex read global.json'\n : 'Specify a report path with: gex read <path-to-report.json>'\n console.error(`Failed to read report at ${reportPath}: ${err?.message || err}`)\n console.error(hint)\n process.exitCode = 1\n }\n })\n\n return readCmd\n}\n\n/**\n * Creates and configures the main CLI program\n *\n * @returns Configured Commander program\n */\nexport async function createProgram(): Promise<Command> {\n const program = new Command()\n .name('gex')\n .description('GEX: Dependency auditing and documentation for Node.js (local and global).')\n .version(await getToolVersion())\n\n program.addHelpText('beforeAll', `\\n${ASCII_BANNER}`)\n\n createLocalCommand(program)\n createGlobalCommand(program)\n createReadCommand(program)\n\n return program\n}\n","/**\n * @fileoverview Package installation utilities for CLI\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Lazily obtain a promisified execFile so tests can mock built-ins reliably.\n */\nasync function getExecFileAsync(): Promise<\n (\n command: string,\n args?: readonly string[] | null,\n options?: any,\n ) => Promise<{ stdout: string; stderr: string }>\n> {\n const { execFile } = await import('node:child_process')\n const { promisify } = await import('node:util')\n return promisify(execFile) as any\n}\n\n/**\n * Installs packages from a report to the local environment\n *\n * @param report - The report containing packages to install\n * @param cwd - Current working directory for installation\n * @throws {Error} If npm installation fails\n */\nexport async function installFromReport(report: Report, cwd: string): Promise<void> {\n const globalPkgs = report.global_packages.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n const localPkgs = report.local_dependencies.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n const devPkgs = report.local_dev_dependencies.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n\n if (globalPkgs.length === 0 && localPkgs.length === 0 && devPkgs.length === 0) {\n console.log('No packages to install from report.')\n return\n }\n\n // Acquire execFileAsync once per run to keep logs grouped, while still mockable in tests\n const execFileAsync = await getExecFileAsync()\n\n if (globalPkgs.length > 0) {\n console.log(`Installing global: ${globalPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', '-g', ...globalPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n\n if (localPkgs.length > 0) {\n console.log(`Installing local deps: ${localPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', ...localPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n\n if (devPkgs.length > 0) {\n console.log(`Installing local devDeps: ${devPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', '-D', ...devPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n}\n\n/**\n * Prints packages from a report to the console\n *\n * @param report - The report to print packages from\n */\nexport function printFromReport(report: Report): void {\n const lines: string[] = []\n\n if (report.global_packages.length > 0) {\n lines.push('Global Packages:')\n for (const p of report.global_packages) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (report.local_dependencies.length > 0) {\n if (lines.length) lines.push('')\n lines.push('Local Dependencies:')\n for (const p of report.local_dependencies) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (report.local_dev_dependencies.length > 0) {\n if (lines.length) lines.push('')\n lines.push('Local Dev Dependencies:')\n for (const p of report.local_dev_dependencies) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (lines.length === 0) {\n lines.push('(no packages found in report)')\n }\n\n console.log(lines.join('\\n'))\n}\n","/**\n * @fileoverview Report output utilities for CLI\n */\n\nimport path from 'node:path'\n\nimport { renderJson } from '../report/json.js'\nimport { renderMarkdown } from '../report/md.js'\nimport { renderHtml } from '../report/html.js'\nimport type { OutputFormat, Report } from '../types.js'\n\n/**\n * Outputs a report to console or file\n *\n * @param report - The report to output\n * @param format - Output format ('json' or 'md')\n * @param outFile - Optional file path to write to\n * @param markdownExtras - Additional metadata for markdown rendering\n */\nexport async function outputReport(\n report: Report,\n format: OutputFormat,\n outFile?: string,\n markdownExtras?: any,\n): Promise<void> {\n const content =\n format === 'json'\n ? renderJson(report)\n : format === 'html'\n ? renderHtml({ ...report, ...(markdownExtras || {}) })\n : renderMarkdown({ ...report, ...(markdownExtras || {}) })\n\n if (outFile) {\n const outDir = path.dirname(outFile)\n const { mkdir, writeFile } = await import('node:fs/promises')\n\n await mkdir(outDir, { recursive: true })\n await writeFile(outFile, content, 'utf8')\n\n console.log(`Wrote report to ${outFile}`)\n } else {\n console.log(content)\n }\n}\n","/**\n * @fileoverview JSON report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Renders a Report object as formatted JSON string\n *\n * @param report - Report object to render\n * @returns Pretty-printed JSON string with consistent package ordering\n *\n * @example\n * ```typescript\n * import { renderJson } from './report/json.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * global_packages: [],\n * local_dependencies: [{ name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }],\n * local_dev_dependencies: []\n * }\n *\n * const jsonOutput = renderJson(report)\n * console.log(jsonOutput) // Pretty-printed JSON\n * ```\n */\nexport function renderJson(report: Report): string {\n const r: Report = {\n ...report,\n global_packages: [...report.global_packages].sort((a, b) => a.name.localeCompare(b.name)),\n local_dependencies: [...report.local_dependencies].sort((a, b) => a.name.localeCompare(b.name)),\n local_dev_dependencies: [...report.local_dev_dependencies].sort((a, b) =>\n a.name.localeCompare(b.name),\n ),\n }\n return JSON.stringify(r, null, 2)\n}\n","/**\n * @fileoverview Markdown report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Creates a markdown table from headers and row data\n *\n * @param headers - Array of table header strings\n * @param rows - Array of row data (each row is array of strings)\n * @returns Formatted markdown table string\n */\nfunction table(headers: string[], rows: string[][]): string {\n const header = `| ${headers.join(' | ')} |`\n const sep = `| ${headers.map(() => '---').join(' | ')} |`\n const body = rows.map((r) => `| ${r.join(' | ')} |`).join('\\n')\n return [header, sep, body].filter(Boolean).join('\\n')\n}\n\n/**\n * Renders a Report object as formatted Markdown\n *\n * @param report - Report object with optional project metadata\n * @returns Formatted Markdown string with tables and sections\n *\n * @example\n * ```typescript\n * import { renderMarkdown } from './report/md.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * project_name: 'my-project',\n * global_packages: [],\n * local_dependencies: [\n * { name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }\n * ],\n * local_dev_dependencies: [],\n * project_description: 'My awesome project'\n * }\n *\n * const markdown = renderMarkdown(report)\n * console.log(markdown) // Formatted markdown with tables\n * ```\n */\nexport function renderMarkdown(\n report: Report & {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n },\n): string {\n const lines: string[] = []\n lines.push('# GEX Report')\n lines.push('')\n\n if (\n report.project_name ||\n report.project_version ||\n (report as any).project_description ||\n (report as any).project_homepage ||\n (report as any).project_bugs\n ) {\n lines.push('## Project Metadata')\n if (report.project_name) lines.push(`- Name: ${report.project_name}`)\n if (report.project_version) lines.push(`- Version: ${report.project_version}`)\n if ((report as any).project_description)\n lines.push(`- Description: ${(report as any).project_description}`)\n if ((report as any).project_homepage)\n lines.push(`- Homepage: ${(report as any).project_homepage}`)\n if ((report as any).project_bugs) lines.push(`- Bugs: ${(report as any).project_bugs}`)\n lines.push('')\n }\n\n if (report.global_packages.length > 0) {\n lines.push('## Global Packages')\n const rows = report.global_packages.map((p) => [p.name, p.version || '', p.resolved_path || ''])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n if (report.local_dependencies.length > 0) {\n lines.push('## Local Dependencies')\n const rows = report.local_dependencies.map((p) => [\n p.name,\n p.version || '',\n p.resolved_path || '',\n ])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n if (report.local_dev_dependencies.length > 0) {\n lines.push('## Local Dev Dependencies')\n const rows = report.local_dev_dependencies.map((p) => [\n p.name,\n p.version || '',\n p.resolved_path || '',\n ])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n lines.push('---')\n lines.push('_Generated by GEX_')\n\n return lines.join('\\n')\n}\n","/**\n * @fileoverview HTML report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Creates an HTML table from headers and row data\n *\n * @param headers - Array of table header strings\n * @param rows - Array of row data (each row is array of strings)\n * @returns HTML table string\n */\nfunction table(headers: string[], rows: string[][]): string {\n const headerHtml = `<tr>${headers.map((h) => `<th>${h}</th>`).join('')}</tr>`\n const bodyHtml = rows\n .map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join('')}</tr>`)\n .join('')\n return `<table><thead>${headerHtml}</thead><tbody>${bodyHtml}</tbody></table>`\n}\n\n/**\n * Escapes HTML entities in a string\n *\n * @param text - Text to escape\n * @returns HTML-escaped string\n */\nfunction escapeHtml(text: string): string {\n const htmlEntities: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;',\n }\n return text.replace(/[&<>\"']/g, (char) => htmlEntities[char])\n}\n\n/**\n * Renders a Report object as formatted HTML\n *\n * @param report - Report object with optional project metadata\n * @returns Formatted HTML string with tables and styling\n *\n * @example\n * ```typescript\n * import { renderHtml } from './report/html.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * project_name: 'my-project',\n * global_packages: [],\n * local_dependencies: [\n * { name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }\n * ],\n * local_dev_dependencies: [],\n * }\n *\n * const html = renderHtml(report)\n * console.log(html) // Formatted HTML with tables\n * ```\n */\nexport function renderHtml(\n report: Report & {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n },\n): string {\n const hasProjectMeta =\n report.project_name ||\n report.project_version ||\n (report as any).project_description ||\n (report as any).project_homepage ||\n (report as any).project_bugs\n\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>GEX Report - ${report.project_name || 'Dependency Audit'}</title>\n <style>\n body {\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n line-height: 1.6;\n color: #333;\n max-width: 1200px;\n margin: 0 auto;\n padding: 20px;\n background-color: #f5f5f5;\n }\n .container {\n background: white;\n border-radius: 8px;\n box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n padding: 30px;\n }\n h1 {\n color: #2c3e50;\n border-bottom: 3px solid #3498db;\n padding-bottom: 10px;\n margin-top: 0;\n }\n h2 {\n color: #34495e;\n border-bottom: 2px solid #bdc3c7;\n padding-bottom: 8px;\n margin-top: 40px;\n margin-bottom: 20px;\n }\n .metadata {\n background: #ecf0f1;\n border-radius: 6px;\n padding: 20px;\n margin-bottom: 20px;\n }\n .metadata dl {\n margin: 0;\n }\n .metadata dt {\n font-weight: bold;\n color: #2c3e50;\n margin-top: 10px;\n }\n .metadata dt:first-child {\n margin-top: 0;\n }\n .metadata dd {\n margin: 5px 0 0 20px;\n color: #555;\n }\n .metadata dd a {\n color: #3498db;\n text-decoration: none;\n }\n .metadata dd a:hover {\n text-decoration: underline;\n }\n table {\n width: 100%;\n border-collapse: collapse;\n margin-bottom: 30px;\n background: white;\n border-radius: 6px;\n overflow: hidden;\n box-shadow: 0 1px 3px rgba(0,0,0,0.1);\n }\n th {\n background: #3498db;\n color: white;\n padding: 12px;\n text-align: left;\n font-weight: 600;\n }\n td {\n padding: 12px;\n border-bottom: 1px solid #ecf0f1;\n font-family: 'SFMono-Regular', Consolas, monospace;\n font-size: 14px;\n }\n tr:nth-child(even) {\n background: #f8f9fa;\n }\n tr:hover {\n background: #e8f4fd;\n }\n .footer {\n text-align: center;\n color: #7f8c8d;\n font-size: 14px;\n margin-top: 40px;\n padding-top: 20px;\n border-top: 1px solid #ecf0f1;\n }\n .footer strong {\n color: #2c3e50;\n }\n .no-data {\n text-align: center;\n color: #7f8c8d;\n font-style: italic;\n padding: 40px;\n }\n .timestamp {\n color: #95a5a6;\n font-size: 14px;\n margin-top: 10px;\n }\n </style>\n</head>\n<body>\n <div class=\"container\">\n <h1>GEX Dependency Report</h1>\n\n ${\n hasProjectMeta\n ? `\n <section class=\"metadata\">\n <h2>Project Information</h2>\n <dl>\n ${report.project_name ? `<dt>Project Name</dt><dd>${escapeHtml(report.project_name)}</dd>` : ''}\n ${report.project_version ? `<dt>Version</dt><dd>${escapeHtml(report.project_version)}</dd>` : ''}\n ${(report as any).project_description ? `<dt>Description</dt><dd>${escapeHtml((report as any).project_description)}</dd>` : ''}\n ${(report as any).project_homepage ? `<dt>Homepage</dt><dd><a href=\"${escapeHtml((report as any).project_homepage)}\" target=\"_blank\">${escapeHtml((report as any).project_homepage)}</a></dd>` : ''}\n ${(report as any).project_bugs ? `<dt>Bugs</dt><dd><a href=\"${escapeHtml((report as any).project_bugs)}\" target=\"_blank\">${escapeHtml((report as any).project_bugs)}</a></dd>` : ''}\n <dt>Report Generated</dt><dd>${new Date(report.timestamp).toLocaleString()}</dd>\n </dl>\n </section>\n `\n : ''\n }\n\n ${\n report.global_packages.length > 0\n ? `\n <section>\n <h2>Global Packages <small>(${report.global_packages.length})</small></h2>\n ${table(\n ['Name', 'Version', 'Path'],\n report.global_packages.map((p) => [\n escapeHtml(p.name),\n escapeHtml(p.version || ''),\n escapeHtml(p.resolved_path || ''),\n ]),\n )}\n </section>\n `\n : '<section><h2>Global Packages</h2><div class=\"no-data\">No global packages found</div></section>'\n }\n\n ${\n report.local_dependencies.length > 0\n ? `\n <section>\n <h2>Local Dependencies <small>(${report.local_dependencies.length})</small></h2>\n ${table(\n ['Name', 'Version', 'Path'],\n report.local_dependencies.map((p) => [\n escapeHtml(p.name),\n escapeHtml(p.version || ''),\n escapeHtml(p.resolved_path || ''),\n ]),\n )}\n </section>\n `\n : '<section><h2>Local Dependencies</h2><div class=\"no-data\">No local dependencies found</div></section>'\n }\n\n ${\n report.local_dev_dependencies.length > 0\n ? `\n <section>\n <h2>Local Dev Dependencies <small>(${report.local_dev_dependencies.length})</small></h2>\n ${table(\n ['Name', 'Version', 'Path'],\n report.local_dev_dependencies.map((p) => [\n escapeHtml(p.name),\n escapeHtml(p.version || ''),\n escapeHtml(p.resolved_path || ''),\n ]),\n )}\n </section>\n `\n : '<section><h2>Local Dev Dependencies</h2><div class=\"no-data\">No local dev dependencies found</div></section>'\n }\n\n <footer class=\"footer\">\n <p>Generated by <strong>GEX v${escapeHtml(report.tool_version)}</strong> on ${new Date(report.timestamp).toLocaleString()}</p>\n <p>Report format version: ${escapeHtml(report.report_version)}</p>\n </footer>\n </div>\n</body>\n</html>`\n}\n","/**\n * @fileoverview Report parsing utilities for CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport type { PackageInfo, Report } from '../types.js'\n\n/**\n * Checks if a file path indicates a markdown report\n */\nexport function isMarkdownReportFile(filePath: string): boolean {\n const ext = path.extname(filePath).toLowerCase()\n return ext === '.md' || ext === '.markdown'\n}\n\n/**\n * Parses a markdown table and extracts package information\n *\n * @param lines - Array of file lines\n * @param startIndex - Index where table starts\n * @returns Array of package information\n */\nfunction parseMarkdownPackagesTable(lines: string[], startIndex: number): PackageInfo[] {\n const rows: PackageInfo[] = []\n if (!lines[startIndex] || !lines[startIndex].trim().startsWith('|')) return rows\n\n let i = startIndex + 2\n while (i < lines.length && lines[i].trim().startsWith('|')) {\n const cols = lines[i]\n .split('|')\n .map((c) => c.trim())\n .filter((_, idx, arr) => !(idx === 0 || idx === arr.length - 1))\n\n const [name = '', version = '', resolved_path = ''] = cols\n if (name) rows.push({ name, version, resolved_path })\n i++\n }\n return rows\n}\n\n/**\n * Parses a markdown report and converts it to a Report object\n *\n * @param md - Markdown content to parse\n * @returns Parsed Report object\n */\nexport function parseMarkdownReport(md: string): Report {\n const lines = md.split(/\\r?\\n/)\n\n const findSection = (title: string) =>\n lines.findIndex((l) => l.trim().toLowerCase() === `## ${title}`.toLowerCase())\n\n const parseSection = (idx: number): PackageInfo[] => {\n if (idx < 0) return []\n\n let i = idx + 1\n while (i < lines.length && !lines[i].trim().startsWith('|')) i++\n return parseMarkdownPackagesTable(lines, i)\n }\n\n const global_packages = parseSection(findSection('Global Packages'))\n const local_dependencies = parseSection(findSection('Local Dependencies'))\n const local_dev_dependencies = parseSection(findSection('Local Dev Dependencies'))\n\n const report: Report = {\n report_version: '1.0',\n timestamp: new Date().toISOString(),\n tool_version: 'unknown',\n global_packages,\n local_dependencies,\n local_dev_dependencies,\n }\n return report\n}\n\n/**\n * Loads and parses a report file (JSON or Markdown)\n *\n * @param reportPath - Path to the report file\n * @returns Parsed Report object\n * @throws {Error} If file cannot be read or parsed\n */\nexport async function loadReportFromFile(reportPath: string): Promise<Report> {\n const raw = await readFile(reportPath, 'utf8')\n\n if (isMarkdownReportFile(reportPath) || raw.startsWith('# GEX Report')) {\n return parseMarkdownReport(raw)\n }\n\n return JSON.parse(raw) as Report\n}\n","/**\n * @fileoverview Report generation utilities for CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { npmLs, npmRootGlobal } from '../npm.js'\nimport { buildReportFromNpmTree } from '../transform.js'\nimport type { OutputFormat, Report } from '../types.js'\n\nimport { getToolVersion } from './utils.js'\n\n/**\n * Options for report generation\n */\nexport interface ReportOptions {\n outputFormat: OutputFormat\n outFile?: string\n fullTree?: boolean\n omitDev?: boolean\n cwd?: string\n}\n\n/**\n * Result of report generation including markdown extras\n */\nexport interface ReportResult {\n report: Report\n markdownExtras?: {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n }\n}\n\n/**\n * Produces a dependency report for local or global context\n *\n * @param ctx - Context for report generation ('local' or 'global')\n * @param options - Report generation options\n * @returns Report and optional markdown extras\n */\nexport async function produceReport(\n ctx: 'local' | 'global',\n options: ReportOptions,\n): Promise<ReportResult> {\n const toolVersion = await getToolVersion()\n const depth0 = !options.fullTree\n const cwd = options.cwd || process.cwd()\n\n const tree = await npmLs({\n global: ctx === 'global',\n omitDev: ctx === 'local' ? Boolean(options.omitDev) : false,\n depth0,\n cwd,\n })\n\n let project_description: string | undefined\n let project_homepage: string | undefined\n let project_bugs: string | undefined\n\n if (ctx === 'local') {\n try {\n const pkgRaw = await readFile(path.join(cwd, 'package.json'), 'utf8')\n const pkg = JSON.parse(pkgRaw)\n project_description = pkg.description\n project_homepage = pkg.homepage\n if (typeof pkg.bugs === 'string') project_bugs = pkg.bugs\n else if (pkg.bugs && typeof pkg.bugs.url === 'string') project_bugs = pkg.bugs.url\n } catch {\n // Ignore errors reading local package.json (e.g., file missing or invalid JSON)\n void 0\n }\n }\n\n const globalRoot = ctx === 'global' ? await npmRootGlobal().catch(() => undefined) : undefined\n\n const report = await buildReportFromNpmTree(tree, {\n context: ctx,\n includeTree: Boolean(options.fullTree),\n omitDev: Boolean(options.omitDev),\n cwd,\n toolVersion,\n globalRoot,\n })\n\n const markdownExtras = { project_description, project_homepage, project_bugs }\n return { report, markdownExtras }\n}\n","/**\n * @fileoverview npm command execution utilities for dependency analysis\n */\n\n/**\n * Lazily obtain a promisified execFile so tests can mock built-ins reliably.\n */\nasync function getExecFileAsync(): Promise<\n (\n command: string,\n args?: readonly string[] | null,\n options?: any,\n ) => Promise<{ stdout: string; stderr: string }>\n> {\n const { execFile } = await import('node:child_process')\n const { promisify } = await import('node:util')\n return promisify(execFile) as any\n}\n\n/**\n * Options for npm ls command execution\n */\nexport type NpmLsOptions = {\n /** Whether to list global packages */\n global?: boolean\n /** Whether to omit devDependencies */\n omitDev?: boolean\n /** Whether to use depth=0 for faster execution */\n depth0?: boolean\n /** Current working directory for command execution */\n cwd?: string\n}\n\n/**\n * Executes npm ls command and returns parsed dependency tree\n *\n * @param options - Configuration options for npm ls command\n * @returns Promise resolving to npm dependency tree object\n * @throws {Error} If npm command fails or output cannot be parsed\n *\n * @example\n * ```typescript\n * import { npmLs } from './npm.js'\n *\n * // Get local dependencies with devDependencies omitted\n * const tree = await npmLs({ omitDev: true, depth0: true })\n *\n * // Get global packages\n * const globalTree = await npmLs({ global: true })\n * ```\n */\nexport async function npmLs(options: NpmLsOptions = {}): Promise<any> {\n const args = ['ls', '--json']\n if (options.global) args.push('--global')\n if (options.omitDev) args.push('--omit=dev')\n if (options.depth0) args.push('--depth=0')\n\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', args, {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n if (stdout && stdout.trim()) return JSON.parse(stdout)\n return {}\n } catch (err: any) {\n const stdout = err?.stdout\n if (typeof stdout === 'string' && stdout.trim()) {\n try {\n return JSON.parse(stdout)\n } catch (parseErr) {\n if (process.env.DEBUG?.includes('gex')) {\n console.warn('npm ls stdout parse failed:', parseErr)\n }\n }\n }\n const stderr = err?.stderr\n const msg = (typeof stderr === 'string' && stderr.trim()) || err?.message || 'npm ls failed'\n throw new Error(`npm ls failed: ${msg}`)\n }\n}\n\n/**\n * Gets the global npm root directory path\n *\n * @returns Promise resolving to the global npm root path\n * @throws {Error} If npm root -g command fails\n *\n * @example\n * ```typescript\n * import { npmRootGlobal } from './npm.js'\n *\n * try {\n * const globalRoot = await npmRootGlobal()\n * console.log('Global npm root:', globalRoot)\n * } catch (error) {\n * console.error('Failed to get global root:', error.message)\n * }\n * ```\n */\nexport async function npmRootGlobal(): Promise<string> {\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', ['root', '-g'])\n return stdout.trim()\n } catch (err: any) {\n const stderr = err?.stderr\n const msg =\n (typeof stderr === 'string' && stderr.trim()) || err?.message || 'npm root -g failed'\n throw new Error(`npm root -g failed: ${msg}`)\n }\n}\n","/**\n * @fileoverview Data transformation utilities for converting npm tree data into reports\n */\n\nimport path from 'node:path'\nimport { readFile } from 'node:fs/promises'\n\nimport type { PackageInfo, Report } from './types.js'\n\n/**\n * Options for report generation and normalization\n */\nexport type NormalizeOptions = {\n /** Context for report generation ('local' or 'global') */\n context: 'local' | 'global'\n /** Whether to include the full npm dependency tree */\n includeTree?: boolean\n /** Whether to omit devDependencies (local context only) */\n omitDev?: boolean\n /** Current working directory */\n cwd?: string\n /** Tool version to include in report */\n toolVersion: string\n /** Global npm root directory path */\n globalRoot?: string\n}\n\n/**\n * Converts npm dependency object to array of package entries\n *\n * @param obj - npm dependency object from npm ls output\n * @returns Array of name/node pairs for packages\n */\nfunction toPkgArray(obj: Record<string, any> | undefined | null): { name: string; node: any }[] {\n if (!obj) return []\n return Object.keys(obj)\n .map((name) => ({ name, node: obj[name] }))\n .filter((p) => p && p.node)\n}\n\n/**\n * Builds a GEX report from npm ls tree output\n *\n * @param tree - Raw npm ls command output\n * @param opts - Report generation options\n * @returns Promise resolving to a formatted Report object\n *\n * @example\n * ```typescript\n * import { buildReportFromNpmTree } from './transform.js'\n * import { npmLs } from './npm.js'\n *\n * const tree = await npmLs({ depth0: true })\n * const report = await buildReportFromNpmTree(tree, {\n * context: 'local',\n * toolVersion: '0.3.2',\n * cwd: process.cwd()\n * })\n *\n * console.log(`Found ${report.local_dependencies.length} dependencies`)\n * ```\n */\nexport async function buildReportFromNpmTree(tree: any, opts: NormalizeOptions): Promise<Report> {\n const timestamp = new Date().toISOString()\n const report: Report = {\n report_version: '1.0',\n timestamp,\n tool_version: opts.toolVersion,\n global_packages: [],\n local_dependencies: [],\n local_dev_dependencies: [],\n }\n\n if (opts.context === 'local') {\n let pkgMeta: any = null\n try {\n const pkgJsonPath = path.join(opts.cwd || process.cwd(), 'package.json')\n const raw = await readFile(pkgJsonPath, 'utf8')\n pkgMeta = JSON.parse(raw)\n } catch {\n // Ignore errors reading/parsing package.json; fall back to undefined metadata\n void 0\n }\n if (pkgMeta?.name) report.project_name = pkgMeta.name\n if (pkgMeta?.version) report.project_version = pkgMeta.version\n\n const depsObj = tree?.dependencies as Record<string, any> | undefined\n const items = toPkgArray(depsObj)\n const devKeys = new Set(Object.keys((pkgMeta?.devDependencies as Record<string, string>) || {}))\n\n for (const { name, node } of items) {\n const version = (node && node.version) || ''\n const resolvedPath =\n (node && node.path) || path.join(opts.cwd || process.cwd(), 'node_modules', name)\n const pkg: PackageInfo = { name, version, resolved_path: resolvedPath }\n if (devKeys.has(name)) {\n report.local_dev_dependencies.push(pkg)\n } else {\n report.local_dependencies.push(pkg)\n }\n }\n\n report.local_dependencies.sort((a, b) => a.name.localeCompare(b.name))\n report.local_dev_dependencies.sort((a, b) => a.name.localeCompare(b.name))\n } else if (opts.context === 'global') {\n const depsObj = tree?.dependencies as Record<string, any> | undefined\n const items = toPkgArray(depsObj)\n\n for (const { name, node } of items) {\n const version = (node && node.version) || ''\n const resolvedPath = (node && node.path) || path.join(opts.globalRoot || '', name)\n const pkg: PackageInfo = { name, version, resolved_path: resolvedPath }\n report.global_packages.push(pkg)\n }\n\n report.global_packages.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n if (opts.includeTree) {\n report.tree = tree\n }\n\n return report\n}\n","/**\n * @fileoverview CLI utility functions for version handling and path resolution\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Gets the path to package.json for version resolution\n */\nexport function getPkgJsonPath(): string {\n try {\n const __filename = fileURLToPath((import.meta as any).url)\n const __dirnameLocal = path.dirname(__filename)\n return path.resolve(__dirnameLocal, '..', '..', 'package.json')\n } catch {\n const dir = typeof __dirname !== 'undefined' ? __dirname : process.cwd()\n return path.resolve(dir, '..', 'package.json')\n }\n}\n\n/**\n * Gets the current tool version from package.json\n */\nexport async function getToolVersion(): Promise<string> {\n try {\n const pkgPath = getPkgJsonPath()\n const raw = await readFile(pkgPath, 'utf8')\n const pkg = JSON.parse(raw)\n return pkg.version || '0.0.0'\n } catch {\n return '0.0.0'\n }\n}\n\n/**\n * ASCII banner for the CLI\n */\nexport const ASCII_BANNER = String.raw`\n ________ __\n / _____/ ____ _____/ |_ ____ ____\n/ \\ ___ / _ \\ / _ \\ __\\/ __ \\ / \\\n\\ \\_\\ ( <_> | <_> ) | \\ ___/| | \\\n \\______ /\\____/ \\____/|__| \\___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AM,IAAI;AAClB,cAAQ,WAAW;AAAA,IACrB;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAOA,eAAsB,gBAAkC;AACtD,QAAM,UAAU,IAAI,yBAAQ,EACzB,KAAK,KAAK,EACV,YAAY,4EAA4E,EACxF,QAAQ,MAAM,eAAe,CAAC;AAEjC,UAAQ,YAAY,aAAa;AAAA,EAAK,YAAY,EAAE;AAEpD,qBAAmB,OAAO;AAC1B,sBAAoB,OAAO;AAC3B,oBAAkB,OAAO;AAEzB,SAAO;AACT;;;ADlLA,IAAAC,eAAA;AAWA,eAAsB,IAAI,OAAO,QAAQ,MAAqB;AAC5D,QAAM,UAAU,MAAM,cAAc;AACpC,QAAM,QAAQ,WAAW,IAAI;AAC/B;AAEA,IAAM,gBAAgB,MAAM;AAC1B,MAAI;AACF,QAAI,OAAO,YAAY,eAAe,OAAO,WAAW,aAAa;AACnE,aAAQ,QAAgB,SAAS;AAAA,IACnC;AAEA,QAAI,OAAOA,iBAAgB,aAAa;AACtC,aAAOA,aAAY,QAAQ,UAAU,QAAQ,KAAK,CAAC,CAAC;AAAA,IACtD;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF,GAAG;AAEH,IAAI,cAAc;AAChB,MAAI,EAAE,MAAM,CAAC,UAAU;AACrB,YAAQ,MAAM,cAAc,KAAK;AACjC,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["import_node_path","table","path","import_node_path","path","import_promises","import_node_path","getExecFileAsync","import_node_path","import_promises","path","import_promises","import_node_path","path","path","path","import_meta"]}
package/dist/cli.mjs CHANGED
@@ -135,9 +135,211 @@ function renderMarkdown(report) {
135
135
  return lines.join("\n");
136
136
  }
137
137
 
138
+ // src/report/html.ts
139
+ function table2(headers, rows) {
140
+ const headerHtml = `<tr>${headers.map((h) => `<th>${h}</th>`).join("")}</tr>`;
141
+ const bodyHtml = rows.map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join("")}</tr>`).join("");
142
+ return `<table><thead>${headerHtml}</thead><tbody>${bodyHtml}</tbody></table>`;
143
+ }
144
+ function escapeHtml(text) {
145
+ const htmlEntities = {
146
+ "&": "&amp;",
147
+ "<": "&lt;",
148
+ ">": "&gt;",
149
+ '"': "&quot;",
150
+ "'": "&#39;"
151
+ };
152
+ return text.replace(/[&<>"']/g, (char) => htmlEntities[char]);
153
+ }
154
+ function renderHtml(report) {
155
+ const hasProjectMeta = report.project_name || report.project_version || report.project_description || report.project_homepage || report.project_bugs;
156
+ return `<!DOCTYPE html>
157
+ <html lang="en">
158
+ <head>
159
+ <meta charset="UTF-8">
160
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
161
+ <title>GEX Report - ${report.project_name || "Dependency Audit"}</title>
162
+ <style>
163
+ body {
164
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
165
+ line-height: 1.6;
166
+ color: #333;
167
+ max-width: 1200px;
168
+ margin: 0 auto;
169
+ padding: 20px;
170
+ background-color: #f5f5f5;
171
+ }
172
+ .container {
173
+ background: white;
174
+ border-radius: 8px;
175
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
176
+ padding: 30px;
177
+ }
178
+ h1 {
179
+ color: #2c3e50;
180
+ border-bottom: 3px solid #3498db;
181
+ padding-bottom: 10px;
182
+ margin-top: 0;
183
+ }
184
+ h2 {
185
+ color: #34495e;
186
+ border-bottom: 2px solid #bdc3c7;
187
+ padding-bottom: 8px;
188
+ margin-top: 40px;
189
+ margin-bottom: 20px;
190
+ }
191
+ .metadata {
192
+ background: #ecf0f1;
193
+ border-radius: 6px;
194
+ padding: 20px;
195
+ margin-bottom: 20px;
196
+ }
197
+ .metadata dl {
198
+ margin: 0;
199
+ }
200
+ .metadata dt {
201
+ font-weight: bold;
202
+ color: #2c3e50;
203
+ margin-top: 10px;
204
+ }
205
+ .metadata dt:first-child {
206
+ margin-top: 0;
207
+ }
208
+ .metadata dd {
209
+ margin: 5px 0 0 20px;
210
+ color: #555;
211
+ }
212
+ .metadata dd a {
213
+ color: #3498db;
214
+ text-decoration: none;
215
+ }
216
+ .metadata dd a:hover {
217
+ text-decoration: underline;
218
+ }
219
+ table {
220
+ width: 100%;
221
+ border-collapse: collapse;
222
+ margin-bottom: 30px;
223
+ background: white;
224
+ border-radius: 6px;
225
+ overflow: hidden;
226
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
227
+ }
228
+ th {
229
+ background: #3498db;
230
+ color: white;
231
+ padding: 12px;
232
+ text-align: left;
233
+ font-weight: 600;
234
+ }
235
+ td {
236
+ padding: 12px;
237
+ border-bottom: 1px solid #ecf0f1;
238
+ font-family: 'SFMono-Regular', Consolas, monospace;
239
+ font-size: 14px;
240
+ }
241
+ tr:nth-child(even) {
242
+ background: #f8f9fa;
243
+ }
244
+ tr:hover {
245
+ background: #e8f4fd;
246
+ }
247
+ .footer {
248
+ text-align: center;
249
+ color: #7f8c8d;
250
+ font-size: 14px;
251
+ margin-top: 40px;
252
+ padding-top: 20px;
253
+ border-top: 1px solid #ecf0f1;
254
+ }
255
+ .footer strong {
256
+ color: #2c3e50;
257
+ }
258
+ .no-data {
259
+ text-align: center;
260
+ color: #7f8c8d;
261
+ font-style: italic;
262
+ padding: 40px;
263
+ }
264
+ .timestamp {
265
+ color: #95a5a6;
266
+ font-size: 14px;
267
+ margin-top: 10px;
268
+ }
269
+ </style>
270
+ </head>
271
+ <body>
272
+ <div class="container">
273
+ <h1>GEX Dependency Report</h1>
274
+
275
+ ${hasProjectMeta ? `
276
+ <section class="metadata">
277
+ <h2>Project Information</h2>
278
+ <dl>
279
+ ${report.project_name ? `<dt>Project Name</dt><dd>${escapeHtml(report.project_name)}</dd>` : ""}
280
+ ${report.project_version ? `<dt>Version</dt><dd>${escapeHtml(report.project_version)}</dd>` : ""}
281
+ ${report.project_description ? `<dt>Description</dt><dd>${escapeHtml(report.project_description)}</dd>` : ""}
282
+ ${report.project_homepage ? `<dt>Homepage</dt><dd><a href="${escapeHtml(report.project_homepage)}" target="_blank">${escapeHtml(report.project_homepage)}</a></dd>` : ""}
283
+ ${report.project_bugs ? `<dt>Bugs</dt><dd><a href="${escapeHtml(report.project_bugs)}" target="_blank">${escapeHtml(report.project_bugs)}</a></dd>` : ""}
284
+ <dt>Report Generated</dt><dd>${new Date(report.timestamp).toLocaleString()}</dd>
285
+ </dl>
286
+ </section>
287
+ ` : ""}
288
+
289
+ ${report.global_packages.length > 0 ? `
290
+ <section>
291
+ <h2>Global Packages <small>(${report.global_packages.length})</small></h2>
292
+ ${table2(
293
+ ["Name", "Version", "Path"],
294
+ report.global_packages.map((p) => [
295
+ escapeHtml(p.name),
296
+ escapeHtml(p.version || ""),
297
+ escapeHtml(p.resolved_path || "")
298
+ ])
299
+ )}
300
+ </section>
301
+ ` : '<section><h2>Global Packages</h2><div class="no-data">No global packages found</div></section>'}
302
+
303
+ ${report.local_dependencies.length > 0 ? `
304
+ <section>
305
+ <h2>Local Dependencies <small>(${report.local_dependencies.length})</small></h2>
306
+ ${table2(
307
+ ["Name", "Version", "Path"],
308
+ report.local_dependencies.map((p) => [
309
+ escapeHtml(p.name),
310
+ escapeHtml(p.version || ""),
311
+ escapeHtml(p.resolved_path || "")
312
+ ])
313
+ )}
314
+ </section>
315
+ ` : '<section><h2>Local Dependencies</h2><div class="no-data">No local dependencies found</div></section>'}
316
+
317
+ ${report.local_dev_dependencies.length > 0 ? `
318
+ <section>
319
+ <h2>Local Dev Dependencies <small>(${report.local_dev_dependencies.length})</small></h2>
320
+ ${table2(
321
+ ["Name", "Version", "Path"],
322
+ report.local_dev_dependencies.map((p) => [
323
+ escapeHtml(p.name),
324
+ escapeHtml(p.version || ""),
325
+ escapeHtml(p.resolved_path || "")
326
+ ])
327
+ )}
328
+ </section>
329
+ ` : '<section><h2>Local Dev Dependencies</h2><div class="no-data">No local dev dependencies found</div></section>'}
330
+
331
+ <footer class="footer">
332
+ <p>Generated by <strong>GEX v${escapeHtml(report.tool_version)}</strong> on ${new Date(report.timestamp).toLocaleString()}</p>
333
+ <p>Report format version: ${escapeHtml(report.report_version)}</p>
334
+ </footer>
335
+ </div>
336
+ </body>
337
+ </html>`;
338
+ }
339
+
138
340
  // src/cli/output.ts
139
341
  async function outputReport(report, format, outFile, markdownExtras) {
140
- const content = format === "json" ? renderJson(report) : renderMarkdown({ ...report, ...markdownExtras || {} });
342
+ const content = format === "json" ? renderJson(report) : format === "html" ? renderHtml({ ...report, ...markdownExtras || {} }) : renderMarkdown({ ...report, ...markdownExtras || {} });
141
343
  if (outFile) {
142
344
  const outDir = path.dirname(outFile);
143
345
  const { mkdir, writeFile } = await import("fs/promises");
@@ -384,8 +586,12 @@ async function produceReport(ctx, options) {
384
586
  function addCommonOptions(cmd, { allowOmitDev }) {
385
587
  cmd.option(
386
588
  "-f, --output-format <format>",
387
- "Output format: md or json",
388
- (val) => val === "md" ? "md" : "json",
589
+ "Output format: json, md, or html",
590
+ (val) => {
591
+ if (val === "md") return "md";
592
+ if (val === "html") return "html";
593
+ return "json";
594
+ },
389
595
  "json"
390
596
  ).option("-o, --out-file <path>", "Write report to file").option("--full-tree", "Include full npm ls tree (omit depth=0 default)", false);
391
597
  if (allowOmitDev) {
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli/commands.ts","../src/cli/install.ts","../src/cli/output.ts","../src/report/json.ts","../src/report/md.ts","../src/cli/parser.ts","../src/cli/report.ts","../src/npm.ts","../src/transform.ts","../src/cli/utils.ts","../src/cli.ts"],"sourcesContent":["/**\n * @fileoverview CLI command definitions and handlers\n */\n\nimport path from 'node:path'\n\nimport { Command } from 'commander'\n\nimport type { OutputFormat } from '../types.js'\n\nimport { installFromReport, printFromReport } from './install.js'\nimport { outputReport } from './output.js'\nimport { isMarkdownReportFile, loadReportFromFile } from './parser.js'\nimport { produceReport } from './report.js'\nimport { ASCII_BANNER, getToolVersion } from './utils.js'\n\n/**\n * Adds common options to a command\n *\n * @param cmd - Command to add options to\n * @param options - Configuration for which options to add\n * @returns Modified command\n */\nfunction addCommonOptions(cmd: Command, { allowOmitDev }: { allowOmitDev: boolean }): Command {\n cmd\n .option(\n '-f, --output-format <format>',\n 'Output format: md or json',\n (val) => (val === 'md' ? 'md' : 'json'),\n 'json',\n )\n .option('-o, --out-file <path>', 'Write report to file')\n .option('--full-tree', 'Include full npm ls tree (omit depth=0 default)', false)\n\n if (allowOmitDev) {\n cmd.option('--omit-dev', 'Exclude devDependencies (local only)', false)\n }\n\n return cmd\n}\n\n/**\n * Creates the local command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createLocalCommand(program: Command): Command {\n const localCmd = program\n .command('local', { isDefault: true })\n .description(\"Generate a report for the current project's dependencies\")\n\n addCommonOptions(localCmd, { allowOmitDev: true })\n\n localCmd.action(async (opts) => {\n const outputFormat = (opts.outputFormat ?? 'json') as OutputFormat\n const outFile = opts.outFile as string | undefined\n const fullTree = Boolean(opts.fullTree)\n const omitDev = Boolean(opts.omitDev)\n\n // Only set finalOutFile when explicitly provided via --out-file\n const finalOutFile = outFile\n\n const { report, markdownExtras } = await produceReport('local', {\n outputFormat,\n outFile: finalOutFile,\n fullTree,\n omitDev,\n })\n\n await outputReport(report, outputFormat, finalOutFile, markdownExtras)\n })\n\n return localCmd\n}\n\n/**\n * Creates the global command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createGlobalCommand(program: Command): Command {\n const globalCmd = program\n .command('global')\n .description('Generate a report of globally installed packages')\n\n addCommonOptions(globalCmd, { allowOmitDev: false })\n\n globalCmd.action(async (opts) => {\n const outputFormat = (opts.outputFormat ?? 'json') as OutputFormat\n const outFile = opts.outFile as string | undefined\n const fullTree = Boolean(opts.fullTree)\n\n // Only set finalOutFile when explicitly provided via --out-file\n const finalOutFile = outFile\n\n const { report, markdownExtras } = await produceReport('global', {\n outputFormat,\n outFile: finalOutFile,\n fullTree,\n })\n\n await outputReport(report, outputFormat, finalOutFile, markdownExtras)\n })\n\n return globalCmd\n}\n\n/**\n * Creates the read command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createReadCommand(program: Command): Command {\n const readCmd = program\n .command('read')\n .description(\n 'Read a previously generated report (JSON or Markdown) and either print package names or install them',\n )\n .argument('[report]', 'Path to report file (JSON or Markdown)', 'gex-report.json')\n .option('-r, --report <path>', 'Path to report file (JSON or Markdown)')\n .option('-p, --print', 'Print package names/versions from the report (default)', false)\n .option('-i, --install', 'Install packages from the report', false)\n\n readCmd.action(async (reportArg: string | undefined, opts: any) => {\n const chosen = (opts.report as string | undefined) || reportArg || 'gex-report.json'\n const reportPath = path.resolve(process.cwd(), chosen)\n\n try {\n const parsed = await loadReportFromFile(reportPath)\n\n const doInstall = Boolean(opts.install)\n const doPrint = Boolean(opts.print) || !doInstall\n\n if (doPrint) {\n printFromReport(parsed)\n }\n if (doInstall) {\n await installFromReport(parsed, process.cwd())\n }\n } catch (err: any) {\n const isMd = isMarkdownReportFile(reportPath)\n const hint = isMd\n ? 'Try generating a JSON report with: gex global -f json -o global.json, then: gex read global.json'\n : 'Specify a report path with: gex read <path-to-report.json>'\n console.error(`Failed to read report at ${reportPath}: ${err?.message || err}`)\n console.error(hint)\n process.exitCode = 1\n }\n })\n\n return readCmd\n}\n\n/**\n * Creates and configures the main CLI program\n *\n * @returns Configured Commander program\n */\nexport async function createProgram(): Promise<Command> {\n const program = new Command()\n .name('gex')\n .description('GEX: Dependency auditing and documentation for Node.js (local and global).')\n .version(await getToolVersion())\n\n program.addHelpText('beforeAll', `\\n${ASCII_BANNER}`)\n\n createLocalCommand(program)\n createGlobalCommand(program)\n createReadCommand(program)\n\n return program\n}\n","/**\n * @fileoverview Package installation utilities for CLI\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Lazily obtain a promisified execFile so tests can mock built-ins reliably.\n */\nasync function getExecFileAsync(): Promise<\n (\n command: string,\n args?: readonly string[] | null,\n options?: any,\n ) => Promise<{ stdout: string; stderr: string }>\n> {\n const { execFile } = await import('node:child_process')\n const { promisify } = await import('node:util')\n return promisify(execFile) as any\n}\n\n/**\n * Installs packages from a report to the local environment\n *\n * @param report - The report containing packages to install\n * @param cwd - Current working directory for installation\n * @throws {Error} If npm installation fails\n */\nexport async function installFromReport(report: Report, cwd: string): Promise<void> {\n const globalPkgs = report.global_packages.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n const localPkgs = report.local_dependencies.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n const devPkgs = report.local_dev_dependencies.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n\n if (globalPkgs.length === 0 && localPkgs.length === 0 && devPkgs.length === 0) {\n console.log('No packages to install from report.')\n return\n }\n\n // Acquire execFileAsync once per run to keep logs grouped, while still mockable in tests\n const execFileAsync = await getExecFileAsync()\n\n if (globalPkgs.length > 0) {\n console.log(`Installing global: ${globalPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', '-g', ...globalPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n\n if (localPkgs.length > 0) {\n console.log(`Installing local deps: ${localPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', ...localPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n\n if (devPkgs.length > 0) {\n console.log(`Installing local devDeps: ${devPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', '-D', ...devPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n}\n\n/**\n * Prints packages from a report to the console\n *\n * @param report - The report to print packages from\n */\nexport function printFromReport(report: Report): void {\n const lines: string[] = []\n\n if (report.global_packages.length > 0) {\n lines.push('Global Packages:')\n for (const p of report.global_packages) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (report.local_dependencies.length > 0) {\n if (lines.length) lines.push('')\n lines.push('Local Dependencies:')\n for (const p of report.local_dependencies) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (report.local_dev_dependencies.length > 0) {\n if (lines.length) lines.push('')\n lines.push('Local Dev Dependencies:')\n for (const p of report.local_dev_dependencies) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (lines.length === 0) {\n lines.push('(no packages found in report)')\n }\n\n console.log(lines.join('\\n'))\n}\n","/**\n * @fileoverview Report output utilities for CLI\n */\n\nimport path from 'node:path'\n\nimport { renderJson } from '../report/json.js'\nimport { renderMarkdown } from '../report/md.js'\nimport type { OutputFormat, Report } from '../types.js'\n\n/**\n * Outputs a report to console or file\n *\n * @param report - The report to output\n * @param format - Output format ('json' or 'md')\n * @param outFile - Optional file path to write to\n * @param markdownExtras - Additional metadata for markdown rendering\n */\nexport async function outputReport(\n report: Report,\n format: OutputFormat,\n outFile?: string,\n markdownExtras?: any,\n): Promise<void> {\n const content =\n format === 'json'\n ? renderJson(report)\n : renderMarkdown({ ...report, ...(markdownExtras || {}) })\n\n if (outFile) {\n const outDir = path.dirname(outFile)\n const { mkdir, writeFile } = await import('node:fs/promises')\n\n await mkdir(outDir, { recursive: true })\n await writeFile(outFile, content, 'utf8')\n\n console.log(`Wrote report to ${outFile}`)\n } else {\n console.log(content)\n }\n}\n","/**\n * @fileoverview JSON report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Renders a Report object as formatted JSON string\n *\n * @param report - Report object to render\n * @returns Pretty-printed JSON string with consistent package ordering\n *\n * @example\n * ```typescript\n * import { renderJson } from './report/json.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * global_packages: [],\n * local_dependencies: [{ name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }],\n * local_dev_dependencies: []\n * }\n *\n * const jsonOutput = renderJson(report)\n * console.log(jsonOutput) // Pretty-printed JSON\n * ```\n */\nexport function renderJson(report: Report): string {\n const r: Report = {\n ...report,\n global_packages: [...report.global_packages].sort((a, b) => a.name.localeCompare(b.name)),\n local_dependencies: [...report.local_dependencies].sort((a, b) => a.name.localeCompare(b.name)),\n local_dev_dependencies: [...report.local_dev_dependencies].sort((a, b) =>\n a.name.localeCompare(b.name),\n ),\n }\n return JSON.stringify(r, null, 2)\n}\n","/**\n * @fileoverview Markdown report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Creates a markdown table from headers and row data\n *\n * @param headers - Array of table header strings\n * @param rows - Array of row data (each row is array of strings)\n * @returns Formatted markdown table string\n */\nfunction table(headers: string[], rows: string[][]): string {\n const header = `| ${headers.join(' | ')} |`\n const sep = `| ${headers.map(() => '---').join(' | ')} |`\n const body = rows.map((r) => `| ${r.join(' | ')} |`).join('\\n')\n return [header, sep, body].filter(Boolean).join('\\n')\n}\n\n/**\n * Renders a Report object as formatted Markdown\n *\n * @param report - Report object with optional project metadata\n * @returns Formatted Markdown string with tables and sections\n *\n * @example\n * ```typescript\n * import { renderMarkdown } from './report/md.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * project_name: 'my-project',\n * global_packages: [],\n * local_dependencies: [\n * { name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }\n * ],\n * local_dev_dependencies: [],\n * project_description: 'My awesome project'\n * }\n *\n * const markdown = renderMarkdown(report)\n * console.log(markdown) // Formatted markdown with tables\n * ```\n */\nexport function renderMarkdown(\n report: Report & {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n },\n): string {\n const lines: string[] = []\n lines.push('# GEX Report')\n lines.push('')\n\n if (\n report.project_name ||\n report.project_version ||\n (report as any).project_description ||\n (report as any).project_homepage ||\n (report as any).project_bugs\n ) {\n lines.push('## Project Metadata')\n if (report.project_name) lines.push(`- Name: ${report.project_name}`)\n if (report.project_version) lines.push(`- Version: ${report.project_version}`)\n if ((report as any).project_description)\n lines.push(`- Description: ${(report as any).project_description}`)\n if ((report as any).project_homepage)\n lines.push(`- Homepage: ${(report as any).project_homepage}`)\n if ((report as any).project_bugs) lines.push(`- Bugs: ${(report as any).project_bugs}`)\n lines.push('')\n }\n\n if (report.global_packages.length > 0) {\n lines.push('## Global Packages')\n const rows = report.global_packages.map((p) => [p.name, p.version || '', p.resolved_path || ''])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n if (report.local_dependencies.length > 0) {\n lines.push('## Local Dependencies')\n const rows = report.local_dependencies.map((p) => [\n p.name,\n p.version || '',\n p.resolved_path || '',\n ])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n if (report.local_dev_dependencies.length > 0) {\n lines.push('## Local Dev Dependencies')\n const rows = report.local_dev_dependencies.map((p) => [\n p.name,\n p.version || '',\n p.resolved_path || '',\n ])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n lines.push('---')\n lines.push('_Generated by GEX_')\n\n return lines.join('\\n')\n}\n","/**\n * @fileoverview Report parsing utilities for CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport type { PackageInfo, Report } from '../types.js'\n\n/**\n * Checks if a file path indicates a markdown report\n */\nexport function isMarkdownReportFile(filePath: string): boolean {\n const ext = path.extname(filePath).toLowerCase()\n return ext === '.md' || ext === '.markdown'\n}\n\n/**\n * Parses a markdown table and extracts package information\n *\n * @param lines - Array of file lines\n * @param startIndex - Index where table starts\n * @returns Array of package information\n */\nfunction parseMarkdownPackagesTable(lines: string[], startIndex: number): PackageInfo[] {\n const rows: PackageInfo[] = []\n if (!lines[startIndex] || !lines[startIndex].trim().startsWith('|')) return rows\n\n let i = startIndex + 2\n while (i < lines.length && lines[i].trim().startsWith('|')) {\n const cols = lines[i]\n .split('|')\n .map((c) => c.trim())\n .filter((_, idx, arr) => !(idx === 0 || idx === arr.length - 1))\n\n const [name = '', version = '', resolved_path = ''] = cols\n if (name) rows.push({ name, version, resolved_path })\n i++\n }\n return rows\n}\n\n/**\n * Parses a markdown report and converts it to a Report object\n *\n * @param md - Markdown content to parse\n * @returns Parsed Report object\n */\nexport function parseMarkdownReport(md: string): Report {\n const lines = md.split(/\\r?\\n/)\n\n const findSection = (title: string) =>\n lines.findIndex((l) => l.trim().toLowerCase() === `## ${title}`.toLowerCase())\n\n const parseSection = (idx: number): PackageInfo[] => {\n if (idx < 0) return []\n\n let i = idx + 1\n while (i < lines.length && !lines[i].trim().startsWith('|')) i++\n return parseMarkdownPackagesTable(lines, i)\n }\n\n const global_packages = parseSection(findSection('Global Packages'))\n const local_dependencies = parseSection(findSection('Local Dependencies'))\n const local_dev_dependencies = parseSection(findSection('Local Dev Dependencies'))\n\n const report: Report = {\n report_version: '1.0',\n timestamp: new Date().toISOString(),\n tool_version: 'unknown',\n global_packages,\n local_dependencies,\n local_dev_dependencies,\n }\n return report\n}\n\n/**\n * Loads and parses a report file (JSON or Markdown)\n *\n * @param reportPath - Path to the report file\n * @returns Parsed Report object\n * @throws {Error} If file cannot be read or parsed\n */\nexport async function loadReportFromFile(reportPath: string): Promise<Report> {\n const raw = await readFile(reportPath, 'utf8')\n\n if (isMarkdownReportFile(reportPath) || raw.startsWith('# GEX Report')) {\n return parseMarkdownReport(raw)\n }\n\n return JSON.parse(raw) as Report\n}\n","/**\n * @fileoverview Report generation utilities for CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { npmLs, npmRootGlobal } from '../npm.js'\nimport { buildReportFromNpmTree } from '../transform.js'\nimport type { OutputFormat, Report } from '../types.js'\n\nimport { getToolVersion } from './utils.js'\n\n/**\n * Options for report generation\n */\nexport interface ReportOptions {\n outputFormat: OutputFormat\n outFile?: string\n fullTree?: boolean\n omitDev?: boolean\n cwd?: string\n}\n\n/**\n * Result of report generation including markdown extras\n */\nexport interface ReportResult {\n report: Report\n markdownExtras?: {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n }\n}\n\n/**\n * Produces a dependency report for local or global context\n *\n * @param ctx - Context for report generation ('local' or 'global')\n * @param options - Report generation options\n * @returns Report and optional markdown extras\n */\nexport async function produceReport(\n ctx: 'local' | 'global',\n options: ReportOptions,\n): Promise<ReportResult> {\n const toolVersion = await getToolVersion()\n const depth0 = !options.fullTree\n const cwd = options.cwd || process.cwd()\n\n const tree = await npmLs({\n global: ctx === 'global',\n omitDev: ctx === 'local' ? Boolean(options.omitDev) : false,\n depth0,\n cwd,\n })\n\n let project_description: string | undefined\n let project_homepage: string | undefined\n let project_bugs: string | undefined\n\n if (ctx === 'local') {\n try {\n const pkgRaw = await readFile(path.join(cwd, 'package.json'), 'utf8')\n const pkg = JSON.parse(pkgRaw)\n project_description = pkg.description\n project_homepage = pkg.homepage\n if (typeof pkg.bugs === 'string') project_bugs = pkg.bugs\n else if (pkg.bugs && typeof pkg.bugs.url === 'string') project_bugs = pkg.bugs.url\n } catch {\n // Ignore errors reading local package.json (e.g., file missing or invalid JSON)\n void 0\n }\n }\n\n const globalRoot = ctx === 'global' ? await npmRootGlobal().catch(() => undefined) : undefined\n\n const report = await buildReportFromNpmTree(tree, {\n context: ctx,\n includeTree: Boolean(options.fullTree),\n omitDev: Boolean(options.omitDev),\n cwd,\n toolVersion,\n globalRoot,\n })\n\n const markdownExtras = { project_description, project_homepage, project_bugs }\n return { report, markdownExtras }\n}\n","/**\n * @fileoverview npm command execution utilities for dependency analysis\n */\n\n/**\n * Lazily obtain a promisified execFile so tests can mock built-ins reliably.\n */\nasync function getExecFileAsync(): Promise<\n (\n command: string,\n args?: readonly string[] | null,\n options?: any,\n ) => Promise<{ stdout: string; stderr: string }>\n> {\n const { execFile } = await import('node:child_process')\n const { promisify } = await import('node:util')\n return promisify(execFile) as any\n}\n\n/**\n * Options for npm ls command execution\n */\nexport type NpmLsOptions = {\n /** Whether to list global packages */\n global?: boolean\n /** Whether to omit devDependencies */\n omitDev?: boolean\n /** Whether to use depth=0 for faster execution */\n depth0?: boolean\n /** Current working directory for command execution */\n cwd?: string\n}\n\n/**\n * Executes npm ls command and returns parsed dependency tree\n *\n * @param options - Configuration options for npm ls command\n * @returns Promise resolving to npm dependency tree object\n * @throws {Error} If npm command fails or output cannot be parsed\n *\n * @example\n * ```typescript\n * import { npmLs } from './npm.js'\n *\n * // Get local dependencies with devDependencies omitted\n * const tree = await npmLs({ omitDev: true, depth0: true })\n *\n * // Get global packages\n * const globalTree = await npmLs({ global: true })\n * ```\n */\nexport async function npmLs(options: NpmLsOptions = {}): Promise<any> {\n const args = ['ls', '--json']\n if (options.global) args.push('--global')\n if (options.omitDev) args.push('--omit=dev')\n if (options.depth0) args.push('--depth=0')\n\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', args, {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n if (stdout && stdout.trim()) return JSON.parse(stdout)\n return {}\n } catch (err: any) {\n const stdout = err?.stdout\n if (typeof stdout === 'string' && stdout.trim()) {\n try {\n return JSON.parse(stdout)\n } catch (parseErr) {\n if (process.env.DEBUG?.includes('gex')) {\n console.warn('npm ls stdout parse failed:', parseErr)\n }\n }\n }\n const stderr = err?.stderr\n const msg = (typeof stderr === 'string' && stderr.trim()) || err?.message || 'npm ls failed'\n throw new Error(`npm ls failed: ${msg}`)\n }\n}\n\n/**\n * Gets the global npm root directory path\n *\n * @returns Promise resolving to the global npm root path\n * @throws {Error} If npm root -g command fails\n *\n * @example\n * ```typescript\n * import { npmRootGlobal } from './npm.js'\n *\n * try {\n * const globalRoot = await npmRootGlobal()\n * console.log('Global npm root:', globalRoot)\n * } catch (error) {\n * console.error('Failed to get global root:', error.message)\n * }\n * ```\n */\nexport async function npmRootGlobal(): Promise<string> {\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', ['root', '-g'])\n return stdout.trim()\n } catch (err: any) {\n const stderr = err?.stderr\n const msg =\n (typeof stderr === 'string' && stderr.trim()) || err?.message || 'npm root -g failed'\n throw new Error(`npm root -g failed: ${msg}`)\n }\n}\n","/**\n * @fileoverview Data transformation utilities for converting npm tree data into reports\n */\n\nimport path from 'node:path'\nimport { readFile } from 'node:fs/promises'\n\nimport type { PackageInfo, Report } from './types.js'\n\n/**\n * Options for report generation and normalization\n */\nexport type NormalizeOptions = {\n /** Context for report generation ('local' or 'global') */\n context: 'local' | 'global'\n /** Whether to include the full npm dependency tree */\n includeTree?: boolean\n /** Whether to omit devDependencies (local context only) */\n omitDev?: boolean\n /** Current working directory */\n cwd?: string\n /** Tool version to include in report */\n toolVersion: string\n /** Global npm root directory path */\n globalRoot?: string\n}\n\n/**\n * Converts npm dependency object to array of package entries\n *\n * @param obj - npm dependency object from npm ls output\n * @returns Array of name/node pairs for packages\n */\nfunction toPkgArray(obj: Record<string, any> | undefined | null): { name: string; node: any }[] {\n if (!obj) return []\n return Object.keys(obj)\n .map((name) => ({ name, node: obj[name] }))\n .filter((p) => p && p.node)\n}\n\n/**\n * Builds a GEX report from npm ls tree output\n *\n * @param tree - Raw npm ls command output\n * @param opts - Report generation options\n * @returns Promise resolving to a formatted Report object\n *\n * @example\n * ```typescript\n * import { buildReportFromNpmTree } from './transform.js'\n * import { npmLs } from './npm.js'\n *\n * const tree = await npmLs({ depth0: true })\n * const report = await buildReportFromNpmTree(tree, {\n * context: 'local',\n * toolVersion: '0.3.2',\n * cwd: process.cwd()\n * })\n *\n * console.log(`Found ${report.local_dependencies.length} dependencies`)\n * ```\n */\nexport async function buildReportFromNpmTree(tree: any, opts: NormalizeOptions): Promise<Report> {\n const timestamp = new Date().toISOString()\n const report: Report = {\n report_version: '1.0',\n timestamp,\n tool_version: opts.toolVersion,\n global_packages: [],\n local_dependencies: [],\n local_dev_dependencies: [],\n }\n\n if (opts.context === 'local') {\n let pkgMeta: any = null\n try {\n const pkgJsonPath = path.join(opts.cwd || process.cwd(), 'package.json')\n const raw = await readFile(pkgJsonPath, 'utf8')\n pkgMeta = JSON.parse(raw)\n } catch {\n // Ignore errors reading/parsing package.json; fall back to undefined metadata\n void 0\n }\n if (pkgMeta?.name) report.project_name = pkgMeta.name\n if (pkgMeta?.version) report.project_version = pkgMeta.version\n\n const depsObj = tree?.dependencies as Record<string, any> | undefined\n const items = toPkgArray(depsObj)\n const devKeys = new Set(Object.keys((pkgMeta?.devDependencies as Record<string, string>) || {}))\n\n for (const { name, node } of items) {\n const version = (node && node.version) || ''\n const resolvedPath =\n (node && node.path) || path.join(opts.cwd || process.cwd(), 'node_modules', name)\n const pkg: PackageInfo = { name, version, resolved_path: resolvedPath }\n if (devKeys.has(name)) {\n report.local_dev_dependencies.push(pkg)\n } else {\n report.local_dependencies.push(pkg)\n }\n }\n\n report.local_dependencies.sort((a, b) => a.name.localeCompare(b.name))\n report.local_dev_dependencies.sort((a, b) => a.name.localeCompare(b.name))\n } else if (opts.context === 'global') {\n const depsObj = tree?.dependencies as Record<string, any> | undefined\n const items = toPkgArray(depsObj)\n\n for (const { name, node } of items) {\n const version = (node && node.version) || ''\n const resolvedPath = (node && node.path) || path.join(opts.globalRoot || '', name)\n const pkg: PackageInfo = { name, version, resolved_path: resolvedPath }\n report.global_packages.push(pkg)\n }\n\n report.global_packages.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n if (opts.includeTree) {\n report.tree = tree\n }\n\n return report\n}\n","/**\n * @fileoverview CLI utility functions for version handling and path resolution\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Gets the path to package.json for version resolution\n */\nexport function getPkgJsonPath(): string {\n try {\n const __filename = fileURLToPath((import.meta as any).url)\n const __dirnameLocal = path.dirname(__filename)\n return path.resolve(__dirnameLocal, '..', '..', 'package.json')\n } catch {\n const dir = typeof __dirname !== 'undefined' ? __dirname : process.cwd()\n return path.resolve(dir, '..', 'package.json')\n }\n}\n\n/**\n * Gets the current tool version from package.json\n */\nexport async function getToolVersion(): Promise<string> {\n try {\n const pkgPath = getPkgJsonPath()\n const raw = await readFile(pkgPath, 'utf8')\n const pkg = JSON.parse(raw)\n return pkg.version || '0.0.0'\n } catch {\n return '0.0.0'\n }\n}\n\n/**\n * ASCII banner for the CLI\n */\nexport const ASCII_BANNER = String.raw`\n ________ __\n / _____/ ____ _____/ |_ ____ ____\n/ \\ ___ / _ \\ / _ \\ __\\/ __ \\ / \\\n\\ \\_\\ ( <_> | <_> ) | \\ ___/| | \\\n \\______ /\\____/ \\____/|__| \\___ >___| /\n \\/ \\/ \\/\n GEX\n`\n","/**\n * @fileoverview Main CLI entry point for GEX dependency auditing tool\n */\n\nimport { createProgram } from './cli/commands.js'\n\n/**\n * Main CLI runner function\n *\n * @param argv - Command line arguments (defaults to process.argv)\n */\nexport async function run(argv = process.argv): Promise<void> {\n const program = await createProgram()\n await program.parseAsync(argv)\n}\n\nconst isMainModule = (() => {\n try {\n if (typeof require !== 'undefined' && typeof module !== 'undefined') {\n return (require as any).main === module\n }\n\n if (typeof import.meta !== 'undefined') {\n return import.meta.url === `file://${process.argv[1]}`\n }\n return false\n } catch {\n return false\n }\n})()\n\nif (isMainModule) {\n run().catch((error) => {\n console.error('CLI error:', error)\n process.exitCode = 1\n })\n}\n"],"mappings":";;;;;;;;;AAIA,OAAOA,WAAU;AAEjB,SAAS,eAAe;;;ACGxB,eAAe,mBAMb;AACA,QAAM,EAAE,SAAS,IAAI,MAAM,OAAO,eAAoB;AACtD,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,MAAW;AAC9C,SAAO,UAAU,QAAQ;AAC3B;AASA,eAAsB,kBAAkB,QAAgB,KAA4B;AAClF,QAAM,aAAa,OAAO,gBAAgB,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,OAAO;AAC7F,QAAM,YAAY,OAAO,mBAAmB,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,OAAO;AAC/F,QAAM,UAAU,OAAO,uBAAuB,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,OAAO;AAEjG,MAAI,WAAW,WAAW,KAAK,UAAU,WAAW,KAAK,QAAQ,WAAW,GAAG;AAC7E,YAAQ,IAAI,qCAAqC;AACjD;AAAA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WAAW,IAAI;AAC/B;AAEA,IAAM,gBAAgB,MAAM;AAC1B,MAAI;AACF,QAAI,OAAO,cAAY,eAAe,OAAO,WAAW,aAAa;AACnE,aAAQ,UAAgB,SAAS;AAAA,IACnC;AAEA,QAAI,OAAO,gBAAgB,aAAa;AACtC,aAAO,YAAY,QAAQ,UAAU,QAAQ,KAAK,CAAC,CAAC;AAAA,IACtD;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF,GAAG;AAEH,IAAI,cAAc;AAChB,MAAI,EAAE,MAAM,CAAC,UAAU;AACrB,YAAQ,MAAM,cAAc,KAAK;AACjC,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["path","path","readFile","path","getExecFileAsync","path","readFile","readFile","path","readFile","path","path"]}
1
+ {"version":3,"sources":["../src/cli/commands.ts","../src/cli/install.ts","../src/cli/output.ts","../src/report/json.ts","../src/report/md.ts","../src/report/html.ts","../src/cli/parser.ts","../src/cli/report.ts","../src/npm.ts","../src/transform.ts","../src/cli/utils.ts","../src/cli.ts"],"sourcesContent":["/**\n * @fileoverview CLI command definitions and handlers\n */\n\nimport path from 'node:path'\n\nimport { Command } from 'commander'\n\nimport type { OutputFormat } from '../types.js'\n\nimport { installFromReport, printFromReport } from './install.js'\nimport { outputReport } from './output.js'\nimport { isMarkdownReportFile, loadReportFromFile } from './parser.js'\nimport { produceReport } from './report.js'\nimport { ASCII_BANNER, getToolVersion } from './utils.js'\n\n/**\n * Adds common options to a command\n *\n * @param cmd - Command to add options to\n * @param options - Configuration for which options to add\n * @returns Modified command\n */\nfunction addCommonOptions(cmd: Command, { allowOmitDev }: { allowOmitDev: boolean }): Command {\n cmd\n .option(\n '-f, --output-format <format>',\n 'Output format: json, md, or html',\n (val) => {\n if (val === 'md') return 'md'\n if (val === 'html') return 'html'\n return 'json'\n },\n 'json',\n )\n .option('-o, --out-file <path>', 'Write report to file')\n .option('--full-tree', 'Include full npm ls tree (omit depth=0 default)', false)\n\n if (allowOmitDev) {\n cmd.option('--omit-dev', 'Exclude devDependencies (local only)', false)\n }\n\n return cmd\n}\n\n/**\n * Creates the local command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createLocalCommand(program: Command): Command {\n const localCmd = program\n .command('local', { isDefault: true })\n .description(\"Generate a report for the current project's dependencies\")\n\n addCommonOptions(localCmd, { allowOmitDev: true })\n\n localCmd.action(async (opts) => {\n const outputFormat = (opts.outputFormat ?? 'json') as OutputFormat\n const outFile = opts.outFile as string | undefined\n const fullTree = Boolean(opts.fullTree)\n const omitDev = Boolean(opts.omitDev)\n\n // Only set finalOutFile when explicitly provided via --out-file\n const finalOutFile = outFile\n\n const { report, markdownExtras } = await produceReport('local', {\n outputFormat,\n outFile: finalOutFile,\n fullTree,\n omitDev,\n })\n\n await outputReport(report, outputFormat, finalOutFile, markdownExtras)\n })\n\n return localCmd\n}\n\n/**\n * Creates the global command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createGlobalCommand(program: Command): Command {\n const globalCmd = program\n .command('global')\n .description('Generate a report of globally installed packages')\n\n addCommonOptions(globalCmd, { allowOmitDev: false })\n\n globalCmd.action(async (opts) => {\n const outputFormat = (opts.outputFormat ?? 'json') as OutputFormat\n const outFile = opts.outFile as string | undefined\n const fullTree = Boolean(opts.fullTree)\n\n // Only set finalOutFile when explicitly provided via --out-file\n const finalOutFile = outFile\n\n const { report, markdownExtras } = await produceReport('global', {\n outputFormat,\n outFile: finalOutFile,\n fullTree,\n })\n\n await outputReport(report, outputFormat, finalOutFile, markdownExtras)\n })\n\n return globalCmd\n}\n\n/**\n * Creates the read command handler\n *\n * @param program - Commander program instance\n * @returns Command instance\n */\nexport function createReadCommand(program: Command): Command {\n const readCmd = program\n .command('read')\n .description(\n 'Read a previously generated report (JSON or Markdown) and either print package names or install them',\n )\n .argument('[report]', 'Path to report file (JSON or Markdown)', 'gex-report.json')\n .option('-r, --report <path>', 'Path to report file (JSON or Markdown)')\n .option('-p, --print', 'Print package names/versions from the report (default)', false)\n .option('-i, --install', 'Install packages from the report', false)\n\n readCmd.action(async (reportArg: string | undefined, opts: any) => {\n const chosen = (opts.report as string | undefined) || reportArg || 'gex-report.json'\n const reportPath = path.resolve(process.cwd(), chosen)\n\n try {\n const parsed = await loadReportFromFile(reportPath)\n\n const doInstall = Boolean(opts.install)\n const doPrint = Boolean(opts.print) || !doInstall\n\n if (doPrint) {\n printFromReport(parsed)\n }\n if (doInstall) {\n await installFromReport(parsed, process.cwd())\n }\n } catch (err: any) {\n const isMd = isMarkdownReportFile(reportPath)\n const hint = isMd\n ? 'Try generating a JSON report with: gex global -f json -o global.json, then: gex read global.json'\n : 'Specify a report path with: gex read <path-to-report.json>'\n console.error(`Failed to read report at ${reportPath}: ${err?.message || err}`)\n console.error(hint)\n process.exitCode = 1\n }\n })\n\n return readCmd\n}\n\n/**\n * Creates and configures the main CLI program\n *\n * @returns Configured Commander program\n */\nexport async function createProgram(): Promise<Command> {\n const program = new Command()\n .name('gex')\n .description('GEX: Dependency auditing and documentation for Node.js (local and global).')\n .version(await getToolVersion())\n\n program.addHelpText('beforeAll', `\\n${ASCII_BANNER}`)\n\n createLocalCommand(program)\n createGlobalCommand(program)\n createReadCommand(program)\n\n return program\n}\n","/**\n * @fileoverview Package installation utilities for CLI\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Lazily obtain a promisified execFile so tests can mock built-ins reliably.\n */\nasync function getExecFileAsync(): Promise<\n (\n command: string,\n args?: readonly string[] | null,\n options?: any,\n ) => Promise<{ stdout: string; stderr: string }>\n> {\n const { execFile } = await import('node:child_process')\n const { promisify } = await import('node:util')\n return promisify(execFile) as any\n}\n\n/**\n * Installs packages from a report to the local environment\n *\n * @param report - The report containing packages to install\n * @param cwd - Current working directory for installation\n * @throws {Error} If npm installation fails\n */\nexport async function installFromReport(report: Report, cwd: string): Promise<void> {\n const globalPkgs = report.global_packages.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n const localPkgs = report.local_dependencies.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n const devPkgs = report.local_dev_dependencies.map((p) => `${p.name}@${p.version}`).filter(Boolean)\n\n if (globalPkgs.length === 0 && localPkgs.length === 0 && devPkgs.length === 0) {\n console.log('No packages to install from report.')\n return\n }\n\n // Acquire execFileAsync once per run to keep logs grouped, while still mockable in tests\n const execFileAsync = await getExecFileAsync()\n\n if (globalPkgs.length > 0) {\n console.log(`Installing global: ${globalPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', '-g', ...globalPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n\n if (localPkgs.length > 0) {\n console.log(`Installing local deps: ${localPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', ...localPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n\n if (devPkgs.length > 0) {\n console.log(`Installing local devDeps: ${devPkgs.join(' ')}`)\n await execFileAsync('npm', ['i', '-D', ...devPkgs], { cwd, maxBuffer: 10 * 1024 * 1024 })\n }\n}\n\n/**\n * Prints packages from a report to the console\n *\n * @param report - The report to print packages from\n */\nexport function printFromReport(report: Report): void {\n const lines: string[] = []\n\n if (report.global_packages.length > 0) {\n lines.push('Global Packages:')\n for (const p of report.global_packages) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (report.local_dependencies.length > 0) {\n if (lines.length) lines.push('')\n lines.push('Local Dependencies:')\n for (const p of report.local_dependencies) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (report.local_dev_dependencies.length > 0) {\n if (lines.length) lines.push('')\n lines.push('Local Dev Dependencies:')\n for (const p of report.local_dev_dependencies) {\n lines.push(`- ${p.name}@${p.version}`)\n }\n }\n\n if (lines.length === 0) {\n lines.push('(no packages found in report)')\n }\n\n console.log(lines.join('\\n'))\n}\n","/**\n * @fileoverview Report output utilities for CLI\n */\n\nimport path from 'node:path'\n\nimport { renderJson } from '../report/json.js'\nimport { renderMarkdown } from '../report/md.js'\nimport { renderHtml } from '../report/html.js'\nimport type { OutputFormat, Report } from '../types.js'\n\n/**\n * Outputs a report to console or file\n *\n * @param report - The report to output\n * @param format - Output format ('json' or 'md')\n * @param outFile - Optional file path to write to\n * @param markdownExtras - Additional metadata for markdown rendering\n */\nexport async function outputReport(\n report: Report,\n format: OutputFormat,\n outFile?: string,\n markdownExtras?: any,\n): Promise<void> {\n const content =\n format === 'json'\n ? renderJson(report)\n : format === 'html'\n ? renderHtml({ ...report, ...(markdownExtras || {}) })\n : renderMarkdown({ ...report, ...(markdownExtras || {}) })\n\n if (outFile) {\n const outDir = path.dirname(outFile)\n const { mkdir, writeFile } = await import('node:fs/promises')\n\n await mkdir(outDir, { recursive: true })\n await writeFile(outFile, content, 'utf8')\n\n console.log(`Wrote report to ${outFile}`)\n } else {\n console.log(content)\n }\n}\n","/**\n * @fileoverview JSON report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Renders a Report object as formatted JSON string\n *\n * @param report - Report object to render\n * @returns Pretty-printed JSON string with consistent package ordering\n *\n * @example\n * ```typescript\n * import { renderJson } from './report/json.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * global_packages: [],\n * local_dependencies: [{ name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }],\n * local_dev_dependencies: []\n * }\n *\n * const jsonOutput = renderJson(report)\n * console.log(jsonOutput) // Pretty-printed JSON\n * ```\n */\nexport function renderJson(report: Report): string {\n const r: Report = {\n ...report,\n global_packages: [...report.global_packages].sort((a, b) => a.name.localeCompare(b.name)),\n local_dependencies: [...report.local_dependencies].sort((a, b) => a.name.localeCompare(b.name)),\n local_dev_dependencies: [...report.local_dev_dependencies].sort((a, b) =>\n a.name.localeCompare(b.name),\n ),\n }\n return JSON.stringify(r, null, 2)\n}\n","/**\n * @fileoverview Markdown report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Creates a markdown table from headers and row data\n *\n * @param headers - Array of table header strings\n * @param rows - Array of row data (each row is array of strings)\n * @returns Formatted markdown table string\n */\nfunction table(headers: string[], rows: string[][]): string {\n const header = `| ${headers.join(' | ')} |`\n const sep = `| ${headers.map(() => '---').join(' | ')} |`\n const body = rows.map((r) => `| ${r.join(' | ')} |`).join('\\n')\n return [header, sep, body].filter(Boolean).join('\\n')\n}\n\n/**\n * Renders a Report object as formatted Markdown\n *\n * @param report - Report object with optional project metadata\n * @returns Formatted Markdown string with tables and sections\n *\n * @example\n * ```typescript\n * import { renderMarkdown } from './report/md.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * project_name: 'my-project',\n * global_packages: [],\n * local_dependencies: [\n * { name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }\n * ],\n * local_dev_dependencies: [],\n * project_description: 'My awesome project'\n * }\n *\n * const markdown = renderMarkdown(report)\n * console.log(markdown) // Formatted markdown with tables\n * ```\n */\nexport function renderMarkdown(\n report: Report & {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n },\n): string {\n const lines: string[] = []\n lines.push('# GEX Report')\n lines.push('')\n\n if (\n report.project_name ||\n report.project_version ||\n (report as any).project_description ||\n (report as any).project_homepage ||\n (report as any).project_bugs\n ) {\n lines.push('## Project Metadata')\n if (report.project_name) lines.push(`- Name: ${report.project_name}`)\n if (report.project_version) lines.push(`- Version: ${report.project_version}`)\n if ((report as any).project_description)\n lines.push(`- Description: ${(report as any).project_description}`)\n if ((report as any).project_homepage)\n lines.push(`- Homepage: ${(report as any).project_homepage}`)\n if ((report as any).project_bugs) lines.push(`- Bugs: ${(report as any).project_bugs}`)\n lines.push('')\n }\n\n if (report.global_packages.length > 0) {\n lines.push('## Global Packages')\n const rows = report.global_packages.map((p) => [p.name, p.version || '', p.resolved_path || ''])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n if (report.local_dependencies.length > 0) {\n lines.push('## Local Dependencies')\n const rows = report.local_dependencies.map((p) => [\n p.name,\n p.version || '',\n p.resolved_path || '',\n ])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n if (report.local_dev_dependencies.length > 0) {\n lines.push('## Local Dev Dependencies')\n const rows = report.local_dev_dependencies.map((p) => [\n p.name,\n p.version || '',\n p.resolved_path || '',\n ])\n lines.push(table(['Name', 'Version', 'Path'], rows))\n lines.push('')\n }\n\n lines.push('---')\n lines.push('_Generated by GEX_')\n\n return lines.join('\\n')\n}\n","/**\n * @fileoverview HTML report rendering utilities\n */\n\nimport type { Report } from '../types.js'\n\n/**\n * Creates an HTML table from headers and row data\n *\n * @param headers - Array of table header strings\n * @param rows - Array of row data (each row is array of strings)\n * @returns HTML table string\n */\nfunction table(headers: string[], rows: string[][]): string {\n const headerHtml = `<tr>${headers.map((h) => `<th>${h}</th>`).join('')}</tr>`\n const bodyHtml = rows\n .map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join('')}</tr>`)\n .join('')\n return `<table><thead>${headerHtml}</thead><tbody>${bodyHtml}</tbody></table>`\n}\n\n/**\n * Escapes HTML entities in a string\n *\n * @param text - Text to escape\n * @returns HTML-escaped string\n */\nfunction escapeHtml(text: string): string {\n const htmlEntities: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;',\n }\n return text.replace(/[&<>\"']/g, (char) => htmlEntities[char])\n}\n\n/**\n * Renders a Report object as formatted HTML\n *\n * @param report - Report object with optional project metadata\n * @returns Formatted HTML string with tables and styling\n *\n * @example\n * ```typescript\n * import { renderHtml } from './report/html.js'\n *\n * const report = {\n * report_version: '1.0',\n * timestamp: new Date().toISOString(),\n * tool_version: '0.3.2',\n * project_name: 'my-project',\n * global_packages: [],\n * local_dependencies: [\n * { name: 'axios', version: '1.6.0', resolved_path: '/path/to/axios' }\n * ],\n * local_dev_dependencies: [],\n * }\n *\n * const html = renderHtml(report)\n * console.log(html) // Formatted HTML with tables\n * ```\n */\nexport function renderHtml(\n report: Report & {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n },\n): string {\n const hasProjectMeta =\n report.project_name ||\n report.project_version ||\n (report as any).project_description ||\n (report as any).project_homepage ||\n (report as any).project_bugs\n\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>GEX Report - ${report.project_name || 'Dependency Audit'}</title>\n <style>\n body {\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n line-height: 1.6;\n color: #333;\n max-width: 1200px;\n margin: 0 auto;\n padding: 20px;\n background-color: #f5f5f5;\n }\n .container {\n background: white;\n border-radius: 8px;\n box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n padding: 30px;\n }\n h1 {\n color: #2c3e50;\n border-bottom: 3px solid #3498db;\n padding-bottom: 10px;\n margin-top: 0;\n }\n h2 {\n color: #34495e;\n border-bottom: 2px solid #bdc3c7;\n padding-bottom: 8px;\n margin-top: 40px;\n margin-bottom: 20px;\n }\n .metadata {\n background: #ecf0f1;\n border-radius: 6px;\n padding: 20px;\n margin-bottom: 20px;\n }\n .metadata dl {\n margin: 0;\n }\n .metadata dt {\n font-weight: bold;\n color: #2c3e50;\n margin-top: 10px;\n }\n .metadata dt:first-child {\n margin-top: 0;\n }\n .metadata dd {\n margin: 5px 0 0 20px;\n color: #555;\n }\n .metadata dd a {\n color: #3498db;\n text-decoration: none;\n }\n .metadata dd a:hover {\n text-decoration: underline;\n }\n table {\n width: 100%;\n border-collapse: collapse;\n margin-bottom: 30px;\n background: white;\n border-radius: 6px;\n overflow: hidden;\n box-shadow: 0 1px 3px rgba(0,0,0,0.1);\n }\n th {\n background: #3498db;\n color: white;\n padding: 12px;\n text-align: left;\n font-weight: 600;\n }\n td {\n padding: 12px;\n border-bottom: 1px solid #ecf0f1;\n font-family: 'SFMono-Regular', Consolas, monospace;\n font-size: 14px;\n }\n tr:nth-child(even) {\n background: #f8f9fa;\n }\n tr:hover {\n background: #e8f4fd;\n }\n .footer {\n text-align: center;\n color: #7f8c8d;\n font-size: 14px;\n margin-top: 40px;\n padding-top: 20px;\n border-top: 1px solid #ecf0f1;\n }\n .footer strong {\n color: #2c3e50;\n }\n .no-data {\n text-align: center;\n color: #7f8c8d;\n font-style: italic;\n padding: 40px;\n }\n .timestamp {\n color: #95a5a6;\n font-size: 14px;\n margin-top: 10px;\n }\n </style>\n</head>\n<body>\n <div class=\"container\">\n <h1>GEX Dependency Report</h1>\n\n ${\n hasProjectMeta\n ? `\n <section class=\"metadata\">\n <h2>Project Information</h2>\n <dl>\n ${report.project_name ? `<dt>Project Name</dt><dd>${escapeHtml(report.project_name)}</dd>` : ''}\n ${report.project_version ? `<dt>Version</dt><dd>${escapeHtml(report.project_version)}</dd>` : ''}\n ${(report as any).project_description ? `<dt>Description</dt><dd>${escapeHtml((report as any).project_description)}</dd>` : ''}\n ${(report as any).project_homepage ? `<dt>Homepage</dt><dd><a href=\"${escapeHtml((report as any).project_homepage)}\" target=\"_blank\">${escapeHtml((report as any).project_homepage)}</a></dd>` : ''}\n ${(report as any).project_bugs ? `<dt>Bugs</dt><dd><a href=\"${escapeHtml((report as any).project_bugs)}\" target=\"_blank\">${escapeHtml((report as any).project_bugs)}</a></dd>` : ''}\n <dt>Report Generated</dt><dd>${new Date(report.timestamp).toLocaleString()}</dd>\n </dl>\n </section>\n `\n : ''\n }\n\n ${\n report.global_packages.length > 0\n ? `\n <section>\n <h2>Global Packages <small>(${report.global_packages.length})</small></h2>\n ${table(\n ['Name', 'Version', 'Path'],\n report.global_packages.map((p) => [\n escapeHtml(p.name),\n escapeHtml(p.version || ''),\n escapeHtml(p.resolved_path || ''),\n ]),\n )}\n </section>\n `\n : '<section><h2>Global Packages</h2><div class=\"no-data\">No global packages found</div></section>'\n }\n\n ${\n report.local_dependencies.length > 0\n ? `\n <section>\n <h2>Local Dependencies <small>(${report.local_dependencies.length})</small></h2>\n ${table(\n ['Name', 'Version', 'Path'],\n report.local_dependencies.map((p) => [\n escapeHtml(p.name),\n escapeHtml(p.version || ''),\n escapeHtml(p.resolved_path || ''),\n ]),\n )}\n </section>\n `\n : '<section><h2>Local Dependencies</h2><div class=\"no-data\">No local dependencies found</div></section>'\n }\n\n ${\n report.local_dev_dependencies.length > 0\n ? `\n <section>\n <h2>Local Dev Dependencies <small>(${report.local_dev_dependencies.length})</small></h2>\n ${table(\n ['Name', 'Version', 'Path'],\n report.local_dev_dependencies.map((p) => [\n escapeHtml(p.name),\n escapeHtml(p.version || ''),\n escapeHtml(p.resolved_path || ''),\n ]),\n )}\n </section>\n `\n : '<section><h2>Local Dev Dependencies</h2><div class=\"no-data\">No local dev dependencies found</div></section>'\n }\n\n <footer class=\"footer\">\n <p>Generated by <strong>GEX v${escapeHtml(report.tool_version)}</strong> on ${new Date(report.timestamp).toLocaleString()}</p>\n <p>Report format version: ${escapeHtml(report.report_version)}</p>\n </footer>\n </div>\n</body>\n</html>`\n}\n","/**\n * @fileoverview Report parsing utilities for CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport type { PackageInfo, Report } from '../types.js'\n\n/**\n * Checks if a file path indicates a markdown report\n */\nexport function isMarkdownReportFile(filePath: string): boolean {\n const ext = path.extname(filePath).toLowerCase()\n return ext === '.md' || ext === '.markdown'\n}\n\n/**\n * Parses a markdown table and extracts package information\n *\n * @param lines - Array of file lines\n * @param startIndex - Index where table starts\n * @returns Array of package information\n */\nfunction parseMarkdownPackagesTable(lines: string[], startIndex: number): PackageInfo[] {\n const rows: PackageInfo[] = []\n if (!lines[startIndex] || !lines[startIndex].trim().startsWith('|')) return rows\n\n let i = startIndex + 2\n while (i < lines.length && lines[i].trim().startsWith('|')) {\n const cols = lines[i]\n .split('|')\n .map((c) => c.trim())\n .filter((_, idx, arr) => !(idx === 0 || idx === arr.length - 1))\n\n const [name = '', version = '', resolved_path = ''] = cols\n if (name) rows.push({ name, version, resolved_path })\n i++\n }\n return rows\n}\n\n/**\n * Parses a markdown report and converts it to a Report object\n *\n * @param md - Markdown content to parse\n * @returns Parsed Report object\n */\nexport function parseMarkdownReport(md: string): Report {\n const lines = md.split(/\\r?\\n/)\n\n const findSection = (title: string) =>\n lines.findIndex((l) => l.trim().toLowerCase() === `## ${title}`.toLowerCase())\n\n const parseSection = (idx: number): PackageInfo[] => {\n if (idx < 0) return []\n\n let i = idx + 1\n while (i < lines.length && !lines[i].trim().startsWith('|')) i++\n return parseMarkdownPackagesTable(lines, i)\n }\n\n const global_packages = parseSection(findSection('Global Packages'))\n const local_dependencies = parseSection(findSection('Local Dependencies'))\n const local_dev_dependencies = parseSection(findSection('Local Dev Dependencies'))\n\n const report: Report = {\n report_version: '1.0',\n timestamp: new Date().toISOString(),\n tool_version: 'unknown',\n global_packages,\n local_dependencies,\n local_dev_dependencies,\n }\n return report\n}\n\n/**\n * Loads and parses a report file (JSON or Markdown)\n *\n * @param reportPath - Path to the report file\n * @returns Parsed Report object\n * @throws {Error} If file cannot be read or parsed\n */\nexport async function loadReportFromFile(reportPath: string): Promise<Report> {\n const raw = await readFile(reportPath, 'utf8')\n\n if (isMarkdownReportFile(reportPath) || raw.startsWith('# GEX Report')) {\n return parseMarkdownReport(raw)\n }\n\n return JSON.parse(raw) as Report\n}\n","/**\n * @fileoverview Report generation utilities for CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { npmLs, npmRootGlobal } from '../npm.js'\nimport { buildReportFromNpmTree } from '../transform.js'\nimport type { OutputFormat, Report } from '../types.js'\n\nimport { getToolVersion } from './utils.js'\n\n/**\n * Options for report generation\n */\nexport interface ReportOptions {\n outputFormat: OutputFormat\n outFile?: string\n fullTree?: boolean\n omitDev?: boolean\n cwd?: string\n}\n\n/**\n * Result of report generation including markdown extras\n */\nexport interface ReportResult {\n report: Report\n markdownExtras?: {\n project_description?: string\n project_homepage?: string\n project_bugs?: string\n }\n}\n\n/**\n * Produces a dependency report for local or global context\n *\n * @param ctx - Context for report generation ('local' or 'global')\n * @param options - Report generation options\n * @returns Report and optional markdown extras\n */\nexport async function produceReport(\n ctx: 'local' | 'global',\n options: ReportOptions,\n): Promise<ReportResult> {\n const toolVersion = await getToolVersion()\n const depth0 = !options.fullTree\n const cwd = options.cwd || process.cwd()\n\n const tree = await npmLs({\n global: ctx === 'global',\n omitDev: ctx === 'local' ? Boolean(options.omitDev) : false,\n depth0,\n cwd,\n })\n\n let project_description: string | undefined\n let project_homepage: string | undefined\n let project_bugs: string | undefined\n\n if (ctx === 'local') {\n try {\n const pkgRaw = await readFile(path.join(cwd, 'package.json'), 'utf8')\n const pkg = JSON.parse(pkgRaw)\n project_description = pkg.description\n project_homepage = pkg.homepage\n if (typeof pkg.bugs === 'string') project_bugs = pkg.bugs\n else if (pkg.bugs && typeof pkg.bugs.url === 'string') project_bugs = pkg.bugs.url\n } catch {\n // Ignore errors reading local package.json (e.g., file missing or invalid JSON)\n void 0\n }\n }\n\n const globalRoot = ctx === 'global' ? await npmRootGlobal().catch(() => undefined) : undefined\n\n const report = await buildReportFromNpmTree(tree, {\n context: ctx,\n includeTree: Boolean(options.fullTree),\n omitDev: Boolean(options.omitDev),\n cwd,\n toolVersion,\n globalRoot,\n })\n\n const markdownExtras = { project_description, project_homepage, project_bugs }\n return { report, markdownExtras }\n}\n","/**\n * @fileoverview npm command execution utilities for dependency analysis\n */\n\n/**\n * Lazily obtain a promisified execFile so tests can mock built-ins reliably.\n */\nasync function getExecFileAsync(): Promise<\n (\n command: string,\n args?: readonly string[] | null,\n options?: any,\n ) => Promise<{ stdout: string; stderr: string }>\n> {\n const { execFile } = await import('node:child_process')\n const { promisify } = await import('node:util')\n return promisify(execFile) as any\n}\n\n/**\n * Options for npm ls command execution\n */\nexport type NpmLsOptions = {\n /** Whether to list global packages */\n global?: boolean\n /** Whether to omit devDependencies */\n omitDev?: boolean\n /** Whether to use depth=0 for faster execution */\n depth0?: boolean\n /** Current working directory for command execution */\n cwd?: string\n}\n\n/**\n * Executes npm ls command and returns parsed dependency tree\n *\n * @param options - Configuration options for npm ls command\n * @returns Promise resolving to npm dependency tree object\n * @throws {Error} If npm command fails or output cannot be parsed\n *\n * @example\n * ```typescript\n * import { npmLs } from './npm.js'\n *\n * // Get local dependencies with devDependencies omitted\n * const tree = await npmLs({ omitDev: true, depth0: true })\n *\n * // Get global packages\n * const globalTree = await npmLs({ global: true })\n * ```\n */\nexport async function npmLs(options: NpmLsOptions = {}): Promise<any> {\n const args = ['ls', '--json']\n if (options.global) args.push('--global')\n if (options.omitDev) args.push('--omit=dev')\n if (options.depth0) args.push('--depth=0')\n\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', args, {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n if (stdout && stdout.trim()) return JSON.parse(stdout)\n return {}\n } catch (err: any) {\n const stdout = err?.stdout\n if (typeof stdout === 'string' && stdout.trim()) {\n try {\n return JSON.parse(stdout)\n } catch (parseErr) {\n if (process.env.DEBUG?.includes('gex')) {\n console.warn('npm ls stdout parse failed:', parseErr)\n }\n }\n }\n const stderr = err?.stderr\n const msg = (typeof stderr === 'string' && stderr.trim()) || err?.message || 'npm ls failed'\n throw new Error(`npm ls failed: ${msg}`)\n }\n}\n\n/**\n * Gets the global npm root directory path\n *\n * @returns Promise resolving to the global npm root path\n * @throws {Error} If npm root -g command fails\n *\n * @example\n * ```typescript\n * import { npmRootGlobal } from './npm.js'\n *\n * try {\n * const globalRoot = await npmRootGlobal()\n * console.log('Global npm root:', globalRoot)\n * } catch (error) {\n * console.error('Failed to get global root:', error.message)\n * }\n * ```\n */\nexport async function npmRootGlobal(): Promise<string> {\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', ['root', '-g'])\n return stdout.trim()\n } catch (err: any) {\n const stderr = err?.stderr\n const msg =\n (typeof stderr === 'string' && stderr.trim()) || err?.message || 'npm root -g failed'\n throw new Error(`npm root -g failed: ${msg}`)\n }\n}\n","/**\n * @fileoverview Data transformation utilities for converting npm tree data into reports\n */\n\nimport path from 'node:path'\nimport { readFile } from 'node:fs/promises'\n\nimport type { PackageInfo, Report } from './types.js'\n\n/**\n * Options for report generation and normalization\n */\nexport type NormalizeOptions = {\n /** Context for report generation ('local' or 'global') */\n context: 'local' | 'global'\n /** Whether to include the full npm dependency tree */\n includeTree?: boolean\n /** Whether to omit devDependencies (local context only) */\n omitDev?: boolean\n /** Current working directory */\n cwd?: string\n /** Tool version to include in report */\n toolVersion: string\n /** Global npm root directory path */\n globalRoot?: string\n}\n\n/**\n * Converts npm dependency object to array of package entries\n *\n * @param obj - npm dependency object from npm ls output\n * @returns Array of name/node pairs for packages\n */\nfunction toPkgArray(obj: Record<string, any> | undefined | null): { name: string; node: any }[] {\n if (!obj) return []\n return Object.keys(obj)\n .map((name) => ({ name, node: obj[name] }))\n .filter((p) => p && p.node)\n}\n\n/**\n * Builds a GEX report from npm ls tree output\n *\n * @param tree - Raw npm ls command output\n * @param opts - Report generation options\n * @returns Promise resolving to a formatted Report object\n *\n * @example\n * ```typescript\n * import { buildReportFromNpmTree } from './transform.js'\n * import { npmLs } from './npm.js'\n *\n * const tree = await npmLs({ depth0: true })\n * const report = await buildReportFromNpmTree(tree, {\n * context: 'local',\n * toolVersion: '0.3.2',\n * cwd: process.cwd()\n * })\n *\n * console.log(`Found ${report.local_dependencies.length} dependencies`)\n * ```\n */\nexport async function buildReportFromNpmTree(tree: any, opts: NormalizeOptions): Promise<Report> {\n const timestamp = new Date().toISOString()\n const report: Report = {\n report_version: '1.0',\n timestamp,\n tool_version: opts.toolVersion,\n global_packages: [],\n local_dependencies: [],\n local_dev_dependencies: [],\n }\n\n if (opts.context === 'local') {\n let pkgMeta: any = null\n try {\n const pkgJsonPath = path.join(opts.cwd || process.cwd(), 'package.json')\n const raw = await readFile(pkgJsonPath, 'utf8')\n pkgMeta = JSON.parse(raw)\n } catch {\n // Ignore errors reading/parsing package.json; fall back to undefined metadata\n void 0\n }\n if (pkgMeta?.name) report.project_name = pkgMeta.name\n if (pkgMeta?.version) report.project_version = pkgMeta.version\n\n const depsObj = tree?.dependencies as Record<string, any> | undefined\n const items = toPkgArray(depsObj)\n const devKeys = new Set(Object.keys((pkgMeta?.devDependencies as Record<string, string>) || {}))\n\n for (const { name, node } of items) {\n const version = (node && node.version) || ''\n const resolvedPath =\n (node && node.path) || path.join(opts.cwd || process.cwd(), 'node_modules', name)\n const pkg: PackageInfo = { name, version, resolved_path: resolvedPath }\n if (devKeys.has(name)) {\n report.local_dev_dependencies.push(pkg)\n } else {\n report.local_dependencies.push(pkg)\n }\n }\n\n report.local_dependencies.sort((a, b) => a.name.localeCompare(b.name))\n report.local_dev_dependencies.sort((a, b) => a.name.localeCompare(b.name))\n } else if (opts.context === 'global') {\n const depsObj = tree?.dependencies as Record<string, any> | undefined\n const items = toPkgArray(depsObj)\n\n for (const { name, node } of items) {\n const version = (node && node.version) || ''\n const resolvedPath = (node && node.path) || path.join(opts.globalRoot || '', name)\n const pkg: PackageInfo = { name, version, resolved_path: resolvedPath }\n report.global_packages.push(pkg)\n }\n\n report.global_packages.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n if (opts.includeTree) {\n report.tree = tree\n }\n\n return report\n}\n","/**\n * @fileoverview CLI utility functions for version handling and path resolution\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Gets the path to package.json for version resolution\n */\nexport function getPkgJsonPath(): string {\n try {\n const __filename = fileURLToPath((import.meta as any).url)\n const __dirnameLocal = path.dirname(__filename)\n return path.resolve(__dirnameLocal, '..', '..', 'package.json')\n } catch {\n const dir = typeof __dirname !== 'undefined' ? __dirname : process.cwd()\n return path.resolve(dir, '..', 'package.json')\n }\n}\n\n/**\n * Gets the current tool version from package.json\n */\nexport async function getToolVersion(): Promise<string> {\n try {\n const pkgPath = getPkgJsonPath()\n const raw = await readFile(pkgPath, 'utf8')\n const pkg = JSON.parse(raw)\n return pkg.version || '0.0.0'\n } catch {\n return '0.0.0'\n }\n}\n\n/**\n * ASCII banner for the CLI\n */\nexport const ASCII_BANNER = String.raw`\n ________ __\n / _____/ ____ _____/ |_ ____ ____\n/ \\ ___ / _ \\ / _ \\ __\\/ __ \\ / \\\n\\ \\_\\ ( <_> | <_> ) | \\ ___/| | \\\n \\______ /\\____/ \\____/|__| \\___ >___| /\n \\/ \\/ \\/\n GEX\n`\n","/**\n * @fileoverview Main CLI entry point for GEX dependency auditing tool\n */\n\nimport { createProgram } from './cli/commands.js'\n\n/**\n * Main CLI runner function\n *\n * @param argv - Command line arguments (defaults to process.argv)\n */\nexport async function run(argv = process.argv): Promise<void> {\n const program = await createProgram()\n await program.parseAsync(argv)\n}\n\nconst isMainModule = (() => {\n try {\n if (typeof require !== 'undefined' && typeof module !== 'undefined') {\n return (require as any).main === module\n }\n\n if (typeof import.meta !== 'undefined') {\n return import.meta.url === `file://${process.argv[1]}`\n }\n return false\n } catch {\n return false\n }\n})()\n\nif (isMainModule) {\n run().catch((error) => {\n console.error('CLI error:', error)\n process.exitCode = 1\n })\n}\n"],"mappings":";;;;;;;;;AAIA,OAAOA,WAAU;AAEjB,SAAS,eAAe;;;ACGxB,eAAe,mBAMb;AACA,QAAM,EAAE,SAAS,IAAI,MAAM,OAAO,eAAoB;AACtD,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,MAAW;AAC9C,SAAO,UAAU,QAAQ;AAC3B;AASA,eAAsB,kBAAkB,QAAgB,KAA4B;AAClF,QAAM,aAAa,OAAO,gBAAgB,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,OAAO;AAC7F,QAAM,YAAY,OAAO,mBAAmB,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,OAAO;AAC/F,QAAM,UAAU,OAAO,uBAAuB,IAAI,CAAC,MAAM,GAA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AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF,GAAG;AAEH,IAAI,cAAc;AAChB,MAAI,EAAE,MAAM,CAAC,UAAU;AACrB,YAAQ,MAAM,cAAc,KAAK;AACjC,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["path","table","path","readFile","path","getExecFileAsync","path","readFile","readFile","path","readFile","path","path"]}
package/dist/index.d.cts CHANGED
@@ -38,7 +38,7 @@ type Report = {
38
38
  /**
39
39
  * Supported output formats for reports
40
40
  */
41
- type OutputFormat = 'json' | 'md';
41
+ type OutputFormat = 'json' | 'md' | 'html';
42
42
 
43
43
  /**
44
44
  * Custom error class for validation failures
package/dist/index.d.ts CHANGED
@@ -38,7 +38,7 @@ type Report = {
38
38
  /**
39
39
  * Supported output formats for reports
40
40
  */
41
- type OutputFormat = 'json' | 'md';
41
+ type OutputFormat = 'json' | 'md' | 'html';
42
42
 
43
43
  /**
44
44
  * Custom error class for validation failures
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yabasha/gex",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "description": "A CLI tool for auditing and documenting your Node.js package environment, generating comprehensive reports of global and local dependencies.",
6
6
  "type": "module",