create-prisma-php-app 1.6.61 → 1.6.63
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/index.js +2 -0
- package/dist/prisma-php.js +100 -83
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -264,6 +264,8 @@ async function createOrUpdateEnvFile(baseDir, content) {
|
|
|
264
264
|
}
|
|
265
265
|
function checkExcludeFiles(destPath) {
|
|
266
266
|
var _a, _b;
|
|
267
|
+
if (!(updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate))
|
|
268
|
+
return false;
|
|
267
269
|
return ((_b = (_a = updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.excludeFilePath) === null || _a === void 0 ? void 0 : _a.includes(destPath.replace(/\\/g, "/"))) !== null && _b !== void 0 ? _b : false);
|
|
268
270
|
}
|
|
269
271
|
async function createDirectoryStructure(baseDir, answer, projectSettings) {
|
package/dist/prisma-php.js
CHANGED
|
@@ -9,100 +9,117 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
const args = process.argv.slice(2);
|
|
11
11
|
const readJsonFile = (filePath) => {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const jsonData = fs.readFileSync(filePath, "utf8");
|
|
13
|
+
return JSON.parse(jsonData);
|
|
14
14
|
};
|
|
15
15
|
const executeCommand = (command, args = [], options = {}) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const process = spawn(command, args, Object.assign({ stdio: "inherit", shell: true }, options));
|
|
18
|
+
process.on("error", (error) => {
|
|
19
|
+
console.error(`Execution error: ${error.message}`);
|
|
20
|
+
reject(error);
|
|
21
|
+
});
|
|
22
|
+
process.on("close", (code) => {
|
|
23
|
+
if (code === 0) {
|
|
24
|
+
resolve();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
reject(new Error(`Process exited with code ${code}`));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
25
30
|
});
|
|
26
|
-
process.on("close", (code) => {
|
|
27
|
-
if (code === 0) {
|
|
28
|
-
resolve();
|
|
29
|
-
} else {
|
|
30
|
-
reject(new Error(`Process exited with code ${code}`));
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
31
|
};
|
|
35
32
|
async function getAnswer() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (Object.keys(response).length === 0) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
return response;
|
|
33
|
+
const questions = [
|
|
34
|
+
{
|
|
35
|
+
type: "toggle",
|
|
36
|
+
name: "shouldProceed",
|
|
37
|
+
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")}?`,
|
|
38
|
+
initial: false,
|
|
39
|
+
active: "Yes",
|
|
40
|
+
inactive: "No",
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
const onCancel = () => {
|
|
44
|
+
console.log(chalk.red("Operation cancelled by the user."));
|
|
45
|
+
process.exit(0);
|
|
46
|
+
};
|
|
47
|
+
const response = await prompts(questions, { onCancel });
|
|
48
|
+
if (Object.keys(response).length === 0) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return response;
|
|
59
52
|
}
|
|
53
|
+
const commandsToExecute = ["npx pphp generate class", "npx pphp update"];
|
|
60
54
|
const main = async () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const answer = await getAnswer();
|
|
64
|
-
if (
|
|
65
|
-
!(answer === null || answer === void 0 ? void 0 : answer.shouldProceed)
|
|
66
|
-
) {
|
|
67
|
-
console.log(chalk.red("Operation cancelled by the user."));
|
|
55
|
+
if (args.length === 0) {
|
|
56
|
+
console.log("No command provided.");
|
|
68
57
|
return;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.error(
|
|
74
|
-
chalk.red(
|
|
75
|
-
"The configuration file 'prisma-php.json' was not found in the current directory."
|
|
76
|
-
)
|
|
77
|
-
);
|
|
58
|
+
}
|
|
59
|
+
const formattedCommand = `npx pphp ${args.join(" ")}`;
|
|
60
|
+
if (!commandsToExecute.includes(formattedCommand)) {
|
|
61
|
+
console.log("Command not recognized or not allowed.");
|
|
78
62
|
return;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
96
|
-
|
|
63
|
+
}
|
|
64
|
+
if (args[0] === "update") {
|
|
65
|
+
try {
|
|
66
|
+
const answer = await getAnswer();
|
|
67
|
+
if (!(answer === null || answer === void 0 ? void 0 : answer.shouldProceed)) {
|
|
68
|
+
console.log(chalk.red("Operation cancelled by the user."));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const currentDir = process.cwd();
|
|
72
|
+
const configPath = path.join(currentDir, "prisma-php.json");
|
|
73
|
+
if (!fs.existsSync(configPath)) {
|
|
74
|
+
console.error(chalk.red("The configuration file 'prisma-php.json' was not found in the current directory."));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const localSettings = readJsonFile(configPath);
|
|
78
|
+
const commandArgs = [localSettings.projectName];
|
|
79
|
+
if (localSettings.tailwindcss)
|
|
80
|
+
commandArgs.push("--tailwindcss");
|
|
81
|
+
if (localSettings.websocket)
|
|
82
|
+
commandArgs.push("--websocket");
|
|
83
|
+
console.log("Executing command...\n");
|
|
84
|
+
await executeCommand("npx", [
|
|
85
|
+
"create-prisma-php-app@alpha-update-command",
|
|
86
|
+
...commandArgs,
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error instanceof Error) {
|
|
91
|
+
if (error.message.includes("no such file or directory")) {
|
|
92
|
+
console.error(chalk.red("The configuration file 'prisma-php.json' was not found in the current directory."));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.error("Error in script execution:", error);
|
|
97
|
+
}
|
|
97
98
|
}
|
|
98
|
-
} else {
|
|
99
|
-
console.error("Error in script execution:", error);
|
|
100
|
-
}
|
|
101
99
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
else if (args[0] === "generate" && args[1] === "class") {
|
|
101
|
+
const executeGenerateCommand = async () => {
|
|
102
|
+
try {
|
|
103
|
+
const currentDir = process.cwd();
|
|
104
|
+
const prismaClientPath = path.join(currentDir, "prisma-client-php", "index.js");
|
|
105
|
+
if (!fs.existsSync(prismaClientPath)) {
|
|
106
|
+
console.error(chalk.red("The prisma-client-php/index.js file was not found in the current directory."));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
console.log("Executing command...\n");
|
|
110
|
+
await executeCommand("node", [prismaClientPath]);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error("Error in script execution:", error);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
// Call the executeGenerateCommand function
|
|
117
|
+
await executeGenerateCommand();
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
console.log("Command not recognized.");
|
|
121
|
+
}
|
|
105
122
|
};
|
|
106
123
|
main().catch((error) => {
|
|
107
|
-
|
|
124
|
+
console.error("Unhandled error in main function:", error);
|
|
108
125
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-prisma-php-app",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.63",
|
|
4
4
|
"description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"bin": {
|
|
13
13
|
"create-prisma-php-app": "dist/index.js",
|
|
14
|
-
"
|
|
15
|
-
"prisma-php": "dist/prisma-php.js"
|
|
14
|
+
"pphp": "dist/prisma-php.js"
|
|
16
15
|
},
|
|
17
16
|
"repository": {
|
|
18
17
|
"type": "git",
|