From 8a8a412a7f24542a6b9ed1255ec7e67eadaa2c48 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 14 Jul 2015 16:51:22 -0700 Subject: [PATCH 1/7] Fix file endings. --- src/compiler/program.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5ce4846b43b..ca12f6de03d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -341,7 +341,7 @@ namespace ts { }); } - function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { if (!isDeclarationFile(sourceFile)) { let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); @@ -350,7 +350,7 @@ namespace ts { return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); } }); - } + } function getOptionsDiagnostics(): Diagnostic[] { let allDiagnostics: Diagnostic[] = []; From b8b4c0f5d4a5b72f3418e502f97ef1ede6769ed9 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 14 Jul 2015 17:25:34 -0700 Subject: [PATCH 2/7] Bump version number. --- package.json | 2 +- src/compiler/program.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 82ab734d6f1..54162c53a57 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "1.5.3", + "version": "1.6.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ca12f6de03d..d79f617e1cf 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -8,7 +8,7 @@ namespace ts { /* @internal */ export let ioWriteTime = 0; /** The version of the TypeScript compiler release */ - export const version = "1.5.3"; + export const version = "1.6.0"; export function findConfigFile(searchPath: string): string { let fileName = "tsconfig.json"; From 86b84054506ce6669175141de9655482ed510241 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 14 Jul 2015 18:09:42 -0700 Subject: [PATCH 3/7] Add configureNightly script. --- .gitignore | 1 + scripts/configureNightly.ts | 69 +++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 scripts/configureNightly.ts diff --git a/.gitignore b/.gitignore index 3147b8e8724..58a45545939 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ tests/baselines/reference/projectOutput/* tests/baselines/local/projectOutput/* tests/services/baselines/prototyping/local/* tests/services/browser/typescriptServices.js +scripts/configureNightly.js scripts/processDiagnosticMessages.d.ts scripts/processDiagnosticMessages.js scripts/importDefinitelyTypedTests.js diff --git a/scripts/configureNightly.ts b/scripts/configureNightly.ts new file mode 100644 index 00000000000..a0e30b007cf --- /dev/null +++ b/scripts/configureNightly.ts @@ -0,0 +1,69 @@ +/// + +/** + * A minimal description for a parsed package.json object. + */ +interface PackageJson { + name: string; + version: string; + keywords: string[]; +} + +function main(): void { + const sys = ts.sys; + if (sys.args.length < 2) { + sys.write("Usage:" + sys.newLine) + sys.write("\tnode configureNightly.js " + sys.newLine); + return; + } + + // Acquire the version from the package.json file and modify it appropriately. + const packageJsonFilePath = ts.normalizePath(sys.args[0]); + const packageJsonContents = sys.readFile(packageJsonFilePath); + const packageJsonValue: PackageJson = JSON.parse(packageJsonContents); + + const nightlyVersion = getNightlyVersionString(packageJsonValue.version); + + // Modify the package.json structure + packageJsonValue.version = nightlyVersion; + + if (packageJsonValue.name !== "typescript-nightly") { + packageJsonValue.name = "typescript-nightly"; + packageJsonValue.keywords.push("nightly", "alpha", "beta", "prerelease"); + } + + // Acquire and modify the source file that exposes the version string. + const tsFilePath = ts.normalizePath(sys.args[1]); + const tsFileContents = sys.readFile(tsFilePath); + const versionAssignmentRegExp = /export\s+const\s+version\s+=\s+".*";/; + const modifiedTsFileContents = tsFileContents.replace(versionAssignmentRegExp, `export const version = "${nightlyVersion}";`); + + // Ensure we are actually changing something - the user probably wants to know that the update failed. + if (tsFileContents === modifiedTsFileContents) { + throw `File '${tsFilePath}' did not contain pattern ${versionAssignmentRegExp}`; + } + + // Finally write the changes to disk. + sys.writeFile(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4)) + sys.writeFile(tsFilePath, modifiedTsFileContents); +} + +function getNightlyVersionString(versionString: string): string { + // If the version string already contains "-nightly", + // then get the base string and update based on that. + const dashNightlyPos = versionString.indexOf("-nightly"); + if (dashNightlyPos >= 0) { + versionString = versionString.slice(0, dashNightlyPos); + } + + // We're going to append a representation of the current time at the end of the current version. + // String.prototype.toISOString() returns a 24-character string formatted as 'YYYY-MM-DDTHH:mm:ss.sssZ', + // but we'd prefer to just use hyphens as separators instead of 'T', ':', and '.'. + // The trailing 'Z' in this string can be removed; UTC time will always be implicit here. + const now = new Date(); + const timeStr = now.toISOString().slice(0, -1).replace(/:|T|\./g, "-"); + + return `${versionString}-nightly-${timeStr}`; +} + +main(); \ No newline at end of file From 230ccd6262115605b295802861da175b9f254580 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 12:56:00 -0700 Subject: [PATCH 4/7] Added a 'publish-nightly' task to to the Jakefile. --- Jakefile.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 33ad46c8b58..b1ec9f3024c 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -311,7 +311,7 @@ var processDiagnosticMessagesTs = path.join(scriptsDirectory, "processDiagnostic var diagnosticMessagesJson = path.join(compilerDirectory, "diagnosticMessages.json"); var diagnosticInfoMapTs = path.join(compilerDirectory, "diagnosticInformationMap.generated.ts"); -file(processDiagnosticMessagesTs) +file(processDiagnosticMessagesTs); // processDiagnosticMessages script compileFile(processDiagnosticMessagesJs, @@ -342,6 +342,65 @@ desc("Generates a diagnostic file in TypeScript based on an input JSON file"); task("generate-diagnostics", [diagnosticInfoMapTs]) +// Publish nightly +var configureNightlyJs = path.join(scriptsDirectory, "configureNightly.js"); +var configureNightlyTs = path.join(scriptsDirectory, "configureNightly.ts"); +var packageJson = "package.json"; +var programTs = path.join(compilerDirectory, "program.ts") + +file(configureNightlyTs); + +compileFile(/*outfile*/configureNightlyJs, + /*sources*/ [configureNightlyTs], + /*prereqs*/ [configureNightlyTs], + /*prefixes*/ [], + /*useBuiltCompiler*/ false, + /*noOutFile*/ false, + /*generateDeclarations*/ false, + /*outDir*/ undefined, + /*preserveConstEnums*/ undefined, + /*keepComments*/ false, + /*noResolve*/ false, + /*stripInternal*/ false, + /*callback*/ function () { + var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs; + console.log(cmd); + var ex = jake.createExec([cmd]); + // Add listeners for output and error + ex.addListener("stdout", function(output) { + process.stdout.write(output); + }); + ex.addListener("stderr", function(error) { + process.stderr.write(error); + }); + ex.addListener("cmdEnd", function() { + complete(); + }); + ex.run(); + }); + +task("setDebugModeTrue", function() { + useDebugMode = true; +}); + +desc("Configure, build, test, and publish the nightly release."); +task("publish-nightly", [configureNightlyJs, "LKG", "clean", "setDebugModeTrue", "runtests"], function () { + var cmd = "npm publish"; + console.log(cmd); + var ex = jake.createExec([cmd]); + // Add listeners for output and error + ex.addListener("stdout", function(output) { + process.stdout.write(output); + }); + ex.addListener("stderr", function(error) { + process.stderr.write(error); + }); + ex.addListener("cmdEnd", function() { + complete(); + }); + ex.run(); +}, {async: true}); + // Local target to build the compiler and services var tscFile = path.join(builtLocalDirectory, compilerFilename); compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false); From 50198247bbd8093923aead123617d9c0c1eae4db Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Jul 2015 14:02:47 -0700 Subject: [PATCH 5/7] Use 'exec'. --- Jakefile.js | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index b1ec9f3024c..edfd14fc1af 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -365,18 +365,7 @@ compileFile(/*outfile*/configureNightlyJs, /*callback*/ function () { var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs; console.log(cmd); - var ex = jake.createExec([cmd]); - // Add listeners for output and error - ex.addListener("stdout", function(output) { - process.stdout.write(output); - }); - ex.addListener("stderr", function(error) { - process.stderr.write(error); - }); - ex.addListener("cmdEnd", function() { - complete(); - }); - ex.run(); + exec(cmd, completeHandler, errorHandler) }); task("setDebugModeTrue", function() { @@ -387,18 +376,7 @@ desc("Configure, build, test, and publish the nightly release."); task("publish-nightly", [configureNightlyJs, "LKG", "clean", "setDebugModeTrue", "runtests"], function () { var cmd = "npm publish"; console.log(cmd); - var ex = jake.createExec([cmd]); - // Add listeners for output and error - ex.addListener("stdout", function(output) { - process.stdout.write(output); - }); - ex.addListener("stderr", function(error) { - process.stderr.write(error); - }); - ex.addListener("cmdEnd", function() { - complete(); - }); - ex.run(); + exec(cmd, completeHandler, errorHandler) }, {async: true}); // Local target to build the compiler and services From d1fe21dda965e917912c30fb9f2fbd1602b6cadc Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 23 Jul 2015 12:32:17 -0700 Subject: [PATCH 6/7] Publish to TypeScript itself, create a task to preview changes. --- Jakefile.js | 25 +++++++++++++------------ scripts/configureNightly.ts | 26 +++++++++++++++----------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index edfd14fc1af..5f8fbfbfce6 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -361,23 +361,24 @@ compileFile(/*outfile*/configureNightlyJs, /*preserveConstEnums*/ undefined, /*keepComments*/ false, /*noResolve*/ false, - /*stripInternal*/ false, - /*callback*/ function () { - var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs; - console.log(cmd); - exec(cmd, completeHandler, errorHandler) - }); + /*stripInternal*/ false); -task("setDebugModeTrue", function() { +task("setDebugMode", function() { useDebugMode = true; }); -desc("Configure, build, test, and publish the nightly release."); -task("publish-nightly", [configureNightlyJs, "LKG", "clean", "setDebugModeTrue", "runtests"], function () { - var cmd = "npm publish"; +task("configure-nightly", [configureNightlyJs], function() { + var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs; console.log(cmd); - exec(cmd, completeHandler, errorHandler) -}, {async: true}); + exec(cmd); +}, { async: true }); + +desc("Configure, build, test, and publish the nightly release."); +task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests"], function () { + var cmd = "npm publish --tag next"; + console.log(cmd); + exec(cmd); +}); // Local target to build the compiler and services var tscFile = path.join(builtLocalDirectory, compilerFilename); diff --git a/scripts/configureNightly.ts b/scripts/configureNightly.ts index a0e30b007cf..640f330b376 100644 --- a/scripts/configureNightly.ts +++ b/scripts/configureNightly.ts @@ -27,11 +27,6 @@ function main(): void { // Modify the package.json structure packageJsonValue.version = nightlyVersion; - if (packageJsonValue.name !== "typescript-nightly") { - packageJsonValue.name = "typescript-nightly"; - packageJsonValue.keywords.push("nightly", "alpha", "beta", "prerelease"); - } - // Acquire and modify the source file that exposes the version string. const tsFilePath = ts.normalizePath(sys.args[1]); const tsFileContents = sys.readFile(tsFilePath); @@ -40,7 +35,16 @@ function main(): void { // Ensure we are actually changing something - the user probably wants to know that the update failed. if (tsFileContents === modifiedTsFileContents) { - throw `File '${tsFilePath}' did not contain pattern ${versionAssignmentRegExp}`; + let err = `\n '${tsFilePath}' was not updated while configuring for a nightly publish.\n `; + + if (tsFileContents.match(versionAssignmentRegExp)) { + err += `Ensure that you have not already run this script; otherwise, erase your changes using 'git checkout -- "${tsFilePath}"'.`; + } + else { + err += `The file seems to no longer have a string matching '${versionAssignmentRegExp}'.`; + } + + throw err + "\n"; } // Finally write the changes to disk. @@ -51,19 +55,19 @@ function main(): void { function getNightlyVersionString(versionString: string): string { // If the version string already contains "-nightly", // then get the base string and update based on that. - const dashNightlyPos = versionString.indexOf("-nightly"); + const dashNightlyPos = versionString.indexOf("-dev"); if (dashNightlyPos >= 0) { versionString = versionString.slice(0, dashNightlyPos); } // We're going to append a representation of the current time at the end of the current version. // String.prototype.toISOString() returns a 24-character string formatted as 'YYYY-MM-DDTHH:mm:ss.sssZ', - // but we'd prefer to just use hyphens as separators instead of 'T', ':', and '.'. - // The trailing 'Z' in this string can be removed; UTC time will always be implicit here. + // but we'd prefer to just remove separators and limit ourselves to YYYYMMDD. + // UTC time will always be implicit here. const now = new Date(); - const timeStr = now.toISOString().slice(0, -1).replace(/:|T|\./g, "-"); + const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8); - return `${versionString}-nightly-${timeStr}`; + return `${versionString}-dev.${timeStr}`; } main(); \ No newline at end of file From b443cfecc9bb4f08439085afc031ce4a3d6aaca3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 23 Jul 2015 12:53:41 -0700 Subject: [PATCH 7/7] Semicolons. --- Jakefile.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 5f8fbfbfce6..5bfd4d7d278 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -336,17 +336,17 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], complete(); }); ex.run(); -}, {async: true}) +}, {async: true}); desc("Generates a diagnostic file in TypeScript based on an input JSON file"); -task("generate-diagnostics", [diagnosticInfoMapTs]) +task("generate-diagnostics", [diagnosticInfoMapTs]); // Publish nightly var configureNightlyJs = path.join(scriptsDirectory, "configureNightly.js"); var configureNightlyTs = path.join(scriptsDirectory, "configureNightly.ts"); var packageJson = "package.json"; -var programTs = path.join(compilerDirectory, "program.ts") +var programTs = path.join(compilerDirectory, "program.ts"); file(configureNightlyTs); @@ -476,11 +476,11 @@ file(specMd, [word2mdJs, specWord], function () { child_process.exec(cmd, function () { complete(); }); -}, {async: true}) +}, {async: true}); desc("Generates a Markdown version of the Language Specification"); -task("generate-spec", [specMd]) +task("generate-spec", [specMd]); // Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory @@ -612,7 +612,7 @@ task("runtests", ["tests", builtLocalDirectory], function() { exec(cmd, deleteTemporaryProjectOutput); }, {async: true}); -desc("Generates code coverage data via instanbul") +desc("Generates code coverage data via instanbul"); task("generate-code-coverage", ["tests", builtLocalDirectory], function () { var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run; console.log(cmd); @@ -655,7 +655,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function( function getDiffTool() { var program = process.env['DIFF'] if (!program) { - fail("Add the 'DIFF' environment variable to the path of the program you want to use.") + fail("Add the 'DIFF' environment variable to the path of the program you want to use."); } return program; } @@ -664,14 +664,14 @@ function getDiffTool() { desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable"); task('diff', function () { var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline; - console.log(cmd) + console.log(cmd); exec(cmd); }, {async: true}); desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable"); task('diff-rwc', function () { var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline; - console.log(cmd) + console.log(cmd); exec(cmd); }, {async: true});