@@ -164,6 +164,112 @@ 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+ await generateBuildOutput (
175+ tmpDir ,
176+ "apps/next-app" ,
177+ {
178+ bundleYamlPath : path . join ( tmpDir , ".apphosting" , "bundle.yaml" ) ,
179+ outputDirectoryBasePath : path . join ( tmpDir , ".apphosting" ) ,
180+ outputDirectoryAppPath : path . join ( tmpDir , ".next" , "standalone" , "apps" , "next-app" ) ,
181+ outputPublicDirectoryPath : path . join (
182+ tmpDir ,
183+ ".next" ,
184+ "standalone" ,
185+ "apps" ,
186+ "next-app" ,
187+ "public" ,
188+ ) ,
189+ outputStaticDirectoryPath : path . join (
190+ tmpDir ,
191+ ".next" ,
192+ "standalone" ,
193+ "apps" ,
194+ "next-app" ,
195+ ".next" ,
196+ "static" ,
197+ ) ,
198+ serverFilePath : path . join ( tmpDir , ".next" , "standalone" , "apps" , "next-app" , "server.js" ) ,
199+ } ,
200+ path . join ( tmpDir , ".next" ) ,
201+ defaultNextVersion ,
202+ adapterMetadata ,
203+ ) ;
204+
205+ const expectedFiles = {
206+ ".gitignore" : "/.apphosting/" ,
207+ } ;
208+ const expectedPartialYaml = {
209+ version : "v1" ,
210+ runConfig : { runCommand : "node .next/standalone/apps/next-app/server.js" } ,
211+ } ;
212+ validateTestFiles ( tmpDir , expectedFiles ) ;
213+ validatePartialYamlContents ( tmpDir , ".apphosting/bundle.yaml" , expectedPartialYaml ) ;
214+ } ) ;
215+
216+ it ( ".apphosting gitignored without existing .gitignore file" , async ( ) => {
217+ const { generateBuildOutput, validateOutputDirectory } = await importUtils ;
218+ const files = {
219+ // .next/standalone/.next/ must be created beforehand otherwise
220+ // generateBuildOutput will attempt to copy
221+ // .next/ into .next/standalone/.next
222+ ".next/standalone/.next/package.json" : "" ,
223+ ".next/static/staticfile" : "" ,
224+ } ;
225+ generateTestFiles ( tmpDir , files ) ;
226+ await generateBuildOutput (
227+ tmpDir ,
228+ tmpDir ,
229+ outputBundleOptions ,
230+ path . join ( tmpDir , ".next" ) ,
231+ defaultNextVersion ,
232+ {
233+ adapterPackageName : "@apphosting/adapter-nextjs" ,
234+ adapterVersion : "14.0.1" ,
235+ } ,
236+ ) ;
237+ await validateOutputDirectory ( outputBundleOptions , path . join ( tmpDir , ".next" ) ) ;
238+
239+ const expectedFiles = {
240+ ".gitignore" : "/.apphosting/" ,
241+ } ;
242+ validateTestFiles ( tmpDir , expectedFiles ) ;
243+ } ) ;
244+ it ( ".apphosting gitignored in existing .gitignore file" , async ( ) => {
245+ const { generateBuildOutput, validateOutputDirectory } = await importUtils ;
246+ const files = {
247+ // .next/standalone/.next/ must be created beforehand otherwise
248+ // generateBuildOutput will attempt to copy
249+ // .next/ into .next/standalone/.next
250+ ".next/standalone/.next/package.json" : "" ,
251+ ".next/static/staticfile" : "" ,
252+ ".gitignore" : "/.next/" ,
253+ } ;
254+ generateTestFiles ( tmpDir , files ) ;
255+ await generateBuildOutput (
256+ tmpDir ,
257+ tmpDir ,
258+ outputBundleOptions ,
259+ path . join ( tmpDir , ".next" ) ,
260+ defaultNextVersion ,
261+ {
262+ adapterPackageName : "@apphosting/adapter-nextjs" ,
263+ adapterVersion : "14.0.1" ,
264+ } ,
265+ ) ;
266+ await validateOutputDirectory ( outputBundleOptions , path . join ( tmpDir , ".next" ) ) ;
267+
268+ const expectedFiles = {
269+ ".gitignore" : "/.next/\n/.apphosting/" ,
270+ } ;
271+ validateTestFiles ( tmpDir , expectedFiles ) ;
272+ } ) ;
167273 it ( "expects directories and other files to be copied over" , async ( ) => {
168274 const { generateBuildOutput, validateOutputDirectory } = await importUtils ;
169275 const files = {
0 commit comments