@@ -161,10 +161,10 @@ nx deploy-functions ${projectName}` : ''}
161161
162162### Data Management
163163\`\`\`bash
164- # Export emulator data
164+ # Export emulator data (also auto-exported on emulator exit)
165165nx data:export ${ projectName }
166166
167- # Import emulator data
167+ # Import emulator data (also auto-imported on emulator start)
168168nx data:import ${ projectName }
169169
170170# Seed development data (customize the seed target)
@@ -225,7 +225,7 @@ ${features.includes('firestore') ? `├── firestore.rules # Firestore
225225├── firestore.indexes.json # Firestore indexes` : '' }
226226${ features . includes ( 'hosting' ) ? `├── public/ # Hosting files` : '' }
227227${ features . includes ( 'storage' ) ? `├── storage.rules # Storage security rules` : '' }
228- └── exports / # Emulator data exports
228+ └── emulator-data / # Emulator data exports (auto-imported/exported)
229229\`\`\`
230230
231231## Learn More
@@ -238,7 +238,7 @@ ${features.includes('storage') ? `├── storage.rules # Storage secu
238238 tree . write ( joinPathFragments ( projectRoot , 'README.md' ) , readmeContent ) ;
239239}
240240
241- function createFunctionsNxApp ( tree : Tree , baseProjectName : string , projectDir : string , initDir : string , dynamicConfig : any ) {
241+ function createFunctionsNxApp ( tree : Tree , baseProjectName : string , projectDir : string , initDir : string ) {
242242 const functionsAppName = `${ baseProjectName } -functions` ;
243243 const functionsAppRoot = joinPathFragments ( projectDir , 'functions' ) ;
244244 const functionsSourceDir = join ( initDir , 'functions' ) ;
@@ -482,7 +482,7 @@ export default async function (tree: Tree, schema: Schema) {
482482 // Create Functions Nx app if functions are detected
483483 let functionsAppName : string | null = null ;
484484 if ( features . includes ( 'functions' ) ) {
485- functionsAppName = createFunctionsNxApp ( tree , baseProjectName , projectDir , initDirResolved , null ) ;
485+ functionsAppName = createFunctionsNxApp ( tree , baseProjectName , projectDir , initDirResolved ) ;
486486 }
487487
488488 // Get dynamic configuration based on detected features
@@ -547,7 +547,7 @@ export default async function (tree: Tree, schema: Schema) {
547547 options : {
548548 cwd : projectRoot ,
549549 command : dynamicConfig . hasEmulators && dynamicConfig . emulatorServices
550- ? `mkdir -p exports && if [ -d "exports" ] && [ "$(ls -A exports)" ]; then firebase emulators:start --only=${ dynamicConfig . emulatorServices } --import=./exports; else firebase emulators:start --only= ${ dynamicConfig . emulatorServices } ; fi `
550+ ? `firebase emulators:start --only=${ dynamicConfig . emulatorServices } --import=./emulator-data --export-on-exit=./emulator-data `
551551 : 'echo "No emulators configured"'
552552 }
553553 } ,
@@ -556,7 +556,7 @@ export default async function (tree: Tree, schema: Schema) {
556556 options : {
557557 cwd : projectRoot ,
558558 command : dynamicConfig . hasEmulators && dynamicConfig . emulatorServices
559- ? `mkdir -p exports && if [ -d "exports" ] && [ "$(ls -A exports)" ]; then firebase emulators:start --inspect-functions --only=${ dynamicConfig . emulatorServices } --import=./exports; else firebase emulators:start --inspect-functions --only= ${ dynamicConfig . emulatorServices } ; fi `
559+ ? `firebase emulators:start --inspect-functions --only=${ dynamicConfig . emulatorServices } --import=./emulator-data --export-on-exit=./emulator-data `
560560 : 'echo "No emulators configured"'
561561 }
562562 } ,
@@ -596,28 +596,28 @@ export default async function (tree: Tree, schema: Schema) {
596596 options : functionsAppName && dynamicConfig . hasEmulators ? {
597597 commands : [
598598 `nx build ${ functionsAppName } --watch` ,
599- `cd ${ projectRoot } && mkdir -p exports && firebase emulators:start --only=${ dynamicConfig . emulatorServices } `
599+ `cd ${ projectRoot } && firebase emulators:start --only=${ dynamicConfig . emulatorServices } --import=./emulator-data --export-on-exit=./emulator-data `
600600 ] ,
601601 parallel : true
602602 } : {
603603 cwd : projectRoot ,
604604 command : dynamicConfig . hasEmulators
605- ? `mkdir -p exports && firebase emulators:start --only=${ dynamicConfig . emulatorServices } `
605+ ? `firebase emulators:start --only=${ dynamicConfig . emulatorServices } --import=./emulator-data --export-on-exit=./emulator-data `
606606 : 'echo "No development environment configured"'
607607 }
608608 } ,
609609 'data:export' : {
610610 executor : 'nx:run-commands' ,
611611 options : {
612612 cwd : projectRoot ,
613- command : 'firebase emulators:export ./exports --force'
613+ command : 'firebase emulators:export ./emulator-data --force'
614614 }
615615 } ,
616616 'data:import' : {
617617 executor : 'nx:run-commands' ,
618618 options : {
619619 cwd : projectRoot ,
620- command : 'firebase emulators:start --import=./exports --export-on-exit=./exports '
620+ command : 'firebase emulators:start --import=./emulator-data --export-on-exit=./emulator-data '
621621 }
622622 } ,
623623 'data:seed' : {
@@ -663,8 +663,8 @@ export default async function (tree: Tree, schema: Schema) {
663663 // Fix ESLint configuration conflicts
664664 fixEslintConfiguration ( tree , projectRoot ) ;
665665
666- // Create exports directory for emulator data
667- tree . write ( joinPathFragments ( projectRoot , 'exports ' , '.gitkeep' ) , '# This directory stores emulator data exports\n' ) ;
666+ // Create emulator-data directory for emulator data
667+ tree . write ( joinPathFragments ( projectRoot , 'emulator-data ' , '.gitkeep' ) , '# This directory stores emulator data exports\n# The emulator-data directory is automatically used by Firebase emulators for data import/export\n# Data is automatically saved on emulator exit and loaded on startup \n' ) ;
668668
669669 // Generate project-specific README
670670 generateProjectReadme ( tree , projectRoot , baseProjectName , features , firebaseProjectName ) ;
@@ -679,6 +679,9 @@ dist/
679679
680680# Node modules (if not already ignored)
681681node_modules/
682+
683+ # Emulator data (comment out if you want to commit emulator data)
684+ emulator-data/
682685` ;
683686
684687 if ( ! existingGitignore . includes ( '.nx/' ) ) {
0 commit comments