create-prisma-php-app 4.0.10 → 4.0.12
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/prisma-php.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import chalk from"chalk";import{spawn}from"child_process";import fs from"fs";import path from"path";import prompts from"prompts";const args=process.argv.slice(2),readJsonFile=e=>{const o=fs.readFileSync(e,"utf8");return JSON.parse(o)},executeCommand=(e,o=[],r={})=>new Promise((s
|
|
2
|
+
import chalk from"chalk";import{spawn}from"child_process";import fs from"fs";import path from"path";import prompts from"prompts";const args=process.argv.slice(2),readJsonFile=e=>{const o=fs.readFileSync(e,"utf8");return JSON.parse(o)},executeCommand=(e,o=[],r={})=>new Promise((n,s)=>{const t=spawn(e,o,{stdio:"inherit",shell:!0,...r});t.on("error",e=>{console.error(`Execution error: ${e.message}`),s(e)}),t.on("close",e=>{0===e?n():s(new Error(`Process exited with code ${e}`))})});async function getAnswer(e){const o=[{type:"toggle",name:"shouldProceed",message:`This command will update the ${chalk.blue("create-prisma-php-app")} package and overwrite all default files. ${chalk.blue("Do you want to proceed")}?`,initial:!1,active:"Yes",inactive:"No"}];e||o.push({type:e=>e?"text":null,name:"versionTag",message:`Enter version tag (e.g., ${chalk.cyan("latest")}, ${chalk.cyan("v4-alpha")}, ${chalk.cyan("1.2.3")}), or press Enter for ${chalk.green("latest")}:`,initial:"latest",validate:e=>!(!e||""===e.trim())||"Version tag cannot be empty"});const r=await prompts(o,{onCancel:()=>{console.warn(chalk.red("Operation cancelled by the user.")),process.exit(0)}});if(0===Object.keys(r).length)return null;let n="latest";return e?n=e:r.versionTag&&(n=r.versionTag),{shouldProceed:r.shouldProceed,versionTag:n}}const commandsToExecute={update:"npx pp update project"},parseVersionFromArgs=e=>{const o=e.find(e=>e.startsWith("@")||e.match(/^\d+\.\d+\.\d+/));if(o)return o.startsWith("@")?o.slice(1):o},main=async()=>{if(0===args.length)return console.log("No command provided."),console.log("\nUsage:"),console.log(` ${chalk.cyan("npx pp update project")} - Update to latest version`),console.log(` ${chalk.cyan("npx pp update project @v4-alpha")} - Update to specific tag`),void console.log(` ${chalk.cyan("npx pp update project @1.2.3")} - Update to specific version`);const e=parseVersionFromArgs(args),o=`npx pp ${args.filter(e=>!e.startsWith("@")&&!e.match(/^\d+\.\d+\.\d+/)).join(" ")}`;if(!Object.values(commandsToExecute).includes(o))return console.log("Command not recognized or not allowed."),console.log("\nAvailable commands:"),void console.log(` ${chalk.cyan("update project")} - Update project files`);if(o===commandsToExecute.update)try{const o=await getAnswer(e);if(!o?.shouldProceed)return void console.log(chalk.red("Operation cancelled by the user."));const r=process.cwd(),n=path.join(r,"prisma-php.json");if(!fs.existsSync(n))return void console.error(chalk.red("The configuration file 'prisma-php.json' was not found in the current directory."));const s=readJsonFile(n),t=o.versionTag||"latest",a=`create-prisma-php-app@${t}`;console.log(chalk.blue(`\nUpdating to: ${chalk.green(a)}\n`));const c=[s.projectName];s.backendOnly&&c.push("--backend-only"),s.swaggerDocs&&c.push("--swagger-docs"),s.tailwindcss&&c.push("--tailwindcss"),s.websocket&&c.push("--websocket"),s.prisma&&c.push("--prisma"),s.docker&&c.push("--docker"),s.mcp&&c.push("--mcp"),s.typescript&&c.push("--typescript"),console.log("Executing command...\n"),await executeCommand("npx",[a,...c]),s.version=t,fs.writeFileSync(n,JSON.stringify(s,null,2)),console.log(chalk.green(`\n✓ Project updated successfully to version ${t}!`)),console.log(chalk.blue("Updated configuration saved to prisma-php.json"))}catch(e){e instanceof Error?e.message.includes("no such file or directory")?console.error(chalk.red("The configuration file 'prisma-php.json' was not found in the current directory.")):console.error(chalk.red(`Error during update: ${e.message}`)):console.error("Error in script execution:",e)}};main().catch(e=>{console.error("Unhandled error in main function:",e)});
|