create-fhevm-playground-pro 1.0.2 → 1.0.4

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.
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "lib": ["ES2020"],
6
+ "moduleResolution": "node",
7
+ "declaration": true,
8
+ "outDir": "./dist",
9
+ "rootDir": "./",
10
+ "strict": true,
11
+ "esModuleInterop": true,
12
+ "skipLibCheck": true,
13
+ "resolveJsonModule": true,
14
+ "forceConsistentCasingInFileNames": true
15
+ },
16
+ "include": ["**/*.ts"],
17
+ "exclude": ["node_modules", "dist"]
18
+ }
@@ -5,21 +5,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createExample = createExample;
7
7
  /**
8
- * Minimal scaffolder used by the CLI.
9
- * Copies `base-template/` into a new project folder, updates package.json and README.
8
+ * Scaffolder that copies actual example contracts/tests from central-repo/examples/
9
+ * Falls back to base-template for npm published users who don't have access to central repo.
10
10
  */
11
11
  const path_1 = __importDefault(require("path"));
12
12
  const fs_extra_1 = __importDefault(require("fs-extra"));
13
13
  const child_process_1 = require("child_process");
14
14
  const chalk_1 = __importDefault(require("chalk"));
15
+ // Category ID to example directory name mapping
16
+ const CATEGORY_TO_EXAMPLE_DIR = {
17
+ 'basic-counter': 'basic-counter',
18
+ 'arithmetic': 'arithmetic',
19
+ 'comparisons': 'comparisons',
20
+ 'single-encryption': 'single-encryption',
21
+ 'access-control': 'access-control',
22
+ 'input-verification-proofs': 'input-proofs',
23
+ 'anti-patterns-guide': 'anti-patterns',
24
+ 'handles-lifecycle': 'handles-lifecycle',
25
+ 'oz-erc7984-basic': 'erc7984',
26
+ 'oz-erc20-wrapper': 'private-erc20',
27
+ 'vesting': 'vesting',
28
+ 'blind-auction': 'blind-auction',
29
+ 'dao-voting-pro': 'dao-voting',
30
+ 'private-lending-pro': 'private-lending',
31
+ 'blind-dex-pro': 'blind-dex',
32
+ 'poker-game-pro': 'encrypted-poker',
33
+ 'yield-farming-pro': 'private-yield',
34
+ 'mev-arbitrage-pro': 'mev-arbitrage',
35
+ 'confidential-stablecoin-pro': 'confidential-stablecoin',
36
+ };
15
37
  async function createExample(options) {
16
38
  const projectDir = path_1.default.resolve(process.cwd(), options.name);
17
39
  if (fs_extra_1.default.existsSync(projectDir)) {
18
40
  throw new Error(`Directory ${options.name} already exists`);
19
41
  }
20
- const srcTemplate = path_1.default.resolve(__dirname, '..', 'base-template');
21
- if (!fs_extra_1.default.existsSync(srcTemplate)) {
22
- throw new Error('base-template not found in package. Ensure base-template/ is published.');
42
+ // Try to find the actual example in central-repo/examples/[category]-premium/
43
+ 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
+ }
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.');
56
+ }
57
+ console.log(chalk_1.default.yellow(`Example not found; using base template`));
23
58
  }
24
59
  // Copy template
25
60
  fs_extra_1.default.copySync(srcTemplate, projectDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fhevm-playground-pro",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Premium scaffolding CLI for fhEVM Playground Pro – Zama bounty",
5
5
  "main": "dist/create-example.js",
6
6
  "bin": {