Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function createProject(
await cloneRepository(selectedTemplate, targetDir);
spinner.succeed("Template cloned successfully (repoless)");

// Step 6: Update package.json if it exists and project name was provided
// Step 6: Update package.json and wrangler.jsonc if it exists and project name was provided
if (projectName) {
const packageJsonPath = path.join(targetDir, "package.json");
if (await fs.pathExists(packageJsonPath)) {
Expand All @@ -83,6 +83,19 @@ export async function createProject(
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
spinner.succeed("Package.json updated with new project name");
}

const wranglerJsoncPath = path.join(targetDir, "apps", "user-application", "wrangler.jsonc");
if (await fs.pathExists(wranglerJsoncPath)) {
spinner.start("Updating wrangler.jsonc...");
// maybe replace with a jsonc parser in the future? like jsonc-parser
let wranglerJsonc = await fs.readFile(wranglerJsoncPath, "utf-8");
wranglerJsonc = wranglerJsonc.replace(
/"name":\s*".*"/,
`"name": "${projectName}"`,
);
await fs.writeFile(wranglerJsoncPath, wranglerJsonc, "utf-8");
spinner.succeed("wrangler.jsonc updated with new project name");
}
}

const successMessage = projectName
Expand Down