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.
- package/README.md +10 -10
- package/dist/scripts/add-mode.d.ts +4 -1
- package/dist/scripts/add-mode.d.ts.map +1 -1
- package/dist/scripts/add-mode.js +4 -1
- package/dist/scripts/builders.d.ts +7 -8
- package/dist/scripts/builders.d.ts.map +1 -1
- package/dist/scripts/builders.js +76 -25
- package/dist/scripts/doctor.d.ts +8 -0
- package/dist/scripts/doctor.d.ts.map +1 -1
- package/dist/scripts/doctor.js +8 -0
- package/dist/scripts/generate-config.d.ts +3 -3
- package/dist/scripts/generate-config.js +17 -9
- package/dist/scripts/generate-docs.d.ts +3 -2
- package/dist/scripts/generate-docs.d.ts.map +1 -1
- package/dist/scripts/generate-docs.js +3 -2
- package/dist/scripts/help.d.ts +9 -0
- package/dist/scripts/help.d.ts.map +1 -0
- package/dist/scripts/help.js +73 -0
- package/dist/scripts/index.js +105 -58
- package/dist/scripts/maintenance.d.ts +5 -4
- package/dist/scripts/maintenance.d.ts.map +1 -1
- package/dist/scripts/maintenance.js +7 -56
- package/dist/scripts/ui.d.ts +3 -10
- package/dist/scripts/ui.d.ts.map +1 -1
- package/dist/scripts/ui.js +3 -30
- package/dist/scripts/utils.d.ts +18 -11
- package/dist/scripts/utils.d.ts.map +1 -1
- package/dist/scripts/utils.js +127 -106
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# create-fhevm-example
|
|
2
|
-
|
|
3
1
|
<p align="center">
|
|
4
2
|
<strong>Create FHEVM example projects with a single command</strong>
|
|
5
3
|
</p>
|
|
@@ -66,14 +64,16 @@ npx create-fhevm-example --example fhe-counter --output ./my-project --install -
|
|
|
66
64
|
|
|
67
65
|
## š CLI Options
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
`--
|
|
72
|
-
`--
|
|
73
|
-
`--
|
|
74
|
-
`--
|
|
75
|
-
`--
|
|
76
|
-
`--
|
|
67
|
+
| Option | Description |
|
|
68
|
+
| :--- | :--- |
|
|
69
|
+
| `--example <name>` | Create a single example project |
|
|
70
|
+
| `--category <name>` | Create a category project |
|
|
71
|
+
| `--add` | Add FHEVM to an existing Hardhat project |
|
|
72
|
+
| `--target <dir>` | Target directory for `--add` mode (default: current dir) |
|
|
73
|
+
| `--output <dir>` | Output directory for new projects |
|
|
74
|
+
| `--install` | Auto-install dependencies after scaffolding |
|
|
75
|
+
| `--test` | Auto-run tests (requires `--install`) |
|
|
76
|
+
| `--help`, `-h` | Show help information |
|
|
77
77
|
|
|
78
78
|
---
|
|
79
79
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Add Mode -
|
|
2
|
+
* Add Mode - Feature for adding FHEVM to existing Hardhat projects.
|
|
3
|
+
*
|
|
4
|
+
* Logic for managing configuration updates, dependency installations,
|
|
5
|
+
* and scaffolding example contracts into established projects.
|
|
3
6
|
*/
|
|
4
7
|
/**
|
|
5
8
|
* Main function to add FHEVM capabilities to an existing Hardhat project
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-mode.d.ts","sourceRoot":"","sources":["../../scripts/add-mode.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"add-mode.d.ts","sourceRoot":"","sources":["../../scripts/add-mode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkRH;;GAEG;AACH,wBAAsB,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8ElE"}
|
package/dist/scripts/add-mode.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Add Mode -
|
|
3
|
+
* Add Mode - Feature for adding FHEVM to existing Hardhat projects.
|
|
4
|
+
*
|
|
5
|
+
* Logic for managing configuration updates, dependency installations,
|
|
6
|
+
* and scaffolding example contracts into established projects.
|
|
4
7
|
*/
|
|
5
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
9
|
if (k2 === undefined) k2 = k;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Project Builders
|
|
2
|
+
* Project Builders - Core logic for scaffolding FHEVM projects.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Handles the creation of single example projects, category-based
|
|
5
|
+
* project bundles, and specialized test environments.
|
|
5
6
|
*/
|
|
6
7
|
/**
|
|
7
8
|
* Creates a single example project from the template
|
|
8
|
-
* @param exampleName - Name of the example to create
|
|
9
|
-
* @param outputDir - Target directory for the project
|
|
10
|
-
* @param tempRepoPath - Path to cloned template repository
|
|
11
9
|
*/
|
|
12
10
|
export declare function createSingleExample(exampleName: string, outputDir: string, tempRepoPath: string): Promise<void>;
|
|
13
11
|
/**
|
|
14
12
|
* Creates a category project with multiple examples
|
|
15
|
-
* @param categoryName - Name of the category to create
|
|
16
|
-
* @param outputDir - Target directory for the project
|
|
17
|
-
* @param tempRepoPath - Path to cloned template repository
|
|
18
13
|
*/
|
|
19
14
|
export declare function createCategoryProject(categoryName: string, outputDir: string, tempRepoPath: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a temporary test project using LOCAL files (used by maintenance.ts)
|
|
17
|
+
*/
|
|
18
|
+
export declare function createLocalTestProject(exampleNames: string[], outputDir: string): Promise<void>;
|
|
20
19
|
//# sourceMappingURL=builders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../scripts/builders.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../scripts/builders.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0DH;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CA8Cf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAiEf;AAMD;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,MAAM,EAAE,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAuEf"}
|
package/dist/scripts/builders.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Project Builders
|
|
3
|
+
* Project Builders - Core logic for scaffolding FHEVM projects.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Handles the creation of single example projects, category-based
|
|
6
|
+
* project bundles, and specialized test environments.
|
|
6
7
|
*/
|
|
7
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
9
|
if (k2 === undefined) k2 = k;
|
|
@@ -40,6 +41,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
42
|
exports.createSingleExample = createSingleExample;
|
|
42
43
|
exports.createCategoryProject = createCategoryProject;
|
|
44
|
+
exports.createLocalTestProject = createLocalTestProject;
|
|
43
45
|
const fs = __importStar(require("fs"));
|
|
44
46
|
const path = __importStar(require("path"));
|
|
45
47
|
const config_1 = require("./config");
|
|
@@ -73,13 +75,10 @@ async function initGitRepo(outputDir) {
|
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
// =============================================================================
|
|
76
|
-
//
|
|
78
|
+
// Project Scaffolding
|
|
77
79
|
// =============================================================================
|
|
78
80
|
/**
|
|
79
81
|
* Creates a single example project from the template
|
|
80
|
-
* @param exampleName - Name of the example to create
|
|
81
|
-
* @param outputDir - Target directory for the project
|
|
82
|
-
* @param tempRepoPath - Path to cloned template repository
|
|
83
82
|
*/
|
|
84
83
|
async function createSingleExample(exampleName, outputDir, tempRepoPath) {
|
|
85
84
|
const example = config_1.EXAMPLES[exampleName];
|
|
@@ -91,31 +90,23 @@ async function createSingleExample(exampleName, outputDir, tempRepoPath) {
|
|
|
91
90
|
if (!contractName) {
|
|
92
91
|
throw new Error("Could not extract contract name");
|
|
93
92
|
}
|
|
94
|
-
//
|
|
93
|
+
// 1. Copy template and clean up
|
|
95
94
|
(0, utils_1.copyDirectoryRecursive)(templateDir, outputDir);
|
|
96
95
|
(0, utils_1.cleanupTemplate)(outputDir);
|
|
97
|
-
//
|
|
96
|
+
// 2. Download example contract and dependencies
|
|
98
97
|
await (0, utils_1.downloadFileFromGitHub)(example.contract, path.join(outputDir, "contracts", `${contractName}.sol`));
|
|
99
|
-
// Download contract dependencies if specified
|
|
100
98
|
if (example.dependencies) {
|
|
101
99
|
await downloadDependencies(example.dependencies, outputDir);
|
|
102
100
|
}
|
|
103
|
-
//
|
|
101
|
+
// 3. Download test file
|
|
104
102
|
await (0, utils_1.downloadFileFromGitHub)(example.test, path.join(outputDir, "test", path.basename(example.test)));
|
|
105
|
-
//
|
|
103
|
+
// 4. Update deploy script and package.json
|
|
106
104
|
fs.writeFileSync(path.join(outputDir, "deploy", "deploy.ts"), (0, utils_1.generateDeployScript)(contractName));
|
|
107
105
|
(0, utils_1.updateProjectPackageJson)(outputDir, `fhevm-example-${exampleName}`, example.description, example.npmDependencies);
|
|
108
|
-
// Initialize git repository
|
|
109
106
|
await initGitRepo(outputDir);
|
|
110
107
|
}
|
|
111
|
-
// =============================================================================
|
|
112
|
-
// Category Project Builder
|
|
113
|
-
// =============================================================================
|
|
114
108
|
/**
|
|
115
109
|
* Creates a category project with multiple examples
|
|
116
|
-
* @param categoryName - Name of the category to create
|
|
117
|
-
* @param outputDir - Target directory for the project
|
|
118
|
-
* @param tempRepoPath - Path to cloned template repository
|
|
119
110
|
*/
|
|
120
111
|
async function createCategoryProject(categoryName, outputDir, tempRepoPath) {
|
|
121
112
|
const category = config_1.CATEGORIES[categoryName];
|
|
@@ -123,10 +114,10 @@ async function createCategoryProject(categoryName, outputDir, tempRepoPath) {
|
|
|
123
114
|
throw new Error(`Unknown category: ${categoryName}`);
|
|
124
115
|
}
|
|
125
116
|
const templateDir = path.join(tempRepoPath, utils_1.TEMPLATE_DIR_NAME);
|
|
126
|
-
//
|
|
117
|
+
// 1. Copy template and clean up
|
|
127
118
|
(0, utils_1.copyDirectoryRecursive)(templateDir, outputDir);
|
|
128
119
|
(0, utils_1.cleanupTemplate)(outputDir);
|
|
129
|
-
//
|
|
120
|
+
// 2. Download all contracts and tests
|
|
130
121
|
for (const item of category.contracts) {
|
|
131
122
|
const contractName = (0, utils_1.getContractName)(item.sol);
|
|
132
123
|
if (contractName) {
|
|
@@ -136,11 +127,16 @@ async function createCategoryProject(categoryName, outputDir, tempRepoPath) {
|
|
|
136
127
|
await (0, utils_1.downloadFileFromGitHub)(item.test, path.join(outputDir, "test", path.basename(item.test)));
|
|
137
128
|
}
|
|
138
129
|
}
|
|
139
|
-
// Collect
|
|
130
|
+
// 3. Collect and download dependencies
|
|
140
131
|
const allDependencies = new Set();
|
|
141
132
|
const allNpmDependencies = {};
|
|
142
133
|
for (const [exampleName, exampleConfig] of Object.entries(config_1.EXAMPLES)) {
|
|
143
|
-
if
|
|
134
|
+
// Check if example belongs to this category
|
|
135
|
+
const configCategoryLower = exampleConfig.category
|
|
136
|
+
.toLowerCase()
|
|
137
|
+
.replace(/\s+/g, "");
|
|
138
|
+
if (configCategoryLower === categoryName ||
|
|
139
|
+
exampleConfig.category === category.name.replace(" Examples", "")) {
|
|
144
140
|
if (exampleConfig.dependencies) {
|
|
145
141
|
exampleConfig.dependencies.forEach((dep) => allDependencies.add(dep));
|
|
146
142
|
}
|
|
@@ -149,12 +145,67 @@ async function createCategoryProject(categoryName, outputDir, tempRepoPath) {
|
|
|
149
145
|
}
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
|
-
// Download all collected dependencies
|
|
153
148
|
if (allDependencies.size > 0) {
|
|
154
149
|
await downloadDependencies(Array.from(allDependencies), outputDir);
|
|
155
150
|
}
|
|
156
|
-
//
|
|
151
|
+
// 4. Update package.json
|
|
157
152
|
(0, utils_1.updateProjectPackageJson)(outputDir, `fhevm-examples-${categoryName}`, undefined, allNpmDependencies);
|
|
158
|
-
// Initialize git repository
|
|
159
153
|
await initGitRepo(outputDir);
|
|
160
154
|
}
|
|
155
|
+
// =============================================================================
|
|
156
|
+
// Specialized Builders
|
|
157
|
+
// =============================================================================
|
|
158
|
+
/**
|
|
159
|
+
* Creates a temporary test project using LOCAL files (used by maintenance.ts)
|
|
160
|
+
*/
|
|
161
|
+
async function createLocalTestProject(exampleNames, outputDir) {
|
|
162
|
+
const rootDir = (0, utils_1.getRootDir)();
|
|
163
|
+
const templateDir = (0, utils_1.getTemplateDir)();
|
|
164
|
+
// 1. Setup base project from local template
|
|
165
|
+
(0, utils_1.copyDirectoryRecursive)(templateDir, outputDir);
|
|
166
|
+
(0, utils_1.cleanupTemplate)(outputDir);
|
|
167
|
+
const allNpmDeps = {};
|
|
168
|
+
const allContractDeps = new Set();
|
|
169
|
+
// 2. Copy local example files
|
|
170
|
+
for (const exampleName of exampleNames) {
|
|
171
|
+
const example = config_1.EXAMPLES[exampleName];
|
|
172
|
+
if (!example)
|
|
173
|
+
continue;
|
|
174
|
+
const contractPath = path.join(rootDir, example.contract);
|
|
175
|
+
const testPath = path.join(rootDir, example.test);
|
|
176
|
+
if (fs.existsSync(contractPath)) {
|
|
177
|
+
const contractName = (0, utils_1.getContractName)(example.contract);
|
|
178
|
+
if (contractName) {
|
|
179
|
+
fs.copyFileSync(contractPath, path.join(outputDir, "contracts", `${contractName}.sol`));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (fs.existsSync(testPath)) {
|
|
183
|
+
fs.copyFileSync(testPath, path.join(outputDir, "test", path.basename(example.test)));
|
|
184
|
+
}
|
|
185
|
+
if (example.dependencies) {
|
|
186
|
+
example.dependencies.forEach((dep) => allContractDeps.add(dep));
|
|
187
|
+
}
|
|
188
|
+
if (example.npmDependencies) {
|
|
189
|
+
Object.assign(allNpmDeps, example.npmDependencies);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// 3. Copy dependencies
|
|
193
|
+
for (const depPath of allContractDeps) {
|
|
194
|
+
const depFullPath = path.join(rootDir, depPath);
|
|
195
|
+
if (fs.existsSync(depFullPath)) {
|
|
196
|
+
const relativePath = depPath.replace(/^contracts\//, "");
|
|
197
|
+
const depDestPath = path.join(outputDir, "contracts", relativePath);
|
|
198
|
+
const depDestDir = path.dirname(depDestPath);
|
|
199
|
+
if (!fs.existsSync(depDestDir)) {
|
|
200
|
+
fs.mkdirSync(depDestDir, { recursive: true });
|
|
201
|
+
}
|
|
202
|
+
fs.copyFileSync(depFullPath, depDestPath);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// 4. Finalize project
|
|
206
|
+
(0, utils_1.updateProjectPackageJson)(outputDir, "fhevm-test-project", `Testing ${exampleNames.length} examples`, Object.keys(allNpmDeps).length > 0 ? allNpmDeps : undefined);
|
|
207
|
+
const typesPath = path.join(outputDir, "test", "types.ts");
|
|
208
|
+
if (!fs.existsSync(typesPath)) {
|
|
209
|
+
fs.writeFileSync(typesPath, utils_1.TEST_TYPES_CONTENT);
|
|
210
|
+
}
|
|
211
|
+
}
|
package/dist/scripts/doctor.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* FHEVM Doctor - Environment and project integrity validator
|
|
4
|
+
*
|
|
5
|
+
* Checks:
|
|
6
|
+
* - Node.js version compatibility
|
|
7
|
+
* - Git installation
|
|
8
|
+
* - Config.ts path integrity (validates all example paths)
|
|
9
|
+
*/
|
|
2
10
|
export {};
|
|
3
11
|
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../scripts/doctor.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../scripts/doctor.ts"],"names":[],"mappings":";AAEA;;;;;;;GAOG"}
|
package/dist/scripts/doctor.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* FHEVM Doctor - Environment and project integrity validator
|
|
5
|
+
*
|
|
6
|
+
* Checks:
|
|
7
|
+
* - Node.js version compatibility
|
|
8
|
+
* - Git installation
|
|
9
|
+
* - Config.ts path integrity (validates all example paths)
|
|
10
|
+
*/
|
|
3
11
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
12
|
if (k2 === undefined) k2 = k;
|
|
5
13
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Auto-Discovery Config Generator
|
|
3
|
+
* Auto-Discovery Config Generator - Automatically updates project configuration.
|
|
4
4
|
*
|
|
5
|
-
* Scans contracts/ directory and generates config.ts
|
|
6
|
-
* Extracts metadata from @notice tags and
|
|
5
|
+
* Scans the contracts/ directory and generates scripts/config.ts.
|
|
6
|
+
* Extracts metadata from @notice tags and infers category structure.
|
|
7
7
|
*/
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=generate-config.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
|
-
* Auto-Discovery Config Generator
|
|
4
|
+
* Auto-Discovery Config Generator - Automatically updates project configuration.
|
|
5
5
|
*
|
|
6
|
-
* Scans contracts/ directory and generates config.ts
|
|
7
|
-
* Extracts metadata from @notice tags and
|
|
6
|
+
* Scans the contracts/ directory and generates scripts/config.ts.
|
|
7
|
+
* Extracts metadata from @notice tags and infers category structure.
|
|
8
8
|
*/
|
|
9
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
@@ -39,10 +39,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
return result;
|
|
40
40
|
};
|
|
41
41
|
})();
|
|
42
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
+
};
|
|
42
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
46
|
const fs = __importStar(require("fs"));
|
|
44
47
|
const path = __importStar(require("path"));
|
|
45
48
|
const utils_1 = require("./utils");
|
|
49
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
46
50
|
const ROOT_DIR = path.resolve(__dirname, "..");
|
|
47
51
|
const CONTRACTS_DIR = path.join(ROOT_DIR, "contracts");
|
|
48
52
|
const TEST_DIR = path.join(ROOT_DIR, "test");
|
|
@@ -293,21 +297,25 @@ export function getDocsFileName(exampleName: string): string {
|
|
|
293
297
|
// Main
|
|
294
298
|
// =============================================================================
|
|
295
299
|
function main() {
|
|
296
|
-
utils_1.log.info(
|
|
300
|
+
utils_1.log.info(`š Scanning examples in: ${picocolors_1.default.cyan("contracts/")}\n`);
|
|
297
301
|
const contracts = scanContracts();
|
|
298
|
-
|
|
302
|
+
if (contracts.length === 0) {
|
|
303
|
+
utils_1.log.error("ā No valid contracts discovered. Check for @notice tags.");
|
|
304
|
+
process.exit(1);
|
|
305
|
+
}
|
|
306
|
+
utils_1.log.success(`ā
Found ${picocolors_1.default.bold(String(contracts.length))} contracts\n`);
|
|
299
307
|
const categoryCount = {};
|
|
300
308
|
for (const c of contracts) {
|
|
301
309
|
categoryCount[c.category] = (categoryCount[c.category] || 0) + 1;
|
|
302
310
|
}
|
|
303
|
-
utils_1.log.message("š
|
|
311
|
+
utils_1.log.message(picocolors_1.default.bold("š Discovery Summary:"));
|
|
304
312
|
for (const [category, count] of Object.entries(categoryCount)) {
|
|
305
|
-
utils_1.log.message(` ${category}
|
|
313
|
+
utils_1.log.message(` ${picocolors_1.default.dim("ā¢")} ${picocolors_1.default.yellow(category.padEnd(25))} ${picocolors_1.default.cyan(String(count).padStart(2))} examples`);
|
|
306
314
|
}
|
|
307
|
-
utils_1.log.message(
|
|
315
|
+
utils_1.log.message(`\nš Generating: ${picocolors_1.default.cyan(path.relative(ROOT_DIR, OUTPUT_FILE))}...`);
|
|
308
316
|
const configContent = generateConfigFile(contracts);
|
|
309
317
|
fs.writeFileSync(OUTPUT_FILE, configContent);
|
|
310
|
-
utils_1.log.success(
|
|
318
|
+
utils_1.log.success(`\n⨠Configuration updated successfully!`);
|
|
311
319
|
}
|
|
312
320
|
const isMainModule = process.argv[1]?.includes("generate-config");
|
|
313
321
|
if (isMainModule) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Documentation Generator - Creates GitBook-compatible markdown docs.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Processes FHEVM examples to produce structured documentation,
|
|
6
|
+
* including contract descriptions and automated index updates.
|
|
6
7
|
*/
|
|
7
8
|
export declare function handleInteractiveDocs(): Promise<void>;
|
|
8
9
|
export declare function handleDirect(args: string[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-docs.d.ts","sourceRoot":"","sources":["../../scripts/generate-docs.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"generate-docs.d.ts","sourceRoot":"","sources":["../../scripts/generate-docs.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAuEH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiE3D;AAMD,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBhE"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Documentation Generator - Creates GitBook-compatible markdown docs.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Processes FHEVM examples to produce structured documentation,
|
|
7
|
+
* including contract descriptions and automated index updates.
|
|
7
8
|
*/
|
|
8
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
10
|
if (k2 === undefined) k2 = k;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../scripts/help.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,IAAI,CAgF/B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Help Menu - CLI Usage and Documentation.
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.showHelp = showHelp;
|
|
10
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
/**
|
|
13
|
+
* Displays the CLI help menu.
|
|
14
|
+
* Adapts content based on LOCAL_DEV environment variable.
|
|
15
|
+
*/
|
|
16
|
+
function showHelp() {
|
|
17
|
+
const isDev = process.env.LOCAL_DEV === "1";
|
|
18
|
+
const cmd = isDev ? "npm run" : "npx";
|
|
19
|
+
const createCmd = isDev ? "create" : "create-fhevm-example";
|
|
20
|
+
console.log(`
|
|
21
|
+
${picocolors_1.default.bgCyan(picocolors_1.default.black(picocolors_1.default.bold(" š create-fhevm-example ")))}
|
|
22
|
+
${picocolors_1.default.dim("āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā")}
|
|
23
|
+
|
|
24
|
+
${picocolors_1.default.cyan(picocolors_1.default.bold("š USAGE"))}
|
|
25
|
+
|
|
26
|
+
${picocolors_1.default.dim("$")} ${picocolors_1.default.white(`${cmd} ${createCmd}`)} ${picocolors_1.default.dim("ā")} Interactive mode ${picocolors_1.default.yellow("(recommended)")}
|
|
27
|
+
${picocolors_1.default.dim("$")} ${picocolors_1.default.white(`${cmd} ${createCmd}`)} ${picocolors_1.default.green("--example")} ${picocolors_1.default.yellow("<name>")} ${picocolors_1.default.dim("ā")} Create single example
|
|
28
|
+
${picocolors_1.default.dim("$")} ${picocolors_1.default.white(`${cmd} ${createCmd}`)} ${picocolors_1.default.green("--category")} ${picocolors_1.default.yellow("<name>")} ${picocolors_1.default.dim("ā")} Create category project
|
|
29
|
+
${picocolors_1.default.dim("$")} ${picocolors_1.default.white(`${cmd} ${createCmd}`)} ${picocolors_1.default.green("--add")} ${picocolors_1.default.dim("ā")} Add to existing project
|
|
30
|
+
|
|
31
|
+
${picocolors_1.default.cyan(picocolors_1.default.bold("āļø OPTIONS"))}
|
|
32
|
+
|
|
33
|
+
${picocolors_1.default.green("--example")} ${picocolors_1.default.dim("<name>")} Create a single example project
|
|
34
|
+
${picocolors_1.default.green("--category")} ${picocolors_1.default.dim("<name>")} Create a category project
|
|
35
|
+
${picocolors_1.default.green("--add")} Add FHEVM to existing Hardhat project
|
|
36
|
+
${picocolors_1.default.green("--target")} ${picocolors_1.default.dim("<dir>")} Target directory for --add mode
|
|
37
|
+
${picocolors_1.default.green("--output")} ${picocolors_1.default.dim("<dir>")} Output directory
|
|
38
|
+
${picocolors_1.default.green("--install")} Auto-install dependencies
|
|
39
|
+
${picocolors_1.default.green("--test")} Auto-run tests (requires --install)
|
|
40
|
+
${picocolors_1.default.green("--help")}${picocolors_1.default.dim(", -h")} Show this help message
|
|
41
|
+
|
|
42
|
+
${isDev
|
|
43
|
+
? `
|
|
44
|
+
${picocolors_1.default.cyan(picocolors_1.default.bold("š ļø DEVELOPER TOOLS"))}
|
|
45
|
+
|
|
46
|
+
${picocolors_1.default.green("npm run create:docs")} Generate documentation
|
|
47
|
+
${picocolors_1.default.green("npm run generate:config")} Update contract registry
|
|
48
|
+
${picocolors_1.default.green("npm run doctor")} Run system health check
|
|
49
|
+
${picocolors_1.default.green("npm run test:all")} Run bulk project tests
|
|
50
|
+
`
|
|
51
|
+
: ""}
|
|
52
|
+
|
|
53
|
+
${picocolors_1.default.cyan(picocolors_1.default.bold("ā” EXAMPLES"))}
|
|
54
|
+
|
|
55
|
+
${picocolors_1.default.dim("$")} ${picocolors_1.default.white(`${cmd} ${createCmd}`)} ${picocolors_1.default.green("--example")} ${picocolors_1.default.yellow("fhe-counter")}
|
|
56
|
+
${picocolors_1.default.dim("$")} ${picocolors_1.default.white(`${cmd} ${createCmd}`)} ${picocolors_1.default.green("--category")} ${picocolors_1.default.yellow("basic")} ${picocolors_1.default.green("--output")} ${picocolors_1.default.blue("./my-project")}
|
|
57
|
+
${picocolors_1.default.dim("$")} ${picocolors_1.default.white(`${cmd} ${createCmd}`)} ${picocolors_1.default.green("--add")}
|
|
58
|
+
|
|
59
|
+
${picocolors_1.default.cyan(picocolors_1.default.bold("š¦ AVAILABLE EXAMPLES"))}
|
|
60
|
+
|
|
61
|
+
${picocolors_1.default.dim(Object.keys(config_1.EXAMPLES).slice(0, 10).join(", "))}
|
|
62
|
+
${picocolors_1.default.dim("...")} and ${picocolors_1.default.yellow(String(Object.keys(config_1.EXAMPLES).length - 10))} more
|
|
63
|
+
|
|
64
|
+
${picocolors_1.default.cyan(picocolors_1.default.bold("š AVAILABLE CATEGORIES"))}
|
|
65
|
+
|
|
66
|
+
${Object.keys(config_1.CATEGORIES)
|
|
67
|
+
.map((c) => picocolors_1.default.yellow(c))
|
|
68
|
+
.join(", ")}
|
|
69
|
+
|
|
70
|
+
${picocolors_1.default.dim("āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā")}
|
|
71
|
+
${picocolors_1.default.dim("š Documentation:")} ${picocolors_1.default.blue("https://github.com/NecipAkgz/fhevm-example-factory")}
|
|
72
|
+
`);
|
|
73
|
+
}
|