1
1
/* eslint-disable @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
2
2
import { execSync } from 'node:child_process' ;
3
- import { readFile , writeFile } from 'node:fs/promises' ;
3
+ import { readFile , rm , writeFile } from 'node:fs/promises' ;
4
4
5
5
const cwd = new URL ( '../website/' , import . meta. url ) ;
6
6
const json = JSON . parse ( await readFile ( new URL ( '../package.json' , import . meta. url ) , { encoding : 'utf8' } ) ) ;
@@ -16,4 +16,21 @@ const parsed = JSON.parse(await readFile(bigJsonPath, { encoding: 'utf8' }));
16
16
17
17
await writeFile ( bigJsonPath , JSON . stringify ( parsed ) ) ;
18
18
19
- console . log ( `✅ Done! Website version created for ${ json . version } ` ) ;
19
+ console . log ( `✅ Website version created for ${ json . version } ` ) ;
20
+
21
+ const versionsJsonPath = new URL ( './versions.json' , cwd ) ;
22
+
23
+ /** @type {string[] } */
24
+ const allVersions = JSON . parse ( await readFile ( versionsJsonPath , 'utf8' ) ) ;
25
+
26
+ const versionToDelete = allVersions . pop ( ) ;
27
+
28
+ await writeFile ( versionsJsonPath , JSON . stringify ( allVersions , null , 2 ) ) ;
29
+
30
+ await rm ( new URL ( `./versioned_docs/version-${ versionToDelete } ` , cwd ) , { force : true , recursive : true } ) ;
31
+ await rm ( new URL ( `./versioned_sidebars/version-${ versionToDelete } -sidebars.json` , cwd ) , {
32
+ force : true ,
33
+ recursive : true ,
34
+ } ) ;
35
+
36
+ console . log ( `♻️ Removed old website version ${ versionToDelete } ` ) ;
0 commit comments