create-fhevm-playground-pro 1.0.13 → 1.0.15

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 +45 -0
  2. package/package.json +1 -1
@@ -72,6 +72,51 @@ async function createExample(options) {
72
72
  if (fs_extra_1.default.existsSync(testSrc)) {
73
73
  fs_extra_1.default.copySync(testSrc, testDest, { overwrite: true });
74
74
  console.log(chalk_1.default.cyan(`Overlaid tests from ${exampleDirName}-premium`));
75
+ // Convert TypeScript test files to JavaScript for ESM compatibility
76
+ const testFiles = fs_extra_1.default.readdirSync(testDest).filter(f => f.endsWith('.ts'));
77
+ for (const testFile of testFiles) {
78
+ const tsPath = path_1.default.join(testDest, testFile);
79
+ const jsPath = path_1.default.join(testDest, testFile.replace('.ts', '.test.js'));
80
+ let testContent = fs_extra_1.default.readFileSync(tsPath, 'utf-8');
81
+ // Remove TypeScript type annotations and imports
82
+ // Remove type annotations like : any, : type, etc.
83
+ testContent = testContent.replace(/:\s*(\w+(<[^>]*>)?(\[\])?)/g, '');
84
+ // Replace absolute paths: ../../../../scripts/test-helpers -> ./test-helpers.js
85
+ testContent = testContent.replace(/import\s+{([^}]+)}\s+from\s+"\.\.\/\.\.\/\.\.\/\.\.\/scripts\/test-helpers"/, 'import { $1 } from "./test-helpers.js"');
86
+ // Write as .test.js
87
+ fs_extra_1.default.writeFileSync(jsPath, testContent);
88
+ // Remove original .ts file
89
+ fs_extra_1.default.removeSync(tsPath);
90
+ }
91
+ // Create test-helpers.js stub if it doesn't exist
92
+ const testHelpersPath = path_1.default.join(testDest, 'test-helpers.js');
93
+ if (!fs_extra_1.default.existsSync(testHelpersPath)) {
94
+ const testHelpersContent = `const isMocked = process.env.MOCK === 'true';
95
+
96
+ export async function initGateway() {
97
+ if (isMocked) {
98
+ console.log('Gateway initialized (mocked mode)');
99
+ } else {
100
+ console.log('Gateway initialized');
101
+ }
102
+ }
103
+
104
+ export async function getSignatureAndEncryption(data) {
105
+ // In mocked mode, return dummy encrypted values for fast testing
106
+ // In real mode, this would handle actual FHE cryptographic operations
107
+ return {
108
+ ciphertext: '0x0000000000000000000000000000000000000000000000000000000000000000',
109
+ signature: '0x0000000000000000000000000000000000000000000000000000000000000000',
110
+ encryption: '0x0000000000000000000000000000000000000000000000000000000000000000'
111
+ };
112
+ }
113
+
114
+ export function isMockedMode() {
115
+ return isMocked;
116
+ }
117
+ `;
118
+ fs_extra_1.default.writeFileSync(testHelpersPath, testHelpersContent);
119
+ }
75
120
  }
76
121
  }
77
122
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fhevm-playground-pro",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Premium scaffolding CLI for fhEVM Playground Pro – Zama bounty",
5
5
  "main": "dist/create-example.js",
6
6
  "bin": {