prisma-client-php 4.2.2 → 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 +1 -1
- package/dist/index.enc +1 -1
- package/dist/init.js +1 -1
- package/package.json +1 -1
package/dist/generate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as fs from"fs";import{
|
|
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});
|