@@ -6,8 +6,23 @@ import { task } from "hereby";
6
6
import _glob from "glob" ;
7
7
import util from "util" ;
8
8
import chalk from "chalk" ;
9
- import { Debouncer , Deferred , exec , getDiffTool , getDirSize , memoize , needsUpdate , readJson } from "./scripts/build/utils.mjs" ;
10
- import { localBaseline , localRwcBaseline , refBaseline , refRwcBaseline , runConsoleTests } from "./scripts/build/tests.mjs" ;
9
+ import {
10
+ Debouncer ,
11
+ Deferred ,
12
+ exec ,
13
+ getDiffTool ,
14
+ getDirSize ,
15
+ memoize ,
16
+ needsUpdate ,
17
+ readJson ,
18
+ } from "./scripts/build/utils.mjs" ;
19
+ import {
20
+ localBaseline ,
21
+ localRwcBaseline ,
22
+ refBaseline ,
23
+ refRwcBaseline ,
24
+ runConsoleTests ,
25
+ } from "./scripts/build/tests.mjs" ;
11
26
import { buildProject , cleanProject , watchProject } from "./scripts/build/projects.mjs" ;
12
27
import { localizationDirectories } from "./scripts/build/localization.mjs" ;
13
28
import cmdLineOptions from "./scripts/build/options.mjs" ;
@@ -109,7 +124,12 @@ const localize = task({
109
124
dependencies : [ generateDiagnostics ] ,
110
125
run : async ( ) => {
111
126
if ( needsUpdate ( diagnosticMessagesGeneratedJson , generatedLCGFile ) ) {
112
- await exec ( process . execPath , [ "scripts/generateLocalizedDiagnosticMessages.mjs" , "src/loc/lcl" , "built/local" , diagnosticMessagesGeneratedJson ] , { ignoreExitCode : true } ) ;
127
+ await exec ( process . execPath , [
128
+ "scripts/generateLocalizedDiagnosticMessages.mjs" ,
129
+ "src/loc/lcl" ,
130
+ "built/local" ,
131
+ diagnosticMessagesGeneratedJson ,
132
+ ] , { ignoreExitCode : true } ) ;
113
133
}
114
134
} ,
115
135
} ) ;
@@ -195,7 +215,9 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
195
215
//
196
216
// See: https://github.com/evanw/esbuild/issues/1958
197
217
return {
198
- errors : [ { text : 'Attempted to bundle from node_modules; ensure "external" is set correctly.' } ] ,
218
+ errors : [ {
219
+ text : 'Attempted to bundle from node_modules; ensure "external" is set correctly.' ,
220
+ } ] ,
199
221
} ;
200
222
} ) ;
201
223
} ,
@@ -237,7 +259,8 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
237
259
238
260
return {
239
261
build : async ( ) => esbuild . build ( await getOptions ( ) ) ,
240
- watch : async ( ) => esbuild . build ( { ...await getOptions ( ) , watch : taskOptions . watchMode ?? true , logLevel : "info" } ) ,
262
+ watch : async ( ) =>
263
+ esbuild . build ( { ...await getOptions ( ) , watch : taskOptions . watchMode ?? true , logLevel : "info" } ) ,
241
264
} ;
242
265
}
243
266
@@ -288,7 +311,10 @@ function entrypointBuildTask(options) {
288
311
const outDir = path . dirname ( options . output ) ;
289
312
await fs . promises . mkdir ( outDir , { recursive : true } ) ;
290
313
const moduleSpecifier = path . relative ( outDir , options . builtEntrypoint ) ;
291
- await fs . promises . writeFile ( options . output , `module.exports = require("./${ moduleSpecifier . replace ( / [ \\ / ] / g, "/" ) } ")` ) ;
314
+ await fs . promises . writeFile (
315
+ options . output ,
316
+ `module.exports = require("./${ moduleSpecifier . replace ( / [ \\ / ] / g, "/" ) } ")` ,
317
+ ) ;
292
318
} ,
293
319
} ) ;
294
320
@@ -312,13 +338,19 @@ function entrypointBuildTask(options) {
312
338
const watch = task ( {
313
339
name : `watch-${ options . name } ` ,
314
340
hiddenFromTaskList : true , // This is best effort.
315
- dependencies : ( options . buildDeps ?? [ ] ) . concat ( options . mainDeps ?? [ ] ) . concat ( cmdLineOptions . bundle ? [ ] : [ shim ] ) ,
341
+ dependencies : ( options . buildDeps ?? [ ] ) . concat ( options . mainDeps ?? [ ] ) . concat (
342
+ cmdLineOptions . bundle ? [ ] : [ shim ] ,
343
+ ) ,
316
344
run : ( ) => {
317
345
// These watch functions return promises that resolve once watch mode has started,
318
346
// allowing them to operate as regular tasks, while creating unresolved promises
319
347
// in the background that keep the process running after all tasks have exited.
320
348
if ( ! printedWatchWarning ) {
321
- console . error ( chalk . yellowBright ( "Warning: watch mode is incomplete and may not work as expected. Use at your own risk." ) ) ;
349
+ console . error (
350
+ chalk . yellowBright (
351
+ "Warning: watch mode is incomplete and may not work as expected. Use at your own risk." ,
352
+ ) ,
353
+ ) ;
322
354
printedWatchWarning = true ;
323
355
}
324
356
@@ -362,7 +394,12 @@ export const dtsServices = task({
362
394
description : "Bundles typescript.d.ts" ,
363
395
dependencies : [ buildServices ] ,
364
396
run : async ( ) => {
365
- if ( needsUpdate ( "./built/local/typescript/tsconfig.tsbuildinfo" , [ "./built/local/typescript.d.ts" , "./built/local/typescript.internal.d.ts" ] ) ) {
397
+ if (
398
+ needsUpdate ( "./built/local/typescript/tsconfig.tsbuildinfo" , [
399
+ "./built/local/typescript.d.ts" ,
400
+ "./built/local/typescript.internal.d.ts" ,
401
+ ] )
402
+ ) {
366
403
await runDtsBundler ( "./built/local/typescript/typescript.d.ts" , "./built/local/typescript.d.ts" ) ;
367
404
}
368
405
} ,
@@ -411,8 +448,16 @@ export const dtsLssl = task({
411
448
description : "Bundles tsserverlibrary.d.ts" ,
412
449
dependencies : [ buildLssl ] ,
413
450
run : async ( ) => {
414
- if ( needsUpdate ( "./built/local/tsserverlibrary/tsconfig.tsbuildinfo" , [ "./built/local/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.internal.d.ts" ] ) ) {
415
- await runDtsBundler ( "./built/local/tsserverlibrary/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.d.ts" ) ;
451
+ if (
452
+ needsUpdate ( "./built/local/tsserverlibrary/tsconfig.tsbuildinfo" , [
453
+ "./built/local/tsserverlibrary.d.ts" ,
454
+ "./built/local/tsserverlibrary.internal.d.ts" ,
455
+ ] )
456
+ ) {
457
+ await runDtsBundler (
458
+ "./built/local/tsserverlibrary/tsserverlibrary.d.ts" ,
459
+ "./built/local/tsserverlibrary.d.ts" ,
460
+ ) ;
416
461
}
417
462
} ,
418
463
} ) ;
@@ -545,7 +590,13 @@ export const watchOtherOutputs = task({
545
590
name : "watch-other-outputs" ,
546
591
description : "Builds miscelaneous scripts and documents distributed with the LKG" ,
547
592
hiddenFromTaskList : true ,
548
- dependencies : [ watchCancellationToken , watchTypingsInstaller , watchWatchGuard , generateTypesMap , copyBuiltLocalDiagnosticMessages ] ,
593
+ dependencies : [
594
+ watchCancellationToken ,
595
+ watchTypingsInstaller ,
596
+ watchWatchGuard ,
597
+ generateTypesMap ,
598
+ copyBuiltLocalDiagnosticMessages ,
599
+ ] ,
549
600
} ) ;
550
601
551
602
export const local = task ( {
@@ -623,7 +674,10 @@ export const runTestsAndWatch = task({
623
674
if ( ! token . signaled ) {
624
675
running = true ;
625
676
try {
626
- await runConsoleTests ( testRunner , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , { token, watching : true } ) ;
677
+ await runConsoleTests ( testRunner , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , {
678
+ token,
679
+ watching : true ,
680
+ } ) ;
627
681
}
628
682
catch {
629
683
// ignore
@@ -782,7 +836,10 @@ export const updateSublime = task({
782
836
dependencies : [ tsserver ] ,
783
837
run : async ( ) => {
784
838
for ( const file of [ "built/local/tsserver.js" , "built/local/tsserver.js.map" ] ) {
785
- await fs . promises . copyFile ( file , path . resolve ( "../TypeScript-Sublime-Plugin/tsserver/" , path . basename ( file ) ) ) ;
839
+ await fs . promises . copyFile (
840
+ file ,
841
+ path . resolve ( "../TypeScript-Sublime-Plugin/tsserver/" , path . basename ( file ) ) ,
842
+ ) ;
786
843
}
787
844
} ,
788
845
} ) ;
@@ -818,7 +875,10 @@ export const produceLKG = task({
818
875
. concat ( localizationTargets )
819
876
. filter ( f => ! fs . existsSync ( f ) ) ;
820
877
if ( missingFiles . length > 0 ) {
821
- throw new Error ( "Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n" + missingFiles . join ( "\n" ) ) ;
878
+ throw new Error (
879
+ "Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n"
880
+ + missingFiles . join ( "\n" ) ,
881
+ ) ;
822
882
}
823
883
const sizeBefore = getDirSize ( "lib" ) ;
824
884
await exec ( process . execPath , [ "scripts/produceLKG.mjs" ] ) ;
@@ -839,7 +899,13 @@ export const generateSpec = task({
839
899
name : "generate-spec" ,
840
900
description : "Generates a Markdown version of the Language Specification" ,
841
901
hiddenFromTaskList : true ,
842
- run : ( ) => exec ( "cscript" , [ "//nologo" , "scripts/word2md.mjs" , path . resolve ( "doc/TypeScript Language Specification - ARCHIVED.docx" ) , path . resolve ( "doc/spec-ARCHIVED.md" ) ] ) ,
902
+ run : ( ) =>
903
+ exec ( "cscript" , [
904
+ "//nologo" ,
905
+ "scripts/word2md.mjs" ,
906
+ path . resolve ( "doc/TypeScript Language Specification - ARCHIVED.docx" ) ,
907
+ path . resolve ( "doc/spec-ARCHIVED.md" ) ,
908
+ ] ) ,
843
909
} ) ;
844
910
845
911
export const cleanBuilt = task ( {
@@ -857,19 +923,37 @@ export const clean = task({
857
923
export const configureNightly = task ( {
858
924
name : "configure-nightly" ,
859
925
description : "Runs scripts/configurePrerelease.mjs to prepare a build for nightly publishing" ,
860
- run : ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs" , "dev" , "package.json" , "src/compiler/corePublic.ts" ] ) ,
926
+ run : ( ) =>
927
+ exec ( process . execPath , [
928
+ "scripts/configurePrerelease.mjs" ,
929
+ "dev" ,
930
+ "package.json" ,
931
+ "src/compiler/corePublic.ts" ,
932
+ ] ) ,
861
933
} ) ;
862
934
863
935
export const configureInsiders = task ( {
864
936
name : "configure-insiders" ,
865
937
description : "Runs scripts/configurePrerelease.mjs to prepare a build for insiders publishing" ,
866
- run : ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs" , "insiders" , "package.json" , "src/compiler/corePublic.ts" ] ) ,
938
+ run : ( ) =>
939
+ exec ( process . execPath , [
940
+ "scripts/configurePrerelease.mjs" ,
941
+ "insiders" ,
942
+ "package.json" ,
943
+ "src/compiler/corePublic.ts" ,
944
+ ] ) ,
867
945
} ) ;
868
946
869
947
export const configureExperimental = task ( {
870
948
name : "configure-experimental" ,
871
949
description : "Runs scripts/configurePrerelease.mjs to prepare a build for experimental publishing" ,
872
- run : ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs" , "experimental" , "package.json" , "src/compiler/corePublic.ts" ] ) ,
950
+ run : ( ) =>
951
+ exec ( process . execPath , [
952
+ "scripts/configurePrerelease.mjs" ,
953
+ "experimental" ,
954
+ "package.json" ,
955
+ "src/compiler/corePublic.ts" ,
956
+ ] ) ,
873
957
} ) ;
874
958
875
959
export const help = task ( {
0 commit comments