prisma-client-php 0.0.4 → 0.0.5

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/init.js CHANGED
@@ -10,7 +10,7 @@ const { __dirname } = getFileMeta();
10
10
  * The `base` parameter represents the original root of the copy.
11
11
  * It is used for computing a relative path for cleaner logging.
12
12
  */
13
- function copyRecursiveSync(src, dest, base = src) {
13
+ function copyRecursiveSync(src, dest, base = src, isPrismaPHP = false) {
14
14
  if (!fs.existsSync(src)) {
15
15
  console.error(`Source folder does not exist: ${src}`);
16
16
  return;
@@ -22,8 +22,13 @@ function copyRecursiveSync(src, dest, base = src) {
22
22
  for (const entry of entries) {
23
23
  const srcPath = path.join(src, entry.name);
24
24
  const destPath = path.join(dest, entry.name);
25
+ // **Skip Validator.php when isPrismaPHP is true**
26
+ if (isPrismaPHP && srcPath.endsWith("src/Lib/Validator.php")) {
27
+ console.log(`Skipping file: ${srcPath}`);
28
+ continue;
29
+ }
25
30
  if (entry.isDirectory()) {
26
- copyRecursiveSync(srcPath, destPath, base);
31
+ copyRecursiveSync(srcPath, destPath, base, isPrismaPHP);
27
32
  } else {
28
33
  // Compute the relative path for logging
29
34
  const relative = path.relative(base, srcPath);
@@ -52,12 +57,15 @@ const directoriesToCopy = [
52
57
  /**
53
58
  * Installs specified packages using npm in the current working directory.
54
59
  */
55
- function installPackages() {
60
+ function installPackages(isPrismaPHP) {
56
61
  const packages = [
57
62
  "prisma@^6.4.1",
58
63
  "@prisma/client@^6.4.1",
59
64
  "@prisma/internals@^6.4.1",
60
65
  ];
66
+ if (!isPrismaPHP) {
67
+ packages.push("tsx@^4.19.3", "typescript@^5.8.2", "@types/node@^22.13.8");
68
+ }
61
69
  const packagesStr = packages.join(" ");
62
70
  try {
63
71
  console.log(`Installing packages: ${packagesStr}`);
@@ -65,6 +73,12 @@ function installPackages() {
65
73
  stdio: "inherit",
66
74
  cwd: process.cwd(),
67
75
  });
76
+ if (!isPrismaPHP) {
77
+ execSync("npx tsc --init", {
78
+ stdio: "inherit",
79
+ cwd: process.cwd(),
80
+ });
81
+ }
68
82
  console.log("Packages installed successfully.");
69
83
  } catch (error) {
70
84
  console.error("Error installing packages:", error);
@@ -112,20 +126,25 @@ async function updateComposerJson(baseDir) {
112
126
  console.log("composer.json updated successfully.");
113
127
  }
114
128
  /**
115
- * Installs the Composer package "calicastle/cuid": "^2.0.0" using the require command.
129
+ * Installs the specified Composer packages using the require command.
116
130
  */
117
- function runComposerInstall() {
131
+ function runComposerInstall(packages) {
132
+ if (packages.length === 0) {
133
+ console.warn("No Composer packages specified for installation.");
134
+ return;
135
+ }
136
+ const packageList = packages.join(" ");
118
137
  try {
119
- console.log("Installing Composer package calicastle/cuid...");
138
+ console.log(`Installing Composer packages: ${packageList}...`);
120
139
  execSync(
121
- `C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar require calicastle/cuid:^2.0.0`,
140
+ `C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar require ${packageList}`,
122
141
  {
123
142
  stdio: "inherit",
124
143
  }
125
144
  );
126
- console.log("Composer package calicastle/cuid installed successfully.");
145
+ console.log("Composer packages installed successfully.");
127
146
  } catch (error) {
128
- console.error("Error installing Composer package calicastle/cuid:", error);
147
+ console.error("Error installing Composer packages:", error);
129
148
  }
130
149
  }
131
150
  /**
@@ -138,17 +157,24 @@ function runComposerInstall() {
138
157
  async function main() {
139
158
  const isPrismaPHP = process.argv.includes("--prisma-php");
140
159
  if (isPrismaPHP) {
141
- // Always update composer.json
142
160
  await updateComposerJson(process.cwd());
143
161
  } else {
144
- // Install the Composer package "calicastle/cuid": "^2.0.0"
145
- runComposerInstall();
162
+ runComposerInstall([
163
+ "ezyang/htmlpurifier:^4.18.0",
164
+ "calicastle/cuid:^2.0.0",
165
+ "symfony/uid:^7.2.0",
166
+ "brick/math:^0.12.1",
167
+ ]);
146
168
  }
147
- installPackages();
169
+ installPackages(isPrismaPHP);
148
170
  initPrisma();
149
171
  directoriesToCopy.forEach((config) => {
150
- // Pass the srcFolder as the base for computing relative paths in the log
151
- copyRecursiveSync(config.srcFolder, config.destFolder, config.srcFolder);
172
+ copyRecursiveSync(
173
+ config.srcFolder,
174
+ config.destFolder,
175
+ config.srcFolder,
176
+ isPrismaPHP
177
+ );
152
178
  });
153
179
  console.log("Finished copying directories.");
154
180
  }
@@ -9,10 +9,10 @@ interface IModel
9
9
  // public function createManyAndReturn(array $data);
10
10
  public function create(array $data);
11
11
  // public function deleteMany(array $criteria);
12
- // public function delete(array $criteria);
13
- // public function findFirst(array $criteria);
12
+ public function delete(array $criteria);
13
+ public function findFirst(array $criteria);
14
14
  // public function findFirstOrThrow(array $criteria);
15
- // public function findMany(array $criteria);
15
+ public function findMany(array $criteria);
16
16
  public function findUnique(array $criteria);
17
17
  // public function findUniqueOrThrow(array $criteria);
18
18
  // public function groupBy(array $by);