@diamondslab/diamonds-hardhat-foundry 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,31 @@
1
1
  import { HardhatRuntimeEnvironment } from "hardhat/types";
2
2
  import { CoverageOptions } from "../types/config";
3
3
  /**
4
- * ForgeCoverageFramework - Orchestrates forge coverage execution for Diamond contracts
4
+ * ForgeCoverageFramework - Main orchestration class for Forge coverage with Diamonds
5
5
  *
6
- * Responsibilities:
7
- * 1. Build forge coverage command with all options
8
- * 2. Execute forge coverage with proper fork URL
9
- * 3. Stream output to terminal
10
- * 4. Handle errors appropriately
6
+ * Coordinates:
7
+ * 1. Diamond deployment via DeploymentManager
8
+ * 2. Helper generation via HelperGenerator
9
+ * 3. Forge coverage execution
10
+ *
11
+ * Mirrors ForgeFuzzingFramework design for consistency and code reuse
11
12
  */
12
13
  export declare class ForgeCoverageFramework {
13
14
  private hre;
15
+ private deploymentManager;
16
+ private helperGenerator;
14
17
  constructor(hre: HardhatRuntimeEnvironment);
15
18
  /**
16
- * Run forge coverage with provided options
19
+ * Run complete Forge coverage workflow
20
+ *
21
+ * Workflow:
22
+ * 1. Validate Foundry installation
23
+ * 2. Deploy or reuse Diamond
24
+ * 3. Generate Solidity helpers
25
+ * 4. Run forge coverage with options
17
26
  *
18
27
  * @param options - Coverage execution options
19
- * @returns Promise<boolean> - true if coverage succeeds, false otherwise
28
+ * @returns Promise<boolean> - true if coverage succeeds
20
29
  */
21
30
  runCoverage(options?: CoverageOptions): Promise<boolean>;
22
31
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ForgeCoverageFramework.d.ts","sourceRoot":"","sources":["../../src/framework/ForgeCoverageFramework.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;;;;;;;GAQG;AACH,qB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;;;;;OAKG;IACH,OAAO,CAAC,YAAY;CAsBrB"}
@@ -2,35 +2,101 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ForgeCoverageFramework = void 0;
4
4
  const child_process_1 = require("child_process");
5
+ const foundry_1 = require("../utils/foundry");
5
6
  const logger_1 = require("../utils/logger");
7
+ const DeploymentManager_1 = require("./DeploymentManager");
8
+ const HelperGenerator_1 = require("./HelperGenerator");
6
9
  /**
7
- * ForgeCoverageFramework - Orchestrates forge coverage execution for Diamond contracts
10
+ * ForgeCoverageFramework - Main orchestration class for Forge coverage with Diamonds
8
11
  *
9
- * Responsibilities:
10
- * 1. Build forge coverage command with all options
11
- * 2. Execute forge coverage with proper fork URL
12
- * 3. Stream output to terminal
13
- * 4. Handle errors appropriately
12
+ * Coordinates:
13
+ * 1. Diamond deployment via DeploymentManager
14
+ * 2. Helper generation via HelperGenerator
15
+ * 3. Forge coverage execution
16
+ *
17
+ * Mirrors ForgeFuzzingFramework design for consistency and code reuse
14
18
  */
15
19
  class ForgeCoverageFramework {
16
20
  hre;
21
+ deploymentManager;
22
+ helperGenerator;
17
23
  constructor(hre) {
18
24
  this.hre = hre;
25
+ this.deploymentManager = new DeploymentManager_1.DeploymentManager(hre);
26
+ this.helperGenerator = new HelperGenerator_1.HelperGenerator(hre);
19
27
  }
20
28
  /**
21
- * Run forge coverage with provided options
29
+ * Run complete Forge coverage workflow
30
+ *
31
+ * Workflow:
32
+ * 1. Validate Foundry installation
33
+ * 2. Deploy or reuse Diamond
34
+ * 3. Generate Solidity helpers
35
+ * 4. Run forge coverage with options
22
36
  *
23
37
  * @param options - Coverage execution options
24
- * @returns Promise<boolean> - true if coverage succeeds, false otherwise
38
+ * @returns Promise<boolean> - true if coverage succeeds
25
39
  */
26
40
  async runCoverage(options = {}) {
27
- logger_1.Logger.section("Forge Coverage - Execution");
41
+ const { diamondName = "ExampleDiamond", networkName = "hardhat", force = false, skipDeployment = false, skipHelpers = false, writeDeployedDiamondData = false, } = options;
42
+ logger_1.Logger.section("Running Forge Coverage with Diamond");
43
+ // Step 1: Validate Foundry
44
+ if (!(0, foundry_1.isFoundryInstalled)()) {
45
+ logger_1.Logger.error("Foundry is not installed. Please install it: https://book.getfoundry.sh/getting-started/installation");
46
+ return false;
47
+ }
28
48
  try {
29
- // Build command arguments
30
- const args = this.buildCoverageCommand(options);
49
+ // Step 2: Ensure Diamond deployment
50
+ if (!skipDeployment) {
51
+ logger_1.Logger.section("Step 1/3: Ensuring Diamond Deployment");
52
+ await this.deploymentManager.ensureDeployment(diamondName, networkName, force, writeDeployedDiamondData);
53
+ }
54
+ else {
55
+ logger_1.Logger.info("Skipping deployment (using existing)");
56
+ }
57
+ // Step 3: Generate helpers
58
+ if (!skipHelpers) {
59
+ logger_1.Logger.section("Step 2/3: Generating Solidity Helpers");
60
+ const deployment = await this.deploymentManager.getDeployment(diamondName, networkName);
61
+ if (!deployment) {
62
+ logger_1.Logger.warn("⚠ No deployment record found");
63
+ if (!skipDeployment) {
64
+ logger_1.Logger.info("ℹ Using cached deployment (ephemeral)");
65
+ }
66
+ }
67
+ else {
68
+ logger_1.Logger.info("Using deployment record");
69
+ }
70
+ const provider = this.hre.ethers.provider;
71
+ const network = await provider.getNetwork();
72
+ const chainId = Number(network.chainId);
73
+ const deploymentData = deployment
74
+ ? deployment.getDeployedDiamondData()
75
+ : await this.deploymentManager
76
+ .ensureDeployment(diamondName, networkName, false, false)
77
+ .then((d) => d.getDeployedDiamondData());
78
+ await this.helperGenerator.generateDeploymentHelpers(diamondName, networkName, chainId, deploymentData, deployment || undefined);
79
+ }
80
+ else {
81
+ logger_1.Logger.info("Skipping helper generation");
82
+ }
83
+ // Step 4: Run coverage
84
+ logger_1.Logger.section("Step 3/3: Running Forge Coverage");
85
+ // Get fork URL for network (same pattern as ForgeFuzzingFramework)
86
+ const provider = this.hre.ethers.provider;
87
+ let forkUrl;
88
+ if (networkName !== "hardhat") {
89
+ forkUrl = provider.connection?.url || "http://127.0.0.1:8545";
90
+ }
91
+ else {
92
+ forkUrl = "http://127.0.0.1:8545";
93
+ logger_1.Logger.warn("⚠️ Network is \"hardhat\" - defaulting to localhost fork: http://127.0.0.1:8545");
94
+ logger_1.Logger.warn("💡 Make sure Hardhat node is running: npx hardhat node");
95
+ logger_1.Logger.warn("💡 Or specify network explicitly: --network localhost");
96
+ }
97
+ const args = this.buildCoverageCommand({ ...options, forkUrl });
31
98
  logger_1.Logger.info(`Executing: forge coverage ${args.join(" ")}`);
32
- logger_1.Logger.info("⏳ Running coverage analysis (this may take a while)...\n");
33
- // Execute forge coverage
99
+ logger_1.Logger.info("⏳ Running coverage analysis (this may take a while)...");
34
100
  const success = await this.executeForge(args);
35
101
  if (success) {
36
102
  logger_1.Logger.success("✅ Coverage analysis completed successfully");
@@ -41,7 +107,7 @@ class ForgeCoverageFramework {
41
107
  return success;
42
108
  }
43
109
  catch (error) {
44
- logger_1.Logger.error(`Coverage execution error: ${error.message}`);
110
+ logger_1.Logger.error(`Coverage execution failed: ${error.message}`);
45
111
  return false;
46
112
  }
47
113
  }
@@ -73,9 +139,9 @@ class ForgeCoverageFramework {
73
139
  const args = [];
74
140
  // Multiple --report flags
75
141
  if (options.report && options.report.length > 0) {
76
- options.report.forEach((reportType) => {
142
+ for (const reportType of options.report) {
77
143
  args.push("--report", reportType);
78
- });
144
+ }
79
145
  }
80
146
  if (options.reportFile) {
81
147
  args.push("--report-file", options.reportFile);
@@ -216,11 +282,12 @@ class ForgeCoverageFramework {
216
282
  */
217
283
  executeForge(args) {
218
284
  return new Promise((resolve, reject) => {
219
- const forgeProcess = (0, child_process_1.spawn)("forge", ["coverage", ...args], {
285
+ const forge = (0, child_process_1.spawn)("forge", ["coverage", ...args], {
220
286
  cwd: this.hre.config.paths.root,
221
- stdio: "inherit", // Stream output directly to terminal
287
+ stdio: "inherit",
288
+ shell: true,
222
289
  });
223
- forgeProcess.on("close", (code) => {
290
+ forge.on("close", (code) => {
224
291
  if (code === 0) {
225
292
  resolve(true);
226
293
  }
@@ -228,8 +295,9 @@ class ForgeCoverageFramework {
228
295
  resolve(false);
229
296
  }
230
297
  });
231
- forgeProcess.on("error", (error) => {
232
- reject(new Error(`Failed to execute forge coverage: ${error.message}`));
298
+ forge.on("error", (error) => {
299
+ logger_1.Logger.error(`Failed to execute forge: ${error.message}`);
300
+ reject(error);
233
301
  });
234
302
  });
235
303
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ForgeCoverageFramework.js","sourceRoot":"","sources":["../../src/framework/ForgeCoverageFramework.ts"],"names":[],"mappings":";;;AAAA,iDAAsC;AAGtC,4CAAyC;AAEzC;;;;;;;;GAQG;AACH,MAAa,sBAAsB;IACb;IAApB,YAAoB,GAA8B;QAA9B,QAAG,GAAH,GAAG,CAA2B;IAAG,CAAC;IAEtD;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,UAA2B,EAAE;QAC7C,eAAM,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAE7C,IAAI;YACF,0BAA0B;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAEhD,eAAM,CAAC,IAAI,CAAC,6BAA6B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3D,eAAM,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;YAExE,yBAAyB;YACzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAE9C,IAAI,OAAO,EAAE;gBACX,eAAM,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAAC;aAC9D;iBAAM;gBACL,eAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;aAC5C;YAED,OAAO,OAAO,CAAC;SAChB;QAAC,OAAO,KAAU,EAAE;YACnB,eAAM,CAAC,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3D,OAAO,KAAK,CAAC;S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AI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACzB;QAED,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;SACjE;QAED,IAAI,OAAO,CAAC,KAAK,EAAE;YACjB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACvB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACK,YAAY,CAAC,IAAc;QACjC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,YAAY,GAAG,IAAA,qBAAK,EAAC,OAAO,EAAE,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,EAAE;gBACzD,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI;gBAC/B,KAAK,EAAE,SAAS,EAAE,qCAAqC;aACxD,CAAC,CAAC;YAEH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChC,IAAI,IAAI,KAAK,CAAC,EAAE;oBACd,OAAO,CAAC,IAAI,CAAC,CAAC;iBACf;qBAAM;oBACL,OAAO,CAAC,KAAK,CAAC,CAAC;iBAChB;YACH,CAAC,CAAC,CAAC;YAEH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gBACjC,MAAM,CAAC,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAC1E,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhRD,wDAgRC","sourcesContent":["import { spawn } from \"child_process\";\nimport { HardhatRuntimeEnvironment } from \"hardhat/types\";\nimport { CoverageOptions } from \"../types/config\";\nimport { Logger } from \"../utils/logger\";\n\n/**\n * ForgeCoverageFramework - Orchestrates forge coverage execution for Diamond contracts\n *\n * Responsibilities:\n * 1. Build forge coverage command with all options\n * 2. Execute forge coverage with proper fork URL\n * 3. Stream output to terminal\n * 4. Handle errors appropriately\n */\nexport class ForgeCoverageFramework {\n constructor(private hre: HardhatRuntimeEnvironment) {}\n\n /**\n * Run forge coverage with provided options\n *\n * @param options - Coverage execution options\n * @returns Promise<boolean> - true if coverage succeeds, false otherwise\n */\n async runCoverage(options: CoverageOptions = {}): Promise<boolean> {\n Logger.section(\"Forge Coverage - Execution\");\n\n try {\n // Build command arguments\n const args = this.buildCoverageCommand(options);\n\n Logger.info(`Executing: forge coverage ${args.join(\" \")}`);\n Logger.info(\"⏳ Running coverage analysis (this may take a while)...\\n\");\n\n // Execute forge coverage\n const success = await this.executeForge(args);\n\n if (success) {\n Logger.success(\"✅ Coverage analysis completed successfully\");\n } else {\n Logger.error(\"❌ Coverage analysis failed\");\n }\n\n return success;\n } catch (error: any) {\n Logger.error(`Coverage execution error: ${error.message}`);\n return false;\n }\n }\n\n /**\n * Build complete forge coverage command arguments\n *\n * @param options - Coverage options\n * @returns Array of command arguments\n */\n private buildCoverageCommand(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Add fork URL if provided\n if (options.forkUrl) {\n args.push(\"--fork-url\", options.forkUrl);\n }\n\n // Add all option groups\n args.push(...this.buildReportOptions(options));\n args.push(...this.buildFilterOptions(options));\n args.push(...this.buildDisplayOptions(options));\n args.push(...this.buildTestOptions(options));\n args.push(...this.buildEvmOptions(options));\n args.push(...this.buildBuildOptions(options));\n\n return args.filter((arg) => arg !== \"\");\n }\n\n /**\n * Build report-related options\n */\n private buildReportOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Multiple --report flags\n if (options.report && options.report.length > 0) {\n options.report.forEach((reportType) => {\n args.push(\"--report\", reportType);\n });\n }\n\n if (options.reportFile) {\n args.push(\"--report-file\", options.reportFile);\n }\n\n if (options.lcovVersion) {\n args.push(\"--lcov-version\", options.lcovVersion);\n }\n\n if (options.includeLibs) {\n args.push(\"--include-libs\");\n }\n\n if (options.excludeTests) {\n args.push(\"--exclude-tests\");\n }\n\n if (options.irMinimum) {\n args.push(\"--ir-minimum\");\n }\n\n return args;\n }\n\n /**\n * Build test filtering options\n */\n private buildFilterOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.matchTest) {\n args.push(\"--match-test\", options.matchTest);\n }\n\n if (options.noMatchTest) {\n args.push(\"--no-match-test\", options.noMatchTest);\n }\n\n if (options.matchContract) {\n args.push(\"--match-contract\", options.matchContract);\n }\n\n if (options.noMatchContract) {\n args.push(\"--no-match-contract\", options.noMatchContract);\n }\n\n if (options.matchPath) {\n args.push(\"--match-path\", options.matchPath);\n }\n\n if (options.noMatchPath) {\n args.push(\"--no-match-path\", options.noMatchPath);\n }\n\n if (options.noMatchCoverage) {\n args.push(\"--no-match-coverage\", options.noMatchCoverage);\n }\n\n return args;\n }\n\n /**\n * Build display options\n */\n private buildDisplayOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Verbosity (-v, -vv, -vvv, etc.)\n if (options.verbosity && options.verbosity > 0) {\n args.push(\"-\" + \"v\".repeat(options.verbosity));\n }\n\n if (options.quiet) {\n args.push(\"--quiet\");\n }\n\n if (options.json) {\n args.push(\"--json\");\n }\n\n if (options.md) {\n args.push(\"--md\");\n }\n\n if (options.color) {\n args.push(\"--color\", options.color);\n }\n\n return args;\n }\n\n /**\n * Build test execution options\n */\n private buildTestOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.threads !== undefined) {\n args.push(\"--threads\", options.threads.toString());\n }\n\n if (options.fuzzRuns !== undefined) {\n args.push(\"--fuzz-runs\", options.fuzzRuns.toString());\n }\n\n if (options.fuzzSeed) {\n args.push(\"--fuzz-seed\", options.fuzzSeed);\n }\n\n if (options.failFast) {\n args.push(\"--fail-fast\");\n }\n\n if (options.allowFailure) {\n args.push(\"--allow-failure\");\n }\n\n return args;\n }\n\n /**\n * Build EVM options\n */\n private buildEvmOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.forkBlockNumber !== undefined) {\n args.push(\"--fork-block-number\", options.forkBlockNumber.toString());\n }\n\n if (options.initialBalance) {\n args.push(\"--initial-balance\", options.initialBalance);\n }\n\n if (options.sender) {\n args.push(\"--sender\", options.sender);\n }\n\n if (options.ffi) {\n args.push(\"--ffi\");\n }\n\n return args;\n }\n\n /**\n * Build build options\n */\n private buildBuildOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.force) {\n args.push(\"--force\");\n }\n\n if (options.noCache) {\n args.push(\"--no-cache\");\n }\n\n if (options.optimize) {\n args.push(\"--optimize\");\n }\n\n if (options.optimizerRuns !== undefined) {\n args.push(\"--optimizer-runs\", options.optimizerRuns.toString());\n }\n\n if (options.viaIr) {\n args.push(\"--via-ir\");\n }\n\n return args;\n }\n\n /**\n * Execute forge coverage command and stream output\n *\n * @param args - Command arguments\n * @returns Promise<boolean> - true if command succeeds\n */\n private executeForge(args: string[]): Promise<boolean> {\n return new Promise((resolve, reject) => {\n const forgeProcess = spawn(\"forge\", [\"coverage\", ...args], {\n cwd: this.hre.config.paths.root,\n stdio: \"inherit\", // Stream output directly to terminal\n });\n\n forgeProcess.on(\"close\", (code) => {\n if (code === 0) {\n resolve(true);\n } else {\n resolve(false);\n }\n });\n\n forgeProcess.on(\"error\", (error) => {\n reject(new Error(`Failed to execute forge coverage: ${error.message}`));\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ForgeCoverageFramework.js","sourceRoot":"","sources":["../../src/framework/ForgeCoverageFramework.ts"],"names":[],"mappings":";;;AAAA,iDAAsC;AAGtC,8CAAsD;AACtD,4CAAyC;AACzC,2DAAwD;AACxD,uDAAoD;AAEpD;;;;;;;;;GASG;AACH,MAAa,sBAAsB;IAIb;IAHZ,iBAAiB,CAAoB;IACrC,eAAe,CAAkB;IAEzC,YAAoB,GAA8B;QAA9B,QAAG,GAAH,GAAG,C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,SAAS;gBAChB,KAAK,EAAE,IAAI;aACZ,CAAC,CAAC;YAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBACzB,IAAI,IAAI,KAAK,CAAC,EAAE;oBACd,OAAO,CAAC,IAAI,CAAC,CAAC;iBACf;qBAAM;oBACL,OAAO,CAAC,KAAK,CAAC,CAAC;iBAChB;YACH,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC1B,eAAM,CAAC,KAAK,CAAC,4BAA4B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC1D,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnXD,wDAmXC","sourcesContent":["import { spawn } from \"child_process\";\nimport { HardhatRuntimeEnvironment } from \"hardhat/types\";\nimport { CoverageOptions } from \"../types/config\";\nimport { isFoundryInstalled } from \"../utils/foundry\";\nimport { Logger } from \"../utils/logger\";\nimport { DeploymentManager } from \"./DeploymentManager\";\nimport { HelperGenerator } from \"./HelperGenerator\";\n\n/**\n * ForgeCoverageFramework - Main orchestration class for Forge coverage with Diamonds\n *\n * Coordinates:\n * 1. Diamond deployment via DeploymentManager\n * 2. Helper generation via HelperGenerator\n * 3. Forge coverage execution\n *\n * Mirrors ForgeFuzzingFramework design for consistency and code reuse\n */\nexport class ForgeCoverageFramework {\n private deploymentManager: DeploymentManager;\n private helperGenerator: HelperGenerator;\n\n constructor(private hre: HardhatRuntimeEnvironment) {\n this.deploymentManager = new DeploymentManager(hre);\n this.helperGenerator = new HelperGenerator(hre);\n }\n\n /**\n * Run complete Forge coverage workflow\n *\n * Workflow:\n * 1. Validate Foundry installation\n * 2. Deploy or reuse Diamond\n * 3. Generate Solidity helpers\n * 4. Run forge coverage with options\n *\n * @param options - Coverage execution options\n * @returns Promise<boolean> - true if coverage succeeds\n */\n async runCoverage(options: CoverageOptions = {}): Promise<boolean> {\n const {\n diamondName = \"ExampleDiamond\",\n networkName = \"hardhat\",\n force = false,\n skipDeployment = false,\n skipHelpers = false,\n writeDeployedDiamondData = false,\n } = options;\n\n Logger.section(\"Running Forge Coverage with Diamond\");\n\n // Step 1: Validate Foundry\n if (!isFoundryInstalled()) {\n Logger.error(\n \"Foundry is not installed. Please install it: https://book.getfoundry.sh/getting-started/installation\"\n );\n return false;\n }\n\n try {\n // Step 2: Ensure Diamond deployment\n if (!skipDeployment) {\n Logger.section(\"Step 1/3: Ensuring Diamond Deployment\");\n await this.deploymentManager.ensureDeployment(\n diamondName,\n networkName,\n force,\n writeDeployedDiamondData\n );\n } else {\n Logger.info(\"Skipping deployment (using existing)\");\n }\n\n // Step 3: Generate helpers\n if (!skipHelpers) {\n Logger.section(\"Step 2/3: Generating Solidity Helpers\");\n\n const deployment = await this.deploymentManager.getDeployment(\n diamondName,\n networkName\n );\n\n if (!deployment) {\n Logger.warn(\"⚠ No deployment record found\");\n if (!skipDeployment) {\n Logger.info(\"ℹ Using cached deployment (ephemeral)\");\n }\n } else {\n Logger.info(\"Using deployment record\");\n }\n\n const provider = this.hre.ethers.provider;\n const network = await provider.getNetwork();\n const chainId = Number(network.chainId);\n\n const deploymentData = deployment\n ? deployment.getDeployedDiamondData()\n : await this.deploymentManager\n .ensureDeployment(diamondName, networkName, false, false)\n .then((d) => d.getDeployedDiamondData());\n\n await this.helperGenerator.generateDeploymentHelpers(\n diamondName,\n networkName,\n chainId,\n deploymentData,\n deployment || undefined\n );\n } else {\n Logger.info(\"Skipping helper generation\");\n }\n\n // Step 4: Run coverage\n Logger.section(\"Step 3/3: Running Forge Coverage\");\n\n // Get fork URL for network (same pattern as ForgeFuzzingFramework)\n const provider = this.hre.ethers.provider;\n let forkUrl: string;\n\n if (networkName !== \"hardhat\") {\n forkUrl = (provider as any).connection?.url || \"http://127.0.0.1:8545\";\n } else {\n forkUrl = \"http://127.0.0.1:8545\";\n Logger.warn(\n \"⚠️ Network is \\\"hardhat\\\" - defaulting to localhost fork: http://127.0.0.1:8545\"\n );\n Logger.warn(\"💡 Make sure Hardhat node is running: npx hardhat node\");\n Logger.warn(\"💡 Or specify network explicitly: --network localhost\");\n }\n\n const args = this.buildCoverageCommand({ ...options, forkUrl });\n\n Logger.info(`Executing: forge coverage ${args.join(\" \")}`);\n Logger.info(\"⏳ Running coverage analysis (this may take a while)...\");\n\n const success = await this.executeForge(args);\n\n if (success) {\n Logger.success(\"✅ Coverage analysis completed successfully\");\n } else {\n Logger.error(\"❌ Coverage analysis failed\");\n }\n\n return success;\n } catch (error: any) {\n Logger.error(`Coverage execution failed: ${error.message}`);\n return false;\n }\n }\n\n /**\n * Build complete forge coverage command arguments\n *\n * @param options - Coverage options\n * @returns Array of command arguments\n */\n private buildCoverageCommand(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Add fork URL if provided\n if (options.forkUrl) {\n args.push(\"--fork-url\", options.forkUrl);\n }\n\n // Add all option groups\n args.push(...this.buildReportOptions(options));\n args.push(...this.buildFilterOptions(options));\n args.push(...this.buildDisplayOptions(options));\n args.push(...this.buildTestOptions(options));\n args.push(...this.buildEvmOptions(options));\n args.push(...this.buildBuildOptions(options));\n\n return args.filter((arg) => arg !== \"\");\n }\n\n /**\n * Build report-related options\n */\n private buildReportOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Multiple --report flags\n if (options.report && options.report.length > 0) {\n for (const reportType of options.report) {\n args.push(\"--report\", reportType);\n }\n }\n\n if (options.reportFile) {\n args.push(\"--report-file\", options.reportFile);\n }\n\n if (options.lcovVersion) {\n args.push(\"--lcov-version\", options.lcovVersion);\n }\n\n if (options.includeLibs) {\n args.push(\"--include-libs\");\n }\n\n if (options.excludeTests) {\n args.push(\"--exclude-tests\");\n }\n\n if (options.irMinimum) {\n args.push(\"--ir-minimum\");\n }\n\n return args;\n }\n\n /**\n * Build test filtering options\n */\n private buildFilterOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.matchTest) {\n args.push(\"--match-test\", options.matchTest);\n }\n\n if (options.noMatchTest) {\n args.push(\"--no-match-test\", options.noMatchTest);\n }\n\n if (options.matchContract) {\n args.push(\"--match-contract\", options.matchContract);\n }\n\n if (options.noMatchContract) {\n args.push(\"--no-match-contract\", options.noMatchContract);\n }\n\n if (options.matchPath) {\n args.push(\"--match-path\", options.matchPath);\n }\n\n if (options.noMatchPath) {\n args.push(\"--no-match-path\", options.noMatchPath);\n }\n\n if (options.noMatchCoverage) {\n args.push(\"--no-match-coverage\", options.noMatchCoverage);\n }\n\n return args;\n }\n\n /**\n * Build display options\n */\n private buildDisplayOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Verbosity (-v, -vv, -vvv, etc.)\n if (options.verbosity && options.verbosity > 0) {\n args.push(\"-\" + \"v\".repeat(options.verbosity));\n }\n\n if (options.quiet) {\n args.push(\"--quiet\");\n }\n\n if (options.json) {\n args.push(\"--json\");\n }\n\n if (options.md) {\n args.push(\"--md\");\n }\n\n if (options.color) {\n args.push(\"--color\", options.color);\n }\n\n return args;\n }\n\n /**\n * Build test execution options\n */\n private buildTestOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.threads !== undefined) {\n args.push(\"--threads\", options.threads.toString());\n }\n\n if (options.fuzzRuns !== undefined) {\n args.push(\"--fuzz-runs\", options.fuzzRuns.toString());\n }\n\n if (options.fuzzSeed) {\n args.push(\"--fuzz-seed\", options.fuzzSeed);\n }\n\n if (options.failFast) {\n args.push(\"--fail-fast\");\n }\n\n if (options.allowFailure) {\n args.push(\"--allow-failure\");\n }\n\n return args;\n }\n\n /**\n * Build EVM options\n */\n private buildEvmOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.forkBlockNumber !== undefined) {\n args.push(\"--fork-block-number\", options.forkBlockNumber.toString());\n }\n\n if (options.initialBalance) {\n args.push(\"--initial-balance\", options.initialBalance);\n }\n\n if (options.sender) {\n args.push(\"--sender\", options.sender);\n }\n\n if (options.ffi) {\n args.push(\"--ffi\");\n }\n\n return args;\n }\n\n /**\n * Build build options\n */\n private buildBuildOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.force) {\n args.push(\"--force\");\n }\n\n if (options.noCache) {\n args.push(\"--no-cache\");\n }\n\n if (options.optimize) {\n args.push(\"--optimize\");\n }\n\n if (options.optimizerRuns !== undefined) {\n args.push(\"--optimizer-runs\", options.optimizerRuns.toString());\n }\n\n if (options.viaIr) {\n args.push(\"--via-ir\");\n }\n\n return args;\n }\n\n /**\n * Execute forge coverage command and stream output\n *\n * @param args - Command arguments\n * @returns Promise<boolean> - true if command succeeds\n */\n private executeForge(args: string[]): Promise<boolean> {\n return new Promise((resolve, reject) => {\n const forge = spawn(\"forge\", [\"coverage\", ...args], {\n cwd: this.hre.config.paths.root,\n stdio: \"inherit\",\n shell: true,\n });\n\n forge.on(\"close\", (code) => {\n if (code === 0) {\n resolve(true);\n } else {\n resolve(false);\n }\n });\n\n forge.on(\"error\", (error) => {\n Logger.error(`Failed to execute forge: ${error.message}`);\n reject(error);\n });\n });\n }\n}\n"]}
@@ -0,0 +1,61 @@
1
+ import { HardhatRuntimeEnvironment } from "hardhat/types";
2
+ import { CoverageOptions } from "../types/config";
3
+ /**
4
+ * ForgeCoverageFramework - Orchestrates forge coverage execution for Diamond contracts
5
+ *
6
+ * Responsibilities:
7
+ * 1. Build forge coverage command with all options
8
+ * 2. Execute forge coverage with proper fork URL
9
+ * 3. Stream output to terminal
10
+ * 4. Handle errors appropriately
11
+ */
12
+ export declare class ForgeCoverageFramework {
13
+ private hre;
14
+ constructor(hre: HardhatRuntimeEnvironment);
15
+ /**
16
+ * Run forge coverage with provided options
17
+ *
18
+ * @param options - Coverage execution options
19
+ * @returns Promise<boolean> - true if coverage succeeds, false otherwise
20
+ */
21
+ runCoverage(options?: CoverageOptions): Promise<boolean>;
22
+ /**
23
+ * Build complete forge coverage command arguments
24
+ *
25
+ * @param options - Coverage options
26
+ * @returns Array of command arguments
27
+ */
28
+ private buildCoverageCommand;
29
+ /**
30
+ * Build report-related options
31
+ */
32
+ private buildReportOptions;
33
+ /**
34
+ * Build test filtering options
35
+ */
36
+ private buildFilterOptions;
37
+ /**
38
+ * Build display options
39
+ */
40
+ private buildDisplayOptions;
41
+ /**
42
+ * Build test execution options
43
+ */
44
+ private buildTestOptions;
45
+ /**
46
+ * Build EVM options
47
+ */
48
+ private buildEvmOptions;
49
+ /**
50
+ * Build build options
51
+ */
52
+ private buildBuildOptions;
53
+ /**
54
+ * Execute forge coverage command and stream output
55
+ *
56
+ * @param args - Command arguments
57
+ * @returns Promise<boolean> - true if command succeeds
58
+ */
59
+ private executeForge;
60
+ }
61
+ //# sourceMappingURL=ForgeCoverageFramework.old.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForgeCoverageFramework.old.d.ts","sourceRoot":"","sources":["../../src/framework/ForgeCoverageFramework.old.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;;;;;;;GAQG;AACH,qBAAa,sBAAsB;IACrB,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,yBAAyB;IAElD;;;;;OAKG;IACG,WAAW,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0BlE;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAmB5B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAiC1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAkC1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA2B3B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA0BxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAsBvB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA0BzB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;CAoBrB"}
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForgeCoverageFramework = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const logger_1 = require("../utils/logger");
6
+ /**
7
+ * ForgeCoverageFramework - Orchestrates forge coverage execution for Diamond contracts
8
+ *
9
+ * Responsibilities:
10
+ * 1. Build forge coverage command with all options
11
+ * 2. Execute forge coverage with proper fork URL
12
+ * 3. Stream output to terminal
13
+ * 4. Handle errors appropriately
14
+ */
15
+ class ForgeCoverageFramework {
16
+ hre;
17
+ constructor(hre) {
18
+ this.hre = hre;
19
+ }
20
+ /**
21
+ * Run forge coverage with provided options
22
+ *
23
+ * @param options - Coverage execution options
24
+ * @returns Promise<boolean> - true if coverage succeeds, false otherwise
25
+ */
26
+ async runCoverage(options = {}) {
27
+ logger_1.Logger.section("Forge Coverage - Execution");
28
+ try {
29
+ // Build command arguments
30
+ const args = this.buildCoverageCommand(options);
31
+ logger_1.Logger.info(`Executing: forge coverage ${args.join(" ")}`);
32
+ logger_1.Logger.info("⏳ Running coverage analysis (this may take a while)...\n");
33
+ // Execute forge coverage
34
+ const success = await this.executeForge(args);
35
+ if (success) {
36
+ logger_1.Logger.success("✅ Coverage analysis completed successfully");
37
+ }
38
+ else {
39
+ logger_1.Logger.error("❌ Coverage analysis failed");
40
+ }
41
+ return success;
42
+ }
43
+ catch (error) {
44
+ logger_1.Logger.error(`Coverage execution error: ${error.message}`);
45
+ return false;
46
+ }
47
+ }
48
+ /**
49
+ * Build complete forge coverage command arguments
50
+ *
51
+ * @param options - Coverage options
52
+ * @returns Array of command arguments
53
+ */
54
+ buildCoverageCommand(options) {
55
+ const args = [];
56
+ // Add fork URL if provided
57
+ if (options.forkUrl) {
58
+ args.push("--fork-url", options.forkUrl);
59
+ }
60
+ // Add all option groups
61
+ args.push(...this.buildReportOptions(options));
62
+ args.push(...this.buildFilterOptions(options));
63
+ args.push(...this.buildDisplayOptions(options));
64
+ args.push(...this.buildTestOptions(options));
65
+ args.push(...this.buildEvmOptions(options));
66
+ args.push(...this.buildBuildOptions(options));
67
+ return args.filter((arg) => arg !== "");
68
+ }
69
+ /**
70
+ * Build report-related options
71
+ */
72
+ buildReportOptions(options) {
73
+ const args = [];
74
+ // Multiple --report flags
75
+ if (options.report && options.report.length > 0) {
76
+ options.report.forEach((reportType) => {
77
+ args.push("--report", reportType);
78
+ });
79
+ }
80
+ if (options.reportFile) {
81
+ args.push("--report-file", options.reportFile);
82
+ }
83
+ if (options.lcovVersion) {
84
+ args.push("--lcov-version", options.lcovVersion);
85
+ }
86
+ if (options.includeLibs) {
87
+ args.push("--include-libs");
88
+ }
89
+ if (options.excludeTests) {
90
+ args.push("--exclude-tests");
91
+ }
92
+ if (options.irMinimum) {
93
+ args.push("--ir-minimum");
94
+ }
95
+ return args;
96
+ }
97
+ /**
98
+ * Build test filtering options
99
+ */
100
+ buildFilterOptions(options) {
101
+ const args = [];
102
+ if (options.matchTest) {
103
+ args.push("--match-test", options.matchTest);
104
+ }
105
+ if (options.noMatchTest) {
106
+ args.push("--no-match-test", options.noMatchTest);
107
+ }
108
+ if (options.matchContract) {
109
+ args.push("--match-contract", options.matchContract);
110
+ }
111
+ if (options.noMatchContract) {
112
+ args.push("--no-match-contract", options.noMatchContract);
113
+ }
114
+ if (options.matchPath) {
115
+ args.push("--match-path", options.matchPath);
116
+ }
117
+ if (options.noMatchPath) {
118
+ args.push("--no-match-path", options.noMatchPath);
119
+ }
120
+ if (options.noMatchCoverage) {
121
+ args.push("--no-match-coverage", options.noMatchCoverage);
122
+ }
123
+ return args;
124
+ }
125
+ /**
126
+ * Build display options
127
+ */
128
+ buildDisplayOptions(options) {
129
+ const args = [];
130
+ // Verbosity (-v, -vv, -vvv, etc.)
131
+ if (options.verbosity && options.verbosity > 0) {
132
+ args.push("-" + "v".repeat(options.verbosity));
133
+ }
134
+ if (options.quiet) {
135
+ args.push("--quiet");
136
+ }
137
+ if (options.json) {
138
+ args.push("--json");
139
+ }
140
+ if (options.md) {
141
+ args.push("--md");
142
+ }
143
+ if (options.color) {
144
+ args.push("--color", options.color);
145
+ }
146
+ return args;
147
+ }
148
+ /**
149
+ * Build test execution options
150
+ */
151
+ buildTestOptions(options) {
152
+ const args = [];
153
+ if (options.threads !== undefined) {
154
+ args.push("--threads", options.threads.toString());
155
+ }
156
+ if (options.fuzzRuns !== undefined) {
157
+ args.push("--fuzz-runs", options.fuzzRuns.toString());
158
+ }
159
+ if (options.fuzzSeed) {
160
+ args.push("--fuzz-seed", options.fuzzSeed);
161
+ }
162
+ if (options.failFast) {
163
+ args.push("--fail-fast");
164
+ }
165
+ if (options.allowFailure) {
166
+ args.push("--allow-failure");
167
+ }
168
+ return args;
169
+ }
170
+ /**
171
+ * Build EVM options
172
+ */
173
+ buildEvmOptions(options) {
174
+ const args = [];
175
+ if (options.forkBlockNumber !== undefined) {
176
+ args.push("--fork-block-number", options.forkBlockNumber.toString());
177
+ }
178
+ if (options.initialBalance) {
179
+ args.push("--initial-balance", options.initialBalance);
180
+ }
181
+ if (options.sender) {
182
+ args.push("--sender", options.sender);
183
+ }
184
+ if (options.ffi) {
185
+ args.push("--ffi");
186
+ }
187
+ return args;
188
+ }
189
+ /**
190
+ * Build build options
191
+ */
192
+ buildBuildOptions(options) {
193
+ const args = [];
194
+ if (options.force) {
195
+ args.push("--force");
196
+ }
197
+ if (options.noCache) {
198
+ args.push("--no-cache");
199
+ }
200
+ if (options.optimize) {
201
+ args.push("--optimize");
202
+ }
203
+ if (options.optimizerRuns !== undefined) {
204
+ args.push("--optimizer-runs", options.optimizerRuns.toString());
205
+ }
206
+ if (options.viaIr) {
207
+ args.push("--via-ir");
208
+ }
209
+ return args;
210
+ }
211
+ /**
212
+ * Execute forge coverage command and stream output
213
+ *
214
+ * @param args - Command arguments
215
+ * @returns Promise<boolean> - true if command succeeds
216
+ */
217
+ executeForge(args) {
218
+ return new Promise((resolve, reject) => {
219
+ const forgeProcess = (0, child_process_1.spawn)("forge", ["coverage", ...args], {
220
+ cwd: this.hre.config.paths.root,
221
+ stdio: "inherit", // Stream output directly to terminal
222
+ });
223
+ forgeProcess.on("close", (code) => {
224
+ if (code === 0) {
225
+ resolve(true);
226
+ }
227
+ else {
228
+ resolve(false);
229
+ }
230
+ });
231
+ forgeProcess.on("error", (error) => {
232
+ reject(new Error(`Failed to execute forge coverage: ${error.message}`));
233
+ });
234
+ });
235
+ }
236
+ }
237
+ exports.ForgeCoverageFramework = ForgeCoverageFramework;
238
+ //# sourceMappingURL=ForgeCoverageFramework.old.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForgeCoverageFramework.old.js","sourceRoot":"","sources":["../../src/framework/ForgeCoverageFramework.old.ts"],"names":[],"mappings":";;;AAAA,iDAAsC;AAGtC,4CAAyC;AAEzC;;;;;;;;GAQG;AACH,MAAa,sBAAsB;IACb;IAApB,YAAoB,GAA8B;QAA9B,QAAG,GAAH,GAAG,CAA2B;IAAG,CAAC;IAEtD;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,UAA2B,EAAE;QAC7C,eAAM,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAE7C,IAAI;YACF,0BAA0B;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAEhD,eAAM,CAAC,IAAI,CAAC,6BAA6B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3D,eAAM,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;YAExE,yBAAyB;YACzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAE9C,IAAI,OAAO,EAAE;gBACX,eAAM,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAAC;aAC9D;iBAAM;gBACL,eAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;aAC5C;YAED,OAAO,OAAO,CAAC;SAChB;QAAC,OAAO,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from \"child_process\";\nimport { HardhatRuntimeEnvironment } from \"hardhat/types\";\nimport { CoverageOptions } from \"../types/config\";\nimport { Logger } from \"../utils/logger\";\n\n/**\n * ForgeCoverageFramework - Orchestrates forge coverage execution for Diamond contracts\n *\n * Responsibilities:\n * 1. Build forge coverage command with all options\n * 2. Execute forge coverage with proper fork URL\n * 3. Stream output to terminal\n * 4. Handle errors appropriately\n */\nexport class ForgeCoverageFramework {\n constructor(private hre: HardhatRuntimeEnvironment) {}\n\n /**\n * Run forge coverage with provided options\n *\n * @param options - Coverage execution options\n * @returns Promise<boolean> - true if coverage succeeds, false otherwise\n */\n async runCoverage(options: CoverageOptions = {}): Promise<boolean> {\n Logger.section(\"Forge Coverage - Execution\");\n\n try {\n // Build command arguments\n const args = this.buildCoverageCommand(options);\n\n Logger.info(`Executing: forge coverage ${args.join(\" \")}`);\n Logger.info(\"⏳ Running coverage analysis (this may take a while)...\\n\");\n\n // Execute forge coverage\n const success = await this.executeForge(args);\n\n if (success) {\n Logger.success(\"✅ Coverage analysis completed successfully\");\n } else {\n Logger.error(\"❌ Coverage analysis failed\");\n }\n\n return success;\n } catch (error: any) {\n Logger.error(`Coverage execution error: ${error.message}`);\n return false;\n }\n }\n\n /**\n * Build complete forge coverage command arguments\n *\n * @param options - Coverage options\n * @returns Array of command arguments\n */\n private buildCoverageCommand(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Add fork URL if provided\n if (options.forkUrl) {\n args.push(\"--fork-url\", options.forkUrl);\n }\n\n // Add all option groups\n args.push(...this.buildReportOptions(options));\n args.push(...this.buildFilterOptions(options));\n args.push(...this.buildDisplayOptions(options));\n args.push(...this.buildTestOptions(options));\n args.push(...this.buildEvmOptions(options));\n args.push(...this.buildBuildOptions(options));\n\n return args.filter((arg) => arg !== \"\");\n }\n\n /**\n * Build report-related options\n */\n private buildReportOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Multiple --report flags\n if (options.report && options.report.length > 0) {\n options.report.forEach((reportType) => {\n args.push(\"--report\", reportType);\n });\n }\n\n if (options.reportFile) {\n args.push(\"--report-file\", options.reportFile);\n }\n\n if (options.lcovVersion) {\n args.push(\"--lcov-version\", options.lcovVersion);\n }\n\n if (options.includeLibs) {\n args.push(\"--include-libs\");\n }\n\n if (options.excludeTests) {\n args.push(\"--exclude-tests\");\n }\n\n if (options.irMinimum) {\n args.push(\"--ir-minimum\");\n }\n\n return args;\n }\n\n /**\n * Build test filtering options\n */\n private buildFilterOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.matchTest) {\n args.push(\"--match-test\", options.matchTest);\n }\n\n if (options.noMatchTest) {\n args.push(\"--no-match-test\", options.noMatchTest);\n }\n\n if (options.matchContract) {\n args.push(\"--match-contract\", options.matchContract);\n }\n\n if (options.noMatchContract) {\n args.push(\"--no-match-contract\", options.noMatchContract);\n }\n\n if (options.matchPath) {\n args.push(\"--match-path\", options.matchPath);\n }\n\n if (options.noMatchPath) {\n args.push(\"--no-match-path\", options.noMatchPath);\n }\n\n if (options.noMatchCoverage) {\n args.push(\"--no-match-coverage\", options.noMatchCoverage);\n }\n\n return args;\n }\n\n /**\n * Build display options\n */\n private buildDisplayOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Verbosity (-v, -vv, -vvv, etc.)\n if (options.verbosity && options.verbosity > 0) {\n args.push(\"-\" + \"v\".repeat(options.verbosity));\n }\n\n if (options.quiet) {\n args.push(\"--quiet\");\n }\n\n if (options.json) {\n args.push(\"--json\");\n }\n\n if (options.md) {\n args.push(\"--md\");\n }\n\n if (options.color) {\n args.push(\"--color\", options.color);\n }\n\n return args;\n }\n\n /**\n * Build test execution options\n */\n private buildTestOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.threads !== undefined) {\n args.push(\"--threads\", options.threads.toString());\n }\n\n if (options.fuzzRuns !== undefined) {\n args.push(\"--fuzz-runs\", options.fuzzRuns.toString());\n }\n\n if (options.fuzzSeed) {\n args.push(\"--fuzz-seed\", options.fuzzSeed);\n }\n\n if (options.failFast) {\n args.push(\"--fail-fast\");\n }\n\n if (options.allowFailure) {\n args.push(\"--allow-failure\");\n }\n\n return args;\n }\n\n /**\n * Build EVM options\n */\n private buildEvmOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.forkBlockNumber !== undefined) {\n args.push(\"--fork-block-number\", options.forkBlockNumber.toString());\n }\n\n if (options.initialBalance) {\n args.push(\"--initial-balance\", options.initialBalance);\n }\n\n if (options.sender) {\n args.push(\"--sender\", options.sender);\n }\n\n if (options.ffi) {\n args.push(\"--ffi\");\n }\n\n return args;\n }\n\n /**\n * Build build options\n */\n private buildBuildOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.force) {\n args.push(\"--force\");\n }\n\n if (options.noCache) {\n args.push(\"--no-cache\");\n }\n\n if (options.optimize) {\n args.push(\"--optimize\");\n }\n\n if (options.optimizerRuns !== undefined) {\n args.push(\"--optimizer-runs\", options.optimizerRuns.toString());\n }\n\n if (options.viaIr) {\n args.push(\"--via-ir\");\n }\n\n return args;\n }\n\n /**\n * Execute forge coverage command and stream output\n *\n * @param args - Command arguments\n * @returns Promise<boolean> - true if command succeeds\n */\n private executeForge(args: string[]): Promise<boolean> {\n return new Promise((resolve, reject) => {\n const forgeProcess = spawn(\"forge\", [\"coverage\", ...args], {\n cwd: this.hre.config.paths.root,\n stdio: \"inherit\", // Stream output directly to terminal\n });\n\n forgeProcess.on(\"close\", (code) => {\n if (code === 0) {\n resolve(true);\n } else {\n resolve(false);\n }\n });\n\n forgeProcess.on(\"error\", (error) => {\n reject(new Error(`Failed to execute forge coverage: ${error.message}`));\n });\n });\n }\n}\n"]}