create-fhevm-playground-pro 1.0.4 → 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 +34 -15
- package/package.json +1 -1
package/dist/scaffolder.js
CHANGED
|
@@ -39,25 +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
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
const searchPaths = [
|
|
51
|
+
path_1.default.resolve(process.cwd(), 'central-repo', 'examples', `${exampleDirName}-premium`),
|
|
52
|
+
path_1.default.resolve(process.cwd(), '..', 'central-repo', 'examples', `${exampleDirName}-premium`),
|
|
53
|
+
path_1.default.resolve(process.cwd(), '..', '..', 'central-repo', 'examples', `${exampleDirName}-premium`),
|
|
54
|
+
];
|
|
55
|
+
let centralRepoExampleDir = null;
|
|
56
|
+
for (const searchPath of searchPaths) {
|
|
57
|
+
if (fs_extra_1.default.existsSync(searchPath)) {
|
|
58
|
+
centralRepoExampleDir = searchPath;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
50
61
|
}
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
if (centralRepoExampleDir) {
|
|
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`));
|
|
56
71
|
}
|
|
57
|
-
|
|
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
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.log(chalk_1.default.yellow(`Example ${exampleDirName} not found; using base template contracts/tests`));
|
|
58
79
|
}
|
|
59
|
-
// Copy template
|
|
60
|
-
fs_extra_1.default.copySync(srcTemplate, projectDir);
|
|
61
80
|
// Update package.json name and description
|
|
62
81
|
const pkgPath = path_1.default.join(projectDir, 'package.json');
|
|
63
82
|
if (fs_extra_1.default.existsSync(pkgPath)) {
|