recon-generate 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/link.js +40 -9
  2. package/package.json +1 -1
package/dist/link.js CHANGED
@@ -74,22 +74,53 @@ const parseLibrariesFromOutput = (output, verbose = false) => {
74
74
  };
75
75
  const runCryticCompile = (cwd, verbose = false) => {
76
76
  return new Promise((resolve, reject) => {
77
- const cmd = 'crytic-compile . --foundry-compile-all --print-libraries';
77
+ const cmd = 'crytic-compile';
78
+ const args = ['.', '--foundry-compile-all', '--print-libraries'];
78
79
  if (verbose) {
79
- console.log(`[VERBOSE] Running command: ${cmd}`);
80
+ console.log(`[VERBOSE] Running command: ${cmd} ${args.join(' ')}`);
80
81
  console.log(`[VERBOSE] Working directory: ${cwd}`);
81
82
  }
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}`);
83
+ const child = (0, child_process_1.spawn)(cmd, args, { cwd, env: { ...process.env, PATH: (0, utils_1.getEnvPath)() } });
84
+ const usesPattern = /^\s+uses:\s+\[(.*?)\]/;
85
+ let stdoutRemainder = '';
86
+ let stderrBuffer = '';
87
+ const relevantLines = [];
88
+ const handleStdoutChunk = (chunk) => {
89
+ var _a;
90
+ const text = stdoutRemainder + chunk.toString('utf8');
91
+ const lines = text.split(/\r?\n/);
92
+ stdoutRemainder = (_a = lines.pop()) !== null && _a !== void 0 ? _a : '';
93
+ for (const line of lines) {
94
+ const sanitized = (0, utils_1.stripAnsiCodes)(line);
95
+ if (usesPattern.test(sanitized)) {
96
+ relevantLines.push(sanitized);
97
+ }
86
98
  }
87
- if (error) {
88
- const errorMsg = `crytic-compile failed with exit code ${error.code}\nstderr: ${stderr}\nstdout: ${stdout}\nerror: ${error.message}`;
99
+ };
100
+ child.stdout.on('data', handleStdoutChunk);
101
+ child.stderr.on('data', chunk => {
102
+ stderrBuffer += chunk.toString('utf8');
103
+ });
104
+ child.on('error', err => {
105
+ reject(new Error(`crytic-compile failed to start: ${err.message}`));
106
+ });
107
+ child.on('close', code => {
108
+ if (stdoutRemainder) {
109
+ const sanitized = (0, utils_1.stripAnsiCodes)(stdoutRemainder);
110
+ if (usesPattern.test(sanitized)) {
111
+ relevantLines.push(sanitized);
112
+ }
113
+ }
114
+ if (code !== 0) {
115
+ const truncatedStderr = stderrBuffer.slice(-4000); // avoid flooding the buffer in errors
116
+ const errorMsg = `crytic-compile failed with exit code ${code}\nstderr (tail): ${truncatedStderr}`;
89
117
  reject(new Error(errorMsg));
90
118
  return;
91
119
  }
92
- resolve(stdout || '');
120
+ if (verbose) {
121
+ console.log(`[VERBOSE] Collected ${relevantLines.length} lines containing 'uses:'`);
122
+ }
123
+ resolve(relevantLines.join('\n'));
93
124
  });
94
125
  });
95
126
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recon-generate",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "CLI to scaffold Recon fuzzing suite inside Foundry projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {