create-prisma-php-app 4.0.0-alpha.46 → 4.0.0-alpha.48
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 +166 -139
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1023,74 +1023,6 @@ function composerPkg(name) {
|
|
|
1023
1023
|
? `${name}:${composerPinnedVersions[name]}`
|
|
1024
1024
|
: name;
|
|
1025
1025
|
}
|
|
1026
|
-
async function downloadStarterKit(starterKit, tempDir) {
|
|
1027
|
-
if (!starterKit.source) {
|
|
1028
|
-
throw new Error("No source defined for starter kit");
|
|
1029
|
-
}
|
|
1030
|
-
const { type, url, branch = "main", subfolder } = starterKit.source;
|
|
1031
|
-
switch (type) {
|
|
1032
|
-
case "git":
|
|
1033
|
-
console.log(chalk.blue(`Cloning ${starterKit.name} from ${url}...`));
|
|
1034
|
-
const cloneCommand = branch
|
|
1035
|
-
? `git clone -b ${branch} --depth 1 ${url} ${tempDir}`
|
|
1036
|
-
: `git clone --depth 1 ${url} ${tempDir}`;
|
|
1037
|
-
execSync(cloneCommand, { stdio: "inherit" });
|
|
1038
|
-
// Remove .git directory
|
|
1039
|
-
const gitDir = path.join(tempDir, ".git");
|
|
1040
|
-
if (fs.existsSync(gitDir)) {
|
|
1041
|
-
fs.rmSync(gitDir, { recursive: true, force: true });
|
|
1042
|
-
}
|
|
1043
|
-
// Return the subfolder if specified
|
|
1044
|
-
return subfolder ? path.join(tempDir, subfolder) : tempDir;
|
|
1045
|
-
case "npm":
|
|
1046
|
-
console.log(chalk.blue(`Downloading ${starterKit.name} from npm...`));
|
|
1047
|
-
execSync(`npm pack ${url}`, { cwd: tempDir, stdio: "inherit" });
|
|
1048
|
-
// Extract the tarball
|
|
1049
|
-
const tarball = fs.readdirSync(tempDir).find((f) => f.endsWith(".tgz"));
|
|
1050
|
-
if (tarball) {
|
|
1051
|
-
execSync(`tar -xzf ${tarball}`, { cwd: tempDir });
|
|
1052
|
-
fs.unlinkSync(path.join(tempDir, tarball));
|
|
1053
|
-
return path.join(tempDir, "package");
|
|
1054
|
-
}
|
|
1055
|
-
throw new Error("Failed to extract npm package");
|
|
1056
|
-
case "url":
|
|
1057
|
-
throw new Error("URL download not implemented yet");
|
|
1058
|
-
default:
|
|
1059
|
-
throw new Error(`Unsupported source type: ${type}`);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
async function mergeStarterKitFiles(starterKitPath, projectPath, answer) {
|
|
1063
|
-
console.log(chalk.blue("Merging starter kit files..."));
|
|
1064
|
-
// Copy all files from starter kit, but don't overwrite base files
|
|
1065
|
-
copyRecursiveSync(starterKitPath, projectPath, answer);
|
|
1066
|
-
// Look for starter kit specific configuration
|
|
1067
|
-
const starterKitConfig = path.join(starterKitPath, "starter-kit.json");
|
|
1068
|
-
if (fs.existsSync(starterKitConfig)) {
|
|
1069
|
-
const config = JSON.parse(fs.readFileSync(starterKitConfig, "utf8"));
|
|
1070
|
-
// Handle post-install scripts
|
|
1071
|
-
if (config.postInstall) {
|
|
1072
|
-
console.log(chalk.blue("Running post-install scripts..."));
|
|
1073
|
-
for (const script of config.postInstall) {
|
|
1074
|
-
console.log(chalk.gray(`Running: ${script}`));
|
|
1075
|
-
execSync(script, { cwd: projectPath, stdio: "inherit" });
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
// Handle additional dependencies
|
|
1079
|
-
if (config.additionalNpmDependencies) {
|
|
1080
|
-
await installNpmDependencies(
|
|
1081
|
-
projectPath,
|
|
1082
|
-
config.additionalNpmDependencies.map(npmPkg),
|
|
1083
|
-
true
|
|
1084
|
-
);
|
|
1085
|
-
}
|
|
1086
|
-
if (config.additionalComposerDependencies) {
|
|
1087
|
-
await installComposerDependencies(
|
|
1088
|
-
projectPath,
|
|
1089
|
-
config.additionalComposerDependencies.map(composerPkg)
|
|
1090
|
-
);
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
1026
|
async function setupStarterKit(baseDir, answer) {
|
|
1095
1027
|
if (!answer.starterKit) return;
|
|
1096
1028
|
let starterKit = null;
|
|
@@ -1119,35 +1051,53 @@ async function setupStarterKit(baseDir, answer) {
|
|
|
1119
1051
|
return;
|
|
1120
1052
|
}
|
|
1121
1053
|
console.log(chalk.green(`Setting up ${starterKit.name}...`));
|
|
1122
|
-
// If it's a custom starter kit with source,
|
|
1054
|
+
// If it's a custom starter kit with source, clone it directly to the target directory
|
|
1123
1055
|
if (starterKit.source) {
|
|
1124
|
-
const tempDir = path.join(baseDir, ".temp-starter-kit");
|
|
1125
1056
|
try {
|
|
1126
|
-
//
|
|
1127
|
-
|
|
1128
|
-
|
|
1057
|
+
// Clone directly to the target directory
|
|
1058
|
+
const cloneCommand = starterKit.source.branch
|
|
1059
|
+
? `git clone -b ${starterKit.source.branch} --depth 1 ${starterKit.source.url} ${baseDir}`
|
|
1060
|
+
: `git clone --depth 1 ${starterKit.source.url} ${baseDir}`;
|
|
1061
|
+
execSync(cloneCommand, { stdio: "inherit" });
|
|
1062
|
+
// Remove .git directory
|
|
1063
|
+
const gitDir = path.join(baseDir, ".git");
|
|
1064
|
+
if (fs.existsSync(gitDir)) {
|
|
1065
|
+
fs.rmSync(gitDir, { recursive: true, force: true });
|
|
1129
1066
|
}
|
|
1130
|
-
|
|
1131
|
-
//
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1067
|
+
console.log(chalk.blue("Starter kit cloned successfully!"));
|
|
1068
|
+
// Update the project name in the existing prisma-php.json
|
|
1069
|
+
const configPath = path.join(baseDir, "prisma-php.json");
|
|
1070
|
+
if (fs.existsSync(configPath)) {
|
|
1071
|
+
try {
|
|
1072
|
+
const existingConfig = JSON.parse(
|
|
1073
|
+
fs.readFileSync(configPath, "utf8")
|
|
1074
|
+
);
|
|
1075
|
+
// Only update project-specific fields, preserve everything else
|
|
1076
|
+
const projectPathModified = baseDir.replace(/\\/g, "\\");
|
|
1077
|
+
const bsConfig = bsConfigUrls(projectPathModified);
|
|
1078
|
+
existingConfig.projectName = answer.projectName;
|
|
1079
|
+
existingConfig.projectRootPath = projectPathModified;
|
|
1080
|
+
existingConfig.bsTarget = bsConfig.bsTarget;
|
|
1081
|
+
existingConfig.bsPathRewrite = bsConfig.bsPathRewrite;
|
|
1082
|
+
// Update version to latest
|
|
1083
|
+
const latestVersion = await fetchPackageVersion(
|
|
1084
|
+
"create-prisma-php-app"
|
|
1085
|
+
);
|
|
1086
|
+
existingConfig.version = latestVersion;
|
|
1087
|
+
fs.writeFileSync(configPath, JSON.stringify(existingConfig, null, 2));
|
|
1088
|
+
console.log(
|
|
1089
|
+
chalk.green("Updated prisma-php.json with new project details")
|
|
1090
|
+
);
|
|
1091
|
+
} catch (error) {
|
|
1092
|
+
console.warn(
|
|
1093
|
+
chalk.yellow(
|
|
1094
|
+
"Failed to update prisma-php.json, will create new one"
|
|
1095
|
+
)
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1142
1098
|
}
|
|
1143
|
-
// Clean up temp directory
|
|
1144
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
1145
1099
|
} catch (error) {
|
|
1146
1100
|
console.error(chalk.red(`Failed to setup starter kit: ${error}`));
|
|
1147
|
-
// Clean up temp directory on error
|
|
1148
|
-
if (fs.existsSync(tempDir)) {
|
|
1149
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
1150
|
-
}
|
|
1151
1101
|
throw error;
|
|
1152
1102
|
}
|
|
1153
1103
|
}
|
|
@@ -1201,10 +1151,27 @@ async function main() {
|
|
|
1201
1151
|
return;
|
|
1202
1152
|
}
|
|
1203
1153
|
let answer = null;
|
|
1154
|
+
let isStarterKitProject = false;
|
|
1204
1155
|
if (projectName) {
|
|
1205
1156
|
const currentDir = process.cwd();
|
|
1206
1157
|
const configPath = path.join(currentDir, "prisma-php.json");
|
|
1207
|
-
if
|
|
1158
|
+
// Check if it's a starter kit project
|
|
1159
|
+
if (starterKitFromArgs && starterKitSource) {
|
|
1160
|
+
isStarterKitProject = true;
|
|
1161
|
+
const predefinedAnswers = {
|
|
1162
|
+
projectName,
|
|
1163
|
+
starterKit: starterKitFromArgs,
|
|
1164
|
+
starterKitSource: starterKitSource,
|
|
1165
|
+
backendOnly: args.includes("--backend-only"),
|
|
1166
|
+
swaggerDocs: args.includes("--swagger-docs"),
|
|
1167
|
+
tailwindcss: args.includes("--tailwindcss"),
|
|
1168
|
+
websocket: args.includes("--websocket"),
|
|
1169
|
+
mcp: args.includes("--mcp"),
|
|
1170
|
+
prisma: args.includes("--prisma"),
|
|
1171
|
+
docker: args.includes("--docker"),
|
|
1172
|
+
};
|
|
1173
|
+
answer = await getAnswer(predefinedAnswers);
|
|
1174
|
+
} else if (fs.existsSync(configPath)) {
|
|
1208
1175
|
// It's an update - read existing settings
|
|
1209
1176
|
const localSettings = readJsonFile(configPath);
|
|
1210
1177
|
let excludeFiles = [];
|
|
@@ -1315,33 +1282,86 @@ async function main() {
|
|
|
1315
1282
|
const currentDir = process.cwd();
|
|
1316
1283
|
let projectPath;
|
|
1317
1284
|
if (projectName) {
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
const projectNameConfigPath = path.join(
|
|
1322
|
-
projectNamePath,
|
|
1323
|
-
"prisma-php.json"
|
|
1324
|
-
);
|
|
1325
|
-
if (fs.existsSync(configPath)) {
|
|
1326
|
-
// We're updating an existing project in current directory
|
|
1327
|
-
projectPath = currentDir;
|
|
1328
|
-
} else if (
|
|
1329
|
-
fs.existsSync(projectNamePath) &&
|
|
1330
|
-
fs.existsSync(projectNameConfigPath)
|
|
1331
|
-
) {
|
|
1332
|
-
// We're updating an existing project in the named directory
|
|
1333
|
-
projectPath = projectNamePath;
|
|
1334
|
-
process.chdir(projectNamePath);
|
|
1335
|
-
} else {
|
|
1336
|
-
// We're creating a new project with the given name
|
|
1285
|
+
if (isStarterKitProject) {
|
|
1286
|
+
// For starter kit projects, create directory first
|
|
1287
|
+
const projectNamePath = path.join(currentDir, projectName);
|
|
1337
1288
|
if (!fs.existsSync(projectNamePath)) {
|
|
1338
1289
|
fs.mkdirSync(projectNamePath, { recursive: true });
|
|
1339
1290
|
}
|
|
1340
1291
|
projectPath = projectNamePath;
|
|
1341
|
-
|
|
1292
|
+
// Clone the starter kit first
|
|
1293
|
+
await setupStarterKit(projectPath, answer);
|
|
1294
|
+
// Change to project directory
|
|
1295
|
+
process.chdir(projectPath);
|
|
1296
|
+
// Now check if it has prisma-php.json and treat as update
|
|
1297
|
+
const configPath = path.join(projectPath, "prisma-php.json");
|
|
1298
|
+
if (fs.existsSync(configPath)) {
|
|
1299
|
+
// Read the existing config and merge with CLI overrides
|
|
1300
|
+
const existingConfig = JSON.parse(
|
|
1301
|
+
fs.readFileSync(configPath, "utf8")
|
|
1302
|
+
);
|
|
1303
|
+
// Override with CLI arguments if provided
|
|
1304
|
+
if (args.includes("--backend-only"))
|
|
1305
|
+
existingConfig.backendOnly = true;
|
|
1306
|
+
if (args.includes("--swagger-docs"))
|
|
1307
|
+
existingConfig.swaggerDocs = true;
|
|
1308
|
+
if (args.includes("--tailwindcss")) existingConfig.tailwindcss = true;
|
|
1309
|
+
if (args.includes("--websocket")) existingConfig.websocket = true;
|
|
1310
|
+
if (args.includes("--mcp")) existingConfig.mcp = true;
|
|
1311
|
+
if (args.includes("--prisma")) existingConfig.prisma = true;
|
|
1312
|
+
if (args.includes("--docker")) existingConfig.docker = true;
|
|
1313
|
+
// Update answer with existing config
|
|
1314
|
+
answer = {
|
|
1315
|
+
...answer,
|
|
1316
|
+
backendOnly: existingConfig.backendOnly,
|
|
1317
|
+
swaggerDocs: existingConfig.swaggerDocs,
|
|
1318
|
+
tailwindcss: existingConfig.tailwindcss,
|
|
1319
|
+
websocket: existingConfig.websocket,
|
|
1320
|
+
mcp: existingConfig.mcp,
|
|
1321
|
+
prisma: existingConfig.prisma,
|
|
1322
|
+
docker: existingConfig.docker,
|
|
1323
|
+
};
|
|
1324
|
+
// Set up as an update
|
|
1325
|
+
let excludeFiles = [];
|
|
1326
|
+
existingConfig.excludeFiles?.map((file) => {
|
|
1327
|
+
const filePath = path.join(projectPath, file);
|
|
1328
|
+
if (fs.existsSync(filePath))
|
|
1329
|
+
excludeFiles.push(filePath.replace(/\\/g, "/"));
|
|
1330
|
+
});
|
|
1331
|
+
updateAnswer = {
|
|
1332
|
+
...answer,
|
|
1333
|
+
isUpdate: true,
|
|
1334
|
+
excludeFiles: existingConfig.excludeFiles ?? [],
|
|
1335
|
+
excludeFilePath: excludeFiles ?? [],
|
|
1336
|
+
filePath: projectPath,
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
} else {
|
|
1340
|
+
// Regular project handling (existing logic)
|
|
1341
|
+
const configPath = path.join(currentDir, "prisma-php.json");
|
|
1342
|
+
const projectNamePath = path.join(currentDir, projectName);
|
|
1343
|
+
const projectNameConfigPath = path.join(
|
|
1344
|
+
projectNamePath,
|
|
1345
|
+
"prisma-php.json"
|
|
1346
|
+
);
|
|
1347
|
+
if (fs.existsSync(configPath)) {
|
|
1348
|
+
projectPath = currentDir;
|
|
1349
|
+
} else if (
|
|
1350
|
+
fs.existsSync(projectNamePath) &&
|
|
1351
|
+
fs.existsSync(projectNameConfigPath)
|
|
1352
|
+
) {
|
|
1353
|
+
projectPath = projectNamePath;
|
|
1354
|
+
process.chdir(projectNamePath);
|
|
1355
|
+
} else {
|
|
1356
|
+
if (!fs.existsSync(projectNamePath)) {
|
|
1357
|
+
fs.mkdirSync(projectNamePath, { recursive: true });
|
|
1358
|
+
}
|
|
1359
|
+
projectPath = projectNamePath;
|
|
1360
|
+
process.chdir(projectNamePath);
|
|
1361
|
+
}
|
|
1342
1362
|
}
|
|
1343
1363
|
} else {
|
|
1344
|
-
// Interactive mode
|
|
1364
|
+
// Interactive mode
|
|
1345
1365
|
fs.mkdirSync(answer.projectName, { recursive: true });
|
|
1346
1366
|
projectPath = path.join(currentDir, answer.projectName);
|
|
1347
1367
|
process.chdir(answer.projectName);
|
|
@@ -1394,8 +1414,8 @@ async function main() {
|
|
|
1394
1414
|
if (answer.prisma) {
|
|
1395
1415
|
execSync("npm install -g prisma-client-php", { stdio: "inherit" });
|
|
1396
1416
|
}
|
|
1397
|
-
//
|
|
1398
|
-
if (answer.starterKit) {
|
|
1417
|
+
// Only setup starter kit if it's not already done
|
|
1418
|
+
if (answer.starterKit && !isStarterKitProject) {
|
|
1399
1419
|
await setupStarterKit(projectPath, answer);
|
|
1400
1420
|
}
|
|
1401
1421
|
await installNpmDependencies(projectPath, npmDependencies, true);
|
|
@@ -1631,30 +1651,37 @@ async function main() {
|
|
|
1631
1651
|
await uninstallComposerDependencies(projectPath, composerToUninstall);
|
|
1632
1652
|
}
|
|
1633
1653
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1654
|
+
// Skip creating prismaPhpConfig if it's a starter kit project that already has one
|
|
1655
|
+
if (
|
|
1656
|
+
!isStarterKitProject ||
|
|
1657
|
+
!fs.existsSync(path.join(projectPath, "prisma-php.json"))
|
|
1658
|
+
) {
|
|
1659
|
+
// Create prisma-php.json with all the existing logic
|
|
1660
|
+
const projectPathModified = projectPath.replace(/\\/g, "\\");
|
|
1661
|
+
const bsConfig = bsConfigUrls(projectPathModified);
|
|
1662
|
+
const prismaPhpConfig = {
|
|
1663
|
+
projectName: answer.projectName,
|
|
1664
|
+
projectRootPath: projectPathModified,
|
|
1665
|
+
phpEnvironment: "XAMPP",
|
|
1666
|
+
phpRootPathExe: "C:\\xampp\\php\\php.exe",
|
|
1667
|
+
bsTarget: bsConfig.bsTarget,
|
|
1668
|
+
bsPathRewrite: bsConfig.bsPathRewrite,
|
|
1669
|
+
backendOnly: answer.backendOnly,
|
|
1670
|
+
swaggerDocs: answer.swaggerDocs,
|
|
1671
|
+
tailwindcss: answer.tailwindcss,
|
|
1672
|
+
websocket: answer.websocket,
|
|
1673
|
+
mcp: answer.mcp,
|
|
1674
|
+
prisma: answer.prisma,
|
|
1675
|
+
docker: answer.docker,
|
|
1676
|
+
version: latestVersionOfCreatePrismaPhpApp,
|
|
1677
|
+
excludeFiles: updateAnswer?.excludeFiles ?? [],
|
|
1678
|
+
};
|
|
1679
|
+
fs.writeFileSync(
|
|
1680
|
+
path.join(projectPath, "prisma-php.json"),
|
|
1681
|
+
JSON.stringify(prismaPhpConfig, null, 2),
|
|
1682
|
+
{ flag: "w" }
|
|
1683
|
+
);
|
|
1684
|
+
}
|
|
1658
1685
|
if (updateAnswer?.isUpdate) {
|
|
1659
1686
|
execSync(
|
|
1660
1687
|
"C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar update",
|