create-fhevm-playground-pro 1.0.5 → 1.0.6
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/dist/scaffolder.js +22 -13
- package/package.json +1 -1
package/dist/scaffolder.js
CHANGED
|
@@ -39,35 +39,44 @@ async function createExample(options) {
|
|
|
39
39
|
if (fs_extra_1.default.existsSync(projectDir)) {
|
|
40
40
|
throw new Error(`Directory ${options.name} already exists`);
|
|
41
41
|
}
|
|
42
|
-
//
|
|
42
|
+
// Always start with base-template for full Hardhat setup
|
|
43
|
+
const baseTemplate = path_1.default.resolve(__dirname, '..', 'base-template');
|
|
44
|
+
if (!fs_extra_1.default.existsSync(baseTemplate)) {
|
|
45
|
+
throw new Error('base-template not found in package. Ensure base-template/ is published.');
|
|
46
|
+
}
|
|
47
|
+
fs_extra_1.default.copySync(baseTemplate, projectDir);
|
|
48
|
+
// Try to find and overlay the actual example's contracts/tests
|
|
43
49
|
const exampleDirName = CATEGORY_TO_EXAMPLE_DIR[options.category] || options.category;
|
|
44
|
-
// Look for central-repo in multiple locations (relative to cwd or parent dirs)
|
|
45
|
-
let centralRepoExampleDir = null;
|
|
46
50
|
const searchPaths = [
|
|
47
51
|
path_1.default.resolve(process.cwd(), 'central-repo', 'examples', `${exampleDirName}-premium`),
|
|
48
52
|
path_1.default.resolve(process.cwd(), '..', 'central-repo', 'examples', `${exampleDirName}-premium`),
|
|
49
53
|
path_1.default.resolve(process.cwd(), '..', '..', 'central-repo', 'examples', `${exampleDirName}-premium`),
|
|
50
54
|
];
|
|
55
|
+
let centralRepoExampleDir = null;
|
|
51
56
|
for (const searchPath of searchPaths) {
|
|
52
57
|
if (fs_extra_1.default.existsSync(searchPath)) {
|
|
53
58
|
centralRepoExampleDir = searchPath;
|
|
54
59
|
break;
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
|
-
let srcTemplate;
|
|
58
62
|
if (centralRepoExampleDir) {
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
// Overlay contracts and tests from the real example
|
|
64
|
+
const contractsSrc = path_1.default.join(centralRepoExampleDir, 'contracts');
|
|
65
|
+
const contractsDest = path_1.default.join(projectDir, 'contracts');
|
|
66
|
+
const testSrc = path_1.default.join(centralRepoExampleDir, 'test');
|
|
67
|
+
const testDest = path_1.default.join(projectDir, 'test');
|
|
68
|
+
if (fs_extra_1.default.existsSync(contractsSrc)) {
|
|
69
|
+
fs_extra_1.default.copySync(contractsSrc, contractsDest, { overwrite: true });
|
|
70
|
+
console.log(chalk_1.default.cyan(`Overlaid contracts from ${exampleDirName}-premium`));
|
|
71
|
+
}
|
|
72
|
+
if (fs_extra_1.default.existsSync(testSrc)) {
|
|
73
|
+
fs_extra_1.default.copySync(testSrc, testDest, { overwrite: true });
|
|
74
|
+
console.log(chalk_1.default.cyan(`Overlaid tests from ${exampleDirName}-premium`));
|
|
75
|
+
}
|
|
61
76
|
}
|
|
62
77
|
else {
|
|
63
|
-
|
|
64
|
-
if (!fs_extra_1.default.existsSync(srcTemplate)) {
|
|
65
|
-
throw new Error('base-template not found in package. Ensure base-template/ is published.');
|
|
66
|
-
}
|
|
67
|
-
console.log(chalk_1.default.yellow(`Example not found; using base template`));
|
|
78
|
+
console.log(chalk_1.default.yellow(`Example ${exampleDirName} not found; using base template contracts/tests`));
|
|
68
79
|
}
|
|
69
|
-
// Copy template
|
|
70
|
-
fs_extra_1.default.copySync(srcTemplate, projectDir);
|
|
71
80
|
// Update package.json name and description
|
|
72
81
|
const pkgPath = path_1.default.join(projectDir, 'package.json');
|
|
73
82
|
if (fs_extra_1.default.existsSync(pkgPath)) {
|