prisma-client-php 4.2.3 → 4.3.0

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/generate.js CHANGED
@@ -1 +1 @@
1
- import*as fs from"fs";import{exec}from"child_process";import path from"path";import CryptoJS from"crypto-js";import chalk from"chalk";import{getFileMeta}from"./utils.js";const{__dirname}=getFileMeta(),getSecretKey=()=>{const e=fs.readFileSync(`${__dirname}/key.enc`,"utf8");if(e.length<400)throw new Error("File content is less than 400 characters.");return e.substring(754,799)},decryptData=(e,r)=>CryptoJS.AES.decrypt(e,r).toString(CryptoJS.enc.Utf8),executePHP=e=>{exec(e,(e,r,t)=>{if(e)return t?.trim()&&console.error(t),void console.error(`Execution error: ${e.message}`);if(t?.trim()){const e=t.split(/\r?\n/).filter(e=>e.trim()&&!/Loaded Prisma config from/i.test(e)&&!/Prisma config detected, skipping environment variable loading/i.test(e)).join("\n");e&&console.warn(e)}r.includes("Result: Prisma schema is valid.")?console.log(chalk.blue(r)):r.trim()&&console.log(`Standard output...\n${r}`)})},main=async()=>{try{const e=process.cwd(),r=path.join(e,"prisma-php.json"),t=fs.readFileSync(r,{encoding:"utf8"}),n=JSON.parse(t),o=n.phpGenerateClassPath??"src/Lib/Prisma/Classes",i=`${__dirname}/index.php`,c=`${__dirname}/index.enc`,s=getSecretKey(),a=fs.readFileSync(c,{encoding:"utf8"}),l=decryptData(a,s);fs.writeFileSync(`${__dirname}/index.php`,l);const m=`${n.phpRootPathExe} ${i} ${o}`;console.log("Executing command...\n"),executePHP(m)}catch(e){console.error("Error in script execution:",e)}};main().catch(e=>{console.error("Unhandled error in main function:",e)});
1
+ import*as fs from"fs";import{spawn}from"child_process";import path from"path";import CryptoJS from"crypto-js";import chalk from"chalk";import{getFileMeta}from"./utils.js";const{__dirname}=getFileMeta(),getSecretKey=()=>{const e=fs.readFileSync(path.join(__dirname,"key.enc"),"utf8");if(e.length<400)throw new Error("File content is less than 400 characters.");return e.substring(754,799)},decryptData=(e,t)=>CryptoJS.AES.decrypt(e,t).toString(CryptoJS.enc.Utf8),executePHP=(e,t,r)=>new Promise((n,i)=>{const o=spawn(e,[t,r],{stdio:["ignore","pipe","pipe"],shell:!1});let s="",a="";o.stdout.on("data",e=>{s+=e.toString()}),o.stderr.on("data",e=>{a+=e.toString()}),o.on("error",e=>{i(e)}),o.on("close",e=>{if(a.trim()){const e=a.split(/\r?\n/).filter(e=>e.trim()&&!/Loaded Prisma config from/i.test(e)&&!/Prisma config detected, skipping environment variable loading/i.test(e)).join("\n");e&&console.warn(e)}0===e?(s.includes("Result: Prisma schema is valid.")?console.log(chalk.blue(s)):s.trim()&&console.log(`Standard output...\n${s}`),n()):i(new Error(`PHP process exited with code ${e}`))})}),main=async()=>{let e="";try{const t=process.cwd(),r=path.join(t,"prisma-php.json");if(!fs.existsSync(r))throw new Error(`Missing config file: ${r}`);const n=fs.readFileSync(r,{encoding:"utf8"}),i=JSON.parse(n),o=i.phpGenerateClassPath??"src/Lib/Prisma/Classes",s=i.phpRootPathExe;if(!s||"string"!=typeof s)throw new Error("Invalid or missing 'phpRootPathExe' in prisma-php.json.");e=path.join(__dirname,"index.php");const a=path.join(__dirname,"index.enc"),c=getSecretKey(),p=fs.readFileSync(a,{encoding:"utf8"}),l=decryptData(p,c);if(!l.trim())throw new Error("Decryption failed: PHP file content is empty.");fs.writeFileSync(e,l,"utf8"),console.log("Executing command...\n"),await executePHP(s,e,o)}catch(e){console.error("Error in script execution:",e),process.exitCode=1}finally{if(e&&fs.existsSync(e))try{fs.unlinkSync(e)}catch{}}};main().catch(e=>{console.error("Unhandled error in main function:",e),process.exitCode=1});
package/dist/init.js CHANGED
@@ -1 +1 @@
1
- import fs from"fs";import path from"path";import{execSync}from"child_process";import{getFileMeta}from"./utils.js";import chalk from"chalk";const{__dirname}=getFileMeta();let projectSettings=null;function checkExcludeFiles(e){const s=e.replace(/\\/g,"/");return!!projectSettings?.excludeFilePath?.includes(s)||!!projectSettings?.excludeFiles&&projectSettings.excludeFiles.some(e=>{const i=e.replace(/\\/g,"/");return s.endsWith("/"+i)||s===i})}function copyRecursiveSync(e,s,i=e,n=!1){if(!fs.existsSync(e))return void console.error(`Source folder does not exist: ${e}`);fs.existsSync(s)||fs.mkdirSync(s,{recursive:!0});const o=fs.readdirSync(e,{withFileTypes:!0});for(const r of o){const o=path.join(e,r.name),t=path.join(s,r.name),c=path.relative(i,o),p=path.join(path.basename(i),c);if(checkExcludeFiles(t))return;const a=path.relative(__dirname,o),l=path.normalize("src/Lib/Validator.php");n&&a===l?console.log(`Skipping file: ${p}`):r.isDirectory()?copyRecursiveSync(o,t,i,n):(fs.copyFileSync(o,t),console.log(`Copied file: ${p}`))}}const directoriesToCopy=[{srcFolder:path.join(__dirname,"src"),destFolder:path.join(process.cwd(),"src")},{srcFolder:path.join(__dirname,"settings"),destFolder:path.join(process.cwd(),"settings")},{srcFolder:path.join(__dirname,"prisma"),destFolder:path.join(process.cwd(),"prisma")}];function installNpmDependencies(e){const s=process.cwd(),i=path.join(s,"package.json");let n;if(!fs.existsSync(i))return void console.error("package.json does not exist.");{const s=fs.readFileSync(i,"utf8");n=JSON.parse(s),e||(n.type="module"),fs.writeFileSync(i,JSON.stringify(n,null,2))}let o=[npmPkg("prisma"),npmPkg("@prisma/client"),npmPkg("@prisma/internals"),npmPkg("better-sqlite3"),npmPkg("@prisma/adapter-better-sqlite3"),npmPkg("mariadb"),npmPkg("@prisma/adapter-mariadb"),npmPkg("pg"),npmPkg("@prisma/adapter-pg"),npmPkg("@types/pg")];e||o.push(npmPkg("tsx"),npmPkg("typescript"),npmPkg("@types/node"));const r=o.join(" ");try{console.log(`Installing packages: ${r}`),execSync(`npm install --save-dev ${r}`,{stdio:"inherit",cwd:s}),e||execSync("npx tsc --init",{stdio:"inherit",cwd:s}),console.log("Packages installed successfully.")}catch(e){console.error("Error installing packages:",e)}}function initPrisma(){const e=process.cwd(),s=path.join(e,"prisma");if(fs.existsSync(s))console.warn("Prisma folder already exists. Skipping prisma init.");else try{console.log("Initializing Prisma..."),execSync("npx prisma init",{stdio:"inherit",cwd:e}),console.log("Prisma initialized successfully.")}catch(e){console.error("Error initializing Prisma:",e)}}async function installComposerDependencies(e){const s=process.cwd(),i=path.join(s,"composer.json");if(!fs.existsSync(i))return void console.error("composer.json does not exist.");let n=[composerPkg("calicastle/cuid")];if(e){const e=path.join(s,"prisma-php.json");if(fs.existsSync(e)){const i=readJsonFile(e);let n=[];i.excludeFiles?.map(e=>{const i=path.join(s,e);fs.existsSync(i)&&n.push(i.replace(/\\/g,"/"))}),projectSettings={...i,excludeFiles:i.excludeFiles??[],excludeFilePath:n??[]}}}else n.push(composerPkg("symfony/uid"),composerPkg("brick/math"),composerPkg("tsnc/prisma-php"));try{console.log("Installing Composer dependencies:"),n.forEach(e=>console.log(`- ${chalk.blue(e)}`));const e=`C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar require ${n.join(" ")}`;execSync(e,{stdio:"inherit",cwd:s})}catch(e){console.error("Error installing Composer dependencies:",e)}}const readJsonFile=e=>{const s=fs.readFileSync(e,"utf8");return JSON.parse(s)},npmPinnedVersions={prisma:"7.3.0","@prisma/client":"7.3.0","@prisma/internals":"7.3.0",tsx:"4.21.0",typescript:"5.9.3","@types/node":"25.1.0","better-sqlite3":"12.6.2","@prisma/adapter-better-sqlite3":"7.3.0",mariadb:"3.4.5","@prisma/adapter-mariadb":"7.3.0",pg:"8.17.2","@prisma/adapter-pg":"7.3.0","@types/pg":"8.16.0"};function npmPkg(e){return npmPinnedVersions[e]?`${e}@${npmPinnedVersions[e]}`:e}const composerPinnedVersions={"calicastle/cuid":"2.0.0","symfony/uid":"7.3.1","brick/math":"0.14.1","tsnc/prisma-php":"1.0.0"};function composerPkg(e){return composerPinnedVersions[e]?`${e}:${composerPinnedVersions[e]}`:e}async function main(){const e=process.argv.includes("--prisma-php");installNpmDependencies(e),await installComposerDependencies(e),initPrisma(),directoriesToCopy.forEach(s=>{copyRecursiveSync(s.srcFolder,s.destFolder,s.srcFolder,e)});const s=path.join(__dirname,"prisma.config.ts"),i=path.join(process.cwd(),"prisma.config.ts");var n,o;checkExcludeFiles(i)?console.log(`Skipping excluded file: ${path.basename(i)}`):(n=s,o=i,fs.existsSync(n)?(fs.copyFileSync(n,o),console.log(`Copied file: ${path.basename(n)}`)):console.warn(`File not found (skip): ${n}`)),console.log("Finished copying directories.")}main().catch(e=>{console.error("Error during execution:",e)});
1
+ import fs from"fs";import path from"path";import{execSync}from"child_process";import{getFileMeta}from"./utils.js";import chalk from"chalk";const{__dirname}=getFileMeta();let projectSettings=null;function checkExcludeFiles(e){const s=e.replace(/\\/g,"/");return!!projectSettings?.excludeFilePath?.includes(s)||!!projectSettings?.excludeFiles&&projectSettings.excludeFiles.some(e=>{const i=e.replace(/\\/g,"/");return s.endsWith("/"+i)||s===i})}function copyRecursiveSync(e,s,i=e,n=!1){if(!fs.existsSync(e))return void console.error(`Source folder does not exist: ${e}`);fs.existsSync(s)||fs.mkdirSync(s,{recursive:!0});const o=fs.readdirSync(e,{withFileTypes:!0});for(const r of o){const o=path.join(e,r.name),t=path.join(s,r.name),c=path.relative(i,o),p=path.join(path.basename(i),c);if(checkExcludeFiles(t))return;const a=path.relative(__dirname,o),l=path.normalize("src/Lib/Validator.php");n&&a===l?console.log(`Skipping file: ${p}`):r.isDirectory()?copyRecursiveSync(o,t,i,n):(fs.copyFileSync(o,t),console.log(`Copied file: ${p}`))}}const directoriesToCopy=[{srcFolder:path.join(__dirname,"src"),destFolder:path.join(process.cwd(),"src")},{srcFolder:path.join(__dirname,"settings"),destFolder:path.join(process.cwd(),"settings")},{srcFolder:path.join(__dirname,"prisma"),destFolder:path.join(process.cwd(),"prisma")}];function installNpmDependencies(e){const s=process.cwd(),i=path.join(s,"package.json");let n;if(!fs.existsSync(i))return void console.error("package.json does not exist.");{const s=fs.readFileSync(i,"utf8");n=JSON.parse(s),e||(n.type="module"),fs.writeFileSync(i,JSON.stringify(n,null,2))}let o=[npmPkg("prisma"),npmPkg("@prisma/client"),npmPkg("@prisma/internals"),npmPkg("better-sqlite3"),npmPkg("@prisma/adapter-better-sqlite3"),npmPkg("mariadb"),npmPkg("@prisma/adapter-mariadb"),npmPkg("pg"),npmPkg("@prisma/adapter-pg"),npmPkg("@types/pg")];e||o.push(npmPkg("tsx"),npmPkg("typescript"),npmPkg("@types/node"));const r=o.join(" ");try{console.log(`Installing packages: ${r}`),execSync(`npm install --save-dev ${r}`,{stdio:"inherit",cwd:s}),e||execSync("npx tsc --init",{stdio:"inherit",cwd:s}),console.log("Packages installed successfully.")}catch(e){console.error("Error installing packages:",e)}}function initPrisma(){const e=process.cwd(),s=path.join(e,"prisma");if(fs.existsSync(s))console.warn("Prisma folder already exists. Skipping prisma init.");else try{console.log("Initializing Prisma..."),execSync("npx prisma init",{stdio:"inherit",cwd:e}),console.log("Prisma initialized successfully.")}catch(e){console.error("Error initializing Prisma:",e)}}async function installComposerDependencies(e){const s=process.cwd(),i=path.join(s,"composer.json");if(!fs.existsSync(i))return void console.error("composer.json does not exist.");let n=[composerPkg("calicastle/cuid")];if(e){const e=path.join(s,"prisma-php.json");if(fs.existsSync(e)){const i=readJsonFile(e);let n=[];i.excludeFiles?.map(e=>{const i=path.join(s,e);fs.existsSync(i)&&n.push(i.replace(/\\/g,"/"))}),projectSettings={...i,excludeFiles:i.excludeFiles??[],excludeFilePath:n??[]}}}else n.push(composerPkg("symfony/uid"),composerPkg("brick/math"),composerPkg("tsnc/prisma-php"));try{console.log("Installing Composer dependencies:"),n.forEach(e=>console.log(`- ${chalk.blue(e)}`));const e=`C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar require ${n.join(" ")}`;execSync(e,{stdio:"inherit",cwd:s})}catch(e){console.error("Error installing Composer dependencies:",e)}}const readJsonFile=e=>{const s=fs.readFileSync(e,"utf8");return JSON.parse(s)},npmPinnedVersions={prisma:"7.5.0","@prisma/client":"7.5.0","@prisma/internals":"7.5.0",tsx:"4.21.0",typescript:"5.9.3","@types/node":"25.1.0","better-sqlite3":"12.8.0","@prisma/adapter-better-sqlite3":"7.5.0",mariadb:"3.5.2","@prisma/adapter-mariadb":"7.5.0",pg:"8.20.0","@prisma/adapter-pg":"7.5.0","@types/pg":"8.18.0"};function npmPkg(e){return npmPinnedVersions[e]?`${e}@${npmPinnedVersions[e]}`:e}const composerPinnedVersions={"calicastle/cuid":"2.0.0","symfony/uid":"7.3.1","brick/math":"0.14.1","tsnc/prisma-php":"1.0.0"};function composerPkg(e){return composerPinnedVersions[e]?`${e}:${composerPinnedVersions[e]}`:e}async function main(){const e=process.argv.includes("--prisma-php");installNpmDependencies(e),await installComposerDependencies(e),initPrisma(),directoriesToCopy.forEach(s=>{copyRecursiveSync(s.srcFolder,s.destFolder,s.srcFolder,e)});const s=path.join(__dirname,"prisma.config.ts"),i=path.join(process.cwd(),"prisma.config.ts");var n,o;checkExcludeFiles(i)?console.log(`Skipping excluded file: ${path.basename(i)}`):(n=s,o=i,fs.existsSync(n)?(fs.copyFileSync(n,o),console.log(`Copied file: ${path.basename(n)}`)):console.warn(`File not found (skip): ${n}`)),console.log("Finished copying directories.")}main().catch(e=>{console.error("Error during execution:",e)});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prisma-client-php",
3
3
  "description": "Prisma Client PHP is an auto-generated query builder that enables type-safe database access in PHP.",
4
- "version": "4.2.3",
4
+ "version": "4.3.0",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {