Skip to content

Commit 6d573bd

Browse files
committed
refactor: simplify .env file naming and add Firebase docs references
- Change export filename from .env.{project} to just .env - Add project information to file header instead of filename - Include Firebase documentation link in header and footer - Update override instructions to suggest .env.local or .env.{projectId} - Update reserved alias warning message to reflect new behavior
1 parent 86fbfa6 commit 6d573bd

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/commands/functions-config-export.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function checkReservedAliases(pInfos: configExport.ProjectConfigInfo[]): void {
3232
if (pInfo.alias && RESERVED_PROJECT_ALIAS.includes(pInfo.alias)) {
3333
logWarning(
3434
`Project alias (${clc.bold(pInfo.alias)}) is reserved for internal use. ` +
35-
`Saving exported config in .env.${pInfo.projectId} instead.`,
35+
`Using project ID (${pInfo.projectId}) in the .env file header instead.`,
3636
);
3737
delete pInfo.alias;
3838
}
@@ -301,21 +301,28 @@ export const command = new Command("functions:config:export")
301301
}
302302

303303
// 5. Generate .env file contents
304-
const header = `# Exported firebase functions:config:export command on ${new Date().toLocaleDateString()}`;
305304
const filesToWrite: Record<string, string> = {};
306305

307306
for (const pInfo of pInfos) {
308307
if (!pInfo.envs || pInfo.envs.length === 0) continue;
309308

309+
// Create project-specific header
310+
const projectInfo = pInfo.alias ? `${pInfo.projectId} (${pInfo.alias})` : pInfo.projectId;
311+
const header =
312+
`# Environment variables for Firebase project: ${projectInfo}\n` +
313+
`# Exported by firebase functions:config:export on ${new Date().toLocaleDateString()}\n` +
314+
`# Learn more: https://firebase.google.com/docs/functions/config-env#env-variables`;
315+
310316
const filename = configExport.generateDotenvFilename(pInfo);
311317
let envContent = configExport.enhancedToDotenvFormat(pInfo.envs, header);
312318

313319
// Add helpful footer
314320
const footer =
315321
`\n\n# === NOTES ===\n` +
316-
`# - Override values: Create .env.local or .env\n` +
322+
`# - Override values: Create .env.local or .env.${pInfo.projectId}\n` +
317323
`# - Never commit files containing secrets\n` +
318-
`# - Use 'firebase functions:secrets:set' for production secrets\n`;
324+
`# - Use 'firebase functions:secrets:set' for production secrets\n` +
325+
`# - Learn more: https://firebase.google.com/docs/functions/config-env#env-variables`;
319326

320327
envContent = envContent + footer;
321328
filesToWrite[filename] = envContent;

src/functions/runtimeConfigExport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export function toDotenvFormat(envs: EnvMap[], header = ""): string {
199199
* Generate dotenv filename for given project.
200200
*/
201201
export function generateDotenvFilename(pInfo: ProjectConfigInfo): string {
202-
return `.env.${pInfo.alias ?? pInfo.projectId}`;
202+
return `.env`;
203203
}
204204

205205
export interface ConfigAnalysis {

0 commit comments

Comments
 (0)