prisma-client-php 0.0.4 → 0.0.6

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,16 @@ 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
+ // **Normalize Path to Avoid Issues on Windows**
26
+ const relativePath = path.relative(__dirname, srcPath);
27
+ const validatorFile = path.normalize("src/Lib/Validator.php");
28
+ // **Skip Validator.php when isPrismaPHP is true**
29
+ if (isPrismaPHP && relativePath === validatorFile) {
30
+ console.log(`Skipping file: ${srcPath}`);
31
+ continue;
32
+ }
25
33
  if (entry.isDirectory()) {
26
- copyRecursiveSync(srcPath, destPath, base);
34
+ copyRecursiveSync(srcPath, destPath, base, isPrismaPHP);
27
35
  } else {
28
36
  // Compute the relative path for logging
29
37
  const relative = path.relative(base, srcPath);
@@ -52,12 +60,15 @@ const directoriesToCopy = [
52
60
  /**
53
61
  * Installs specified packages using npm in the current working directory.
54
62
  */
55
- function installPackages() {
63
+ function installPackages(isPrismaPHP) {
56
64
  const packages = [
57
65
  "prisma@^6.4.1",
58
66
  "@prisma/client@^6.4.1",
59
67
  "@prisma/internals@^6.4.1",
60
68
  ];
69
+ if (!isPrismaPHP) {
70
+ packages.push("tsx@^4.19.3", "typescript@^5.8.2", "@types/node@^22.13.8");
71
+ }
61
72
  const packagesStr = packages.join(" ");
62
73
  try {
63
74
  console.log(`Installing packages: ${packagesStr}`);
@@ -65,6 +76,12 @@ function installPackages() {
65
76
  stdio: "inherit",
66
77
  cwd: process.cwd(),
67
78
  });
79
+ if (!isPrismaPHP) {
80
+ execSync("npx tsc --init", {
81
+ stdio: "inherit",
82
+ cwd: process.cwd(),
83
+ });
84
+ }
68
85
  console.log("Packages installed successfully.");
69
86
  } catch (error) {
70
87
  console.error("Error installing packages:", error);
@@ -112,20 +129,25 @@ async function updateComposerJson(baseDir) {
112
129
  console.log("composer.json updated successfully.");
113
130
  }
114
131
  /**
115
- * Installs the Composer package "calicastle/cuid": "^2.0.0" using the require command.
132
+ * Installs the specified Composer packages using the require command.
116
133
  */
117
- function runComposerInstall() {
134
+ function runComposerInstall(packages) {
135
+ if (packages.length === 0) {
136
+ console.warn("No Composer packages specified for installation.");
137
+ return;
138
+ }
139
+ const packageList = packages.join(" ");
118
140
  try {
119
- console.log("Installing Composer package calicastle/cuid...");
141
+ console.log(`Installing Composer packages: ${packageList}...`);
120
142
  execSync(
121
- `C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar require calicastle/cuid:^2.0.0`,
143
+ `C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar require ${packageList}`,
122
144
  {
123
145
  stdio: "inherit",
124
146
  }
125
147
  );
126
- console.log("Composer package calicastle/cuid installed successfully.");
148
+ console.log("Composer packages installed successfully.");
127
149
  } catch (error) {
128
- console.error("Error installing Composer package calicastle/cuid:", error);
150
+ console.error("Error installing Composer packages:", error);
129
151
  }
130
152
  }
131
153
  /**
@@ -138,17 +160,24 @@ function runComposerInstall() {
138
160
  async function main() {
139
161
  const isPrismaPHP = process.argv.includes("--prisma-php");
140
162
  if (isPrismaPHP) {
141
- // Always update composer.json
142
163
  await updateComposerJson(process.cwd());
143
164
  } else {
144
- // Install the Composer package "calicastle/cuid": "^2.0.0"
145
- runComposerInstall();
165
+ runComposerInstall([
166
+ "ezyang/htmlpurifier:^4.18.0",
167
+ "calicastle/cuid:^2.0.0",
168
+ "symfony/uid:^7.2.0",
169
+ "brick/math:^0.12.1",
170
+ ]);
146
171
  }
147
- installPackages();
172
+ installPackages(isPrismaPHP);
148
173
  initPrisma();
149
174
  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);
175
+ copyRecursiveSync(
176
+ config.srcFolder,
177
+ config.destFolder,
178
+ config.srcFolder,
179
+ isPrismaPHP
180
+ );
152
181
  });
153
182
  console.log("Finished copying directories.");
154
183
  }
@@ -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);