recon-generate 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -163,6 +163,7 @@ async function main() {
163
163
  .option('--medusa-config <path>', 'Path to medusa json (defaults based on --name)')
164
164
  .option('--name <suite>', 'Suite name to pick config defaults (echidna-<name>.yaml / medusa-<name>.json)')
165
165
  .option('--foundry-config <path>', 'Path to foundry.toml (defaults to ./foundry.toml)')
166
+ .option('--verbose', 'Enable verbose output for debugging')
166
167
  .action(async (opts, cmd) => {
167
168
  var _a;
168
169
  const workspaceRoot = process.cwd();
@@ -182,7 +183,7 @@ async function main() {
182
183
  const medusaConfigPath = path.isAbsolute(medusaConfigOpt)
183
184
  ? medusaConfigOpt
184
185
  : path.join(foundryRoot, medusaConfigOpt);
185
- await (0, link_1.runLink)(foundryRoot, echidnaConfigPath, medusaConfigPath);
186
+ await (0, link_1.runLink)(foundryRoot, echidnaConfigPath, medusaConfigPath, !!opts.verbose);
186
187
  });
187
188
  program
188
189
  .action(async (opts) => {
package/dist/link.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function runLink(foundryRoot: string, echidnaConfigPath: string, medusaConfigPath: string): Promise<void>;
1
+ export declare function runLink(foundryRoot: string, echidnaConfigPath: string, medusaConfigPath: string, verbose?: boolean): Promise<void>;
package/dist/link.js CHANGED
@@ -44,9 +44,15 @@ const utils_1 = require("./utils");
44
44
  const generateHexAddress = (index) => {
45
45
  return `0xf${(index + 1).toString().padStart(2, '0')}`;
46
46
  };
47
- const parseLibrariesFromOutput = (output) => {
47
+ const parseLibrariesFromOutput = (output, verbose = false) => {
48
+ if (verbose) {
49
+ console.log(`[VERBOSE] Parsing libraries from output (${output.length} chars)`);
50
+ }
48
51
  const usesPattern = /^\s+uses: \[(.*?)\]/gm;
49
52
  const matches = [...(0, utils_1.stripAnsiCodes)(output).matchAll(usesPattern)];
53
+ if (verbose) {
54
+ console.log(`[VERBOSE] Found ${matches.length} 'uses:' patterns`);
55
+ }
50
56
  const allLibraries = [];
51
57
  for (const match of matches) {
52
58
  if (match[1]) {
@@ -54,6 +60,9 @@ const parseLibrariesFromOutput = (output) => {
54
60
  .split(',')
55
61
  .map(lib => lib.trim().replace(/["'\s]/g, ''))
56
62
  .filter(lib => lib.length > 0);
63
+ if (verbose) {
64
+ console.log(`[VERBOSE] Parsed libraries from match: ${libs.join(', ')}`);
65
+ }
57
66
  for (const lib of libs) {
58
67
  if (!allLibraries.includes(lib)) {
59
68
  allLibraries.push(lib);
@@ -63,11 +72,21 @@ const parseLibrariesFromOutput = (output) => {
63
72
  }
64
73
  return allLibraries;
65
74
  };
66
- const runCryticCompile = (cwd) => {
75
+ const runCryticCompile = (cwd, verbose = false) => {
67
76
  return new Promise((resolve, reject) => {
68
- (0, child_process_1.exec)('crytic-compile . --foundry-compile-all --print-libraries', { cwd, env: { ...process.env, PATH: (0, utils_1.getEnvPath)() } }, (error, stdout, stderr) => {
77
+ const cmd = 'crytic-compile . --foundry-compile-all --print-libraries';
78
+ if (verbose) {
79
+ console.log(`[VERBOSE] Running command: ${cmd}`);
80
+ console.log(`[VERBOSE] Working directory: ${cwd}`);
81
+ }
82
+ (0, child_process_1.exec)(cmd, { cwd, env: { ...process.env, PATH: (0, utils_1.getEnvPath)() } }, (error, stdout, stderr) => {
83
+ if (verbose) {
84
+ console.log(`[VERBOSE] stdout:\n${stdout}`);
85
+ console.log(`[VERBOSE] stderr:\n${stderr}`);
86
+ }
69
87
  if (error) {
70
- reject(new Error(stderr || error.message));
88
+ const errorMsg = `crytic-compile failed with exit code ${error.code}\nstderr: ${stderr}\nstdout: ${stdout}\nerror: ${error.message}`;
89
+ reject(new Error(errorMsg));
71
90
  return;
72
91
  }
73
92
  resolve(stdout || '');
@@ -92,13 +111,22 @@ const formatEchidnaYaml = (config, libraries) => {
92
111
  });
93
112
  return out;
94
113
  };
95
- const updateEchidnaConfig = async (configPath, libraries) => {
114
+ const updateEchidnaConfig = async (configPath, libraries, verbose = false) => {
115
+ if (verbose) {
116
+ console.log(`[VERBOSE] Reading echidna config from: ${configPath}`);
117
+ }
96
118
  const content = await fs.readFile(configPath, 'utf8');
97
119
  const parsed = yaml_1.default.parse(content) || {};
98
120
  const updated = formatEchidnaYaml(parsed, libraries);
121
+ if (verbose) {
122
+ console.log(`[VERBOSE] Updated echidna config:\n${updated}`);
123
+ }
99
124
  await fs.writeFile(configPath, updated, 'utf8');
100
125
  };
101
- const updateMedusaConfig = async (configPath, libraries) => {
126
+ const updateMedusaConfig = async (configPath, libraries, verbose = false) => {
127
+ if (verbose) {
128
+ console.log(`[VERBOSE] Reading medusa config from: ${configPath}`);
129
+ }
102
130
  const content = await fs.readFile(configPath, 'utf8');
103
131
  const parsed = JSON.parse(content);
104
132
  if (!parsed.compilation)
@@ -112,26 +140,50 @@ const updateMedusaConfig = async (configPath, libraries) => {
112
140
  else {
113
141
  delete parsed.compilation.platformConfig.args;
114
142
  }
143
+ if (verbose) {
144
+ console.log(`[VERBOSE] Updated medusa config:\n${JSON.stringify(parsed, null, 2)}`);
145
+ }
115
146
  await fs.writeFile(configPath, JSON.stringify(parsed, null, 2), 'utf8');
116
147
  };
117
- async function runLink(foundryRoot, echidnaConfigPath, medusaConfigPath) {
118
- const output = await runCryticCompile(foundryRoot);
119
- const libraries = parseLibrariesFromOutput(output);
148
+ async function runLink(foundryRoot, echidnaConfigPath, medusaConfigPath, verbose = false) {
149
+ if (verbose) {
150
+ console.log(`[VERBOSE] Starting runLink`);
151
+ console.log(`[VERBOSE] Foundry root: ${foundryRoot}`);
152
+ console.log(`[VERBOSE] Echidna config path: ${echidnaConfigPath}`);
153
+ console.log(`[VERBOSE] Medusa config path: ${medusaConfigPath}`);
154
+ }
155
+ let output;
156
+ try {
157
+ output = await runCryticCompile(foundryRoot, verbose);
158
+ }
159
+ catch (e) {
160
+ throw new Error(`crytic-compile execution failed: ${e instanceof Error ? e.message : String(e)}`);
161
+ }
162
+ const libraries = parseLibrariesFromOutput(output, verbose);
120
163
  console.log('Detected libraries:', libraries.length ? libraries.join(', ') : '(none)');
121
164
  try {
122
165
  await fs.access(echidnaConfigPath);
123
- await updateEchidnaConfig(echidnaConfigPath, libraries);
166
+ if (verbose) {
167
+ console.log(`[VERBOSE] Echidna config exists, updating...`);
168
+ }
169
+ await updateEchidnaConfig(echidnaConfigPath, libraries, verbose);
124
170
  console.log(`Updated echidna config at ${echidnaConfigPath}`);
125
171
  }
126
172
  catch (e) {
127
- throw new Error(`Failed to update echidna config: ${e}`);
173
+ throw new Error(`Failed to update echidna config: ${e instanceof Error ? e.message : String(e)}`);
128
174
  }
129
175
  try {
130
176
  await fs.access(medusaConfigPath);
131
- await updateMedusaConfig(medusaConfigPath, libraries);
177
+ if (verbose) {
178
+ console.log(`[VERBOSE] Medusa config exists, updating...`);
179
+ }
180
+ await updateMedusaConfig(medusaConfigPath, libraries, verbose);
132
181
  console.log(`Updated medusa config at ${medusaConfigPath}`);
133
182
  }
134
183
  catch (e) {
135
- throw new Error(`Failed to update medusa config: ${e}`);
184
+ throw new Error(`Failed to update medusa config: ${e instanceof Error ? e.message : String(e)}`);
185
+ }
186
+ if (verbose) {
187
+ console.log(`[VERBOSE] runLink completed successfully`);
136
188
  }
137
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recon-generate",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "CLI to scaffold Recon fuzzing suite inside Foundry projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {