1313 * build context logging to `Element/Sky/Source/Function/Debug.ts`.
1414 *--------------------------------------------------------------------------------------------*/
1515
16- import { copyFile , cp , mkdir , readdir , readFile , writeFile } from "node:fs/promises" ;
16+ import {
17+ copyFile ,
18+ cp ,
19+ mkdir ,
20+ readdir ,
21+ readFile ,
22+ writeFile ,
23+ } from "node:fs/promises" ;
1724import { join , resolve } from "node:path" ;
1825import { fileURLToPath } from "node:url" ;
1926
@@ -63,7 +70,9 @@ export default defineConfig({
6370 "astro:build:done" : async ( { dir } ) => {
6471 const BuildStart = performance . now ( ) ;
6572 const StepTimings : Record < string , number > = { } ;
66- const StepMark = ( Step : string ) => { StepTimings [ Step ] = performance . now ( ) - BuildStart ; } ;
73+ const StepMark = ( Step : string ) => {
74+ StepTimings [ Step ] = performance . now ( ) - BuildStart ;
75+ } ;
6776
6877 const TargetDir = fileURLToPath ( dir ) ;
6978
@@ -274,10 +283,14 @@ export default defineConfig({
274283 try {
275284 await readFile ( OutputServicePath ) ;
276285 TauriServiceSource = OutputServicePath ;
277- console . log ( "[CopyVSCode] Step 7: Using Output/Configuration/Service/TauriMainProcessService.js" ) ;
286+ console . log (
287+ "[CopyVSCode] Step 7: Using Output/Configuration/Service/TauriMainProcessService.js" ,
288+ ) ;
278289 } catch {
279290 TauriServiceSource = WindServicePath ;
280- console . log ( "[CopyVSCode] Step 7: Falling back to Wind/Target/Service/TauriMainProcessService.js" ) ;
291+ console . log (
292+ "[CopyVSCode] Step 7: Falling back to Wind/Target/Service/TauriMainProcessService.js" ,
293+ ) ;
281294 }
282295
283296 // Copy the compiled service as a separate module
@@ -294,7 +307,10 @@ export default defineConfig({
294307 if ( ServiceJS . includes ( "sourceMappingURL" ) ) {
295308 await writeFile (
296309 join ( IPCDir , "TauriMainProcessService.js" ) ,
297- ServiceJS . replace ( / \/ \/ # s o u r c e M a p p i n g U R L = .* / g, "" ) ,
310+ ServiceJS . replace (
311+ / \/ \/ # s o u r c e M a p p i n g U R L = .* / g,
312+ "" ,
313+ ) ,
298314 "utf-8" ,
299315 ) ;
300316 }
@@ -582,36 +598,55 @@ export default defineConfig({
582598 "[CopyVSCode] Step 12: Created stubs for unpublished addons" ,
583599 ) ;
584600
585- // Step 13: Copy built-in extensions from VS Code build output.
586- // `npm run gulp compile-extensions-build` produces .build/extensions/
601+ // Step 13: Copy built-in extensions.
602+ // Primary: .build/extensions/ (compiled via gulp compile-extensions-build)
603+ // Fallback: extensions/ (source — themes, snippets, grammars work uncompiled)
587604 // Mountain scans Static/Application/extensions/ at startup.
588- const ExtensionsSource = resolve (
589- process . cwd ( ) ,
590- "../../Dependency/Microsoft/Dependency/Editor/.build/extensions" ,
591- ) ;
592605 const ExtensionsTarget = join (
593606 TargetDir ,
594607 "Static/Application/extensions" ,
595608 ) ;
596- try {
597- const ExtDirs = await readdir ( ExtensionsSource ) ;
598- let Copied = 0 ;
599- for ( const Ext of ExtDirs ) {
600- const Source = join ( ExtensionsSource , Ext ) ;
601- const Dest = join ( ExtensionsTarget , Ext ) ;
602- try {
603- await cp ( Source , Dest , { recursive : true } ) ;
604- Copied ++ ;
605- } catch {
606- // Skip broken extensions
609+ const ExtensionsSources = [
610+ resolve (
611+ process . cwd ( ) ,
612+ "../../Dependency/Microsoft/Dependency/Editor/.build/extensions" ,
613+ ) ,
614+ resolve (
615+ process . cwd ( ) ,
616+ "../../Dependency/Microsoft/Dependency/Editor/extensions" ,
617+ ) ,
618+ ] ;
619+ let ExtensionsCopied = false ;
620+ for ( const ExtensionsSource of ExtensionsSources ) {
621+ try {
622+ const ExtDirs = await readdir ( ExtensionsSource ) ;
623+ let Copied = 0 ;
624+ for ( const Ext of ExtDirs ) {
625+ const Source = join ( ExtensionsSource , Ext ) ;
626+ const PkgPath = join ( Source , "package.json" ) ;
627+ try {
628+ await readFile ( PkgPath ) ;
629+ const Dest = join ( ExtensionsTarget , Ext ) ;
630+ await cp ( Source , Dest , { recursive : true } ) ;
631+ Copied ++ ;
632+ } catch {
633+ // Skip dirs without package.json or broken extensions
634+ }
635+ }
636+ if ( Copied > 0 ) {
637+ console . log (
638+ `[CopyVSCode] Step 13: Copied ${ Copied } built-in extensions from ${ ExtensionsSource } ` ,
639+ ) ;
640+ ExtensionsCopied = true ;
641+ break ;
607642 }
643+ } catch {
644+ // Source dir not found, try next
608645 }
609- console . log (
610- `[CopyVSCode] Step 13: Copied ${ Copied } /${ ExtDirs . length } built-in extensions` ,
611- ) ;
612- } catch {
646+ }
647+ if ( ! ExtensionsCopied ) {
613648 console . warn (
614- "[CopyVSCode] Step 13: No built-in extensions found (run: npm run gulp compile-extensions-build) " ,
649+ "[CopyVSCode] Step 13: No built-in extensions found" ,
615650 ) ;
616651 }
617652
@@ -623,25 +658,42 @@ export default defineConfig({
623658 try {
624659 const { request } = await import ( "node:https" ) ;
625660 const Body = JSON . stringify ( {
626- api_key : "phc_mCwHy7LgvbnEqh6a2DyMiLUJcaZvmmj7JNmmpQzvr7mA" ,
661+ api_key :
662+ "phc_mCwHy7LgvbnEqh6a2DyMiLUJcaZvmmj7JNmmpQzvr7mA" ,
627663 event : "sky:build:complete" ,
628664 properties : {
629665 distinct_id : `land-dev-${ process . env [ "USER" ] || "unknown" } ` ,
630666 $app : "land-editor" ,
631667 $component : "sky" ,
632- $build_mode : process . env [ "NODE_ENV" ] || "development" ,
633- electron : process . env [ "Electron" ] || "false" ,
634- total_ms : Math . round ( performance . now ( ) - BuildStart ) ,
668+ $build_mode :
669+ process . env [ "NODE_ENV" ] ||
670+ "development" ,
671+ electron :
672+ process . env [ "Electron" ] || "false" ,
673+ total_ms : Math . round (
674+ performance . now ( ) - BuildStart ,
675+ ) ,
635676 steps : StepTimings ,
636677 } ,
637678 timestamp : new Date ( ) . toISOString ( ) ,
638679 } ) ;
639- const Url = new URL ( "https://eu.i.posthog.com/capture/" ) ;
640- const Req = request ( { hostname : Url . hostname , port : 443 , path : Url . pathname , method : "POST" , headers : { "Content-Type" : "application/json" , "Content-Length" : Buffer . byteLength ( Body ) } } ) ;
680+ const Url = new URL (
681+ "https://eu.i.posthog.com/capture/" ,
682+ ) ;
683+ const Req = request ( {
684+ hostname : Url . hostname ,
685+ port : 443 ,
686+ path : Url . pathname ,
687+ method : "POST" ,
688+ headers : {
689+ "Content-Type" : "application/json" ,
690+ "Content-Length" : Buffer . byteLength ( Body ) ,
691+ } ,
692+ } ) ;
641693 Req . on ( "error" , ( ) => { } ) ;
642694 Req . write ( Body ) ;
643695 Req . end ( ) ;
644- } catch { } ;
696+ } catch { }
645697 }
646698 } ,
647699 } ,
0 commit comments