@yabasha/gex 1.3.6 → 1.3.7
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/README.md +55 -31
- package/dist/cli-bun.mjs +2 -3
- package/dist/cli-bun.mjs.map +1 -1
- package/dist/cli-node.cjs +3 -17
- package/dist/cli-node.cjs.map +1 -1
- package/dist/cli-node.mjs +2 -3
- package/dist/cli-node.mjs.map +1 -1
- package/dist/cli.cjs +1310 -36
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1307 -34
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,31 +37,55 @@ node dist/cli.cjs --help
|
|
|
37
37
|
|
|
38
38
|
## Usage
|
|
39
39
|
|
|
40
|
-
### Top-level entry: `gex` (interactive
|
|
40
|
+
### Top-level entry: `gex` (interactive launcher)
|
|
41
41
|
|
|
42
|
-
Starting with v1.3.6, the primary `gex` binary is an interactive launcher that lets you choose
|
|
42
|
+
Starting with v1.3.6, the primary `gex` binary is an interactive launcher that lets you choose both:
|
|
43
|
+
|
|
44
|
+
- Which runtime to use: Node/npm (`gex-node`) or Bun (`gex-bun`)
|
|
45
|
+
- Which command to run: `local`, `global`, or `read`
|
|
46
|
+
|
|
47
|
+
Run:
|
|
43
48
|
|
|
44
49
|
```bash
|
|
45
50
|
gex
|
|
46
51
|
```
|
|
47
52
|
|
|
48
|
-
You will
|
|
53
|
+
You will see a menu similar to:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
GEX interactive launcher
|
|
57
|
+
Choose a runtime and command to run:
|
|
58
|
+
|
|
59
|
+
1) gex-node local – Node (npm) local project report
|
|
60
|
+
2) gex-node global – Node (npm) global packages report
|
|
61
|
+
3) gex-node read – Node (npm) read existing report
|
|
62
|
+
4) gex-bun local – Bun local project report
|
|
63
|
+
5) gex-bun global – Bun global packages report
|
|
64
|
+
6) gex-bun read – Bun read existing report
|
|
65
|
+
q) Quit without running anything
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
After selecting an option (for example, `1`), GEX shows the base command and asks for any extra flags you want to include:
|
|
49
69
|
|
|
50
70
|
```text
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
2) gex-npm (npm / Node.js package manager)
|
|
71
|
+
Selected: gex-node local
|
|
72
|
+
Enter extra flags/arguments for "gex-node local" (or press Enter for none):
|
|
54
73
|
```
|
|
55
74
|
|
|
56
|
-
|
|
75
|
+
Anything you type here is used to build and execute the final command. For example:
|
|
76
|
+
|
|
77
|
+
- Input: `--full-tree -f md -o report.md`
|
|
78
|
+
- Executed command: `gex-node local --full-tree -f md -o report.md`
|
|
79
|
+
|
|
80
|
+
If you run `gex` **with arguments** (for example `gex local --check-outdated`), it behaves like `gex-node` for backward compatibility and forwards those arguments to the Node runtime.
|
|
57
81
|
|
|
58
|
-
### Direct runtimes: `gex-
|
|
82
|
+
### Direct runtimes: `gex-node` (Node) and `gex-bun` (Bun)
|
|
59
83
|
|
|
60
|
-
You can
|
|
84
|
+
You can also call each runtime directly without the interactive launcher:
|
|
61
85
|
|
|
62
86
|
```bash
|
|
63
|
-
gex-
|
|
64
|
-
gex-bun [command] [options]
|
|
87
|
+
gex-node [command] [options] # Node.js / npm runtime (formerly `gex`)
|
|
88
|
+
gex-bun [command] [options] # Bun runtime
|
|
65
89
|
```
|
|
66
90
|
|
|
67
91
|
Common command options:
|
|
@@ -73,43 +97,43 @@ Common command options:
|
|
|
73
97
|
- -c, --check-outdated Print a table of outdated packages (shows a lightweight spinner while checking; skips console report output unless `-o` is set so you can write the report to file instead)
|
|
74
98
|
- -u, --update-outdated [pkg1 pkg2 ...] Update outdated packages (omit names to update everything). Node CLI shells out to `npm update`; Bun CLI mirrors `bun update` for locals and reinstalls globals via `bun add -g pkg@latest`.
|
|
75
99
|
|
|
76
|
-
Examples (Node/npm runtime via `gex-
|
|
100
|
+
Examples (Node/npm runtime via `gex-node`):
|
|
77
101
|
|
|
78
102
|
```bash
|
|
79
103
|
# Local (default): JSON output to console
|
|
80
|
-
gex-
|
|
81
|
-
gex-
|
|
82
|
-
gex-
|
|
83
|
-
gex-
|
|
104
|
+
gex-node # prints JSON to console (same as: gex-node local)
|
|
105
|
+
gex-node -o report.json # writes JSON to file
|
|
106
|
+
gex-node -f md # prints markdown to console
|
|
107
|
+
gex-node -f md -o report.md # writes markdown to file
|
|
84
108
|
|
|
85
109
|
# Local: exclude devDependencies
|
|
86
|
-
gex-
|
|
87
|
-
gex-
|
|
110
|
+
gex-node local --omit-dev # prints JSON to console
|
|
111
|
+
gex-node local --omit-dev -o deps.json # writes JSON to file
|
|
88
112
|
|
|
89
113
|
# Global packages
|
|
90
|
-
gex-
|
|
91
|
-
gex-
|
|
92
|
-
gex-
|
|
114
|
+
gex-node global # prints JSON to console
|
|
115
|
+
gex-node global -o global.json # writes JSON to file
|
|
116
|
+
gex-node global -f md # prints markdown to console
|
|
93
117
|
|
|
94
118
|
# Read a previous report (JSON or Markdown)
|
|
95
119
|
# Default prints names@versions; add -i to install
|
|
96
120
|
# Positional path or -r/--report are accepted
|
|
97
121
|
# JSON
|
|
98
|
-
gex-
|
|
99
|
-
gex-
|
|
122
|
+
gex-node read
|
|
123
|
+
gex-node read -r path/to/report.json -i
|
|
100
124
|
# Markdown
|
|
101
|
-
gex-
|
|
102
|
-
gex-
|
|
125
|
+
gex-node read global.md
|
|
126
|
+
gex-node read global.md -i
|
|
103
127
|
|
|
104
128
|
# Shell redirection (alternative to -o flag)
|
|
105
|
-
gex-
|
|
106
|
-
gex-
|
|
129
|
+
gex-node > report.json # redirect JSON output to file
|
|
130
|
+
gex-node global | jq '.global_packages' # pipe output to jq for processing
|
|
107
131
|
|
|
108
132
|
# Check outdated packages / update them (Node runtime)
|
|
109
|
-
gex-
|
|
110
|
-
gex-
|
|
111
|
-
gex-
|
|
112
|
-
gex-
|
|
133
|
+
gex-node local --check-outdated # show outdated local deps as a table
|
|
134
|
+
gex-node global -c # short flag works too
|
|
135
|
+
gex-node local --update-outdated # update every outdated local dependency
|
|
136
|
+
gex-node local -u axios react # update specific packages
|
|
113
137
|
|
|
114
138
|
# Bun runtime uses the same flags with Bun semantics
|
|
115
139
|
gex-bun local --check-outdated
|
package/dist/cli-bun.mjs
CHANGED
|
@@ -890,6 +890,8 @@ async function run(argv = process.argv) {
|
|
|
890
890
|
const program = await createProgram();
|
|
891
891
|
await program.parseAsync(argv);
|
|
892
892
|
}
|
|
893
|
+
|
|
894
|
+
// src/runtimes/bun/cli.entry.ts
|
|
893
895
|
var isMainModule = (() => {
|
|
894
896
|
try {
|
|
895
897
|
if (typeof __require !== "undefined" && typeof module !== "undefined") {
|
|
@@ -909,7 +911,4 @@ if (isMainModule) {
|
|
|
909
911
|
process.exitCode = 1;
|
|
910
912
|
});
|
|
911
913
|
}
|
|
912
|
-
export {
|
|
913
|
-
run
|
|
914
|
-
};
|
|
915
914
|
//# sourceMappingURL=cli-bun.mjs.map
|
package/dist/cli-bun.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtimes/bun/commands.ts","../src/shared/cli/install.ts","../src/shared/cli/output.ts","../src/shared/report/json.ts","../src/shared/report/md.ts","../src/shared/cli/parser.ts","../src/shared/npm-cli.ts","../src/shared/cli/loader.ts","../src/shared/cli/outdated.ts","../src/shared/cli/utils.ts","../src/runtimes/bun/report.ts","../src/shared/transform.ts","../src/runtimes/bun/package-manager.ts","../src/runtimes/bun/cli.ts"],"sourcesContent":["/**\n * @fileoverview CLI command definitions and handlers for Bun runtime\n */\n\nimport path from 'node:path'\nimport { readFile } from 'node:fs/promises'\n\nimport { Command } from 'commander'\n\nimport type { OutputFormat } from '../../shared/types.js'\nimport { installFromReport, printFromReport } from '../../shared/cli/install.js'\nimport { outputReport } from '../../shared/cli/output.js'\nimport { isMarkdownReportFile, loadReportFromFile } from '../../shared/cli/parser.js'\nimport {\n normalizeUpdateSelection,\n handleOutdatedWorkflow,\n resolveOutdatedWithNpmView,\n formatOutdatedTable,\n} from '../../shared/cli/outdated.js'\nimport { ASCII_BANNER, getToolVersion } from '../../shared/cli/utils.js'\n\nimport { produceReport } from './report.js'\nimport { bunUpdate, bunPmLs } from './package-manager.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 bun pm ls tree (when available)', false)\n .option('-c, --check-outdated', 'List outdated packages instead of printing the report', false)\n .option(\n '-u, --update-outdated [packages...]',\n 'Update outdated packages (omit package names to update every package)',\n )\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 Bun 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 const cwd = process.cwd()\n\n const selection = normalizeUpdateSelection(opts.updateOutdated)\n const result = await handleOutdatedWorkflow({\n checkOutdated: Boolean(opts.checkOutdated),\n selection,\n contextLabel: 'local',\n outFile,\n fetchOutdated: async () => {\n const tree = await bunPmLs({ cwd, omitDev })\n const manifest = await readPackageManifest(cwd)\n const declared = {\n ...(manifest?.dependencies || {}),\n ...(manifest?.optionalDependencies || {}),\n ...(manifest?.devDependencies || {}),\n }\n\n const packages = Object.entries(tree.dependencies).map(([name, node]) => ({\n name,\n current: node.version,\n declared: declared[name],\n type: 'prod',\n }))\n\n if (tree.devDependencies) {\n for (const [name, node] of Object.entries(tree.devDependencies)) {\n packages.push({\n name,\n current: node.version,\n declared: declared[name],\n type: 'dev',\n })\n }\n }\n\n return resolveOutdatedWithNpmView(packages)\n },\n updateRunner: selection.shouldUpdate\n ? async (packages) => {\n await bunUpdate({ cwd, packages })\n }\n : undefined,\n })\n if (opts.checkOutdated) {\n if (result.outdated.length === 0) console.log('All local packages are up to date.')\n else console.log(formatOutdatedTable(result.outdated))\n }\n if (!result.proceed) return\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 Bun 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 const cwd = process.cwd()\n\n const selection = normalizeUpdateSelection(opts.updateOutdated)\n const result = await handleOutdatedWorkflow({\n checkOutdated: Boolean(opts.checkOutdated),\n selection,\n contextLabel: 'global',\n outFile,\n fetchOutdated: async () => {\n const tree = await bunPmLs({ global: true })\n const packages = Object.entries(tree.dependencies).map(([name, node]) => ({\n name,\n current: node.version,\n type: 'global',\n }))\n return resolveOutdatedWithNpmView(packages)\n },\n updateRunner: selection.shouldUpdate\n ? async (packages) => {\n await bunUpdate({ cwd, global: true, packages })\n }\n : undefined,\n })\n if (opts.checkOutdated) {\n if (result.outdated.length === 0) console.log('All global packages are up to date.')\n else console.log(formatOutdatedTable(result.outdated))\n }\n if (!result.proceed) return\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)', 'bun-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 using Bun', false)\n\n readCmd.action(async (reportArg: string | undefined, opts: any) => {\n const chosen = (opts.report as string | undefined) || reportArg || 'bun-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, { cwd: process.cwd(), packageManager: 'bun' })\n }\n } catch (err: any) {\n const isMd = isMarkdownReportFile(reportPath)\n const hint = isMd\n ? 'Try generating a JSON report with: gex-bun global -f json -o global.json, then: gex-bun read global.json'\n : 'Specify a report path with: gex-bun 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 for Bun runtime\n *\n * @returns Configured Commander program\n */\nexport async function createProgram(): Promise<Command> {\n const program = new Command()\n .name('gex-bun')\n .description('GEX: Dependency auditing and documentation for Bun (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\nasync function readPackageManifest(cwd: string): Promise<any | null> {\n try {\n const raw = await readFile(path.join(cwd, 'package.json'), 'utf8')\n return JSON.parse(raw)\n } catch {\n return null\n }\n}\n","/**\n * @fileoverview Package installation utilities for CLI\n */\n\nimport type { Report } from '../types.js'\n\ntype PackageManager = 'npm' | 'bun'\n\nexport type InstallOptions = {\n cwd: string\n packageManager?: PackageManager\n}\n\nconst INSTALL_COMMANDS: Record<\n PackageManager,\n { global: string[]; local: string[]; dev: string[] }\n> = {\n npm: {\n global: ['i', '-g'],\n local: ['i'],\n dev: ['i', '-D'],\n },\n bun: {\n global: ['add', '-g'],\n local: ['add'],\n dev: ['add', '-d'],\n },\n}\n\nconst MAX_BUFFER = 10 * 1024 * 1024\n\nfunction formatSpec(pkg: { name: string; version: string }): string {\n return pkg.version ? `${pkg.name}@${pkg.version}` : pkg.name\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 * 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(\n report: Report,\n options: InstallOptions | string,\n): Promise<void> {\n const opts = typeof options === 'string' ? { cwd: options } : options\n const { cwd, packageManager = 'npm' } = opts\n\n const globalPkgs = report.global_packages.map(formatSpec).filter(Boolean)\n const localPkgs = report.local_dependencies.map(formatSpec).filter(Boolean)\n const devPkgs = report.local_dev_dependencies.map(formatSpec).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 const cmd = INSTALL_COMMANDS[packageManager]\n const binary = packageManager === 'bun' ? 'bun' : 'npm'\n\n if (globalPkgs.length > 0) {\n console.log(`Installing global: ${globalPkgs.join(' ')}`)\n await execFileAsync(binary, [...cmd.global, ...globalPkgs], { cwd, maxBuffer: MAX_BUFFER })\n }\n\n if (localPkgs.length > 0) {\n console.log(`Installing local deps: ${localPkgs.join(' ')}`)\n await execFileAsync(binary, [...cmd.local, ...localPkgs], { cwd, maxBuffer: MAX_BUFFER })\n }\n\n if (devPkgs.length > 0) {\n console.log(`Installing local devDeps: ${devPkgs.join(' ')}`)\n await execFileAsync(binary, [...cmd.dev, ...devPkgs], { cwd, maxBuffer: MAX_BUFFER })\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","import { promisify } from 'node:util'\n\nexport type OutdatedInfo = {\n name: string\n current: string\n wanted: string\n latest: string\n type?: string\n}\n\nexport type NpmOutdatedOptions = {\n global?: boolean\n cwd?: string\n}\n\nexport type NpmUpdateOptions = {\n global?: boolean\n cwd: string\n packages?: string[]\n}\n\nasync function getExecFileAsync(): Promise<(\n command: string,\n args?: readonly string[] | null,\n options?: any,\n) => Promise<{ stdout: string; stderr: string }>> {\n const { execFile } = await import('node:child_process')\n return promisify(execFile) as any\n}\n\nexport async function npmOutdated(options: NpmOutdatedOptions = {}): Promise<OutdatedInfo[]> {\n const args = ['outdated', '--json']\n if (options.global) args.push('--global')\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 return normalizeOutdated(stdout)\n } catch (error: any) {\n const stdout = typeof error?.stdout === 'string' ? error.stdout : ''\n if (stdout.trim()) {\n return normalizeOutdated(stdout)\n }\n throw formatNpmError(error, 'npm outdated')\n }\n}\n\nexport async function npmUpdate(options: NpmUpdateOptions): Promise<void> {\n const args = ['update']\n if (options.global) args.push('-g')\n if (options.packages && options.packages.length > 0) args.push(...options.packages)\n\n try {\n const execFileAsync = await getExecFileAsync()\n await execFileAsync('npm', args, {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n } catch (error) {\n throw formatNpmError(error, 'npm update')\n }\n}\n\nfunction normalizeOutdated(stdout: string): OutdatedInfo[] {\n if (!stdout.trim()) return []\n let data: Record<string, any>\n try {\n data = JSON.parse(stdout)\n } catch {\n return []\n }\n\n if (!data) return []\n return Object.entries(data).map(([name, info]) => ({\n name,\n current: info?.current ? String(info.current) : '',\n wanted: info?.wanted ? String(info.wanted) : '',\n latest: info?.latest ? String(info.latest) : '',\n type: info?.type ? String(info.type) : undefined,\n }))\n}\n\nfunction formatNpmError(error: any, commandLabel: string): Error {\n const stderr = typeof error?.stderr === 'string' ? error.stderr.trim() : ''\n const message = stderr || error?.message || `${commandLabel} failed`\n return new Error(`${commandLabel} failed: ${message}`)\n}\n\nexport async function npmViewVersion(packageName: string): Promise<string> {\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', ['view', packageName, 'version', '--json'], {\n maxBuffer: 5 * 1024 * 1024,\n })\n const parsed = JSON.parse(stdout)\n if (typeof parsed === 'string') return parsed\n if (Array.isArray(parsed)) return parsed[parsed.length - 1] ?? ''\n return ''\n } catch (error) {\n throw formatNpmError(error, `npm view ${packageName}`)\n }\n}\n","const frames = ['-', '\\\\', '|', '/'] as const\n\nexport type Loader = {\n stop: (finalMessage?: string) => void\n}\n\nexport function createLoader(message: string): Loader {\n if (!process.stdout.isTTY) {\n console.log(`${message}...`)\n return {\n stop(finalMessage) {\n if (finalMessage) console.log(finalMessage)\n },\n }\n }\n\n let index = 0\n const interval = globalThis.setInterval(() => {\n const frame = frames[index % frames.length]\n index += 1\n process.stdout.write(`\\r${message} ${frame}`)\n }, 80)\n\n return {\n stop(finalMessage) {\n globalThis.clearInterval(interval)\n process.stdout.write('\\r')\n if (finalMessage) {\n console.log(finalMessage)\n } else {\n process.stdout.write('\\x1b[2K')\n }\n },\n }\n}\n","import type { OutdatedInfo } from '../npm-cli.js'\nimport { npmViewVersion } from '../npm-cli.js'\n\nimport { createLoader } from './loader.js'\n\nexport type OutdatedEntry = OutdatedInfo\n\nexport type OutdatedSelection = {\n shouldUpdate: boolean\n updateAll: boolean\n packages: string[]\n}\n\nexport function normalizeUpdateSelection(value: unknown): OutdatedSelection {\n if (value === undefined) {\n return { shouldUpdate: false, updateAll: false, packages: [] }\n }\n if (value === true) {\n return { shouldUpdate: true, updateAll: true, packages: [] }\n }\n const packages = Array.isArray(value) ? value : typeof value === 'string' ? [value] : []\n const normalized = packages\n .flatMap((entry) =>\n String(entry)\n .split(',')\n .map((part) => part.trim()),\n )\n .filter(Boolean)\n\n return {\n shouldUpdate: true,\n updateAll: false,\n packages: normalized,\n }\n}\n\nexport function formatOutdatedTable(entries: OutdatedEntry[]): string {\n const headers = ['Name', 'Current', 'Wanted', 'Latest', 'Type']\n const rows = entries.map((entry) => [\n entry.name,\n entry.current || '-',\n entry.wanted || '-',\n entry.latest || '-',\n entry.type || '-',\n ])\n\n const widths = headers.map((header, index) =>\n Math.max(header.length, ...rows.map((row) => row[index].length)),\n )\n\n const formatRow = (columns: string[]) =>\n columns.map((col, idx) => col.padEnd(widths[idx], ' ')).join(' ')\n\n const lines = [formatRow(headers), formatRow(widths.map((w) => '-'.repeat(w)))]\n for (const row of rows) {\n lines.push(formatRow(row))\n }\n return lines.join('\\n')\n}\n\nexport type OutdatedWorkflowOptions = {\n checkOutdated: boolean\n selection: OutdatedSelection\n contextLabel: 'local' | 'global'\n outFile?: string\n fetchOutdated: () => Promise<OutdatedEntry[]>\n updateRunner?: (packages: string[]) => Promise<void>\n}\n\nexport type OutdatedWorkflowResult = {\n proceed: boolean\n outdated: OutdatedEntry[]\n}\n\nexport async function handleOutdatedWorkflow(\n opts: OutdatedWorkflowOptions,\n): Promise<OutdatedWorkflowResult> {\n if (!opts.checkOutdated && !opts.selection.shouldUpdate) {\n return { proceed: true, outdated: [] }\n }\n\n let fetchLoader: ReturnType<typeof createLoader> | undefined\n if (opts.checkOutdated || opts.selection.shouldUpdate) {\n fetchLoader = createLoader('Checking for outdated packages')\n }\n const outdated = await opts.fetchOutdated()\n fetchLoader?.stop('Finished checking outdated packages.')\n\n if (opts.selection.shouldUpdate && opts.updateRunner) {\n const packagesToUpdate = opts.selection.updateAll\n ? outdated.map((entry) => entry.name)\n : opts.selection.packages\n\n if (!packagesToUpdate || packagesToUpdate.length === 0) {\n if (opts.selection.updateAll) {\n console.log('No outdated packages to update.')\n } else {\n console.log('No packages were specified for updating.')\n }\n } else {\n const updateLoader = createLoader('Updating packages')\n await opts.updateRunner(packagesToUpdate)\n updateLoader.stop('Finished updating packages.')\n }\n }\n\n const proceed = !((opts.checkOutdated || opts.selection.shouldUpdate) && !opts.outFile)\n return { proceed, outdated }\n}\n\nexport type InstalledPackageInput = {\n name: string\n current: string\n declared?: string\n type?: string\n}\n\nexport async function resolveOutdatedWithNpmView(\n packages: InstalledPackageInput[],\n): Promise<OutdatedEntry[]> {\n const results: OutdatedEntry[] = []\n for (const pkg of packages) {\n try {\n const latest = await npmViewVersion(pkg.name)\n if (latest && pkg.current && latest !== pkg.current) {\n results.push({\n name: pkg.name,\n current: pkg.current,\n wanted: pkg.declared || latest,\n latest,\n type: pkg.type,\n })\n }\n } catch {\n continue\n }\n }\n return results\n}\n","/**\n * @fileoverview CLI utility functions for version handling and path resolution\n */\n\nimport { existsSync } from 'node:fs'\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 let startDir: string\n try {\n const __filename = fileURLToPath((import.meta as any).url)\n startDir = path.dirname(__filename)\n } catch {\n startDir = typeof __dirname !== 'undefined' ? __dirname : process.cwd()\n }\n\n return findPackageJson(startDir)\n}\n\nfunction findPackageJson(startDir: string): string {\n let current = startDir\n const maxDepth = 6\n\n for (let i = 0; i < maxDepth; i++) {\n const candidate = path.resolve(current, 'package.json')\n if (existsSync(candidate)) {\n return candidate\n }\n\n const parent = path.dirname(current)\n if (parent === current) break\n current = parent\n }\n\n return path.resolve(process.cwd(), 'package.json')\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 Report generation utilities for Bun CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { buildReportFromNpmTree } from '../../shared/transform.js'\nimport type { OutputFormat, Report } from '../../shared/types.js'\nimport { getToolVersion } from '../../shared/cli/utils.js'\n\nimport { bunPmLs, bunPmRootGlobal, bunPmRootLocal } from './package-manager.js'\n\n/**\n * Options for Bun 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 using Bun package manager\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 cwd = options.cwd || process.cwd()\n\n const tree = await bunPmLs({\n global: ctx === 'global',\n omitDev: ctx === 'local' ? Boolean(options.omitDev) : false,\n cwd,\n })\n const nodeModulesPath = tree?.node_modules_path\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 resolvedRoot = nodeModulesPath\n ? nodeModulesPath\n : ctx === 'global'\n ? await bunPmRootGlobal().catch(() => undefined)\n : await bunPmRootLocal(cwd).catch(() => `${cwd}/node_modules`)\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: resolvedRoot,\n })\n\n const markdownExtras = { project_description, project_homepage, project_bugs }\n return { report, markdownExtras }\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 devDepsObj = tree?.devDependencies as Record<string, any> | undefined\n const prodItems = toPkgArray(depsObj)\n const treeDevItems = toPkgArray(devDepsObj)\n\n if (treeDevItems.length > 0) {\n for (const { name, node } of treeDevItems) {\n const version = (node && node.version) || ''\n const resolvedPath =\n (node && node.path) || path.join(opts.cwd || process.cwd(), 'node_modules', name)\n report.local_dev_dependencies.push({ name, version, resolved_path: resolvedPath })\n }\n }\n\n const devKeys =\n treeDevItems.length > 0\n ? new Set(treeDevItems.map((entry) => entry.name))\n : new Set(Object.keys((pkgMeta?.devDependencies as Record<string, string>) || {}))\n\n for (const { name, node } of prodItems) {\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 (!treeDevItems.length && 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","import path from 'node:path'\nimport { constants as fsConstants, type Dirent } from 'node:fs'\nimport { access, readFile, readdir, stat } from 'node:fs/promises'\nimport { promisify } from 'node:util'\n\nexport type BunPmLsOptions = {\n global?: boolean\n omitDev?: boolean\n depth0?: boolean\n cwd?: string\n}\n\ntype PackageNode = {\n version: string\n path: string\n}\n\ntype BunPackageTree = {\n dependencies: Record<string, PackageNode>\n devDependencies?: Record<string, PackageNode>\n node_modules_path?: string\n}\n\nconst IGNORED_ENTRIES = new Set(['.bin'])\n\n/**\n * Executes a Bun package listing by inspecting node_modules directories directly.\n */\nexport async function bunPmLs(options: BunPmLsOptions = {}): Promise<BunPackageTree> {\n if (options.global) {\n const root = await bunPmRootGlobal()\n const manifest = await readJson(path.join(path.dirname(root), 'package.json'))\n const selections = buildSelections(manifest, { includeDev: false })\n const dependencies =\n selections.prod.size > 0\n ? await collectPackagesForNames(root, mapSelections(selections.prod))\n : await collectPackagesFromNodeModules(root)\n return { dependencies, node_modules_path: root }\n }\n\n const cwd = options.cwd || process.cwd()\n const nodeModulesPath = await bunPmRootLocal(cwd)\n const manifest = await readJson(path.join(cwd, 'package.json'))\n const includeDev = !options.omitDev\n const selections = buildSelections(manifest, { includeDev })\n\n const dependencies =\n selections.prod.size > 0\n ? await collectPackagesForNames(nodeModulesPath, mapSelections(selections.prod))\n : await collectPackagesFromNodeModules(nodeModulesPath)\n\n let devDependencies: Record<string, PackageNode> | undefined\n if (includeDev) {\n if (selections.dev.size > 0) {\n devDependencies = await collectPackagesForNames(\n nodeModulesPath,\n mapSelections(selections.dev),\n )\n } else {\n devDependencies = {}\n }\n }\n\n return { dependencies, devDependencies, node_modules_path: nodeModulesPath }\n}\n\n/**\n * Attempts to resolve the Bun global node_modules directory.\n */\nexport async function bunPmRootGlobal(): Promise<string> {\n if (process.env.GEX_BUN_GLOBAL_ROOT) {\n return process.env.GEX_BUN_GLOBAL_ROOT\n }\n\n const candidates = getGlobalRootCandidates()\n for (const candidate of candidates) {\n if (candidate && (await pathExists(candidate))) {\n return candidate\n }\n }\n\n return (\n candidates.find((c) => Boolean(c)) ||\n path.join(process.env.HOME || process.cwd(), '.bun', 'install', 'global', 'node_modules')\n )\n}\n\n/**\n * Resolves the Bun local node_modules directory for the provided cwd.\n */\nexport async function bunPmRootLocal(cwd: string = process.cwd()): Promise<string> {\n if (process.env.GEX_BUN_LOCAL_ROOT) {\n return process.env.GEX_BUN_LOCAL_ROOT\n }\n return path.join(cwd, 'node_modules')\n}\n\nexport type BunUpdateOptions = {\n cwd: string\n global?: boolean\n packages?: string[]\n}\n\nexport async function bunUpdate(options: BunUpdateOptions): Promise<void> {\n const execFileAsync = await getExecFileAsync()\n const packages = options.packages && options.packages.length > 0 ? options.packages : []\n\n if (options.global) {\n const targets = packages.length > 0 ? packages : []\n const list = targets.length > 0 ? targets : []\n const cmdPackages = list.map((name) => `${name}@latest`)\n try {\n await execFileAsync('bun', ['add', '-g', ...cmdPackages], {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n } catch (error: any) {\n const stderr = typeof error?.stderr === 'string' ? error.stderr.trim() : ''\n throw new Error(`bun add -g failed: ${stderr || error?.message || 'unknown error'}`)\n }\n return\n }\n\n const args = ['update']\n if (packages.length > 0) args.push(...packages)\n\n try {\n await execFileAsync('bun', args, {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n } catch (error: any) {\n const stderr = typeof error?.stderr === 'string' ? error.stderr.trim() : ''\n throw new Error(`bun update failed: ${stderr || error?.message || 'unknown error'}`)\n }\n}\n\nasync function collectPackagesForNames(\n nodeModulesPath: string,\n packages: { name: string; declared?: string }[],\n): Promise<Record<string, PackageNode>> {\n const result: Record<string, PackageNode> = {}\n await Promise.all(\n packages.map(async ({ name, declared }) => {\n const pkgDir = packageDir(nodeModulesPath, name)\n const manifest = await readJson(path.join(pkgDir, 'package.json'))\n const pkgName = typeof manifest?.name === 'string' ? manifest.name : name\n const version = typeof manifest?.version === 'string' ? manifest.version : declared || ''\n result[pkgName] = { version, path: pkgDir }\n }),\n )\n return result\n}\n\nasync function collectPackagesFromNodeModules(root: string): Promise<Record<string, PackageNode>> {\n const result: Record<string, PackageNode> = {}\n const entries = await safeReadDir(root)\n\n for (const entry of entries) {\n if (!entry || !entry.name || entry.name.startsWith('.') || IGNORED_ENTRIES.has(entry.name)) {\n continue\n }\n\n const entryPath = path.join(root, entry.name)\n if (!(await isDir(entry, entryPath))) continue\n\n if (entry.name.startsWith('@')) {\n const scopedEntries = await safeReadDir(entryPath)\n for (const scopedEntry of scopedEntries) {\n if (!scopedEntry || !scopedEntry.name || scopedEntry.name.startsWith('.')) continue\n const scopedPath = path.join(entryPath, scopedEntry.name)\n if (!(await isDir(scopedEntry, scopedPath))) continue\n const manifest = await readJson(path.join(scopedPath, 'package.json'))\n const pkgName =\n typeof manifest?.name === 'string' ? manifest.name : `${entry.name}/${scopedEntry.name}`\n const version = typeof manifest?.version === 'string' ? manifest.version : ''\n result[pkgName] = { version, path: scopedPath }\n }\n } else {\n const manifest = await readJson(path.join(entryPath, 'package.json'))\n const pkgName = typeof manifest?.name === 'string' ? manifest.name : entry.name\n const version = typeof manifest?.version === 'string' ? manifest.version : ''\n result[pkgName] = { version, path: entryPath }\n }\n }\n\n return result\n}\n\nasync function readJson(file: string): Promise<any | null> {\n try {\n const raw = await readFile(file, 'utf8')\n return JSON.parse(raw)\n } catch {\n return null\n }\n}\n\nfunction packageDir(root: string, packageName: string): string {\n const segments = packageName.startsWith('@') ? packageName.split('/') : [packageName]\n return path.join(root, ...segments)\n}\n\nfunction buildSelections(\n manifest: Record<string, any> | null,\n { includeDev }: { includeDev: boolean },\n): { prod: Map<string, string | undefined>; dev: Map<string, string | undefined> } {\n const prod = new Map<string, string | undefined>()\n const dev = new Map<string, string | undefined>()\n\n const addAll = (\n target: Map<string, string | undefined>,\n record: Record<string, string> | undefined,\n ) => {\n if (!record) return\n for (const [name, range] of Object.entries(record)) {\n if (!target.has(name)) {\n target.set(name, range)\n }\n }\n }\n\n addAll(prod, manifest?.dependencies)\n addAll(prod, manifest?.optionalDependencies)\n if (includeDev) addAll(dev, manifest?.devDependencies)\n\n return { prod, dev }\n}\n\nfunction mapSelections(\n map: Map<string, string | undefined>,\n): { name: string; declared?: string }[] {\n return Array.from(map.entries()).map(([name, declared]) => ({ name, declared }))\n}\n\nasync function safeReadDir(dir: string): Promise<Dirent[]> {\n try {\n return await readdir(dir, { withFileTypes: true })\n } catch {\n return []\n }\n}\n\nasync function isDir(entry: Dirent, fullPath: string): Promise<boolean> {\n if (entry.isDirectory()) return true\n if (entry.isSymbolicLink()) {\n try {\n const stats = await stat(fullPath)\n return stats.isDirectory()\n } catch {\n return false\n }\n }\n return false\n}\n\nasync function pathExists(target: string): Promise<boolean> {\n try {\n await access(target, fsConstants.R_OK)\n return true\n } catch {\n return false\n }\n}\n\nfunction getGlobalRootCandidates(): string[] {\n const candidates = new Set<string>()\n const bunInstall =\n process.env.BUN_INSTALL || (process.env.HOME ? path.join(process.env.HOME, '.bun') : undefined)\n const maybeAdd = (value: string | undefined) => {\n if (value) candidates.add(value)\n }\n\n if (bunInstall) {\n maybeAdd(path.join(bunInstall, 'install', 'global', 'node_modules'))\n maybeAdd(path.join(bunInstall, 'global', 'node_modules'))\n }\n if (process.env.XDG_DATA_HOME) {\n maybeAdd(path.join(process.env.XDG_DATA_HOME, 'bun', 'install', 'global', 'node_modules'))\n }\n maybeAdd('/usr/local/share/bun/global/node_modules')\n maybeAdd('/opt/homebrew/var/bun/install/global/node_modules')\n\n return Array.from(candidates)\n}\n\nasync function getExecFileAsync(): Promise<(\n command: string,\n args?: readonly string[] | null,\n options?: any,\n) => Promise<{ stdout: string; stderr: string }>> {\n const { execFile } = await import('node:child_process')\n return promisify(execFile) as any\n}\n","/**\n * @fileoverview Bun CLI entry point for GEX dependency auditing tool\n */\n\nimport { createProgram } from './commands.js'\n\n/**\n * Main CLI runner function for Bun runtime\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('Bun CLI error:', error)\n process.exitCode = 1\n })\n}\n"],"mappings":";;;;;;;;;AAIA,OAAOA,WAAU;AACjB,SAAS,YAAAC,iBAAgB;AAEzB,SAAS,eAAe;;;ACMxB,IAAM,mBAGF;AAAA,EACF,KAAK;AAAA,IACH,QAAQ,CAAC,KAAK,IAAI;AAAA,IAClB,OAAO,CAAC,GAAG;AAAA,IACX,KAAK,CAAC,KAAK,IAAI;AAAA,EACjB;AAAA,EACA,KAAK;AAAA,IACH,QAAQ,CAAC,OAAO,IAAI;AAAA,IACpB,OAAO,CAAC,KAAK;AAAA,IACb,KAAK,CAAC,OAAO,IAAI;AAAA,EACnB;AACF;AAEA,IAAM,aAAa,KAAK,OAAO;AAE/B,SAAS,WAAW,KAAgD;AAClE,SAAO,IAAI,UAAU,GAAG,IAAI,IAAI,IAAI,IAAI,OAAO,KAAK,IAAI;AAC1D;AAKA,eAAe,mBAMb;AACA,QAAM,EAAE,SAAS,IAAI,MAAM,OAAO,eAAoB;AACtD,QAAM,EAAE,WAAAC,WAAU,IAAI,MAAM,OAAO,MAAW;AAC9C,SAAOA,WAAU,QAAQ;AAC3B;AASA,eAAsB,kB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kB,OAAO;AAEzB,SAAO;AACT;AAEA,eAAe,oBAAoB,KAAkC;AACnE,MAAI;AACF,UAAM,MAAM,MAAMC,UAASD,MAAK,KAAK,KAAK,cAAc,GAAG,MAAM;AACjE,WAAO,KAAK,MAAM,GAAG;AAAA,EACvB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;AarQA,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,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,kBAAkB,KAAK;AACrC,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":["path","readFile","promisify","path","getExecFileAsync","getExecFileAsync","readFile","path","readFile","path","path","readFile","path","readFile","promisify","manifest","selections","dependencies","getExecFileAsync","readFile","path","path","readFile"]}
|
|
1
|
+
{"version":3,"sources":["../src/runtimes/bun/commands.ts","../src/shared/cli/install.ts","../src/shared/cli/output.ts","../src/shared/report/json.ts","../src/shared/report/md.ts","../src/shared/cli/parser.ts","../src/shared/npm-cli.ts","../src/shared/cli/loader.ts","../src/shared/cli/outdated.ts","../src/shared/cli/utils.ts","../src/runtimes/bun/report.ts","../src/shared/transform.ts","../src/runtimes/bun/package-manager.ts","../src/runtimes/bun/cli.ts","../src/runtimes/bun/cli.entry.ts"],"sourcesContent":["/**\n * @fileoverview CLI command definitions and handlers for Bun runtime\n */\n\nimport path from 'node:path'\nimport { readFile } from 'node:fs/promises'\n\nimport { Command } from 'commander'\n\nimport type { OutputFormat } from '../../shared/types.js'\nimport { installFromReport, printFromReport } from '../../shared/cli/install.js'\nimport { outputReport } from '../../shared/cli/output.js'\nimport { isMarkdownReportFile, loadReportFromFile } from '../../shared/cli/parser.js'\nimport {\n normalizeUpdateSelection,\n handleOutdatedWorkflow,\n resolveOutdatedWithNpmView,\n formatOutdatedTable,\n} from '../../shared/cli/outdated.js'\nimport { ASCII_BANNER, getToolVersion } from '../../shared/cli/utils.js'\n\nimport { produceReport } from './report.js'\nimport { bunUpdate, bunPmLs } from './package-manager.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 bun pm ls tree (when available)', false)\n .option('-c, --check-outdated', 'List outdated packages instead of printing the report', false)\n .option(\n '-u, --update-outdated [packages...]',\n 'Update outdated packages (omit package names to update every package)',\n )\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 Bun 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 const cwd = process.cwd()\n\n const selection = normalizeUpdateSelection(opts.updateOutdated)\n const result = await handleOutdatedWorkflow({\n checkOutdated: Boolean(opts.checkOutdated),\n selection,\n contextLabel: 'local',\n outFile,\n fetchOutdated: async () => {\n const tree = await bunPmLs({ cwd, omitDev })\n const manifest = await readPackageManifest(cwd)\n const declared = {\n ...(manifest?.dependencies || {}),\n ...(manifest?.optionalDependencies || {}),\n ...(manifest?.devDependencies || {}),\n }\n\n const packages = Object.entries(tree.dependencies).map(([name, node]) => ({\n name,\n current: node.version,\n declared: declared[name],\n type: 'prod',\n }))\n\n if (tree.devDependencies) {\n for (const [name, node] of Object.entries(tree.devDependencies)) {\n packages.push({\n name,\n current: node.version,\n declared: declared[name],\n type: 'dev',\n })\n }\n }\n\n return resolveOutdatedWithNpmView(packages)\n },\n updateRunner: selection.shouldUpdate\n ? async (packages) => {\n await bunUpdate({ cwd, packages })\n }\n : undefined,\n })\n if (opts.checkOutdated) {\n if (result.outdated.length === 0) console.log('All local packages are up to date.')\n else console.log(formatOutdatedTable(result.outdated))\n }\n if (!result.proceed) return\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 Bun 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 const cwd = process.cwd()\n\n const selection = normalizeUpdateSelection(opts.updateOutdated)\n const result = await handleOutdatedWorkflow({\n checkOutdated: Boolean(opts.checkOutdated),\n selection,\n contextLabel: 'global',\n outFile,\n fetchOutdated: async () => {\n const tree = await bunPmLs({ global: true })\n const packages = Object.entries(tree.dependencies).map(([name, node]) => ({\n name,\n current: node.version,\n type: 'global',\n }))\n return resolveOutdatedWithNpmView(packages)\n },\n updateRunner: selection.shouldUpdate\n ? async (packages) => {\n await bunUpdate({ cwd, global: true, packages })\n }\n : undefined,\n })\n if (opts.checkOutdated) {\n if (result.outdated.length === 0) console.log('All global packages are up to date.')\n else console.log(formatOutdatedTable(result.outdated))\n }\n if (!result.proceed) return\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)', 'bun-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 using Bun', false)\n\n readCmd.action(async (reportArg: string | undefined, opts: any) => {\n const chosen = (opts.report as string | undefined) || reportArg || 'bun-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, { cwd: process.cwd(), packageManager: 'bun' })\n }\n } catch (err: any) {\n const isMd = isMarkdownReportFile(reportPath)\n const hint = isMd\n ? 'Try generating a JSON report with: gex-bun global -f json -o global.json, then: gex-bun read global.json'\n : 'Specify a report path with: gex-bun 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 for Bun runtime\n *\n * @returns Configured Commander program\n */\nexport async function createProgram(): Promise<Command> {\n const program = new Command()\n .name('gex-bun')\n .description('GEX: Dependency auditing and documentation for Bun (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\nasync function readPackageManifest(cwd: string): Promise<any | null> {\n try {\n const raw = await readFile(path.join(cwd, 'package.json'), 'utf8')\n return JSON.parse(raw)\n } catch {\n return null\n }\n}\n","/**\n * @fileoverview Package installation utilities for CLI\n */\n\nimport type { Report } from '../types.js'\n\ntype PackageManager = 'npm' | 'bun'\n\nexport type InstallOptions = {\n cwd: string\n packageManager?: PackageManager\n}\n\nconst INSTALL_COMMANDS: Record<\n PackageManager,\n { global: string[]; local: string[]; dev: string[] }\n> = {\n npm: {\n global: ['i', '-g'],\n local: ['i'],\n dev: ['i', '-D'],\n },\n bun: {\n global: ['add', '-g'],\n local: ['add'],\n dev: ['add', '-d'],\n },\n}\n\nconst MAX_BUFFER = 10 * 1024 * 1024\n\nfunction formatSpec(pkg: { name: string; version: string }): string {\n return pkg.version ? `${pkg.name}@${pkg.version}` : pkg.name\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 * 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(\n report: Report,\n options: InstallOptions | string,\n): Promise<void> {\n const opts = typeof options === 'string' ? { cwd: options } : options\n const { cwd, packageManager = 'npm' } = opts\n\n const globalPkgs = report.global_packages.map(formatSpec).filter(Boolean)\n const localPkgs = report.local_dependencies.map(formatSpec).filter(Boolean)\n const devPkgs = report.local_dev_dependencies.map(formatSpec).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 const cmd = INSTALL_COMMANDS[packageManager]\n const binary = packageManager === 'bun' ? 'bun' : 'npm'\n\n if (globalPkgs.length > 0) {\n console.log(`Installing global: ${globalPkgs.join(' ')}`)\n await execFileAsync(binary, [...cmd.global, ...globalPkgs], { cwd, maxBuffer: MAX_BUFFER })\n }\n\n if (localPkgs.length > 0) {\n console.log(`Installing local deps: ${localPkgs.join(' ')}`)\n await execFileAsync(binary, [...cmd.local, ...localPkgs], { cwd, maxBuffer: MAX_BUFFER })\n }\n\n if (devPkgs.length > 0) {\n console.log(`Installing local devDeps: ${devPkgs.join(' ')}`)\n await execFileAsync(binary, [...cmd.dev, ...devPkgs], { cwd, maxBuffer: MAX_BUFFER })\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","import { promisify } from 'node:util'\n\nexport type OutdatedInfo = {\n name: string\n current: string\n wanted: string\n latest: string\n type?: string\n}\n\nexport type NpmOutdatedOptions = {\n global?: boolean\n cwd?: string\n}\n\nexport type NpmUpdateOptions = {\n global?: boolean\n cwd: string\n packages?: string[]\n}\n\nasync function getExecFileAsync(): Promise<(\n command: string,\n args?: readonly string[] | null,\n options?: any,\n) => Promise<{ stdout: string; stderr: string }>> {\n const { execFile } = await import('node:child_process')\n return promisify(execFile) as any\n}\n\nexport async function npmOutdated(options: NpmOutdatedOptions = {}): Promise<OutdatedInfo[]> {\n const args = ['outdated', '--json']\n if (options.global) args.push('--global')\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 return normalizeOutdated(stdout)\n } catch (error: any) {\n const stdout = typeof error?.stdout === 'string' ? error.stdout : ''\n if (stdout.trim()) {\n return normalizeOutdated(stdout)\n }\n throw formatNpmError(error, 'npm outdated')\n }\n}\n\nexport async function npmUpdate(options: NpmUpdateOptions): Promise<void> {\n const args = ['update']\n if (options.global) args.push('-g')\n if (options.packages && options.packages.length > 0) args.push(...options.packages)\n\n try {\n const execFileAsync = await getExecFileAsync()\n await execFileAsync('npm', args, {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n } catch (error) {\n throw formatNpmError(error, 'npm update')\n }\n}\n\nfunction normalizeOutdated(stdout: string): OutdatedInfo[] {\n if (!stdout.trim()) return []\n let data: Record<string, any>\n try {\n data = JSON.parse(stdout)\n } catch {\n return []\n }\n\n if (!data) return []\n return Object.entries(data).map(([name, info]) => ({\n name,\n current: info?.current ? String(info.current) : '',\n wanted: info?.wanted ? String(info.wanted) : '',\n latest: info?.latest ? String(info.latest) : '',\n type: info?.type ? String(info.type) : undefined,\n }))\n}\n\nfunction formatNpmError(error: any, commandLabel: string): Error {\n const stderr = typeof error?.stderr === 'string' ? error.stderr.trim() : ''\n const message = stderr || error?.message || `${commandLabel} failed`\n return new Error(`${commandLabel} failed: ${message}`)\n}\n\nexport async function npmViewVersion(packageName: string): Promise<string> {\n try {\n const execFileAsync = await getExecFileAsync()\n const { stdout } = await execFileAsync('npm', ['view', packageName, 'version', '--json'], {\n maxBuffer: 5 * 1024 * 1024,\n })\n const parsed = JSON.parse(stdout)\n if (typeof parsed === 'string') return parsed\n if (Array.isArray(parsed)) return parsed[parsed.length - 1] ?? ''\n return ''\n } catch (error) {\n throw formatNpmError(error, `npm view ${packageName}`)\n }\n}\n","const frames = ['-', '\\\\', '|', '/'] as const\n\nexport type Loader = {\n stop: (finalMessage?: string) => void\n}\n\nexport function createLoader(message: string): Loader {\n if (!process.stdout.isTTY) {\n console.log(`${message}...`)\n return {\n stop(finalMessage) {\n if (finalMessage) console.log(finalMessage)\n },\n }\n }\n\n let index = 0\n const interval = globalThis.setInterval(() => {\n const frame = frames[index % frames.length]\n index += 1\n process.stdout.write(`\\r${message} ${frame}`)\n }, 80)\n\n return {\n stop(finalMessage) {\n globalThis.clearInterval(interval)\n process.stdout.write('\\r')\n if (finalMessage) {\n console.log(finalMessage)\n } else {\n process.stdout.write('\\x1b[2K')\n }\n },\n }\n}\n","import type { OutdatedInfo } from '../npm-cli.js'\nimport { npmViewVersion } from '../npm-cli.js'\n\nimport { createLoader } from './loader.js'\n\nexport type OutdatedEntry = OutdatedInfo\n\nexport type OutdatedSelection = {\n shouldUpdate: boolean\n updateAll: boolean\n packages: string[]\n}\n\nexport function normalizeUpdateSelection(value: unknown): OutdatedSelection {\n if (value === undefined) {\n return { shouldUpdate: false, updateAll: false, packages: [] }\n }\n if (value === true) {\n return { shouldUpdate: true, updateAll: true, packages: [] }\n }\n const packages = Array.isArray(value) ? value : typeof value === 'string' ? [value] : []\n const normalized = packages\n .flatMap((entry) =>\n String(entry)\n .split(',')\n .map((part) => part.trim()),\n )\n .filter(Boolean)\n\n return {\n shouldUpdate: true,\n updateAll: false,\n packages: normalized,\n }\n}\n\nexport function formatOutdatedTable(entries: OutdatedEntry[]): string {\n const headers = ['Name', 'Current', 'Wanted', 'Latest', 'Type']\n const rows = entries.map((entry) => [\n entry.name,\n entry.current || '-',\n entry.wanted || '-',\n entry.latest || '-',\n entry.type || '-',\n ])\n\n const widths = headers.map((header, index) =>\n Math.max(header.length, ...rows.map((row) => row[index].length)),\n )\n\n const formatRow = (columns: string[]) =>\n columns.map((col, idx) => col.padEnd(widths[idx], ' ')).join(' ')\n\n const lines = [formatRow(headers), formatRow(widths.map((w) => '-'.repeat(w)))]\n for (const row of rows) {\n lines.push(formatRow(row))\n }\n return lines.join('\\n')\n}\n\nexport type OutdatedWorkflowOptions = {\n checkOutdated: boolean\n selection: OutdatedSelection\n contextLabel: 'local' | 'global'\n outFile?: string\n fetchOutdated: () => Promise<OutdatedEntry[]>\n updateRunner?: (packages: string[]) => Promise<void>\n}\n\nexport type OutdatedWorkflowResult = {\n proceed: boolean\n outdated: OutdatedEntry[]\n}\n\nexport async function handleOutdatedWorkflow(\n opts: OutdatedWorkflowOptions,\n): Promise<OutdatedWorkflowResult> {\n if (!opts.checkOutdated && !opts.selection.shouldUpdate) {\n return { proceed: true, outdated: [] }\n }\n\n let fetchLoader: ReturnType<typeof createLoader> | undefined\n if (opts.checkOutdated || opts.selection.shouldUpdate) {\n fetchLoader = createLoader('Checking for outdated packages')\n }\n const outdated = await opts.fetchOutdated()\n fetchLoader?.stop('Finished checking outdated packages.')\n\n if (opts.selection.shouldUpdate && opts.updateRunner) {\n const packagesToUpdate = opts.selection.updateAll\n ? outdated.map((entry) => entry.name)\n : opts.selection.packages\n\n if (!packagesToUpdate || packagesToUpdate.length === 0) {\n if (opts.selection.updateAll) {\n console.log('No outdated packages to update.')\n } else {\n console.log('No packages were specified for updating.')\n }\n } else {\n const updateLoader = createLoader('Updating packages')\n await opts.updateRunner(packagesToUpdate)\n updateLoader.stop('Finished updating packages.')\n }\n }\n\n const proceed = !((opts.checkOutdated || opts.selection.shouldUpdate) && !opts.outFile)\n return { proceed, outdated }\n}\n\nexport type InstalledPackageInput = {\n name: string\n current: string\n declared?: string\n type?: string\n}\n\nexport async function resolveOutdatedWithNpmView(\n packages: InstalledPackageInput[],\n): Promise<OutdatedEntry[]> {\n const results: OutdatedEntry[] = []\n for (const pkg of packages) {\n try {\n const latest = await npmViewVersion(pkg.name)\n if (latest && pkg.current && latest !== pkg.current) {\n results.push({\n name: pkg.name,\n current: pkg.current,\n wanted: pkg.declared || latest,\n latest,\n type: pkg.type,\n })\n }\n } catch {\n continue\n }\n }\n return results\n}\n","/**\n * @fileoverview CLI utility functions for version handling and path resolution\n */\n\nimport { existsSync } from 'node:fs'\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 let startDir: string\n try {\n const __filename = fileURLToPath((import.meta as any).url)\n startDir = path.dirname(__filename)\n } catch {\n startDir = typeof __dirname !== 'undefined' ? __dirname : process.cwd()\n }\n\n return findPackageJson(startDir)\n}\n\nfunction findPackageJson(startDir: string): string {\n let current = startDir\n const maxDepth = 6\n\n for (let i = 0; i < maxDepth; i++) {\n const candidate = path.resolve(current, 'package.json')\n if (existsSync(candidate)) {\n return candidate\n }\n\n const parent = path.dirname(current)\n if (parent === current) break\n current = parent\n }\n\n return path.resolve(process.cwd(), 'package.json')\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 Report generation utilities for Bun CLI\n */\n\nimport { readFile } from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { buildReportFromNpmTree } from '../../shared/transform.js'\nimport type { OutputFormat, Report } from '../../shared/types.js'\nimport { getToolVersion } from '../../shared/cli/utils.js'\n\nimport { bunPmLs, bunPmRootGlobal, bunPmRootLocal } from './package-manager.js'\n\n/**\n * Options for Bun 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 using Bun package manager\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 cwd = options.cwd || process.cwd()\n\n const tree = await bunPmLs({\n global: ctx === 'global',\n omitDev: ctx === 'local' ? Boolean(options.omitDev) : false,\n cwd,\n })\n const nodeModulesPath = tree?.node_modules_path\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 resolvedRoot = nodeModulesPath\n ? nodeModulesPath\n : ctx === 'global'\n ? await bunPmRootGlobal().catch(() => undefined)\n : await bunPmRootLocal(cwd).catch(() => `${cwd}/node_modules`)\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: resolvedRoot,\n })\n\n const markdownExtras = { project_description, project_homepage, project_bugs }\n return { report, markdownExtras }\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 devDepsObj = tree?.devDependencies as Record<string, any> | undefined\n const prodItems = toPkgArray(depsObj)\n const treeDevItems = toPkgArray(devDepsObj)\n\n if (treeDevItems.length > 0) {\n for (const { name, node } of treeDevItems) {\n const version = (node && node.version) || ''\n const resolvedPath =\n (node && node.path) || path.join(opts.cwd || process.cwd(), 'node_modules', name)\n report.local_dev_dependencies.push({ name, version, resolved_path: resolvedPath })\n }\n }\n\n const devKeys =\n treeDevItems.length > 0\n ? new Set(treeDevItems.map((entry) => entry.name))\n : new Set(Object.keys((pkgMeta?.devDependencies as Record<string, string>) || {}))\n\n for (const { name, node } of prodItems) {\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 (!treeDevItems.length && 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","import path from 'node:path'\nimport { constants as fsConstants, type Dirent } from 'node:fs'\nimport { access, readFile, readdir, stat } from 'node:fs/promises'\nimport { promisify } from 'node:util'\n\nexport type BunPmLsOptions = {\n global?: boolean\n omitDev?: boolean\n depth0?: boolean\n cwd?: string\n}\n\ntype PackageNode = {\n version: string\n path: string\n}\n\ntype BunPackageTree = {\n dependencies: Record<string, PackageNode>\n devDependencies?: Record<string, PackageNode>\n node_modules_path?: string\n}\n\nconst IGNORED_ENTRIES = new Set(['.bin'])\n\n/**\n * Executes a Bun package listing by inspecting node_modules directories directly.\n */\nexport async function bunPmLs(options: BunPmLsOptions = {}): Promise<BunPackageTree> {\n if (options.global) {\n const root = await bunPmRootGlobal()\n const manifest = await readJson(path.join(path.dirname(root), 'package.json'))\n const selections = buildSelections(manifest, { includeDev: false })\n const dependencies =\n selections.prod.size > 0\n ? await collectPackagesForNames(root, mapSelections(selections.prod))\n : await collectPackagesFromNodeModules(root)\n return { dependencies, node_modules_path: root }\n }\n\n const cwd = options.cwd || process.cwd()\n const nodeModulesPath = await bunPmRootLocal(cwd)\n const manifest = await readJson(path.join(cwd, 'package.json'))\n const includeDev = !options.omitDev\n const selections = buildSelections(manifest, { includeDev })\n\n const dependencies =\n selections.prod.size > 0\n ? await collectPackagesForNames(nodeModulesPath, mapSelections(selections.prod))\n : await collectPackagesFromNodeModules(nodeModulesPath)\n\n let devDependencies: Record<string, PackageNode> | undefined\n if (includeDev) {\n if (selections.dev.size > 0) {\n devDependencies = await collectPackagesForNames(\n nodeModulesPath,\n mapSelections(selections.dev),\n )\n } else {\n devDependencies = {}\n }\n }\n\n return { dependencies, devDependencies, node_modules_path: nodeModulesPath }\n}\n\n/**\n * Attempts to resolve the Bun global node_modules directory.\n */\nexport async function bunPmRootGlobal(): Promise<string> {\n if (process.env.GEX_BUN_GLOBAL_ROOT) {\n return process.env.GEX_BUN_GLOBAL_ROOT\n }\n\n const candidates = getGlobalRootCandidates()\n for (const candidate of candidates) {\n if (candidate && (await pathExists(candidate))) {\n return candidate\n }\n }\n\n return (\n candidates.find((c) => Boolean(c)) ||\n path.join(process.env.HOME || process.cwd(), '.bun', 'install', 'global', 'node_modules')\n )\n}\n\n/**\n * Resolves the Bun local node_modules directory for the provided cwd.\n */\nexport async function bunPmRootLocal(cwd: string = process.cwd()): Promise<string> {\n if (process.env.GEX_BUN_LOCAL_ROOT) {\n return process.env.GEX_BUN_LOCAL_ROOT\n }\n return path.join(cwd, 'node_modules')\n}\n\nexport type BunUpdateOptions = {\n cwd: string\n global?: boolean\n packages?: string[]\n}\n\nexport async function bunUpdate(options: BunUpdateOptions): Promise<void> {\n const execFileAsync = await getExecFileAsync()\n const packages = options.packages && options.packages.length > 0 ? options.packages : []\n\n if (options.global) {\n const targets = packages.length > 0 ? packages : []\n const list = targets.length > 0 ? targets : []\n const cmdPackages = list.map((name) => `${name}@latest`)\n try {\n await execFileAsync('bun', ['add', '-g', ...cmdPackages], {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n } catch (error: any) {\n const stderr = typeof error?.stderr === 'string' ? error.stderr.trim() : ''\n throw new Error(`bun add -g failed: ${stderr || error?.message || 'unknown error'}`)\n }\n return\n }\n\n const args = ['update']\n if (packages.length > 0) args.push(...packages)\n\n try {\n await execFileAsync('bun', args, {\n cwd: options.cwd,\n maxBuffer: 10 * 1024 * 1024,\n })\n } catch (error: any) {\n const stderr = typeof error?.stderr === 'string' ? error.stderr.trim() : ''\n throw new Error(`bun update failed: ${stderr || error?.message || 'unknown error'}`)\n }\n}\n\nasync function collectPackagesForNames(\n nodeModulesPath: string,\n packages: { name: string; declared?: string }[],\n): Promise<Record<string, PackageNode>> {\n const result: Record<string, PackageNode> = {}\n await Promise.all(\n packages.map(async ({ name, declared }) => {\n const pkgDir = packageDir(nodeModulesPath, name)\n const manifest = await readJson(path.join(pkgDir, 'package.json'))\n const pkgName = typeof manifest?.name === 'string' ? manifest.name : name\n const version = typeof manifest?.version === 'string' ? manifest.version : declared || ''\n result[pkgName] = { version, path: pkgDir }\n }),\n )\n return result\n}\n\nasync function collectPackagesFromNodeModules(root: string): Promise<Record<string, PackageNode>> {\n const result: Record<string, PackageNode> = {}\n const entries = await safeReadDir(root)\n\n for (const entry of entries) {\n if (!entry || !entry.name || entry.name.startsWith('.') || IGNORED_ENTRIES.has(entry.name)) {\n continue\n }\n\n const entryPath = path.join(root, entry.name)\n if (!(await isDir(entry, entryPath))) continue\n\n if (entry.name.startsWith('@')) {\n const scopedEntries = await safeReadDir(entryPath)\n for (const scopedEntry of scopedEntries) {\n if (!scopedEntry || !scopedEntry.name || scopedEntry.name.startsWith('.')) continue\n const scopedPath = path.join(entryPath, scopedEntry.name)\n if (!(await isDir(scopedEntry, scopedPath))) continue\n const manifest = await readJson(path.join(scopedPath, 'package.json'))\n const pkgName =\n typeof manifest?.name === 'string' ? manifest.name : `${entry.name}/${scopedEntry.name}`\n const version = typeof manifest?.version === 'string' ? manifest.version : ''\n result[pkgName] = { version, path: scopedPath }\n }\n } else {\n const manifest = await readJson(path.join(entryPath, 'package.json'))\n const pkgName = typeof manifest?.name === 'string' ? manifest.name : entry.name\n const version = typeof manifest?.version === 'string' ? manifest.version : ''\n result[pkgName] = { version, path: entryPath }\n }\n }\n\n return result\n}\n\nasync function readJson(file: string): Promise<any | null> {\n try {\n const raw = await readFile(file, 'utf8')\n return JSON.parse(raw)\n } catch {\n return null\n }\n}\n\nfunction packageDir(root: string, packageName: string): string {\n const segments = packageName.startsWith('@') ? packageName.split('/') : [packageName]\n return path.join(root, ...segments)\n}\n\nfunction buildSelections(\n manifest: Record<string, any> | null,\n { includeDev }: { includeDev: boolean },\n): { prod: Map<string, string | undefined>; dev: Map<string, string | undefined> } {\n const prod = new Map<string, string | undefined>()\n const dev = new Map<string, string | undefined>()\n\n const addAll = (\n target: Map<string, string | undefined>,\n record: Record<string, string> | undefined,\n ) => {\n if (!record) return\n for (const [name, range] of Object.entries(record)) {\n if (!target.has(name)) {\n target.set(name, range)\n }\n }\n }\n\n addAll(prod, manifest?.dependencies)\n addAll(prod, manifest?.optionalDependencies)\n if (includeDev) addAll(dev, manifest?.devDependencies)\n\n return { prod, dev }\n}\n\nfunction mapSelections(\n map: Map<string, string | undefined>,\n): { name: string; declared?: string }[] {\n return Array.from(map.entries()).map(([name, declared]) => ({ name, declared }))\n}\n\nasync function safeReadDir(dir: string): Promise<Dirent[]> {\n try {\n return await readdir(dir, { withFileTypes: true })\n } catch {\n return []\n }\n}\n\nasync function isDir(entry: Dirent, fullPath: string): Promise<boolean> {\n if (entry.isDirectory()) return true\n if (entry.isSymbolicLink()) {\n try {\n const stats = await stat(fullPath)\n return stats.isDirectory()\n } catch {\n return false\n }\n }\n return false\n}\n\nasync function pathExists(target: string): Promise<boolean> {\n try {\n await access(target, fsConstants.R_OK)\n return true\n } catch {\n return false\n }\n}\n\nfunction getGlobalRootCandidates(): string[] {\n const candidates = new Set<string>()\n const bunInstall =\n process.env.BUN_INSTALL || (process.env.HOME ? path.join(process.env.HOME, '.bun') : undefined)\n const maybeAdd = (value: string | undefined) => {\n if (value) candidates.add(value)\n }\n\n if (bunInstall) {\n maybeAdd(path.join(bunInstall, 'install', 'global', 'node_modules'))\n maybeAdd(path.join(bunInstall, 'global', 'node_modules'))\n }\n if (process.env.XDG_DATA_HOME) {\n maybeAdd(path.join(process.env.XDG_DATA_HOME, 'bun', 'install', 'global', 'node_modules'))\n }\n maybeAdd('/usr/local/share/bun/global/node_modules')\n maybeAdd('/opt/homebrew/var/bun/install/global/node_modules')\n\n return Array.from(candidates)\n}\n\nasync function getExecFileAsync(): Promise<(\n command: string,\n args?: readonly string[] | null,\n options?: any,\n) => Promise<{ stdout: string; stderr: string }>> {\n const { execFile } = await import('node:child_process')\n return promisify(execFile) as any\n}\n","/**\n * @fileoverview Bun CLI runner for GEX dependency auditing tool\n *\n * This module only exports the `run` function and does not auto-execute\n * itself. Binary entrypoints (e.g. `cli-bun`) are responsible for invoking\n * `run()` when appropriate so this file can be safely imported by other\n * entrypoints without triggering side effects.\n */\n\nimport { createProgram } from './commands.js'\n\n/**\n * Main CLI runner function for Bun runtime\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","/**\n * @fileoverview Bun CLI entrypoint for the `gex-bun` binary.\n *\n * This thin wrapper invokes the shared Bun runtime `run` function when the\n * generated bundle is executed as the main module.\n */\n\nimport { run } from './cli.js'\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('Bun CLI error:', error)\n process.exitCode = 1\n })\n}\n"],"mappings":";;;;;;;;;AAIA,OAAOA,WAAU;AACjB,SAAS,YAAAC,iBAAgB;AAEzB,SAAS,eAAe;;;ACMxB,IAAM,mBAGF;AAAA,EACF,KAAK;AAAA,IACH,QAAQ,CAAC,KAAK,IAAI;AAAA,IAClB,OAAO,CAAC,GAAG;AA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["path","readFile","promisify","path","getExecFileAsync","getExecFileAsync","readFile","path","readFile","path","path","readFile","path","readFile","promisify","manifest","selections","dependencies","getExecFileAsync","readFile","path","path","readFile"]}
|
package/dist/cli-node.cjs
CHANGED
|
@@ -6,10 +6,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
9
|
var __copyProps = (to, from, except, desc) => {
|
|
14
10
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
11
|
for (let key of __getOwnPropNames(from))
|
|
@@ -26,14 +22,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
22
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
23
|
mod
|
|
28
24
|
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/runtimes/node/cli.ts
|
|
32
|
-
var cli_exports = {};
|
|
33
|
-
__export(cli_exports, {
|
|
34
|
-
run: () => run
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(cli_exports);
|
|
37
25
|
|
|
38
26
|
// src/runtimes/node/commands.ts
|
|
39
27
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
@@ -734,11 +722,13 @@ ${ASCII_BANNER}`);
|
|
|
734
722
|
}
|
|
735
723
|
|
|
736
724
|
// src/runtimes/node/cli.ts
|
|
737
|
-
var import_meta2 = {};
|
|
738
725
|
async function run(argv = process.argv) {
|
|
739
726
|
const program = await createProgram();
|
|
740
727
|
await program.parseAsync(argv);
|
|
741
728
|
}
|
|
729
|
+
|
|
730
|
+
// src/runtimes/node/cli.entry.ts
|
|
731
|
+
var import_meta2 = {};
|
|
742
732
|
var isMainModule = (() => {
|
|
743
733
|
try {
|
|
744
734
|
if (typeof require !== "undefined" && typeof module !== "undefined") {
|
|
@@ -758,8 +748,4 @@ if (isMainModule) {
|
|
|
758
748
|
process.exitCode = 1;
|
|
759
749
|
});
|
|
760
750
|
}
|
|
761
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
762
|
-
0 && (module.exports = {
|
|
763
|
-
run
|
|
764
|
-
});
|
|
765
751
|
//# sourceMappingURL=cli-node.cjs.map
|