feat(cli): auto-copy .env from @zen/core template after install
Automatically copies `.env.example` from the installed `@zen/core` package to `.env` in the project root if it doesn't already exist. This removes the need for users to manually locate and configure environment variables. Updated the post-install instructions to reflect the new behavior.
This commit is contained in:
+8
-2
@@ -127,9 +127,15 @@ export default nextConfig;
|
|||||||
execSync('npm install @zen/core', { stdio: 'inherit' });
|
execSync('npm install @zen/core', { stdio: 'inherit' });
|
||||||
done('@zen/core installed');
|
done('@zen/core installed');
|
||||||
|
|
||||||
|
const envExample = path.resolve(process.cwd(), 'node_modules/@zen/core/.env.example');
|
||||||
|
const envDest = path.resolve(process.cwd(), '.env');
|
||||||
|
if (fs.existsSync(envExample) && !fs.existsSync(envDest)) {
|
||||||
|
fs.copyFileSync(envExample, envDest);
|
||||||
|
done('Created .env from @zen/core template');
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`\n ${c.green}${c.bold}Project ready.${c.reset} Next steps:\n`);
|
console.log(`\n ${c.green}${c.bold}Project ready.${c.reset} Next steps:\n`);
|
||||||
console.log(` ${c.dim}1.${c.reset} Configure environment variables`);
|
console.log(` ${c.dim}1.${c.reset} Fill in the environment variables in ${c.cyan}.env${c.reset}`);
|
||||||
console.log(` ${c.dim}https://git.hyko.cx/zen/core${c.reset}`);
|
|
||||||
console.log(` ${c.dim}2.${c.reset} Initialize the database`);
|
console.log(` ${c.dim}2.${c.reset} Initialize the database`);
|
||||||
console.log(` ${c.dim}npx zen-db init${c.reset}\n`);
|
console.log(` ${c.dim}npx zen-db init${c.reset}\n`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user