create-fhevm-example 1.3.1 → 1.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.
Files changed (122) hide show
  1. package/contracts/advanced/BlindAuction.sol +255 -0
  2. package/contracts/advanced/EncryptedEscrow.sol +315 -0
  3. package/contracts/advanced/HiddenVoting.sol +231 -0
  4. package/contracts/advanced/PrivateKYC.sol +309 -0
  5. package/contracts/advanced/PrivatePayroll.sol +285 -0
  6. package/contracts/basic/decryption/PublicDecryptMultipleValues.sol +160 -0
  7. package/contracts/basic/decryption/PublicDecryptSingleValue.sol +142 -0
  8. package/contracts/basic/decryption/UserDecryptMultipleValues.sol +61 -0
  9. package/contracts/basic/decryption/UserDecryptSingleValue.sol +59 -0
  10. package/contracts/basic/encryption/EncryptMultipleValues.sol +72 -0
  11. package/contracts/basic/encryption/EncryptSingleValue.sol +44 -0
  12. package/contracts/basic/encryption/FHECounter.sol +54 -0
  13. package/contracts/basic/fhe-operations/FHEAdd.sol +51 -0
  14. package/contracts/basic/fhe-operations/FHEArithmetic.sol +99 -0
  15. package/contracts/basic/fhe-operations/FHEComparison.sol +116 -0
  16. package/contracts/basic/fhe-operations/FHEIfThenElse.sol +53 -0
  17. package/contracts/concepts/FHEAccessControl.sol +94 -0
  18. package/contracts/concepts/FHEAntiPatterns.sol +329 -0
  19. package/contracts/concepts/FHEHandles.sol +128 -0
  20. package/contracts/concepts/FHEInputProof.sol +104 -0
  21. package/contracts/gaming/EncryptedLottery.sol +298 -0
  22. package/contracts/gaming/EncryptedPoker.sol +337 -0
  23. package/contracts/gaming/RockPaperScissors.sol +213 -0
  24. package/contracts/openzeppelin/ERC7984.sol +85 -0
  25. package/contracts/openzeppelin/ERC7984ERC20Wrapper.sol +43 -0
  26. package/contracts/openzeppelin/SwapERC7984ToERC20.sol +110 -0
  27. package/contracts/openzeppelin/SwapERC7984ToERC7984.sol +48 -0
  28. package/contracts/openzeppelin/VestingWallet.sol +147 -0
  29. package/contracts/openzeppelin/mocks/ERC20Mock.sol +31 -0
  30. package/dist/scripts/commands/add-mode.d.ts.map +1 -0
  31. package/dist/scripts/{add-mode.js → commands/add-mode.js} +27 -61
  32. package/dist/scripts/commands/doctor.d.ts.map +1 -0
  33. package/dist/scripts/{doctor.js → commands/doctor.js} +2 -2
  34. package/dist/scripts/commands/generate-config.d.ts.map +1 -0
  35. package/dist/scripts/{generate-config.js → commands/generate-config.js} +3 -10
  36. package/dist/scripts/commands/generate-docs.d.ts.map +1 -0
  37. package/dist/scripts/{generate-docs.js → commands/generate-docs.js} +4 -3
  38. package/dist/scripts/commands/maintenance.d.ts.map +1 -0
  39. package/dist/scripts/{maintenance.js → commands/maintenance.js} +11 -10
  40. package/dist/scripts/index.js +63 -59
  41. package/dist/scripts/{builders.d.ts → shared/builders.d.ts} +2 -2
  42. package/dist/scripts/shared/builders.d.ts.map +1 -0
  43. package/dist/scripts/{builders.js → shared/builders.js} +49 -30
  44. package/dist/scripts/{config.d.ts → shared/config.d.ts} +0 -2
  45. package/dist/scripts/shared/config.d.ts.map +1 -0
  46. package/dist/scripts/{config.js → shared/config.js} +48 -59
  47. package/dist/scripts/shared/generators.d.ts +42 -0
  48. package/dist/scripts/shared/generators.d.ts.map +1 -0
  49. package/dist/scripts/{utils.js → shared/generators.js} +34 -271
  50. package/dist/scripts/shared/ui.d.ts.map +1 -0
  51. package/dist/scripts/{ui.js → shared/ui.js} +3 -2
  52. package/dist/scripts/{utils.d.ts → shared/utils.d.ts} +4 -27
  53. package/dist/scripts/shared/utils.d.ts.map +1 -0
  54. package/dist/scripts/shared/utils.js +228 -0
  55. package/fhevm-hardhat-template/.eslintignore +26 -0
  56. package/fhevm-hardhat-template/.eslintrc.yml +21 -0
  57. package/fhevm-hardhat-template/.github/workflows/main.yml +47 -0
  58. package/fhevm-hardhat-template/.github/workflows/manual-windows.yml +28 -0
  59. package/fhevm-hardhat-template/.github/workflows/manual.yml +28 -0
  60. package/fhevm-hardhat-template/.prettierignore +25 -0
  61. package/fhevm-hardhat-template/.prettierrc.yml +15 -0
  62. package/fhevm-hardhat-template/.solcover.js +4 -0
  63. package/fhevm-hardhat-template/.solhint.json +12 -0
  64. package/fhevm-hardhat-template/.solhintignore +3 -0
  65. package/fhevm-hardhat-template/.vscode/extensions.json +3 -0
  66. package/fhevm-hardhat-template/.vscode/settings.json +9 -0
  67. package/fhevm-hardhat-template/LICENSE +33 -0
  68. package/fhevm-hardhat-template/README.md +110 -0
  69. package/fhevm-hardhat-template/contracts/FHECounter.sol +46 -0
  70. package/fhevm-hardhat-template/deploy/deploy.ts +17 -0
  71. package/fhevm-hardhat-template/hardhat.config.ts +90 -0
  72. package/fhevm-hardhat-template/package-lock.json +10405 -0
  73. package/fhevm-hardhat-template/package.json +104 -0
  74. package/fhevm-hardhat-template/tasks/FHECounter.ts +184 -0
  75. package/fhevm-hardhat-template/tasks/accounts.ts +9 -0
  76. package/fhevm-hardhat-template/test/FHECounter.ts +104 -0
  77. package/fhevm-hardhat-template/test/FHECounterSepolia.ts +104 -0
  78. package/fhevm-hardhat-template/tsconfig.json +23 -0
  79. package/package.json +13 -10
  80. package/test/advanced/BlindAuction.ts +246 -0
  81. package/test/advanced/EncryptedEscrow.ts +295 -0
  82. package/test/advanced/HiddenVoting.ts +268 -0
  83. package/test/advanced/PrivateKYC.ts +382 -0
  84. package/test/advanced/PrivatePayroll.ts +253 -0
  85. package/test/basic/decryption/PublicDecryptMultipleValues.ts +254 -0
  86. package/test/basic/decryption/PublicDecryptSingleValue.ts +264 -0
  87. package/test/basic/decryption/UserDecryptMultipleValues.ts +107 -0
  88. package/test/basic/decryption/UserDecryptSingleValue.ts +97 -0
  89. package/test/basic/encryption/EncryptMultipleValues.ts +110 -0
  90. package/test/basic/encryption/EncryptSingleValue.ts +124 -0
  91. package/test/basic/encryption/FHECounter.ts +112 -0
  92. package/test/basic/fhe-operations/FHEAdd.ts +97 -0
  93. package/test/basic/fhe-operations/FHEArithmetic.ts +161 -0
  94. package/test/basic/fhe-operations/FHEComparison.ts +167 -0
  95. package/test/basic/fhe-operations/FHEIfThenElse.ts +97 -0
  96. package/test/concepts/FHEAccessControl.ts +154 -0
  97. package/test/concepts/FHEAntiPatterns.ts +111 -0
  98. package/test/concepts/FHEHandles.ts +156 -0
  99. package/test/concepts/FHEInputProof.ts +151 -0
  100. package/test/gaming/EncryptedLottery.ts +214 -0
  101. package/test/gaming/EncryptedPoker.ts +349 -0
  102. package/test/gaming/RockPaperScissors.ts +205 -0
  103. package/test/openzeppelin/ERC7984.ts +142 -0
  104. package/test/openzeppelin/ERC7984ERC20Wrapper.ts +71 -0
  105. package/test/openzeppelin/SwapERC7984ToERC20.ts +76 -0
  106. package/test/openzeppelin/SwapERC7984ToERC7984.ts +113 -0
  107. package/test/openzeppelin/VestingWallet.ts +89 -0
  108. package/dist/scripts/add-mode.d.ts.map +0 -1
  109. package/dist/scripts/builders.d.ts.map +0 -1
  110. package/dist/scripts/config.d.ts.map +0 -1
  111. package/dist/scripts/doctor.d.ts.map +0 -1
  112. package/dist/scripts/generate-config.d.ts.map +0 -1
  113. package/dist/scripts/generate-docs.d.ts.map +0 -1
  114. package/dist/scripts/maintenance.d.ts.map +0 -1
  115. package/dist/scripts/ui.d.ts.map +0 -1
  116. package/dist/scripts/utils.d.ts.map +0 -1
  117. /package/dist/scripts/{add-mode.d.ts → commands/add-mode.d.ts} +0 -0
  118. /package/dist/scripts/{doctor.d.ts → commands/doctor.d.ts} +0 -0
  119. /package/dist/scripts/{generate-config.d.ts → commands/generate-config.d.ts} +0 -0
  120. /package/dist/scripts/{generate-docs.d.ts → commands/generate-docs.d.ts} +0 -0
  121. /package/dist/scripts/{maintenance.d.ts → commands/maintenance.d.ts} +0 -0
  122. /package/dist/scripts/{ui.d.ts → shared/ui.d.ts} +0 -0
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /**
3
- * Shared Utilities - Helper functions for the FHEVM Example Factory.
3
+ * Generators - Template processing and code generation utilities.
4
4
  *
5
- * Contains common logic for file system operations, string formatting,
6
- * error handling, and terminal logging used throughout the project.
5
+ * Contains functions for scaffolding templates, generating deploy scripts,
6
+ * and creating documentation.
7
7
  */
8
8
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
9
  if (k2 === undefined) k2 = k;
@@ -38,23 +38,7 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  return result;
39
39
  };
40
40
  })();
41
- var __importDefault = (this && this.__importDefault) || function (mod) {
42
- return (mod && mod.__esModule) ? mod : { "default": mod };
43
- };
44
41
  Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.log = exports.ERROR_MESSAGES = exports.TEST_TYPES_CONTENT = exports.CATEGORY_ORDER = exports.FHEVM_DEPENDENCIES = exports.EXCLUDE_DIRS = exports.MAX_DESCRIPTION_LENGTH = exports.TEMPLATE_DIR_NAME = exports.CATEGORY_ICON = void 0;
46
- exports.handleError = handleError;
47
- exports.getRootDir = getRootDir;
48
- exports.getTemplateDir = getTemplateDir;
49
- exports.copyDirectoryRecursive = copyDirectoryRecursive;
50
- exports.toKebabCase = toKebabCase;
51
- exports.contractNameToExampleName = contractNameToExampleName;
52
- exports.contractNameToTitle = contractNameToTitle;
53
- exports.formatCategoryName = formatCategoryName;
54
- exports.getContractName = getContractName;
55
- exports.validateExample = validateExample;
56
- exports.validateCategory = validateCategory;
57
- exports.validateDirectoryNotExists = validateDirectoryNotExists;
58
42
  exports.cleanupTemplate = cleanupTemplate;
59
43
  exports.generateDeployScript = generateDeployScript;
60
44
  exports.generateGitBookMarkdown = generateGitBookMarkdown;
@@ -63,184 +47,16 @@ exports.runCommand = runCommand;
63
47
  exports.runCommandWithStatus = runCommandWithStatus;
64
48
  exports.extractTestResults = extractTestResults;
65
49
  exports.extractErrorMessage = extractErrorMessage;
66
- exports.downloadFileFromGitHub = downloadFileFromGitHub;
67
- exports.cloneTemplate = cloneTemplate;
68
- exports.initSubmodule = initSubmodule;
69
50
  const fs = __importStar(require("fs"));
70
51
  const path = __importStar(require("path"));
71
52
  const child_process_1 = require("child_process");
72
- const picocolors_1 = __importDefault(require("picocolors"));
73
- const config_1 = require("./config");
74
- exports.CATEGORY_ICON = "📁";
75
- /** Template directory name within the cloned repo */
76
- exports.TEMPLATE_DIR_NAME = "fhevm-hardhat-template";
77
- /** Maximum description length for UI display */
78
- exports.MAX_DESCRIPTION_LENGTH = 80;
79
- /** Directories to exclude when copying template */
80
- exports.EXCLUDE_DIRS = [
81
- "node_modules",
82
- "artifacts",
83
- "cache",
84
- "coverage",
85
- "types",
86
- "dist",
87
- ".git",
88
- ];
89
- /** FHEVM package versions for --add mode */
90
- exports.FHEVM_DEPENDENCIES = {
91
- dependencies: {
92
- "encrypted-types": "^0.0.4",
93
- "@fhevm/solidity": "^0.9.1",
94
- },
95
- devDependencies: {
96
- "@fhevm/hardhat-plugin": "^0.3.0-1",
97
- "@zama-fhe/relayer-sdk": "^0.3.0-5",
98
- },
99
- };
100
- exports.CATEGORY_ORDER = [
101
- "Basic - Encryption",
102
- "Basic - Decryption",
103
- "Basic - FHE Operations",
104
- "Concepts",
105
- "Gaming",
106
- "Openzeppelin",
107
- "Advanced",
108
- ];
109
- exports.TEST_TYPES_CONTENT = `import type { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
110
-
111
- /**
112
- * Common signers interface used across test files
113
- */
114
- export interface Signers {
115
- owner: HardhatEthersSigner;
116
- alice: HardhatEthersSigner;
117
- }
118
- `;
119
- exports.ERROR_MESSAGES = {
120
- EXAMPLE_REQUIRED: "Error: Either --example or --category is required",
121
- BOTH_SPECIFIED: "Error: Cannot use both --example and --category",
122
- UNKNOWN_EXAMPLE: (name) => `Error: Unknown example "${name}"`,
123
- UNKNOWN_CATEGORY: (name) => `Error: Unknown category "${name}"`,
124
- DIR_EXISTS: (path) => `Error: Directory already exists: ${path}`,
125
- NOT_HARDHAT: "This directory does not contain a valid Hardhat project.",
126
- CONFIG_NOT_FOUND: "hardhat.config.ts or hardhat.config.js not found",
127
- CONTRACT_NAME_FAILED: "Could not extract contract name",
128
- };
53
+ const utils_1 = require("./utils");
129
54
  // =============================================================================
130
- // Logging Utility
55
+ // Template & Scaffolding Utilities
131
56
  // =============================================================================
132
- exports.log = {
133
- success: (msg) => console.log(picocolors_1.default.green(msg)),
134
- error: (msg) => console.error(picocolors_1.default.red(msg)),
135
- info: (msg) => console.log(picocolors_1.default.cyan(msg)),
136
- dim: (msg) => console.log(picocolors_1.default.dim(msg)),
137
- message: (msg) => console.log(msg),
138
- };
139
57
  /**
140
- * Standardized error handler for CLI - logs error and exits
58
+ * Cleans up the template directory after copying
141
59
  */
142
- function handleError(error, exitCode = 1) {
143
- const message = error instanceof Error ? error.message : String(error);
144
- exports.log.error(message);
145
- process.exit(exitCode);
146
- }
147
- // =============================================================================
148
- // File System Utilities
149
- // =============================================================================
150
- /** Resolves root directory of the project */
151
- function getRootDir() {
152
- return path.resolve(__dirname, "..");
153
- }
154
- /** Resolves template directory path */
155
- function getTemplateDir() {
156
- return path.join(getRootDir(), exports.TEMPLATE_DIR_NAME);
157
- }
158
- /** Copies directory recursively, excluding specified directories */
159
- function copyDirectoryRecursive(source, destination, excludeDirs = exports.EXCLUDE_DIRS) {
160
- if (!fs.existsSync(destination)) {
161
- fs.mkdirSync(destination, { recursive: true });
162
- }
163
- const items = fs.readdirSync(source);
164
- items.forEach((item) => {
165
- const sourcePath = path.join(source, item);
166
- const destPath = path.join(destination, item);
167
- const stat = fs.statSync(sourcePath);
168
- if (stat.isDirectory()) {
169
- if (excludeDirs.includes(item)) {
170
- return;
171
- }
172
- copyDirectoryRecursive(sourcePath, destPath, excludeDirs);
173
- }
174
- else {
175
- fs.copyFileSync(sourcePath, destPath);
176
- }
177
- });
178
- }
179
- // =============================================================================
180
- // Naming Utilities
181
- // =============================================================================
182
- function toKebabCase(str) {
183
- return str
184
- .replace(/([a-z])([A-Z])/g, "$1-$2")
185
- .replace(/([0-9])([A-Z])/g, "$1-$2")
186
- .replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2")
187
- .toLowerCase();
188
- }
189
- function contractNameToExampleName(contractName) {
190
- return toKebabCase(contractName);
191
- }
192
- function contractNameToTitle(contractName) {
193
- return contractName
194
- .replace(/([a-z])([A-Z])/g, "$1 $2")
195
- .replace(/([0-9])([A-Z])/g, "$1 $2")
196
- .replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2");
197
- }
198
- function formatCategoryName(folderName) {
199
- return folderName
200
- .replace(/\bfhe\b/gi, "FHE")
201
- .replace(/-/g, " ")
202
- .replace(/\b\w/g, (char) => char.toUpperCase());
203
- }
204
- function getContractName(contractPathOrContent) {
205
- let content;
206
- if (contractPathOrContent.includes("contract ") ||
207
- contractPathOrContent.includes("pragma solidity")) {
208
- content = contractPathOrContent;
209
- }
210
- else {
211
- const fullPath = contractPathOrContent.startsWith("/")
212
- ? contractPathOrContent
213
- : path.join(getRootDir(), contractPathOrContent);
214
- if (!fs.existsSync(fullPath)) {
215
- const match = contractPathOrContent.match(/([^/]+)\.sol$/);
216
- return match ? match[1] : null;
217
- }
218
- content = fs.readFileSync(fullPath, "utf-8");
219
- }
220
- const match = content.match(/^\s*contract\s+(\w+)(?:\s+is\s+|\s*\{)/m);
221
- return match ? match[1] : null;
222
- }
223
- // =============================================================================
224
- // Validation Functions
225
- // =============================================================================
226
- function validateExample(name) {
227
- if (!config_1.EXAMPLES[name]) {
228
- throw new Error(exports.ERROR_MESSAGES.UNKNOWN_EXAMPLE(name));
229
- }
230
- }
231
- function validateCategory(name) {
232
- if (!config_1.CATEGORIES[name]) {
233
- throw new Error(exports.ERROR_MESSAGES.UNKNOWN_CATEGORY(name));
234
- }
235
- }
236
- function validateDirectoryNotExists(dirPath) {
237
- if (fs.existsSync(dirPath)) {
238
- throw new Error(exports.ERROR_MESSAGES.DIR_EXISTS(dirPath));
239
- }
240
- }
241
- // =============================================================================
242
- // Template & Scaffolding Utilities
243
- // =============================================================================
244
60
  function cleanupTemplate(outputDir) {
245
61
  const gitDir = path.join(outputDir, ".git");
246
62
  if (fs.existsSync(gitDir)) {
@@ -276,8 +92,14 @@ function cleanupTemplate(outputDir) {
276
92
  if (fs.existsSync(oldTaskFile)) {
277
93
  fs.unlinkSync(oldTaskFile);
278
94
  }
279
- fs.writeFileSync(path.join(outputDir, "test", "types.ts"), exports.TEST_TYPES_CONTENT);
95
+ fs.writeFileSync(path.join(outputDir, "test", "types.ts"), utils_1.TEST_TYPES_CONTENT);
280
96
  }
97
+ // =============================================================================
98
+ // Code Generators
99
+ // =============================================================================
100
+ /**
101
+ * Generates a deploy script for a contract
102
+ */
281
103
  function generateDeployScript(contractName) {
282
104
  return `import { DeployFunction } from "hardhat-deploy/types";
283
105
  import { HardhatRuntimeEnvironment } from "hardhat/types";
@@ -313,6 +135,9 @@ func.id = "deploy_${contractName.toLowerCase()}";
313
135
  func.tags = ["${contractName}"];
314
136
  `;
315
137
  }
138
+ /**
139
+ * Generates GitBook-compatible markdown documentation
140
+ */
316
141
  function generateGitBookMarkdown(description, contractContent, testContent, contractName, testFileName) {
317
142
  let markdown = `${description}\n\n`;
318
143
  markdown += `{% hint style="info" %}\n`;
@@ -335,6 +160,12 @@ function generateGitBookMarkdown(description, contractContent, testContent, cont
335
160
  markdown += `{% endtabs %}\n`;
336
161
  return markdown;
337
162
  }
163
+ // =============================================================================
164
+ // Package.json Utilities
165
+ // =============================================================================
166
+ /**
167
+ * Updates package.json with project name and dependencies
168
+ */
338
169
  function updateProjectPackageJson(outputDir, projectName, description, npmDependencies) {
339
170
  const packageJsonPath = path.join(outputDir, "package.json");
340
171
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
@@ -353,6 +184,9 @@ function updateProjectPackageJson(outputDir, projectName, description, npmDepend
353
184
  // =============================================================================
354
185
  // Command Execution Utilities
355
186
  // =============================================================================
187
+ /**
188
+ * Runs a command and returns the output
189
+ */
356
190
  function runCommand(cmd, args, cwd) {
357
191
  return new Promise((resolve, reject) => {
358
192
  const child = (0, child_process_1.spawn)(cmd, args, {
@@ -379,6 +213,9 @@ function runCommand(cmd, args, cwd) {
379
213
  child.on("error", reject);
380
214
  });
381
215
  }
216
+ /**
217
+ * Runs a command and returns success status with output
218
+ */
382
219
  function runCommandWithStatus(cmd, args, cwd) {
383
220
  return new Promise((resolve) => {
384
221
  let output = "";
@@ -402,6 +239,9 @@ function runCommandWithStatus(cmd, args, cwd) {
402
239
  });
403
240
  });
404
241
  }
242
+ /**
243
+ * Extracts test results from command output
244
+ */
405
245
  function extractTestResults(output) {
406
246
  const passingMatch = output.match(/(\d+)\s+passing/);
407
247
  const failingMatch = output.match(/(\d+)\s+failing/);
@@ -417,6 +257,9 @@ function extractTestResults(output) {
417
257
  }
418
258
  return null;
419
259
  }
260
+ /**
261
+ * Extracts error messages from command output
262
+ */
420
263
  function extractErrorMessage(output) {
421
264
  const lines = output.split("\n");
422
265
  const errorLines = [];
@@ -443,83 +286,3 @@ function extractErrorMessage(output) {
443
286
  const nonEmptyLines = lines.filter((l) => l.trim().length > 0);
444
287
  return nonEmptyLines.slice(-5).join("\n");
445
288
  }
446
- // =============================================================================
447
- // GitHub Repository Utilities
448
- // =============================================================================
449
- /**
450
- * Downloads a file from GitHub repository
451
- */
452
- async function downloadFileFromGitHub(filePath, outputPath) {
453
- const urlParts = config_1.REPO_URL.replace("https://github.com/", "").split("/");
454
- const owner = urlParts[0];
455
- const repo = urlParts[1];
456
- const url = `https://raw.githubusercontent.com/${owner}/${repo}/${config_1.REPO_BRANCH}/${filePath}`;
457
- const response = await fetch(url);
458
- if (!response.ok) {
459
- throw new Error(`Failed to download ${filePath}: ${response.statusText}`);
460
- }
461
- const content = await response.text();
462
- const dir = path.dirname(outputPath);
463
- if (!fs.existsSync(dir)) {
464
- fs.mkdirSync(dir, { recursive: true });
465
- }
466
- fs.writeFileSync(outputPath, content);
467
- }
468
- /**
469
- * Clones the template repository to temp directory
470
- */
471
- async function cloneTemplate(tempDir) {
472
- const templatePath = path.join(tempDir, "template");
473
- return new Promise((resolve, reject) => {
474
- const cloneUrl = `${config_1.REPO_URL}.git`;
475
- const args = [
476
- "clone",
477
- "--depth=1",
478
- "--branch",
479
- config_1.REPO_BRANCH,
480
- "--single-branch",
481
- cloneUrl,
482
- templatePath,
483
- ];
484
- const child = (0, child_process_1.spawn)("git", args, {
485
- stdio: "pipe",
486
- });
487
- let stderr = "";
488
- child.stderr?.on("data", (data) => {
489
- stderr += data.toString();
490
- });
491
- child.on("close", (code) => {
492
- if (code === 0) {
493
- resolve(templatePath);
494
- }
495
- else {
496
- reject(new Error(`Git clone failed: ${stderr}`));
497
- }
498
- });
499
- child.on("error", reject);
500
- });
501
- }
502
- /**
503
- * Initializes git submodule for the template
504
- */
505
- async function initSubmodule(repoPath) {
506
- return new Promise((resolve, reject) => {
507
- const child = (0, child_process_1.spawn)("git", ["submodule", "update", "--init", "--recursive", exports.TEMPLATE_DIR_NAME], {
508
- cwd: repoPath,
509
- stdio: "pipe",
510
- });
511
- let stderr = "";
512
- child.stderr?.on("data", (data) => {
513
- stderr += data.toString();
514
- });
515
- child.on("close", (code) => {
516
- if (code === 0) {
517
- resolve();
518
- }
519
- else {
520
- reject(new Error(`Submodule init failed: ${stderr}`));
521
- }
522
- });
523
- child.on("error", reject);
524
- });
525
- }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../scripts/shared/ui.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMjE;AAMD;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAmBrE;AAED;;GAEG;AACH,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAe1B;AAED;;GAEG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAS5E;AAMD;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiD1E"}
@@ -51,6 +51,7 @@ const p = __importStar(require("@clack/prompts"));
51
51
  const picocolors_1 = __importDefault(require("picocolors"));
52
52
  const config_1 = require("./config");
53
53
  const utils_1 = require("./utils");
54
+ const generators_1 = require("./generators");
54
55
  // =============================================================================
55
56
  // Category Helpers
56
57
  // =============================================================================
@@ -147,9 +148,9 @@ async function runInstallAndTest(projectPath) {
147
148
  const s = p.spinner();
148
149
  s.start(step.name + "...");
149
150
  try {
150
- const output = await (0, utils_1.runCommand)(step.cmd, step.args, projectPath);
151
+ const output = await (0, generators_1.runCommand)(step.cmd, step.args, projectPath);
151
152
  if (step.showOutput) {
152
- const testResults = (0, utils_1.extractTestResults)(output);
153
+ const testResults = (0, generators_1.extractTestResults)(output);
153
154
  s.stop(testResults
154
155
  ? picocolors_1.default.green(`✓ ${step.name} - ${testResults}`)
155
156
  : picocolors_1.default.green(`✓ ${step.name} completed`));
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Shared Utilities - Helper functions for the FHEVM Example Factory.
2
+ * Core Utilities - Essential helper functions for the FHEVM Example Factory.
3
3
  *
4
- * Contains common logic for file system operations, string formatting,
5
- * error handling, and terminal logging used throughout the project.
4
+ * Contains constants, types, logging, file system operations,
5
+ * naming utilities, and validation functions.
6
6
  */
7
7
  export type ProjectMode = "single" | "category";
8
8
  export declare const CATEGORY_ICON = "\uD83D\uDCC1";
@@ -46,7 +46,7 @@ export declare const log: {
46
46
  * Standardized error handler for CLI - logs error and exits
47
47
  */
48
48
  export declare function handleError(error: unknown, exitCode?: number): never;
49
- /** Resolves root directory of the project */
49
+ /** Resolves root directory of the project (from scripts/shared/) */
50
50
  export declare function getRootDir(): string;
51
51
  /** Resolves template directory path */
52
52
  export declare function getTemplateDir(): string;
@@ -60,27 +60,4 @@ export declare function getContractName(contractPathOrContent: string): string |
60
60
  export declare function validateExample(name: string): void;
61
61
  export declare function validateCategory(name: string): void;
62
62
  export declare function validateDirectoryNotExists(dirPath: string): void;
63
- export declare function cleanupTemplate(outputDir: string): void;
64
- export declare function generateDeployScript(contractName: string): string;
65
- export declare function generateGitBookMarkdown(description: string, contractContent: string, testContent: string, contractName: string, testFileName: string): string;
66
- export declare function updateProjectPackageJson(outputDir: string, projectName: string, description?: string, npmDependencies?: Record<string, string>): void;
67
- export declare function runCommand(cmd: string, args: string[], cwd: string): Promise<string>;
68
- export declare function runCommandWithStatus(cmd: string, args: string[], cwd: string): Promise<{
69
- success: boolean;
70
- output: string;
71
- }>;
72
- export declare function extractTestResults(output: string): string | null;
73
- export declare function extractErrorMessage(output: string): string;
74
- /**
75
- * Downloads a file from GitHub repository
76
- */
77
- export declare function downloadFileFromGitHub(filePath: string, outputPath: string): Promise<void>;
78
- /**
79
- * Clones the template repository to temp directory
80
- */
81
- export declare function cloneTemplate(tempDir: string): Promise<string>;
82
- /**
83
- * Initializes git submodule for the template
84
- */
85
- export declare function initSubmodule(repoPath: string): Promise<void>;
86
63
  //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../scripts/shared/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEhD,eAAO,MAAM,aAAa,iBAAO,CAAC;AAElC,qDAAqD;AACrD,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAE1D,gDAAgD;AAChD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,mDAAmD;AACnD,eAAO,MAAM,YAAY,UAQxB,CAAC;AAEF,4CAA4C;AAC5C,eAAO,MAAM,kBAAkB;;;;;;;;;CAS9B,CAAC;AAEF,eAAO,MAAM,cAAc,UAQ1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,yPAS9B,CAAC;AAEF,eAAO,MAAM,cAAc;;;4BAGD,MAAM;6BACL,MAAM;uBACZ,MAAM;;;;CAI1B,CAAC;AAMF,eAAO,MAAM,GAAG;mBACC,MAAM;iBACR,MAAM;gBACP,MAAM;eACP,MAAM;mBACF,MAAM;CACtB,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,SAAI,GAAG,KAAK,CAI/D;AAMD,oEAAoE;AACpE,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,uCAAuC;AACvC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,oEAAoE;AACpE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,WAAW,GAAE,MAAM,EAAiB,GACnC,IAAI,CAoBN;AAMD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAKhE;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED,wBAAgB,eAAe,CAAC,qBAAqB,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqB5E;AAMD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAIlD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAInD;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIhE"}