create-fhevm-example 1.3.0 → 1.3.2

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.
@@ -133,10 +133,19 @@ async function getProjectConfig() {
133
133
  p.cancel("Operation cancelled.");
134
134
  return null;
135
135
  }
136
+ const shouldInstall = await p.confirm({
137
+ message: "Install dependencies and run tests?",
138
+ initialValue: false,
139
+ });
140
+ if (p.isCancel(shouldInstall)) {
141
+ p.cancel("Operation cancelled.");
142
+ return null;
143
+ }
136
144
  return {
137
145
  mode: mode,
138
146
  name,
139
147
  outputDir: outputDir,
148
+ shouldInstall: shouldInstall,
140
149
  };
141
150
  }
142
151
  /** Scaffolds project and shows completion message */
@@ -165,17 +174,27 @@ async function scaffoldProject(config) {
165
174
  p.log.success(`📁 Created: ${picocolors_1.default.cyan(relativePath)}`);
166
175
  if (config.mode === "single") {
167
176
  const exampleConfig = config_1.EXAMPLES[config.name];
168
- p.log.info(`📝 Example: ${picocolors_1.default.yellow(exampleConfig?.title || config.name)}`);
177
+ if (exampleConfig) {
178
+ p.log.info(`📝 Example: ${picocolors_1.default.yellow(exampleConfig.title)}`);
179
+ }
169
180
  }
170
181
  else {
171
182
  const categoryConfig = config_1.CATEGORIES[config.name];
172
- p.log.info(`📦 Category: ${picocolors_1.default.yellow(categoryConfig?.name || config.name)}`);
173
- p.log.info(`📄 Contracts: ${picocolors_1.default.green(String(categoryConfig?.contracts.length || 0))}`);
183
+ if (categoryConfig) {
184
+ p.log.info(`📦 Category: ${picocolors_1.default.yellow(categoryConfig.name)}`);
185
+ p.log.info(`📄 Contracts: ${picocolors_1.default.green(String(categoryConfig.contracts.length))}`);
186
+ }
187
+ }
188
+ if (config.shouldInstall) {
189
+ p.log.message("");
190
+ await (0, ui_1.runInstallAndTest)(resolvedOutput);
191
+ }
192
+ else {
193
+ p.note(`${picocolors_1.default.dim("$")} cd ${relativePath}\n${picocolors_1.default.dim("$")} npm install\n${picocolors_1.default.dim("$")} npm run compile\n${picocolors_1.default.dim("$")} npm run test`, "🚀 Quick Start");
174
194
  }
175
- await (0, ui_1.askInstallAndTest)(resolvedOutput, relativePath);
176
195
  }
177
196
  catch (error) {
178
- s.stop("Failed to create project");
197
+ s.stop(picocolors_1.default.red("Failed to create project"));
179
198
  p.log.error(error instanceof Error ? error.message : String(error));
180
199
  process.exit(1);
181
200
  }
@@ -195,54 +214,6 @@ async function runInteractiveMode() {
195
214
  return;
196
215
  await scaffoldProject(config);
197
216
  }
198
- // =============================================================================
199
- // QUICK MODE (CLI Arguments)
200
- // =============================================================================
201
- function showHelp() {
202
- console.log(`
203
- ${picocolors_1.default.bgCyan(picocolors_1.default.black(picocolors_1.default.bold(" 🔐 create-fhevm-example ")))}
204
- ${picocolors_1.default.dim("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")}
205
-
206
- ${picocolors_1.default.cyan(picocolors_1.default.bold("📋 USAGE"))}
207
-
208
- ${picocolors_1.default.dim("$")} ${picocolors_1.default.white("npx create-fhevm-example")} ${picocolors_1.default.dim("→")} Interactive mode ${picocolors_1.default.yellow("(recommended)")}
209
- ${picocolors_1.default.dim("$")} ${picocolors_1.default.white("npx create-fhevm-example")} ${picocolors_1.default.green("--example")} ${picocolors_1.default.yellow("<name>")} ${picocolors_1.default.dim("→")} Create single example
210
- ${picocolors_1.default.dim("$")} ${picocolors_1.default.white("npx create-fhevm-example")} ${picocolors_1.default.green("--category")} ${picocolors_1.default.yellow("<name>")} ${picocolors_1.default.dim("→")} Create category project
211
- ${picocolors_1.default.dim("$")} ${picocolors_1.default.white("npx create-fhevm-example")} ${picocolors_1.default.green("--add")} ${picocolors_1.default.dim("→")} Add to existing project
212
-
213
- ${picocolors_1.default.cyan(picocolors_1.default.bold("⚙️ OPTIONS"))}
214
-
215
- ${picocolors_1.default.green("--example")} ${picocolors_1.default.dim("<name>")} Create a single example project
216
- ${picocolors_1.default.green("--category")} ${picocolors_1.default.dim("<name>")} Create a category project
217
- ${picocolors_1.default.green("--add")} Add FHEVM to existing Hardhat project
218
- ${picocolors_1.default.green("--target")} ${picocolors_1.default.dim("<dir>")} Target directory for --add mode
219
- ${picocolors_1.default.green("--output")} ${picocolors_1.default.dim("<dir>")} Output directory
220
- ${picocolors_1.default.green("--install")} Auto-install dependencies
221
- ${picocolors_1.default.green("--test")} Auto-run tests (requires --install)
222
- ${picocolors_1.default.green("--help")}${picocolors_1.default.dim(", -h")} Show this help message
223
-
224
- ${picocolors_1.default.cyan(picocolors_1.default.bold("⚡ EXAMPLES"))}
225
-
226
- ${picocolors_1.default.dim("$")} ${picocolors_1.default.white("npx create-fhevm-example")} ${picocolors_1.default.green("--example")} ${picocolors_1.default.yellow("fhe-counter")}
227
- ${picocolors_1.default.dim("$")} ${picocolors_1.default.white("npx create-fhevm-example")} ${picocolors_1.default.green("--category")} ${picocolors_1.default.yellow("basic")} ${picocolors_1.default.green("--output")} ${picocolors_1.default.blue("./my-project")}
228
- ${picocolors_1.default.dim("$")} ${picocolors_1.default.white("npx create-fhevm-example")} ${picocolors_1.default.green("--add")}
229
- ${picocolors_1.default.dim("$")} ${picocolors_1.default.white("npx create-fhevm-example")} ${picocolors_1.default.green("--example")} ${picocolors_1.default.yellow("fhe-counter")} ${picocolors_1.default.green("--install")} ${picocolors_1.default.green("--test")}
230
-
231
- ${picocolors_1.default.cyan(picocolors_1.default.bold("📦 AVAILABLE EXAMPLES"))}
232
-
233
- ${picocolors_1.default.dim(Object.keys(config_1.EXAMPLES).slice(0, 10).join(", "))}
234
- ${picocolors_1.default.dim("...")} and ${picocolors_1.default.yellow(String(Object.keys(config_1.EXAMPLES).length - 10))} more
235
-
236
- ${picocolors_1.default.cyan(picocolors_1.default.bold("📁 AVAILABLE CATEGORIES"))}
237
-
238
- ${Object.keys(config_1.CATEGORIES)
239
- .map((c) => picocolors_1.default.yellow(c))
240
- .join(", ")}
241
-
242
- ${picocolors_1.default.dim("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")}
243
- ${picocolors_1.default.dim("📚 Documentation:")} ${picocolors_1.default.blue("https://github.com/NecipAkgz/fhevm-example-factory")}
244
- `);
245
- }
246
217
  function parseArgs(args) {
247
218
  const parsed = {};
248
219
  for (let i = 0; i < args.length; i++) {
@@ -313,25 +284,30 @@ async function runDirectMode(args) {
313
284
  }
314
285
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "fhevm-"));
315
286
  try {
316
- utils_1.log.info(`Creating ${mode}: ${name}`);
287
+ utils_1.log.info(`\n🚀 Creating ${mode}: ${picocolors_1.default.yellow(name)}`);
288
+ utils_1.log.dim("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
317
289
  utils_1.log.dim("Downloading template...");
318
290
  const tempRepoPath = await (0, utils_1.cloneTemplate)(tempDir);
319
291
  utils_1.log.dim("Initializing submodules...");
320
292
  await (0, utils_1.initSubmodule)(tempRepoPath);
321
- utils_1.log.dim("Creating project...");
293
+ utils_1.log.dim("Building project...");
322
294
  if (mode === "example") {
323
295
  await (0, builders_1.createSingleExample)(name, resolved, tempRepoPath);
324
296
  }
325
297
  else {
326
298
  await (0, builders_1.createCategoryProject)(name, resolved, tempRepoPath);
327
299
  }
328
- utils_1.log.success(`✓ Created: ${output}`);
300
+ utils_1.log.success(`\n✨ Successfully created: ${picocolors_1.default.cyan(output)}`);
329
301
  if (shouldInstall) {
330
- utils_1.log.dim("\nInstalling dependencies...");
302
+ utils_1.log.dim("Installing dependencies and running tests...");
331
303
  await (0, ui_1.runInstallAndTest)(resolved);
332
304
  }
333
305
  else {
334
- utils_1.log.dim(`\nNext: cd ${output} && npm install && npm run compile && npm run test`);
306
+ utils_1.log.message(picocolors_1.default.dim("\nNext steps:"));
307
+ utils_1.log.message(` ${picocolors_1.default.cyan("cd")} ${output}`);
308
+ utils_1.log.message(` ${picocolors_1.default.cyan("npm install")}`);
309
+ utils_1.log.message(` ${picocolors_1.default.cyan("npm run compile")}`);
310
+ utils_1.log.message(` ${picocolors_1.default.cyan("npm run test")}`);
335
311
  }
336
312
  }
337
313
  catch (error) {
@@ -344,6 +320,77 @@ async function runDirectMode(args) {
344
320
  }
345
321
  }
346
322
  // =============================================================================
323
+ // QUICK MODE (CLI Arguments)
324
+ // =============================================================================
325
+ function showHelp() {
326
+ const isDev = process.env.LOCAL_DEV === "1";
327
+ if (isDev) {
328
+ // Developer help - show npm run scripts
329
+ console.log(`
330
+ ${picocolors_1.default.bgCyan(picocolors_1.default.black(picocolors_1.default.bold(" 🔐 FHEVM Example Factory - Developer Mode ")))}
331
+ ${picocolors_1.default.dim("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")}
332
+
333
+ ${picocolors_1.default.cyan(picocolors_1.default.bold("📋 CREATE COMMANDS"))}
334
+
335
+ ${picocolors_1.default.green("npm run create")} Interactive mode ${picocolors_1.default.yellow("(recommended)")}
336
+ ${picocolors_1.default.green("npm run create:example")} ${picocolors_1.default.dim("<name>")} Create single example
337
+ ${picocolors_1.default.green("npm run create:category")} ${picocolors_1.default.dim("<name>")} Create category project
338
+ ${picocolors_1.default.green("npm run create:docs")} Generate documentation
339
+
340
+ ${picocolors_1.default.cyan(picocolors_1.default.bold("🛠️ MAINTENANCE"))}
341
+
342
+ ${picocolors_1.default.green("npm run test:all")} Test multiple examples
343
+ ${picocolors_1.default.green("npm run generate:config")} Update contract registry
344
+ ${picocolors_1.default.green("npm run doctor")} System health check
345
+
346
+ ${picocolors_1.default.cyan(picocolors_1.default.bold("❓ HELP"))}
347
+
348
+ ${picocolors_1.default.green("npm run help:create")} This help
349
+ ${picocolors_1.default.green("npm run help:docs")} Docs generator help
350
+ ${picocolors_1.default.green("npm run help:test")} Test runner help
351
+
352
+ ${picocolors_1.default.dim("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")}
353
+ `);
354
+ }
355
+ else {
356
+ // End-user help - show npx commands
357
+ console.log(`
358
+ ${picocolors_1.default.bgCyan(picocolors_1.default.black(picocolors_1.default.bold(" 🔐 create-fhevm-example ")))}
359
+ ${picocolors_1.default.dim("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")}
360
+
361
+ ${picocolors_1.default.cyan(picocolors_1.default.bold("📋 USAGE"))}
362
+
363
+ ${picocolors_1.default.dim("$")} npx create-fhevm-example ${picocolors_1.default.dim("→")} Interactive ${picocolors_1.default.yellow("(recommended)")}
364
+ ${picocolors_1.default.dim("$")} npx create-fhevm-example ${picocolors_1.default.green("--example")} ${picocolors_1.default.yellow("<name>")} ${picocolors_1.default.dim("→")} Single example
365
+ ${picocolors_1.default.dim("$")} npx create-fhevm-example ${picocolors_1.default.green("--category")} ${picocolors_1.default.yellow("<name>")} ${picocolors_1.default.dim("→")} Category project
366
+ ${picocolors_1.default.dim("$")} npx create-fhevm-example ${picocolors_1.default.green("--add")} ${picocolors_1.default.dim("→")} Add to existing project
367
+
368
+ ${picocolors_1.default.cyan(picocolors_1.default.bold("⚙️ OPTIONS"))}
369
+
370
+ ${picocolors_1.default.green("--example")} ${picocolors_1.default.dim("<name>")} Single example project
371
+ ${picocolors_1.default.green("--category")} ${picocolors_1.default.dim("<name>")} Category project
372
+ ${picocolors_1.default.green("--add")} Add FHEVM to existing Hardhat project
373
+ ${picocolors_1.default.green("--output")} ${picocolors_1.default.dim("<dir>")} Output directory
374
+ ${picocolors_1.default.green("--install")} Auto-install dependencies
375
+ ${picocolors_1.default.green("--help")} Show this help
376
+
377
+ ${picocolors_1.default.cyan(picocolors_1.default.bold("⚡ EXAMPLES"))}
378
+
379
+ ${picocolors_1.default.dim("$")} npx create-fhevm-example --example fhe-counter
380
+ ${picocolors_1.default.dim("$")} npx create-fhevm-example --category basic --output ./my-project
381
+ ${picocolors_1.default.dim("$")} npx create-fhevm-example --add
382
+
383
+ ${picocolors_1.default.cyan(picocolors_1.default.bold("📦 AVAILABLE"))}
384
+
385
+ Examples: ${picocolors_1.default.dim(Object.keys(config_1.EXAMPLES).slice(0, 5).join(", "))} ${picocolors_1.default.dim("...")} (${Object.keys(config_1.EXAMPLES).length} total)
386
+ Categories: ${Object.keys(config_1.CATEGORIES).map((c) => picocolors_1.default.yellow(c)).join(", ")}
387
+
388
+ ${picocolors_1.default.dim("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")}
389
+ ${picocolors_1.default.dim("📚 Docs:")} ${picocolors_1.default.blue("https://github.com/NecipAkgz/fhevm-example-factory")}
390
+ `);
391
+ }
392
+ }
393
+ // =============================================================================
347
394
  // MAIN ENTRY POINT
348
395
  // =============================================================================
349
396
  async function main() {
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * FHEVM Example Factory - Maintenance Tools
3
+ * Maintenance Tools - Utilities for project maintenance and testing.
4
4
  *
5
- * Test multiple examples efficiently in a single project.
5
+ * Includes the test-all runner which allows for efficient testing
6
+ * of multiple examples in a temporary workspace.
6
7
  *
7
8
  * Usage:
8
- * npm run test:all # Interactive selection
9
- * npm run test:all fhe-counter,fhe-add # Direct CLI
9
+ * npm run test:all # Interactive selection
10
+ * npm run test:all fhe-counter,fhe-add # Direct CLI
10
11
  */
11
12
  export declare function testAllExamples(cliExamples?: string[]): Promise<void>;
12
13
  //# sourceMappingURL=maintenance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"maintenance.d.ts","sourceRoot":"","sources":["../../scripts/maintenance.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AA0SH,wBAAsB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAqC3E"}
1
+ {"version":3,"file":"maintenance.d.ts","sourceRoot":"","sources":["../../scripts/maintenance.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG;AAwNH,wBAAsB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAqC3E"}
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  /**
4
- * FHEVM Example Factory - Maintenance Tools
4
+ * Maintenance Tools - Utilities for project maintenance and testing.
5
5
  *
6
- * Test multiple examples efficiently in a single project.
6
+ * Includes the test-all runner which allows for efficient testing
7
+ * of multiple examples in a temporary workspace.
7
8
  *
8
9
  * Usage:
9
- * npm run test:all # Interactive selection
10
- * npm run test:all fhe-counter,fhe-add # Direct CLI
10
+ * npm run test:all # Interactive selection
11
+ * npm run test:all fhe-counter,fhe-add # Direct CLI
11
12
  */
12
13
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
14
  if (k2 === undefined) k2 = k;
@@ -53,57 +54,7 @@ const fs = __importStar(require("fs"));
53
54
  const path = __importStar(require("path"));
54
55
  const config_1 = require("./config");
55
56
  const utils_1 = require("./utils");
56
- // =============================================================================
57
- // Project Builder
58
- // =============================================================================
59
- async function createTestProject(exampleNames, outputDir) {
60
- const rootDir = (0, utils_1.getRootDir)();
61
- const templateDir = (0, utils_1.getTemplateDir)();
62
- (0, utils_1.copyDirectoryRecursive)(templateDir, outputDir);
63
- (0, utils_1.cleanupTemplate)(outputDir);
64
- const allNpmDeps = {};
65
- const allContractDeps = new Set();
66
- for (const exampleName of exampleNames) {
67
- const example = config_1.EXAMPLES[exampleName];
68
- if (!example)
69
- continue;
70
- const contractPath = path.join(rootDir, example.contract);
71
- const testPath = path.join(rootDir, example.test);
72
- if (fs.existsSync(contractPath)) {
73
- const contractName = (0, utils_1.getContractName)(example.contract);
74
- if (contractName) {
75
- fs.copyFileSync(contractPath, path.join(outputDir, "contracts", `${contractName}.sol`));
76
- }
77
- }
78
- if (fs.existsSync(testPath)) {
79
- fs.copyFileSync(testPath, path.join(outputDir, "test", path.basename(example.test)));
80
- }
81
- if (example.dependencies) {
82
- example.dependencies.forEach((dep) => allContractDeps.add(dep));
83
- }
84
- if (example.npmDependencies) {
85
- Object.assign(allNpmDeps, example.npmDependencies);
86
- }
87
- }
88
- for (const depPath of allContractDeps) {
89
- const depFullPath = path.join(rootDir, depPath);
90
- if (fs.existsSync(depFullPath)) {
91
- const relativePath = depPath.replace(/^contracts\//, "");
92
- const depDestPath = path.join(outputDir, "contracts", relativePath);
93
- const depDestDir = path.dirname(depDestPath);
94
- if (!fs.existsSync(depDestDir)) {
95
- fs.mkdirSync(depDestDir, { recursive: true });
96
- }
97
- fs.copyFileSync(depFullPath, depDestPath);
98
- }
99
- }
100
- // Update package.json using shared utility
101
- (0, utils_1.updateProjectPackageJson)(outputDir, "fhevm-test-project", `Testing ${exampleNames.length} examples`, Object.keys(allNpmDeps).length > 0 ? allNpmDeps : undefined);
102
- const typesPath = path.join(outputDir, "test", "types.ts");
103
- if (!fs.existsSync(typesPath)) {
104
- fs.writeFileSync(typesPath, utils_1.TEST_TYPES_CONTENT);
105
- }
106
- }
57
+ const builders_1 = require("./builders");
107
58
  // =============================================================================
108
59
  // Example Selection
109
60
  // =============================================================================
@@ -266,7 +217,7 @@ async function testAllExamples(cliExamples) {
266
217
  try {
267
218
  const s = p.spinner();
268
219
  s.start("Setting up test project...");
269
- await createTestProject(examplesToTest, tempDir);
220
+ await (0, builders_1.createLocalTestProject)(examplesToTest, tempDir);
270
221
  s.stop(picocolors_1.default.green("✓ Project ready"));
271
222
  summary = await runTestPipeline(tempDir, examplesToTest.length);
272
223
  }
@@ -1,7 +1,8 @@
1
1
  /**
2
- * User Interface - Prompts & Commands
2
+ * User Interface - CLI Prompts and Interaction Logic.
3
3
  *
4
- * Interactive prompts and command execution for CLI.
4
+ * Provides centralized components for user input, selection menus,
5
+ * and standard command execution feedback for the CLI.
5
6
  */
6
7
  /**
7
8
  * Counts how many examples exist in each category
@@ -23,12 +24,4 @@ export declare function promptSelectCategoryProject(): Promise<string | symbol>;
23
24
  * Runs npm install, compile, and test in the project directory
24
25
  */
25
26
  export declare function runInstallAndTest(projectPath: string): Promise<void>;
26
- /**
27
- * Shows quick start commands for the created project
28
- */
29
- export declare function showQuickStart(relativePath: string): void;
30
- /**
31
- * Asks user if they want to install and test
32
- */
33
- export declare function askInstallAndTest(resolvedOutput: string, relativePath: string): Promise<void>;
34
27
  //# sourceMappingURL=ui.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../scripts/ui.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH;;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;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAOzD;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAiBf"}
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../scripts/ui.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH;;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"}
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  /**
3
- * User Interface - Prompts & Commands
3
+ * User Interface - CLI Prompts and Interaction Logic.
4
4
  *
5
- * Interactive prompts and command execution for CLI.
5
+ * Provides centralized components for user input, selection menus,
6
+ * and standard command execution feedback for the CLI.
6
7
  */
7
8
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
9
  if (k2 === undefined) k2 = k;
@@ -46,8 +47,6 @@ exports.promptSelectCategory = promptSelectCategory;
46
47
  exports.promptSelectExampleFromCategory = promptSelectExampleFromCategory;
47
48
  exports.promptSelectCategoryProject = promptSelectCategoryProject;
48
49
  exports.runInstallAndTest = runInstallAndTest;
49
- exports.showQuickStart = showQuickStart;
50
- exports.askInstallAndTest = askInstallAndTest;
51
50
  const p = __importStar(require("@clack/prompts"));
52
51
  const picocolors_1 = __importDefault(require("picocolors"));
53
52
  const config_1 = require("./config");
@@ -169,29 +168,3 @@ async function runInstallAndTest(projectPath) {
169
168
  }
170
169
  p.log.success(picocolors_1.default.green("🔐 All encryption tests passed!"));
171
170
  }
172
- /**
173
- * Shows quick start commands for the created project
174
- */
175
- function showQuickStart(relativePath) {
176
- p.note(`${picocolors_1.default.dim("$")} cd ${relativePath}\n${picocolors_1.default.dim("$")} npm install\n${picocolors_1.default.dim("$")} npm run compile\n${picocolors_1.default.dim("$")} npm run test`, "🚀 Quick Start");
177
- }
178
- /**
179
- * Asks user if they want to install and test
180
- */
181
- async function askInstallAndTest(resolvedOutput, relativePath) {
182
- const shouldInstall = await p.confirm({
183
- message: "Install dependencies and run tests?",
184
- initialValue: false,
185
- });
186
- if (p.isCancel(shouldInstall)) {
187
- showQuickStart(relativePath);
188
- return;
189
- }
190
- if (shouldInstall) {
191
- p.log.message("");
192
- await runInstallAndTest(resolvedOutput);
193
- }
194
- else {
195
- showQuickStart(relativePath);
196
- }
197
- }
@@ -1,5 +1,8 @@
1
1
  /**
2
- * Utility functions for FHEVM Example Factory CLI
2
+ * Shared Utilities - Helper functions for the FHEVM Example Factory.
3
+ *
4
+ * Contains common logic for file system operations, string formatting,
5
+ * error handling, and terminal logging used throughout the project.
3
6
  */
4
7
  export type ProjectMode = "single" | "category";
5
8
  export declare const CATEGORY_ICON = "\uD83D\uDCC1";
@@ -45,30 +48,22 @@ export declare const log: {
45
48
  export declare function handleError(error: unknown, exitCode?: number): never;
46
49
  /** Resolves root directory of the project */
47
50
  export declare function getRootDir(): string;
51
+ /** Resolves template directory path */
48
52
  export declare function getTemplateDir(): string;
49
- /** Extracts contract name from file path or content */
50
- export declare function getContractName(contractPathOrContent: string): string | null;
51
53
  /** Copies directory recursively, excluding specified directories */
52
54
  export declare function copyDirectoryRecursive(source: string, destination: string, excludeDirs?: string[]): void;
53
55
  export declare function toKebabCase(str: string): string;
54
56
  export declare function contractNameToExampleName(contractName: string): string;
55
57
  export declare function contractNameToTitle(contractName: string): string;
56
58
  export declare function formatCategoryName(folderName: string): string;
59
+ export declare function getContractName(contractPathOrContent: string): string | null;
57
60
  export declare function validateExample(name: string): void;
58
61
  export declare function validateCategory(name: string): void;
59
62
  export declare function validateDirectoryNotExists(dirPath: string): void;
60
63
  export declare function cleanupTemplate(outputDir: string): void;
61
64
  export declare function generateDeployScript(contractName: string): string;
62
65
  export declare function generateGitBookMarkdown(description: string, contractContent: string, testContent: string, contractName: string, testFileName: string): string;
63
- /** Downloads a file from GitHub repository */
64
- export declare function downloadFileFromGitHub(filePath: string, outputPath: string): Promise<void>;
65
- /** Clones the template repository to temp directory */
66
- export declare function cloneTemplate(tempDir: string): Promise<string>;
67
- /** Initializes git submodule for the template */
68
- export declare function initSubmodule(repoPath: string): Promise<void>;
69
- /** Updates package.json with project name, description, and npm dependencies */
70
66
  export declare function updateProjectPackageJson(outputDir: string, projectName: string, description?: string, npmDependencies?: Record<string, string>): void;
71
- /** Executes a command and returns output */
72
67
  export declare function runCommand(cmd: string, args: string[], cwd: string): Promise<string>;
73
68
  export declare function runCommandWithStatus(cmd: string, args: string[], cwd: string): Promise<{
74
69
  success: boolean;
@@ -76,4 +71,16 @@ export declare function runCommandWithStatus(cmd: string, args: string[], cwd: s
76
71
  }>;
77
72
  export declare function extractTestResults(output: string): string | null;
78
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>;
79
86
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../scripts/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,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,UAQ1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