@@ -2,15 +2,26 @@ import { cpus } from 'os'
2
2
3
3
import type { NetlifyConfig } from '@netlify/build'
4
4
import { 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'
6
17
import globby from 'globby'
7
18
import { PrerenderManifest } from 'next/dist/build'
8
19
import { outdent } from 'outdent'
9
20
import pLimit from 'p-limit'
10
21
import { join , resolve , dirname } from 'pathe'
11
22
import slash from 'slash'
12
23
13
- import { MINIMUM_REVALIDATE_SECONDS , DIVIDER } from '../constants'
24
+ import { MINIMUM_REVALIDATE_SECONDS , DIVIDER , HIDDEN_PATHS } from '../constants'
14
25
15
26
import { NextConfig } from './config'
16
27
import { loadPrerenderManifest } from './edge'
@@ -138,8 +149,8 @@ export const moveStaticPages = async ({
138
149
console . warn ( 'Error moving file' , source , error )
139
150
}
140
151
}
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}' ] , {
143
154
cwd : outputDir ,
144
155
dot : true ,
145
156
} )
@@ -467,3 +478,15 @@ export const movePublicFiles = async ({
467
478
await copy ( publicDir , `${ publish } ${ basePath } /` )
468
479
}
469
480
}
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