@@ -177,7 +177,7 @@ function copyDirectory(src, dest, excludePaths = []) {
177177}
178178
179179// Process a single release branch
180- function processBranch ( branch , isLatest = false ) {
180+ function processBranch ( branch ) {
181181 const version = branchToVersion ( branch ) ;
182182 console . log ( `\n=== Processing ${ branch } (version ${ version } ) ===` ) ;
183183
@@ -249,14 +249,6 @@ function processBranch(branch, isLatest = false) {
249249 // Generate sidebar for this version
250250 generateVersionedSidebar ( version , versionedPath ) ;
251251
252- // If this is the latest version, ALSO copy to main docs directory
253- if ( isLatest ) {
254- console . log ( 'Also copying latest version to main docs directory...' ) ;
255- const mainDocsPath = path . join ( SITE_DIR , 'docs' ) ;
256- fs . rmSync ( mainDocsPath , { recursive : true , force : true } ) ;
257- copyDirectory ( outputPath , mainDocsPath ) ;
258- }
259-
260252 // Copy images to static directory with version prefix
261253 const versionedImagesPath = path . join ( SITE_DIR , 'static' , 'img' , `v${ version } ` ) ;
262254 if ( fs . existsSync ( path . join ( tempVersionDir , 'images' ) ) ) {
@@ -556,10 +548,9 @@ async function migrate() {
556548 const versions = [ ] ;
557549 for ( let i = 0 ; i < RELEASE_BRANCHES . length ; i ++ ) {
558550 const branch = RELEASE_BRANCHES [ i ] ;
559- const isLatest = i === RELEASE_BRANCHES . length - 1 ;
560551
561552 try {
562- const version = processBranch ( branch , isLatest ) ;
553+ const version = processBranch ( branch ) ;
563554 versions . push ( version ) ; // Add all versions, including the latest
564555 } catch ( error ) {
565556 console . error ( `Failed to process ${ branch } :` , error . message ) ;
@@ -570,6 +561,45 @@ async function migrate() {
570561 // Generate versions.json
571562 generateVersionsJson ( versions ) ;
572563
564+ // Process main branch docs (current/vNext content) and convert them in-place
565+ console . log ( '\n=== Processing main branch docs (current/vNext) ===' ) ;
566+ console . log ( 'Converting main branch /docs from GitBook to Docusaurus format (in-place)...' ) ;
567+
568+ if ( fs . existsSync ( DOCS_DIR ) ) {
569+ // Create temp directory for main branch conversion
570+ const tempMainDir = path . join ( TEMP_DIR , 'main-branch' ) ;
571+ fs . mkdirSync ( tempMainDir , { recursive : true } ) ;
572+
573+ // Copy main branch docs and images to temp
574+ copyDirectory ( DOCS_DIR , path . join ( tempMainDir , 'docs' ) ) ;
575+ if ( fs . existsSync ( IMAGES_DIR ) ) {
576+ copyDirectory ( IMAGES_DIR , path . join ( tempMainDir , 'images' ) ) ;
577+ }
578+
579+ // Set IMAGES_PATH for conversion
580+ const originalImagesPath = process . env . IMAGES_PATH ;
581+ process . env . IMAGES_PATH = path . join ( tempMainDir , 'images' ) ;
582+
583+ // Convert main branch docs
584+ const mainDocsInput = path . join ( tempMainDir , 'docs' ) ;
585+ const mainDocsOutput = path . join ( tempMainDir , 'converted-docs' ) ;
586+ convertGitBookToDocusaurus ( mainDocsInput , mainDocsOutput , mainDocsInput , mainDocsOutput ) ;
587+
588+ // Replace root /docs with converted version
589+ console . log ( 'Replacing root /docs with converted Docusaurus format...' ) ;
590+ fs . rmSync ( DOCS_DIR , { recursive : true , force : true } ) ;
591+ copyDirectory ( mainDocsOutput , DOCS_DIR ) ;
592+
593+ // Restore IMAGES_PATH
594+ if ( originalImagesPath ) {
595+ process . env . IMAGES_PATH = originalImagesPath ;
596+ } else {
597+ delete process . env . IMAGES_PATH ;
598+ }
599+
600+ console . log ( '✓ Main branch /docs converted to Docusaurus format (in-place)' ) ;
601+ }
602+
573603 // Clean up temp directory
574604 console . log ( '\nCleaning up temporary files...' ) ;
575605 fs . rmSync ( TEMP_DIR , { recursive : true , force : true } ) ;
0 commit comments