create-prisma-php-app 4.0.0-alpha.41 → 4.0.0-alpha.46
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 +35 -291
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -411,7 +411,7 @@ async function createOrUpdateEnvFile(baseDir, content) {
|
|
|
411
411
|
fs.writeFileSync(envPath, content, { flag: "w" });
|
|
412
412
|
}
|
|
413
413
|
function checkExcludeFiles(destPath) {
|
|
414
|
-
if (!updateAnswer) return false;
|
|
414
|
+
if (!updateAnswer?.isUpdate) return false;
|
|
415
415
|
return (
|
|
416
416
|
updateAnswer?.excludeFilePath?.includes(destPath.replace(/\\/g, "/")) ??
|
|
417
417
|
false
|
|
@@ -1061,8 +1061,8 @@ async function downloadStarterKit(starterKit, tempDir) {
|
|
|
1061
1061
|
}
|
|
1062
1062
|
async function mergeStarterKitFiles(starterKitPath, projectPath, answer) {
|
|
1063
1063
|
console.log(chalk.blue("Merging starter kit files..."));
|
|
1064
|
-
//
|
|
1065
|
-
|
|
1064
|
+
// Copy all files from starter kit, but don't overwrite base files
|
|
1065
|
+
copyRecursiveSync(starterKitPath, projectPath, answer);
|
|
1066
1066
|
// Look for starter kit specific configuration
|
|
1067
1067
|
const starterKitConfig = path.join(starterKitPath, "starter-kit.json");
|
|
1068
1068
|
if (fs.existsSync(starterKitConfig)) {
|
|
@@ -1183,168 +1183,6 @@ function showStarterKits() {
|
|
|
1183
1183
|
);
|
|
1184
1184
|
console.log();
|
|
1185
1185
|
}
|
|
1186
|
-
// Starter kit specific copy function that respects exclusions
|
|
1187
|
-
function copyRecursiveSyncWithExclusions(
|
|
1188
|
-
src,
|
|
1189
|
-
dest,
|
|
1190
|
-
answer,
|
|
1191
|
-
respectExclusions = true
|
|
1192
|
-
) {
|
|
1193
|
-
const exists = fs.existsSync(src);
|
|
1194
|
-
const stats = exists && fs.statSync(src);
|
|
1195
|
-
const isDirectory = exists && stats && stats.isDirectory();
|
|
1196
|
-
if (isDirectory) {
|
|
1197
|
-
const destLower = dest.toLowerCase();
|
|
1198
|
-
// Apply feature-based exclusions
|
|
1199
|
-
if (!answer.websocket && destLower.includes("websocket")) return;
|
|
1200
|
-
if (!answer.mcp && destLower.includes("mcp")) return;
|
|
1201
|
-
if (!answer.swaggerDocs && destLower.includes("swagger-docs")) return;
|
|
1202
|
-
if (
|
|
1203
|
-
answer.backendOnly &&
|
|
1204
|
-
(destLower.includes("js") ||
|
|
1205
|
-
destLower.includes("css") ||
|
|
1206
|
-
destLower.includes("assets"))
|
|
1207
|
-
)
|
|
1208
|
-
return;
|
|
1209
|
-
// Apply user-defined exclusions
|
|
1210
|
-
const destModified = dest.replace(/\\/g, "/");
|
|
1211
|
-
if (
|
|
1212
|
-
respectExclusions &&
|
|
1213
|
-
updateAnswer?.excludeFilePath?.includes(destModified)
|
|
1214
|
-
) {
|
|
1215
|
-
console.log(chalk.yellow(`Skipping excluded directory: ${destModified}`));
|
|
1216
|
-
return;
|
|
1217
|
-
}
|
|
1218
|
-
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
|
1219
|
-
fs.readdirSync(src).forEach((childItemName) => {
|
|
1220
|
-
copyRecursiveSyncWithExclusions(
|
|
1221
|
-
path.join(src, childItemName),
|
|
1222
|
-
path.join(dest, childItemName),
|
|
1223
|
-
answer,
|
|
1224
|
-
respectExclusions
|
|
1225
|
-
);
|
|
1226
|
-
});
|
|
1227
|
-
} else {
|
|
1228
|
-
const fileName = path.basename(dest);
|
|
1229
|
-
// Always exclude critical config files from starter kit overwrites
|
|
1230
|
-
if (fileName === "prisma-php.json") {
|
|
1231
|
-
console.log(
|
|
1232
|
-
chalk.yellow(`Protecting config file: ${dest.replace(/\\/g, "/")}`)
|
|
1233
|
-
);
|
|
1234
|
-
return;
|
|
1235
|
-
}
|
|
1236
|
-
// Apply user-defined exclusions for files
|
|
1237
|
-
if (respectExclusions && checkExcludeFiles(dest)) {
|
|
1238
|
-
console.log(
|
|
1239
|
-
chalk.yellow(`Skipping excluded file: ${dest.replace(/\\/g, "/")}`)
|
|
1240
|
-
);
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
|
-
// Apply feature-based exclusions
|
|
1244
|
-
if (
|
|
1245
|
-
!answer.tailwindcss &&
|
|
1246
|
-
(dest.includes("tailwind.css") || dest.includes("styles.css"))
|
|
1247
|
-
)
|
|
1248
|
-
return;
|
|
1249
|
-
if (!answer.websocket && dest.includes("restart-websocket.ts")) return;
|
|
1250
|
-
if (!answer.mcp && dest.includes("restart-mcp.ts")) return;
|
|
1251
|
-
if (!answer.docker && dockerFiles.some((file) => dest.includes(file)))
|
|
1252
|
-
return;
|
|
1253
|
-
if (
|
|
1254
|
-
answer.backendOnly &&
|
|
1255
|
-
nonBackendFiles.some((file) => dest.includes(file))
|
|
1256
|
-
)
|
|
1257
|
-
return;
|
|
1258
|
-
if (!answer.backendOnly && dest.includes("route.php")) return;
|
|
1259
|
-
if (
|
|
1260
|
-
answer.backendOnly &&
|
|
1261
|
-
!answer.swaggerDocs &&
|
|
1262
|
-
dest.includes("layout.php")
|
|
1263
|
-
)
|
|
1264
|
-
return;
|
|
1265
|
-
if (!answer.swaggerDocs && dest.includes("swagger-config.ts")) return;
|
|
1266
|
-
if (answer.tailwindcss && dest.includes("index.css")) return;
|
|
1267
|
-
fs.copyFileSync(src, dest, 0);
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
function mergeConfigurationFiles(
|
|
1271
|
-
projectPath,
|
|
1272
|
-
answer,
|
|
1273
|
-
latestVersion,
|
|
1274
|
-
existingConfig
|
|
1275
|
-
) {
|
|
1276
|
-
const projectPathModified = projectPath.replace(/\\/g, "\\");
|
|
1277
|
-
const bsConfig = bsConfigUrls(projectPathModified);
|
|
1278
|
-
// If we have existing config, merge with it
|
|
1279
|
-
if (existingConfig) {
|
|
1280
|
-
console.log(chalk.blue("Merging with existing configuration..."));
|
|
1281
|
-
console.log(
|
|
1282
|
-
chalk.gray(
|
|
1283
|
-
`Preserving excludeFiles: ${JSON.stringify(
|
|
1284
|
-
existingConfig.excludeFiles || []
|
|
1285
|
-
)}`
|
|
1286
|
-
)
|
|
1287
|
-
);
|
|
1288
|
-
const mergedConfig = {
|
|
1289
|
-
...existingConfig, // Start with existing config to preserve all existing fields
|
|
1290
|
-
// Only update specific fields that should be updated for starter kits
|
|
1291
|
-
projectName: answer.projectName,
|
|
1292
|
-
projectRootPath: projectPathModified,
|
|
1293
|
-
bsTarget: bsConfig.bsTarget,
|
|
1294
|
-
bsPathRewrite: bsConfig.bsPathRewrite,
|
|
1295
|
-
version: latestVersion,
|
|
1296
|
-
// Update feature flags based on starter kit
|
|
1297
|
-
backendOnly: answer.backendOnly,
|
|
1298
|
-
swaggerDocs: answer.swaggerDocs,
|
|
1299
|
-
tailwindcss: answer.tailwindcss,
|
|
1300
|
-
websocket: answer.websocket,
|
|
1301
|
-
mcp: answer.mcp,
|
|
1302
|
-
prisma: answer.prisma,
|
|
1303
|
-
docker: answer.docker,
|
|
1304
|
-
// CRITICAL: Always preserve existing excludeFiles
|
|
1305
|
-
excludeFiles: existingConfig.excludeFiles || [],
|
|
1306
|
-
};
|
|
1307
|
-
fs.writeFileSync(
|
|
1308
|
-
path.join(projectPath, "prisma-php.json"),
|
|
1309
|
-
JSON.stringify(mergedConfig, null, 2),
|
|
1310
|
-
{ flag: "w" }
|
|
1311
|
-
);
|
|
1312
|
-
console.log(chalk.green("✓ Configuration merged successfully!"));
|
|
1313
|
-
console.log(
|
|
1314
|
-
chalk.green(
|
|
1315
|
-
`✓ Preserved ${
|
|
1316
|
-
(existingConfig.excludeFiles || []).length
|
|
1317
|
-
} excluded files`
|
|
1318
|
-
)
|
|
1319
|
-
);
|
|
1320
|
-
} else {
|
|
1321
|
-
console.log(chalk.blue("Creating new configuration..."));
|
|
1322
|
-
// New project - create fresh config
|
|
1323
|
-
const prismaPhpConfig = {
|
|
1324
|
-
projectName: answer.projectName,
|
|
1325
|
-
projectRootPath: projectPathModified,
|
|
1326
|
-
phpEnvironment: "XAMPP",
|
|
1327
|
-
phpRootPathExe: "C:\\xampp\\php\\php.exe",
|
|
1328
|
-
bsTarget: bsConfig.bsTarget,
|
|
1329
|
-
bsPathRewrite: bsConfig.bsPathRewrite,
|
|
1330
|
-
backendOnly: answer.backendOnly,
|
|
1331
|
-
swaggerDocs: answer.swaggerDocs,
|
|
1332
|
-
tailwindcss: answer.tailwindcss,
|
|
1333
|
-
websocket: answer.websocket,
|
|
1334
|
-
mcp: answer.mcp,
|
|
1335
|
-
prisma: answer.prisma,
|
|
1336
|
-
docker: answer.docker,
|
|
1337
|
-
version: latestVersion,
|
|
1338
|
-
excludeFiles: [],
|
|
1339
|
-
};
|
|
1340
|
-
fs.writeFileSync(
|
|
1341
|
-
path.join(projectPath, "prisma-php.json"),
|
|
1342
|
-
JSON.stringify(prismaPhpConfig, null, 2),
|
|
1343
|
-
{ flag: "w" }
|
|
1344
|
-
);
|
|
1345
|
-
console.log(chalk.green("✓ New configuration created"));
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
1186
|
async function main() {
|
|
1349
1187
|
try {
|
|
1350
1188
|
const args = process.argv.slice(2);
|
|
@@ -1366,31 +1204,16 @@ async function main() {
|
|
|
1366
1204
|
if (projectName) {
|
|
1367
1205
|
const currentDir = process.cwd();
|
|
1368
1206
|
const configPath = path.join(currentDir, "prisma-php.json");
|
|
1369
|
-
const projectNamePath = path.join(currentDir, projectName);
|
|
1370
|
-
const projectNameConfigPath = path.join(
|
|
1371
|
-
projectNamePath,
|
|
1372
|
-
"prisma-php.json"
|
|
1373
|
-
);
|
|
1374
|
-
// Check if there's an existing config in current directory or project directory
|
|
1375
|
-
let existingConfigPath = null;
|
|
1376
1207
|
if (fs.existsSync(configPath)) {
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
existingConfigPath = projectNameConfigPath;
|
|
1380
|
-
}
|
|
1381
|
-
// If we found an existing config and we're using a starter kit, load exclusions
|
|
1382
|
-
if (existingConfigPath && (starterKitFromArgs || starterKitSource)) {
|
|
1383
|
-
const localSettings = readJsonFile(existingConfigPath);
|
|
1208
|
+
// It's an update - read existing settings
|
|
1209
|
+
const localSettings = readJsonFile(configPath);
|
|
1384
1210
|
let excludeFiles = [];
|
|
1385
1211
|
localSettings.excludeFiles?.map((file) => {
|
|
1386
|
-
const filePath = path.join(
|
|
1387
|
-
existingConfigPath === configPath ? currentDir : projectNamePath,
|
|
1388
|
-
file
|
|
1389
|
-
);
|
|
1212
|
+
const filePath = path.join(currentDir, file);
|
|
1390
1213
|
if (fs.existsSync(filePath))
|
|
1391
1214
|
excludeFiles.push(filePath.replace(/\\/g, "/"));
|
|
1392
1215
|
});
|
|
1393
|
-
// Set updateAnswer
|
|
1216
|
+
// Set updateAnswer with OLD settings initially (for checkExcludeFiles function)
|
|
1394
1217
|
updateAnswer = {
|
|
1395
1218
|
projectName,
|
|
1396
1219
|
backendOnly: localSettings.backendOnly,
|
|
@@ -1400,11 +1223,10 @@ async function main() {
|
|
|
1400
1223
|
mcp: localSettings.mcp,
|
|
1401
1224
|
prisma: localSettings.prisma,
|
|
1402
1225
|
docker: localSettings.docker,
|
|
1403
|
-
isUpdate:
|
|
1226
|
+
isUpdate: true,
|
|
1404
1227
|
excludeFiles: localSettings.excludeFiles ?? [],
|
|
1405
1228
|
excludeFilePath: excludeFiles ?? [],
|
|
1406
|
-
filePath:
|
|
1407
|
-
existingConfigPath === configPath ? currentDir : projectNamePath,
|
|
1229
|
+
filePath: currentDir,
|
|
1408
1230
|
};
|
|
1409
1231
|
// For updates, use existing settings but allow CLI overrides
|
|
1410
1232
|
const predefinedAnswers = {
|
|
@@ -1524,10 +1346,6 @@ async function main() {
|
|
|
1524
1346
|
projectPath = path.join(currentDir, answer.projectName);
|
|
1525
1347
|
process.chdir(answer.projectName);
|
|
1526
1348
|
}
|
|
1527
|
-
// Add starter kit setup before npm/composer installation
|
|
1528
|
-
if (answer.starterKit) {
|
|
1529
|
-
await setupStarterKit(projectPath, answer);
|
|
1530
|
-
}
|
|
1531
1349
|
let npmDependencies = [
|
|
1532
1350
|
npmPkg("typescript"),
|
|
1533
1351
|
npmPkg("@types/node"),
|
|
@@ -1576,6 +1394,10 @@ async function main() {
|
|
|
1576
1394
|
if (answer.prisma) {
|
|
1577
1395
|
execSync("npm install -g prisma-client-php", { stdio: "inherit" });
|
|
1578
1396
|
}
|
|
1397
|
+
// Add starter kit setup before npm/composer installation
|
|
1398
|
+
if (answer.starterKit) {
|
|
1399
|
+
await setupStarterKit(projectPath, answer);
|
|
1400
|
+
}
|
|
1579
1401
|
await installNpmDependencies(projectPath, npmDependencies, true);
|
|
1580
1402
|
await installComposerDependencies(projectPath, composerDependencies);
|
|
1581
1403
|
if (!projectName) {
|
|
@@ -1809,107 +1631,29 @@ async function main() {
|
|
|
1809
1631
|
await uninstallComposerDependencies(projectPath, composerToUninstall);
|
|
1810
1632
|
}
|
|
1811
1633
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
chalk.blue(
|
|
1831
|
-
`Found configuration with exclusions in: ${entry.name}/`
|
|
1832
|
-
)
|
|
1833
|
-
);
|
|
1834
|
-
console.log(
|
|
1835
|
-
chalk.gray(
|
|
1836
|
-
`Found excludeFiles: ${JSON.stringify(config.excludeFiles)}`
|
|
1837
|
-
)
|
|
1838
|
-
);
|
|
1839
|
-
return config;
|
|
1840
|
-
}
|
|
1841
|
-
} catch (error) {
|
|
1842
|
-
console.warn(
|
|
1843
|
-
chalk.yellow(`Could not read config in ${entry.name}/`)
|
|
1844
|
-
);
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
return null;
|
|
1634
|
+
const projectPathModified = projectPath.replace(/\\/g, "\\");
|
|
1635
|
+
const bsConfig = bsConfigUrls(projectPathModified);
|
|
1636
|
+
const prismaPhpConfig = {
|
|
1637
|
+
projectName: answer.projectName,
|
|
1638
|
+
projectRootPath: projectPathModified,
|
|
1639
|
+
phpEnvironment: "XAMPP",
|
|
1640
|
+
phpRootPathExe: "C:\\xampp\\php\\php.exe",
|
|
1641
|
+
bsTarget: bsConfig.bsTarget,
|
|
1642
|
+
bsPathRewrite: bsConfig.bsPathRewrite,
|
|
1643
|
+
backendOnly: answer.backendOnly,
|
|
1644
|
+
swaggerDocs: answer.swaggerDocs,
|
|
1645
|
+
tailwindcss: answer.tailwindcss,
|
|
1646
|
+
websocket: answer.websocket,
|
|
1647
|
+
mcp: answer.mcp,
|
|
1648
|
+
prisma: answer.prisma,
|
|
1649
|
+
docker: answer.docker,
|
|
1650
|
+
version: latestVersionOfCreatePrismaPhpApp,
|
|
1651
|
+
excludeFiles: updateAnswer?.excludeFiles ?? [],
|
|
1850
1652
|
};
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
currentDirConfigPath !== finalProjectConfigPath
|
|
1856
|
-
) {
|
|
1857
|
-
try {
|
|
1858
|
-
const rawConfig = fs.readFileSync(currentDirConfigPath, "utf8");
|
|
1859
|
-
existingConfig = JSON.parse(rawConfig);
|
|
1860
|
-
console.log(
|
|
1861
|
-
chalk.blue("Found existing configuration in current directory")
|
|
1862
|
-
);
|
|
1863
|
-
console.log(
|
|
1864
|
-
chalk.gray(
|
|
1865
|
-
`Current dir excludeFiles: ${JSON.stringify(
|
|
1866
|
-
existingConfig.excludeFiles || []
|
|
1867
|
-
)}`
|
|
1868
|
-
)
|
|
1869
|
-
);
|
|
1870
|
-
} catch (error) {
|
|
1871
|
-
console.warn(chalk.yellow("Could not read current directory config"));
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
// If no config in current directory, search subdirectories for configs with excludeFiles
|
|
1875
|
-
if (!existingConfig) {
|
|
1876
|
-
console.log(
|
|
1877
|
-
chalk.blue("Searching for existing configurations with exclusions...")
|
|
1878
|
-
);
|
|
1879
|
-
existingConfig = findConfigWithExclusions(currentDir);
|
|
1880
|
-
}
|
|
1881
|
-
// If still no config, check the target project directory
|
|
1882
|
-
if (!existingConfig && fs.existsSync(finalProjectConfigPath)) {
|
|
1883
|
-
try {
|
|
1884
|
-
const rawConfig = fs.readFileSync(finalProjectConfigPath, "utf8");
|
|
1885
|
-
existingConfig = JSON.parse(rawConfig);
|
|
1886
|
-
console.log(
|
|
1887
|
-
chalk.blue("Found existing configuration in project directory")
|
|
1888
|
-
);
|
|
1889
|
-
console.log(
|
|
1890
|
-
chalk.gray(
|
|
1891
|
-
`Project excludeFiles: ${JSON.stringify(
|
|
1892
|
-
existingConfig.excludeFiles || []
|
|
1893
|
-
)}`
|
|
1894
|
-
)
|
|
1895
|
-
);
|
|
1896
|
-
} catch (error) {
|
|
1897
|
-
console.warn(chalk.yellow("Could not read project config"));
|
|
1898
|
-
existingConfig = null;
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
// If still no existing config found
|
|
1902
|
-
if (!existingConfig) {
|
|
1903
|
-
console.log(
|
|
1904
|
-
chalk.blue("No existing configuration found, creating new one...")
|
|
1905
|
-
);
|
|
1906
|
-
}
|
|
1907
|
-
// Merge or create configuration
|
|
1908
|
-
mergeConfigurationFiles(
|
|
1909
|
-
projectPath,
|
|
1910
|
-
answer,
|
|
1911
|
-
latestVersionOfCreatePrismaPhpApp,
|
|
1912
|
-
existingConfig
|
|
1653
|
+
fs.writeFileSync(
|
|
1654
|
+
path.join(projectPath, "prisma-php.json"),
|
|
1655
|
+
JSON.stringify(prismaPhpConfig, null, 2),
|
|
1656
|
+
{ flag: "w" }
|
|
1913
1657
|
);
|
|
1914
1658
|
if (updateAnswer?.isUpdate) {
|
|
1915
1659
|
execSync(
|