()
| 8 | const parameterMatrix = {}; |
| 9 | |
| 10 | function generateChibiTypes() { |
| 11 | console.log('Generating ChibiScript type definitions...'); |
| 12 | |
| 13 | const functionsDir = path.resolve(__dirname, '../src/chibiScript/functions'); |
| 14 | const functionFilePaths = glob.sync(path.join(functionsDir, '**/*Functions.ts')); |
| 15 | const functionModules = functionFilePaths.map(filePath => |
| 16 | path.relative(functionsDir, filePath).replace(/\\/g, '/'), |
| 17 | ); |
| 18 | |
| 19 | const allFunctionParts = []; |
| 20 | |
| 21 | functionModules.forEach(moduleFile => { |
| 22 | const modulePath = path.join(functionsDir, moduleFile); |
| 23 | const moduleSource = fs.readFileSync(modulePath, 'utf8'); |
| 24 | |
| 25 | const sourceFile = ts.createSourceFile( |
| 26 | moduleFile, |
| 27 | moduleSource, |
| 28 | ts.ScriptTarget.ESNext, |
| 29 | true |
| 30 | ); |
| 31 | |
| 32 | allFunctionParts.push(extractFunction(sourceFile)); |
| 33 | }); |
| 34 | |
| 35 | const utilitiesDir = path.resolve(__dirname, '../src/chibiScript/utilities'); |
| 36 | const utilityFilePaths = glob.sync(path.join(utilitiesDir, '**/*Utilities.ts')); |
| 37 | const utilityModules = utilityFilePaths.map(filePath => |
| 38 | path.relative(utilitiesDir, filePath).replace(/\\/g, '/'), |
| 39 | ); |
| 40 | |
| 41 | const allUtilityParts = []; |
| 42 | |
| 43 | utilityModules.forEach(moduleFile => { |
| 44 | const modulePath = path.join(utilitiesDir, moduleFile); |
| 45 | const moduleSource = fs.readFileSync(modulePath, 'utf8'); |
| 46 | |
| 47 | const sourceFile = ts.createSourceFile(moduleFile, moduleSource, ts.ScriptTarget.ESNext, true); |
| 48 | |
| 49 | allUtilityParts.push(extractUtilities(sourceFile)); |
| 50 | }); |
| 51 | |
| 52 | let typeDefinitions = `/* eslint-disable prettier/prettier */\n`; |
| 53 | typeDefinitions += `/* eslint-disable @stylistic/quotes */\n`; |
| 54 | typeDefinitions += `/* eslint-disable @stylistic/quote-props */\n\n`; |
| 55 | typeDefinitions += `import functionsRegistry from './functions';\n`; |
| 56 | typeDefinitions += `import utilitiesRegistry from './utilities';\n`; |
| 57 | typeDefinitions += `import type { ChibiGenerator, ChibiJson } from './ChibiGenerator';\n`; |
| 58 | typeDefinitions += `import type { ReservedKey } from './ChibiRegistry';\n`; |
| 59 | typeDefinitions += `import type * as CT from './ChibiTypeHelper';\n\n`; |
| 60 | typeDefinitions += `type ChibiParam<T> = T | ChibiJson<T>;\n\n`; |
| 61 | typeDefinitions += `export interface ChibiGeneratorFunctions<Input> {\n`; |
| 62 | |
| 63 | typeDefinitions += allFunctionParts.join('\n'); |
| 64 | |
| 65 | typeDefinitions += `\n}\n\n`; |
| 66 | |
| 67 | typeDefinitions += `export interface ChibiGeneratorUtilities<Input> {\n`; |
no test coverage detected