Skip to content

Conversation

@jacobsfletch
Copy link
Member

@jacobsfletch jacobsfletch commented May 27, 2025

When cloning a new project from the examples dir via create-payload-app, the corresponding .env file is not being generated. This is because the --example flag does not prompt for database credentials, which ultimately skips this step.

For example:

npx create-payload-app --example live-preview

The result will include the provided .env.example, but lacks a .env.

We were previously writing to the .env.example file, which is unexpected. We should only be writing to the .env file itself. To do this, we only write the .env.example to memory as needed, instead of the file system.

This PR also simplifies the logic needed to set default vars, and improves the testing coverage overall.


@jacobsfletch jacobsfletch changed the title fix(cpa): copy .env.example when cloning from examples dir fix(cpa): generate .env when using the --example flag May 27, 2025
Copy link
Member

@denolfe denolfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a few notes.

@jacobsfletch jacobsfletch merged commit 836fd86 into main May 30, 2025
76 checks passed
@jacobsfletch jacobsfletch deleted the fix/cpa-example-envs branch May 30, 2025 18:26
@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2025

🚀 This is included in version v3.41.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment