@@ -2,15 +2,26 @@ import { cpus } from 'os'
22
33import type { NetlifyConfig } from '@netlify/build'
44import { yellowBright } from 'chalk'
5- import { existsSync , readJson , move , copy , writeJson , readFile , writeFile , ensureDir , readFileSync } from 'fs-extra'
5+ import {
6+ existsSync ,
7+ readJson ,
8+ move ,
9+ copy ,
10+ writeJson ,
11+ readFile ,
12+ writeFile ,
13+ ensureDir ,
14+ readFileSync ,
15+ remove ,
16+ } from 'fs-extra'
617import globby from 'globby'
718import { PrerenderManifest } from 'next/dist/build'
819import { outdent } from 'outdent'
920import pLimit from 'p-limit'
1021import { join , resolve , dirname } from 'pathe'
1122import slash from 'slash'
1223
13- import { MINIMUM_REVALIDATE_SECONDS , DIVIDER } from '../constants'
24+ import { MINIMUM_REVALIDATE_SECONDS , DIVIDER , HIDDEN_PATHS } from '../constants'
1425
1526import { NextConfig } from './config'
1627import { loadPrerenderManifest } from './edge'
@@ -138,8 +149,8 @@ export const moveStaticPages = async ({
138149 console . warn ( 'Error moving file' , source , error )
139150 }
140151 }
141- // Move all static files, except error documents and nft manifests
142- const pages = await globby ( [ '{app,pages}/**/*.{html,json,rsc}' , '!**/(500|404| *.js.nft) .{html,json}' ] , {
152+ // Move all static files, except nft manifests
153+ const pages = await globby ( [ '{app,pages}/**/*.{html,json,rsc}' , '!**/*.js.nft.{html,json}' ] , {
143154 cwd : outputDir ,
144155 dot : true ,
145156 } )
@@ -467,3 +478,15 @@ export const movePublicFiles = async ({
467478 await copy ( publicDir , `${ publish } ${ basePath } /` )
468479 }
469480}
481+
482+ export const removeMetadataFiles = async ( publish : string ) => {
483+ // Limit concurrent deletions to number of cpus or 2 if there is only 1
484+ const limit = pLimit ( Math . max ( 2 , cpus ( ) . length ) )
485+
486+ const removePromises = HIDDEN_PATHS . map ( ( HIDDEN_PATH ) => {
487+ const pathToDelete = join ( publish , HIDDEN_PATH )
488+ return limit ( ( ) => remove ( pathToDelete ) )
489+ } )
490+
491+ await Promise . all ( removePromises )
492+ }
0 commit comments