@@ -15,19 +15,19 @@ const scriptConfig = {
1515} ;
1616
1717const watchConfig = {
18- watch : {
19- onRebuild ( error , result ) {
20- console . log ( "[watch] build started" ) ;
21- if ( error ) {
22- error . errors . forEach ( error =>
23- console . error ( `> ${ error . location . file } :${ error . location . line } :${ error . location . column } : error: ${ error . text } ` )
24- ) ;
25- } else {
26- console . log ( "[watch] build finished" ) ;
27- }
28- } ,
18+ watch : {
19+ onRebuild ( error , result ) {
20+ console . log ( "[watch] build started" ) ;
21+ if ( error ) {
22+ error . errors . forEach ( error =>
23+ console . error ( `> ${ error . location . file } :${ error . location . line } :${ error . location . column } : error: ${ error . text } ` )
24+ ) ;
25+ } else {
26+ console . log ( "[watch] build finished" ) ;
27+ }
2928 } ,
30- } ;
29+ } ,
30+ } ;
3131
3232const NON_NPM_ARTIFACTORY = new RegExp (
3333 String . raw `"resolved"\s*:\s*"http[s]*://(?!registry.npmjs.org)[^"]+"` ,
@@ -43,26 +43,74 @@ const checkAritfactoryUrl = () => {
4343 }
4444}
4545
46- ( async ( ) => {
47- const args = process . argv . slice ( 2 ) ;
48- try {
49- if ( args . includes ( "--watch" ) ) {
50- // Build and watch source code
51- console . log ( "[watch] build started" ) ;
52- await build ( {
53- ...scriptConfig ,
54- ...watchConfig ,
46+ const createTelemetryConfig = ( ) => {
47+ const defaultConfig = {
48+ telemetryRetryConfig : {
49+ maxRetries : 6 ,
50+ baseCapacity : 256 ,
51+ baseTimer : 5000 ,
52+ maxDelayMs : 100000 ,
53+ backoffFactor : 2 ,
54+ jitterFactor : 0.25
55+ } ,
56+ telemetryApi : {
57+ baseUrl : null ,
58+ baseEndpoint : "/vscode/java/sendTelemetry" ,
59+ version : "/v1"
60+ }
61+ }
62+
63+ const envConfig = Object . freeze ( {
64+ telemetryRetryConfig : {
65+ maxRetries : process . env . TELEMETRY_MAX_RETRIES ,
66+ baseCapacity : process . env . TELEMETRY_BASE_CAPACITY ,
67+ baseTimer : process . env . TELEMETRY_BASE_TIMER ,
68+ maxDelayMs : process . env . TELEMETRY_MAX_DELAY ,
69+ backoffFactor : process . env . TELEMETRY_BACKOFF_FACTOR ,
70+ jitterFactor : process . env . TELEMETRY_JITTER_FACTOR
71+ } ,
72+ telemetryApi : {
73+ baseUrl : process . env . TELEMETRY_API_BASE_URL ,
74+ baseEndpoint : process . env . TELEMETRY_API_ENDPOINT ,
75+ version : process . env . TELEMETRY_API_VERSION
76+ }
77+ } ) ;
78+
79+ Object . entries ( defaultConfig ) . forEach ( ( [ parent , configs ] ) => {
80+ if ( parent in envConfig ) {
81+ Object . entries ( configs ) . forEach ( ( [ key , _ ] ) => {
82+ if ( envConfig [ parent ] ?. [ key ] ) {
83+ defaultConfig [ parent ] [ key ] = envConfig [ parent ] [ key ] ;
84+ }
5585 } ) ;
56- console . log ( "[watch] build finished" ) ;
57- } else if ( args . includes ( "--artifactory-check" ) ) {
58- checkAritfactoryUrl ( ) ;
59- } else {
60- // Build source code
61- await build ( scriptConfig ) ;
62- console . log ( "build complete" ) ;
6386 }
64- } catch ( err ) {
65- process . stderr . write ( err . message ) ;
66- process . exit ( 1 ) ;
87+ } ) ;
88+
89+ fs . writeFileSync ( "telemetryConfig.json" , JSON . stringify ( defaultConfig , null , 4 ) ) ;
90+ console . log ( "Telemetry config generated successfully." ) ;
91+ }
92+
93+ ( async ( ) => {
94+ const args = process . argv . slice ( 2 ) ;
95+ try {
96+ if ( args . includes ( "--watch" ) ) {
97+ // Build and watch source code
98+ console . log ( "[watch] build started" ) ;
99+ await build ( {
100+ ...scriptConfig ,
101+ ...watchConfig ,
102+ } ) ;
103+ console . log ( "[watch] build finished" ) ;
104+ } else if ( args . includes ( "--artifactory-check" ) ) {
105+ checkAritfactoryUrl ( ) ;
106+ } else {
107+ // Build source code
108+ createTelemetryConfig ( ) ;
109+ await build ( scriptConfig ) ;
110+ console . log ( "build complete" ) ;
67111 }
68- } ) ( ) ;
112+ } catch ( err ) {
113+ process . stderr . write ( err . message ) ;
114+ process . exit ( 1 ) ;
115+ }
116+ } ) ( ) ;
0 commit comments