1
1
// @ts -check
2
- const path = require ( "path" ) ;
3
- const fs = require ( "fs" ) ;
4
- const log = require ( "fancy-log" ) ;
5
- const newer = require ( "gulp-newer" ) ;
6
- const sourcemaps = require ( "gulp-sourcemaps" ) ;
7
- const del = require ( "del" ) ;
8
- const rename = require ( "gulp-rename" ) ;
9
- const concat = require ( "gulp-concat" ) ;
10
- const merge2 = require ( "merge2" ) ;
11
- const { src, dest, task, parallel, series, watch } = require ( "gulp" ) ;
12
- const { append, transform } = require ( "gulp-insert" ) ;
13
- const { prependFile } = require ( "./scripts/build/prepend" ) ;
14
- const { exec, readJson, needsUpdate, getDiffTool, getDirSize, rm } = require ( "./scripts/build/utils" ) ;
15
- const { runConsoleTests, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require ( "./scripts/build/tests" ) ;
16
- const { buildProject, cleanProject, watchProject } = require ( "./scripts/build/projects" ) ;
17
- const cmdLineOptions = require ( "./scripts/build/options" ) ;
2
+ import path from "path" ;
3
+ import fs from "fs" ;
4
+ import log from "fancy-log" ;
5
+ import newer from "gulp-newer" ;
6
+ import sourcemaps from "gulp-sourcemaps" ;
7
+ import del from "del" ;
8
+ import rename from "gulp-rename" ;
9
+ import concat from "gulp-concat" ;
10
+ import merge2 from "merge2" ;
11
+ import gulp from "gulp" ;
12
+ import { append , transform } from "gulp-insert" ;
13
+ import { prependFile } from "./scripts/build/prepend.mjs" ;
14
+ import { exec , readJson , needsUpdate , getDiffTool , getDirSize , rm } from "./scripts/build/utils.mjs" ;
15
+ import { runConsoleTests , refBaseline , localBaseline , refRwcBaseline , localRwcBaseline } from "./scripts/build/tests.mjs" ;
16
+ import { buildProject , cleanProject , watchProject } from "./scripts/build/projects.mjs" ;
17
+ import cmdLineOptions from "./scripts/build/options.mjs" ;
18
+
19
+ const { src, dest, task, parallel, series, watch } = gulp ;
18
20
19
21
const copyright = "CopyrightNotice.txt" ;
20
22
const cleanTasks = [ ] ;
@@ -23,9 +25,6 @@ const buildScripts = () => buildProject("scripts");
23
25
task ( "scripts" , buildScripts ) ;
24
26
task ( "scripts" ) . description = "Builds files in the 'scripts' folder." ;
25
27
26
- const cleanScripts = ( ) => cleanProject ( "scripts" ) ;
27
- cleanTasks . push ( cleanScripts ) ;
28
-
29
28
/** @type {{ libs: string[]; paths: Record<string, string | undefined>; } } */
30
29
const libraries = readJson ( "./src/lib/libs.json" ) ;
31
30
const libs = libraries . libs . map ( lib => {
@@ -56,10 +55,10 @@ const diagnosticMessagesJson = "src/compiler/diagnosticMessages.json";
56
55
const diagnosticMessagesGeneratedJson = "src/compiler/diagnosticMessages.generated.json" ;
57
56
const generateDiagnostics = async ( ) => {
58
57
if ( needsUpdate ( diagnosticMessagesJson , [ diagnosticMessagesGeneratedJson , diagnosticInformationMapTs ] ) ) {
59
- await exec ( process . execPath , [ "scripts/processDiagnosticMessages.js " , diagnosticMessagesJson ] ) ;
58
+ await exec ( process . execPath , [ "scripts/processDiagnosticMessages.mjs " , diagnosticMessagesJson ] ) ;
60
59
}
61
60
} ;
62
- task ( "generate-diagnostics" , series ( buildScripts , generateDiagnostics ) ) ;
61
+ task ( "generate-diagnostics" , generateDiagnostics ) ;
63
62
task ( "generate-diagnostics" ) . description = "Generates a diagnostic file in TypeScript based on an input JSON file" ;
64
63
65
64
const cleanDiagnostics = ( ) => del ( [ diagnosticInformationMapTs , diagnosticMessagesGeneratedJson ] ) ;
@@ -88,7 +87,7 @@ const localizationTargets = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt
88
87
89
88
const localize = async ( ) => {
90
89
if ( needsUpdate ( diagnosticMessagesGeneratedJson , generatedLCGFile ) ) {
91
- return exec ( process . execPath , [ "scripts/generateLocalizedDiagnosticMessages.js " , "src/loc/lcl" , "built/local" , diagnosticMessagesGeneratedJson ] , { ignoreExitCode : true } ) ;
90
+ return exec ( process . execPath , [ "scripts/generateLocalizedDiagnosticMessages.mjs " , "src/loc/lcl" , "built/local" , diagnosticMessagesGeneratedJson ] , { ignoreExitCode : true } ) ;
92
91
}
93
92
} ;
94
93
@@ -97,7 +96,7 @@ const cleanDebugTools = () => cleanProject("src/debug");
97
96
cleanTasks . push ( cleanDebugTools ) ;
98
97
99
98
// Pre-build steps when targeting the LKG compiler
100
- const lkgPreBuild = parallel ( generateLibs , series ( buildScripts , generateDiagnostics , buildDebugTools ) ) ;
99
+ const lkgPreBuild = parallel ( generateLibs , series ( generateDiagnostics , buildDebugTools ) ) ;
101
100
102
101
const buildTsc = ( ) => buildProject ( "src/tsc" ) ;
103
102
task ( "tsc" , series ( lkgPreBuild , buildTsc ) ) ;
@@ -113,7 +112,7 @@ task("watch-tsc", series(lkgPreBuild, parallel(watchLib, watchDiagnostics, watch
113
112
task ( "watch-tsc" ) . description = "Watch for changes and rebuild the command-line compiler only." ;
114
113
115
114
// Pre-build steps when targeting the built/local compiler.
116
- const localPreBuild = parallel ( generateLibs , series ( buildScripts , generateDiagnostics , buildDebugTools , buildTsc ) ) ;
115
+ const localPreBuild = parallel ( generateLibs , series ( generateDiagnostics , buildDebugTools , buildTsc ) ) ;
117
116
118
117
// Pre-build steps to use based on supplied options.
119
118
const preBuild = cmdLineOptions . lkg ? lkgPreBuild : localPreBuild ;
@@ -335,17 +334,8 @@ task("clean-tests").description = "Cleans the outputs for the test infrastructur
335
334
336
335
const watchTests = ( ) => watchProject ( "src/testRunner" , cmdLineOptions ) ;
337
336
338
- const buildEslintRules = ( ) => buildProject ( "scripts/eslint" ) ;
339
- task ( "build-eslint-rules" , buildEslintRules ) ;
340
- task ( "build-eslint-rules" ) . description = "Compiles eslint rules to js" ;
341
-
342
- const cleanEslintRules = ( ) => cleanProject ( "scripts/eslint" ) ;
343
- cleanTasks . push ( cleanEslintRules ) ;
344
- task ( "clean-eslint-rules" , cleanEslintRules ) ;
345
- task ( "clean-eslint-rules" ) . description = "Cleans the outputs for the eslint rules" ;
346
-
347
- const runEslintRulesTests = ( ) => runConsoleTests ( "scripts/eslint/built/tests" , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , /*watchMode*/ false ) ;
348
- task ( "run-eslint-rules-tests" , series ( buildEslintRules , runEslintRulesTests ) ) ;
337
+ const runEslintRulesTests = ( ) => runConsoleTests ( "scripts/eslint/tests" , "mocha-fivemat-progress-reporter" , /*runInParallel*/ false , /*watchMode*/ false ) ;
338
+ task ( "run-eslint-rules-tests" , runEslintRulesTests ) ;
349
339
task ( "run-eslint-rules-tests" ) . description = "Runs the eslint rule tests" ;
350
340
351
341
/** @type { (folder: string) => { (): Promise<any>; displayName?: string } } */
@@ -459,8 +449,8 @@ task("runtests-parallel").flags = {
459
449
} ;
460
450
461
451
462
- task ( "test-browser-integration" , ( ) => exec ( process . execPath , [ "scripts/browserIntegrationTest.js " ] ) ) ;
463
- task ( "test-browser-integration" ) . description = "Runs scripts/browserIntegrationTest.ts which tests that typescript.js loads in a browser" ;
452
+ task ( "test-browser-integration" , ( ) => exec ( process . execPath , [ "scripts/browserIntegrationTest.mjs " ] ) ) ;
453
+ task ( "test-browser-integration" ) . description = "Runs scripts/browserIntegrationTest.mjs which tests that typescript.js loads in a browser" ;
464
454
465
455
466
456
task ( "diff" , ( ) => exec ( getDiffTool ( ) , [ refBaseline , localBaseline ] , { ignoreExitCode : true , waitForExit : false } ) ) ;
@@ -493,13 +483,9 @@ const updateSublime = () => src(["built/local/tsserver.js", "built/local/tsserve
493
483
task ( "update-sublime" , updateSublime ) ;
494
484
task ( "update-sublime" ) . description = "Updates the sublime plugin's tsserver" ;
495
485
496
- const buildImportDefinitelyTypedTests = ( ) => buildProject ( "scripts/importDefinitelyTypedTests" ) ;
497
- const cleanImportDefinitelyTypedTests = ( ) => cleanProject ( "scripts/importDefinitelyTypedTests" ) ;
498
- cleanTasks . push ( cleanImportDefinitelyTypedTests ) ;
499
-
500
486
// TODO(rbuckton): Should the path to DefinitelyTyped be configurable via an environment variable?
501
- const importDefinitelyTypedTests = ( ) => exec ( process . execPath , [ "scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js " , "./" , "../DefinitelyTyped" ] ) ;
502
- task ( "importDefinitelyTypedTests" , series ( buildImportDefinitelyTypedTests , importDefinitelyTypedTests ) ) ;
487
+ const importDefinitelyTypedTests = ( ) => exec ( process . execPath , [ "scripts/importDefinitelyTypedTests.mjs " , "./" , "../DefinitelyTyped" ] ) ;
488
+ task ( "importDefinitelyTypedTests" , importDefinitelyTypedTests ) ;
503
489
task ( "importDefinitelyTypedTests" ) . description = "Runs the importDefinitelyTypedTests script to copy DT's tests to the TS-internal RWC tests" ;
504
490
505
491
const buildReleaseTsc = ( ) => buildProject ( "src/tsc/tsconfig.release.json" ) ;
@@ -529,7 +515,7 @@ const produceLKG = async () => {
529
515
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" ) ) ;
530
516
}
531
517
const sizeBefore = getDirSize ( "lib" ) ;
532
- await exec ( process . execPath , [ "scripts/produceLKG.js " ] ) ;
518
+ await exec ( process . execPath , [ "scripts/produceLKG.mjs " ] ) ;
533
519
const sizeAfter = getDirSize ( "lib" ) ;
534
520
if ( sizeAfter > ( sizeBefore * 1.10 ) ) {
535
521
throw new Error ( "The lib folder increased by 10% or more. This likely indicates a bug." ) ;
@@ -543,8 +529,8 @@ task("LKG").flags = {
543
529
} ;
544
530
task ( "lkg" , series ( "LKG" ) ) ;
545
531
546
- const generateSpec = ( ) => exec ( "cscript" , [ "//nologo" , "scripts/word2md.js " , path . resolve ( "doc/TypeScript Language Specification - ARCHIVED.docx" ) , path . resolve ( "doc/spec-ARCHIVED.md" ) ] ) ;
547
- task ( "generate-spec" , series ( buildScripts , generateSpec ) ) ;
532
+ const generateSpec = ( ) => exec ( "cscript" , [ "//nologo" , "scripts/word2md.mjs " , path . resolve ( "doc/TypeScript Language Specification - ARCHIVED.docx" ) , path . resolve ( "doc/spec-ARCHIVED.md" ) ] ) ;
533
+ task ( "generate-spec" , generateSpec ) ;
548
534
task ( "generate-spec" ) . description = "Generates a Markdown version of the Language Specification" ;
549
535
550
536
task ( "clean" , series ( parallel ( cleanTasks ) , cleanBuilt ) ) ;
@@ -554,13 +540,13 @@ const configureNightly = () => exec(process.execPath, ["scripts/configurePrerele
554
540
task ( "configure-nightly" , series ( buildScripts , configureNightly ) ) ;
555
541
task ( "configure-nightly" ) . description = "Runs scripts/configurePrerelease.ts to prepare a build for nightly publishing" ;
556
542
557
- const configureInsiders = ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.js " , "insiders" , "package.json" , "src/compiler/corePublic.ts" ] ) ;
558
- task ( "configure-insiders" , series ( buildScripts , configureInsiders ) ) ;
559
- task ( "configure-insiders" ) . description = "Runs scripts/configurePrerelease.ts to prepare a build for insiders publishing" ;
543
+ const configureInsiders = ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs " , "insiders" , "package.json" , "src/compiler/corePublic.ts" ] ) ;
544
+ task ( "configure-insiders" , configureInsiders ) ;
545
+ task ( "configure-insiders" ) . description = "Runs scripts/configurePrerelease.mjs to prepare a build for insiders publishing" ;
560
546
561
- const configureExperimental = ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.js " , "experimental" , "package.json" , "src/compiler/corePublic.ts" ] ) ;
562
- task ( "configure-experimental" , series ( buildScripts , configureExperimental ) ) ;
563
- task ( "configure-experimental" ) . description = "Runs scripts/configurePrerelease.ts to prepare a build for experimental publishing" ;
547
+ const configureExperimental = ( ) => exec ( process . execPath , [ "scripts/configurePrerelease.mjs " , "experimental" , "package.json" , "src/compiler/corePublic.ts" ] ) ;
548
+ task ( "configure-experimental" , configureExperimental ) ;
549
+ task ( "configure-experimental" ) . description = "Runs scripts/configurePrerelease.mjs to prepare a build for experimental publishing" ;
564
550
565
551
const publishNightly = ( ) => exec ( "npm" , [ "publish" , "--tag" , "next" ] ) ;
566
552
task ( "publish-nightly" , series ( task ( "clean" ) , task ( "LKG" ) , task ( "clean" ) , task ( "runtests-parallel" ) , publishNightly ) ) ;
0 commit comments