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.
Files changed (2) hide show
  1. package/dist/scaffolder.js +34 -15
  2. package/package.json +1 -1
@@ -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
- // Try to find the actual example in central-repo/examples/[category]-premium/
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 centralRepoExampleDir = path_1.default.resolve(__dirname, '..', '..', '..', 'central-repo', 'examples', `${exampleDirName}-premium`);
45
- let srcTemplate;
46
- if (fs_extra_1.default.existsSync(centralRepoExampleDir)) {
47
- // Use the actual example from central-repo
48
- srcTemplate = centralRepoExampleDir;
49
- console.log(chalk_1.default.cyan(`Using example from ${exampleDirName}-premium`));
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
- else {
52
- // Fall back to base-template (for npm published users)
53
- srcTemplate = path_1.default.resolve(__dirname, '..', 'base-template');
54
- if (!fs_extra_1.default.existsSync(srcTemplate)) {
55
- throw new Error('base-template not found in package. Ensure base-template/ is published.');
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
- console.log(chalk_1.default.yellow(`Example not found; using base template`));
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)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fhevm-playground-pro",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Premium scaffolding CLI for fhEVM Playground Pro – Zama bounty",
5
5
  "main": "dist/create-example.js",
6
6
  "bin": {