1111 */
1212
1313const tempy = require ( 'tempy' ) ;
14- const fs = require ( 'fs-extra ' ) ;
14+ const fs = require ( 'fs' ) ;
1515const packageJSON = require ( '../package.json' ) ;
1616const path = require ( 'path' ) ;
1717const glob = require ( 'fast-glob' ) ;
@@ -58,7 +58,7 @@ async function build() {
5858 let srcDir = archiveDir ?? path . join ( __dirname , '..' ) ;
5959 let distDir = path . join ( __dirname , '..' , 'dist' , args . values . output ?? 'branch-api' ) ;
6060 // if we already have a directory with a built dist, remove it so we can write cleanly into it at the end
61- fs . removeSync ( distDir ) ;
61+ fs . rmSync ( distDir , { recursive : true , force : true } ) ;
6262 // Create a temp directory to build the site in
6363 let dir = tempy . directory ( ) ;
6464 console . log ( `Building branch api into ${ dir } ...` ) ;
@@ -118,29 +118,29 @@ async function build() {
118118 }` ) ;
119119
120120 // Copy necessary code and configuration over
121- fs . copySync ( path . join ( srcDir , 'packages' , '@adobe' , 'spectrum-css-temp' ) , path . join ( dir , 'packages' , '@adobe' , 'spectrum-css-temp' ) ) ;
121+ fs . cpSync ( path . join ( srcDir , 'packages' , '@adobe' , 'spectrum-css-temp' ) , path . join ( dir , 'packages' , '@adobe' , 'spectrum-css-temp' ) , { recursive : true } ) ;
122122 try {
123- fs . copySync ( path . join ( srcDir , 'packages' , '@adobe' , 'spectrum-css-builder-temp' ) , path . join ( dir , 'packages' , '@adobe' , 'spectrum-css-builder-temp' ) ) ;
123+ fs . cpSync ( path . join ( srcDir , 'packages' , '@adobe' , 'spectrum-css-builder-temp' ) , path . join ( dir , 'packages' , '@adobe' , 'spectrum-css-builder-temp' ) , { recursive : true } ) ;
124124 } catch ( e ) {
125- fs . copySync ( path . join ( backupDir , 'packages' , '@adobe' , 'spectrum-css-builder-temp' ) , path . join ( dir , 'packages' , '@adobe' , 'spectrum-css-builder-temp' ) ) ;
125+ fs . cpSync ( path . join ( backupDir , 'packages' , '@adobe' , 'spectrum-css-builder-temp' ) , path . join ( dir , 'packages' , '@adobe' , 'spectrum-css-builder-temp' ) , { recursive : true } ) ;
126126 }
127- fs . copySync ( path . join ( srcDir , 'postcss.config.js' ) , path . join ( dir , 'postcss.config.js' ) ) ;
128- fs . copySync ( path . join ( srcDir , 'lib' ) , path . join ( dir , 'lib' ) ) ;
129- fs . copySync ( path . join ( srcDir , 'CONTRIBUTING.md' ) , path . join ( dir , 'CONTRIBUTING.md' ) ) ;
127+ fs . cpSync ( path . join ( srcDir , 'postcss.config.js' ) , path . join ( dir , 'postcss.config.js' ) ) ;
128+ fs . cpSync ( path . join ( srcDir , 'lib' ) , path . join ( dir , 'lib' ) , { recursive : true } ) ;
129+ fs . cpSync ( path . join ( srcDir , 'CONTRIBUTING.md' ) , path . join ( dir , 'CONTRIBUTING.md' ) ) ;
130130 // need dev from latest on branch since it will generate the API for diffing, and in older commits it may not be able to do this or
131131 // does it in a different format
132- fs . copySync ( path . join ( __dirname , '..' , 'packages' , 'dev' ) , path . join ( dir , 'packages' , 'dev' ) ) ;
133- fs . copySync ( path . join ( __dirname , '..' , '.parcelrc' ) , path . join ( dir , '.parcelrc' ) ) ;
132+ fs . cpSync ( path . join ( __dirname , '..' , 'packages' , 'dev' ) , path . join ( dir , 'packages' , 'dev' ) , { recursive : true } ) ;
133+ fs . cpSync ( path . join ( __dirname , '..' , '.parcelrc' ) , path . join ( dir , '.parcelrc' ) ) ;
134134 // Delete test-utils from copied packages since we don't expose anything from there
135- fs . removeSync ( path . join ( dir , 'packages' , 'dev' , 'test-utils' ) ) ;
135+ fs . rmSync ( path . join ( dir , 'packages' , 'dev' , 'test-utils' ) , { recursive : true , force : true } ) ;
136136
137- fs . copySync ( path . join ( __dirname , '..' , '.yarn' ) , path . join ( dir , '.yarn' ) ) ;
138- fs . copySync ( path . join ( __dirname , '..' , '.yarnrc.yml' ) , path . join ( dir , '.yarnrc.yml' ) ) ;
137+ fs . cpSync ( path . join ( __dirname , '..' , '.yarn' ) , path . join ( dir , '.yarn' ) , { recursive : true } ) ;
138+ fs . cpSync ( path . join ( __dirname , '..' , '.yarnrc.yml' ) , path . join ( dir , '.yarnrc.yml' ) ) ;
139139
140140 // Only copy babel patch over
141141 let patches = fs . readdirSync ( path . join ( srcDir , 'patches' ) ) ;
142142 let babelPatch = patches . find ( name => name . startsWith ( '@babel' ) ) ;
143- fs . copySync ( path . join ( srcDir , 'patches' , babelPatch ) , path . join ( dir , 'patches' , babelPatch ) ) ;
143+ fs . cpSync ( path . join ( srcDir , 'patches' , babelPatch ) , path . join ( dir , 'patches' , babelPatch ) , { recursive : true } ) ;
144144
145145 let excludeList = [ '@react-spectrum/story-utils' ] ;
146146 // Copy packages over to temp dir
@@ -153,7 +153,7 @@ async function build() {
153153 continue ;
154154 }
155155
156- fs . copySync ( path . join ( srcDir , 'packages' , path . dirname ( p ) ) , path . join ( dir , 'packages' , path . dirname ( p ) ) , { dereference : true } ) ;
156+ fs . cpSync ( path . join ( srcDir , 'packages' , path . dirname ( p ) ) , path . join ( dir , 'packages' , path . dirname ( p ) ) , { dereference : true , recursive : true } ) ;
157157
158158 if ( ! p . includes ( '@react-types' ) ) {
159159 delete json . types ;
@@ -169,18 +169,18 @@ async function build() {
169169 }
170170 }
171171 // Install dependencies from npm
172- fs . copySync ( path . join ( srcDir , 'yarn.lock' ) , path . join ( dir , 'yarn.lock' ) ) ;
172+ fs . cpSync ( path . join ( srcDir , 'yarn.lock' ) , path . join ( dir , 'yarn.lock' ) ) ;
173173 await run ( 'yarn' , [ '--no-immutable' ] , { cwd : dir , stdio : 'inherit' } ) ;
174174
175175 // Build the website
176176 console . log ( 'building api files' ) ;
177177 await run ( 'yarn' , [ 'parcel' , 'build' , 'packages/react-aria-components' , 'packages/@react-{spectrum,aria,stately}/*/' , 'packages/@internationalized/{message,string,date,number}' , '--target' , 'apiCheck' ] , { cwd : dir , stdio : 'inherit' } ) ;
178178
179179 // Copy the build back into dist, and delete the temp dir.
180- fs . copySync ( path . join ( dir , 'packages' ) , distDir , { dereference : true } ) ;
181- fs . removeSync ( dir ) ;
180+ fs . cpSync ( path . join ( dir , 'packages' ) , distDir , { dereference : true , recursive : true } ) ;
181+ fs . rmSync ( dir , { recursive : true , force : true } ) ;
182182 if ( archiveDir ) {
183- fs . removeSync ( archiveDir ) ;
183+ fs . rmSync ( archiveDir , { recursive : true , force : true } ) ;
184184 }
185185}
186186
0 commit comments