@@ -164,6 +164,95 @@ outputFiles:
164164 async ( ) => await validateOutputDirectory ( outputBundleOptions , path . join ( tmpDir , ".next" ) ) ,
165165 ) ;
166166 } ) ;
167+ it ( ".apphosting gitignored correctly in a monorepo setup" , async ( ) => {
168+ const { generateBuildOutput } = await importUtils ;
169+ const files = {
170+ ".next/standalone/apps/next-app/standalonefile" : "" ,
171+ ".next/static/staticfile" : "" ,
172+ } ;
173+ generateTestFiles ( tmpDir , files ) ;
174+ const standaloneAppPath = path . join ( tmpDir , ".next" , "standalone" , "apps" , "next-app" ) ;
175+ await generateBuildOutput (
176+ tmpDir ,
177+ "apps/next-app" ,
178+ {
179+ bundleYamlPath : path . join ( tmpDir , ".apphosting" , "bundle.yaml" ) ,
180+ outputDirectoryBasePath : path . join ( tmpDir , ".apphosting" ) ,
181+ outputDirectoryAppPath : standaloneAppPath ,
182+ outputPublicDirectoryPath : path . join ( standaloneAppPath , "public" ) ,
183+ outputStaticDirectoryPath : path . join ( standaloneAppPath , ".next" , "static" ) ,
184+ serverFilePath : path . join ( standaloneAppPath , "server.js" ) ,
185+ } ,
186+ path . join ( tmpDir , ".next" ) ,
187+ defaultNextVersion ,
188+ adapterMetadata ,
189+ ) ;
190+
191+ const expectedFiles = {
192+ ".gitignore" : "/.apphosting/" ,
193+ } ;
194+ const expectedPartialYaml = {
195+ version : "v1" ,
196+ runConfig : { runCommand : "node .next/standalone/apps/next-app/server.js" } ,
197+ } ;
198+ validateTestFiles ( tmpDir , expectedFiles ) ;
199+ validatePartialYamlContents ( tmpDir , ".apphosting/bundle.yaml" , expectedPartialYaml ) ;
200+ } ) ;
201+
202+ it ( ".apphosting gitignored without existing .gitignore file" , async ( ) => {
203+ const { generateBuildOutput, validateOutputDirectory } = await importUtils ;
204+ const files = {
205+ // .next/standalone/.next/ must be created beforehand otherwise
206+ // generateBuildOutput will attempt to copy
207+ // .next/ into .next/standalone/.next
208+ ".next/standalone/.next/package.json" : "" ,
209+ ".next/static/staticfile" : "" ,
210+ } ;
211+ generateTestFiles ( tmpDir , files ) ;
212+ await generateBuildOutput (
213+ tmpDir ,
214+ tmpDir ,
215+ outputBundleOptions ,
216+ path . join ( tmpDir , ".next" ) ,
217+ defaultNextVersion ,
218+ adapterMetadata ,
219+ ) ;
220+ await validateOutputDirectory ( outputBundleOptions , path . join ( tmpDir , ".next" ) ) ;
221+
222+ const expectedFiles = {
223+ ".gitignore" : "/.apphosting/" ,
224+ } ;
225+ validateTestFiles ( tmpDir , expectedFiles ) ;
226+ } ) ;
227+ it ( ".apphosting gitignored in existing .gitignore file" , async ( ) => {
228+ const { generateBuildOutput, validateOutputDirectory } = await importUtils ;
229+ const files = {
230+ // .next/standalone/.next/ must be created beforehand otherwise
231+ // generateBuildOutput will attempt to copy
232+ // .next/ into .next/standalone/.next
233+ ".next/standalone/.next/package.json" : "" ,
234+ ".next/static/staticfile" : "" ,
235+ ".gitignore" : "/.next/" ,
236+ } ;
237+ generateTestFiles ( tmpDir , files ) ;
238+ await generateBuildOutput (
239+ tmpDir ,
240+ tmpDir ,
241+ outputBundleOptions ,
242+ path . join ( tmpDir , ".next" ) ,
243+ defaultNextVersion ,
244+ {
245+ adapterPackageName : "@apphosting/adapter-nextjs" ,
246+ adapterVersion : "14.0.1" ,
247+ } ,
248+ ) ;
249+ await validateOutputDirectory ( outputBundleOptions , path . join ( tmpDir , ".next" ) ) ;
250+
251+ const expectedFiles = {
252+ ".gitignore" : "/.next/\n/.apphosting/" ,
253+ } ;
254+ validateTestFiles ( tmpDir , expectedFiles ) ;
255+ } ) ;
167256 it ( "expects directories and other files to be copied over" , async ( ) => {
168257 const { generateBuildOutput, validateOutputDirectory } = await importUtils ;
169258 const files = {
@@ -188,10 +277,7 @@ outputFiles:
188277 outputBundleOptions ,
189278 path . join ( tmpDir , ".next" ) ,
190279 defaultNextVersion ,
191- {
192- adapterPackageName : "@apphosting/adapter-nextjs" ,
193- adapterVersion : "14.0.1" ,
194- } ,
280+ adapterMetadata ,
195281 ) ;
196282 await validateOutputDirectory ( outputBundleOptions , path . join ( tmpDir , ".next" ) ) ;
197283
0 commit comments