@@ -10,8 +10,8 @@ interface NetlifyUtils {
10
10
11
11
interface NetlifyInputs {
12
12
// The TOML config uses camelcase for readability and because it's convention
13
- custom_build_dir_name ? : string ;
14
- build_dir_path ? : string ;
13
+ custom_build_dir_name : string ;
14
+ build_dir_path : string ;
15
15
}
16
16
17
17
interface NetlifyOpts {
@@ -33,9 +33,9 @@ function generateAbsolutePaths(
33
33
buildDirName : string ;
34
34
} {
35
35
/** The name of the build folder. `.next`, unless specially configured. */
36
- const buildDirName = options . inputs . custom_build_dir_name ?? '.next' ;
36
+ const buildDirName = options . inputs . custom_build_dir_name ;
37
37
/** The directory the build folder is in. Defaults to current directory, although some larger repositories might keep this in a `frontend` folder. */
38
- const buildDirPathFromProject = options . inputs . build_dir_path ?? '.' ;
38
+ const buildDirPathFromProject = options . inputs . build_dir_path ;
39
39
40
40
/** The absolute path to the build folder for Next.js. */
41
41
const absoluteBuildDirPath = joinPaths ( buildDirPathFromProject , buildDirName , 'cache' ) ;
@@ -53,19 +53,18 @@ function generateAbsolutePaths(
53
53
}
54
54
55
55
module . exports = {
56
- name : 'cache-nextjs' ,
57
56
// Restore file/directory cached in previous builds.
58
57
// Does not do anything if:
59
58
// - the file/directory already exists locally
60
59
// - the file/directory has not been cached yet
61
60
async onPreBuild ( { utils, inputs} : ReadonlyDeep < NetlifyOpts > ) {
62
61
const paths = generateAbsolutePaths ( { inputs} ) ;
63
- const success = await utils . cache . restore ( paths . absolute . buildDir , { move : true } ) ;
62
+ const success = await utils . cache . restore ( paths . absolute . buildDir ) ;
64
63
65
64
if ( success ) {
66
65
console . log ( `Restored the cached ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
67
66
} else {
68
- console . log ( `Unable to restore the cached ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
67
+ console . log ( `No cache found for the ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
69
68
}
70
69
} ,
71
70
// Cache file/directory for future builds.
@@ -78,14 +77,13 @@ module.exports = {
78
77
const paths = generateAbsolutePaths ( { inputs} ) ;
79
78
80
79
const success = await utils . cache . save ( paths . absolute . buildDir , {
81
- digests : [ paths . absolute . manifest ] ,
82
- move : true
80
+ digests : [ paths . absolute . manifest ]
83
81
} ) ;
84
82
85
83
if ( success ) {
86
84
console . log ( `Cached the ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
87
85
} else {
88
- console . error ( `An error occurred and the ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \` could not be cached `) ;
86
+ console . log ( `No ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \``) ;
89
87
}
90
88
}
91
89
} ;
0 commit comments