From 9db45dff6dc319ad35c96b79ec9587d9ef5d33ee Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 19 Jan 2018 15:58:35 -0800 Subject: [PATCH 1/2] Create a 'configure-insiders' and 'publish-insiders' task. --- Jakefile.js | 15 ++++++++++++++- scripts/configureNightly.ts | 27 ++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 2026544a249..54b7e3af94d 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -575,7 +575,7 @@ task("setDebugMode", function () { }); task("configure-nightly", [configureNightlyJs], function () { - var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + versionFile; + var cmd = host + " " + configureNightlyJs + " dev " + packageJson + " " + versionFile; console.log(cmd); exec(cmd); }, { async: true }); @@ -587,6 +587,19 @@ task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "r exec(cmd); }); +task("configure-insiders", [configureNightlyJs], function () { + var cmd = host + " " + configureNightlyJs + " insiders " + packageJson + " " + versionFile; + console.log(cmd); + exec(cmd); +}, { async: true }); + +desc("Configure, build, test, and publish the insiders release."); +task("publish-insiders", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests-parallel"], function () { + var cmd = "npm publish --tag insiders"; + console.log(cmd); + exec(cmd); +}); + var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDefinitelyTypedTests"); var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js"); var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts"); diff --git a/scripts/configureNightly.ts b/scripts/configureNightly.ts index 778f5ce3727..a63490ca051 100644 --- a/scripts/configureNightly.ts +++ b/scripts/configureNightly.ts @@ -11,34 +11,39 @@ interface PackageJson { function main(): void { const sys = ts.sys; - if (sys.args.length < 2) { + if (sys.args.length < 3) { sys.write("Usage:" + sys.newLine) - sys.write("\tnode configureNightly.js " + sys.newLine); + sys.write("\tnode configureNightly.js " + sys.newLine); return; } + const tag = sys.args[0]; + if (tag !== "dev" && tag !== "insiders") { + throw new Error(`Unexpected tag name '${tag}'.`); + } + // Acquire the version from the package.json file and modify it appropriately. - const packageJsonFilePath = ts.normalizePath(sys.args[0]); + const packageJsonFilePath = ts.normalizePath(sys.args[1]); const packageJsonValue: PackageJson = JSON.parse(sys.readFile(packageJsonFilePath)); const { majorMinor, patch } = parsePackageJsonVersion(packageJsonValue.version); - const nightlyPatch = getNightlyPatch(patch); + const prereleasePatch = getPrereleasePatch(tag, patch); // Acquire and modify the source file that exposes the version string. - const tsFilePath = ts.normalizePath(sys.args[1]); + const tsFilePath = ts.normalizePath(sys.args[2]); const tsFileContents = ts.sys.readFile(tsFilePath); - const modifiedTsFileContents = updateTsFile(tsFilePath, tsFileContents, majorMinor, patch, nightlyPatch); + const modifiedTsFileContents = updateTsFile(tsFilePath, tsFileContents, majorMinor, patch, prereleasePatch); // Ensure we are actually changing something - the user probably wants to know that the update failed. if (tsFileContents === modifiedTsFileContents) { - let err = `\n '${tsFilePath}' was not updated while configuring for a nightly publish.\n `; + let err = `\n '${tsFilePath}' was not updated while configuring for a prerelease publish for '${tag}'.\n `; err += `Ensure that you have not already run this script; otherwise, erase your changes using 'git checkout -- "${tsFilePath}"'.`; - throw err + "\n"; + throw new Error(err + "\n"); } // Finally write the changes to disk. // Modify the package.json structure - packageJsonValue.version = `${majorMinor}.${nightlyPatch}`; + packageJsonValue.version = `${majorMinor}.${prereleasePatch}`; sys.writeFile(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4)) sys.writeFile(tsFilePath, modifiedTsFileContents); } @@ -69,7 +74,7 @@ function parsePackageJsonVersion(versionString: string): { majorMinor: string, p } /** e.g. 0-dev.20170707 */ -function getNightlyPatch(plainPatch: string): string { +function getPrereleasePatch(tag: string, plainPatch: string): string { // 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 remove separators and limit ourselves to YYYYMMDD. @@ -77,7 +82,7 @@ function getNightlyPatch(plainPatch: string): string { const now = new Date(); const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8); - return `${plainPatch}-dev.${timeStr}`; + return `${plainPatch}-${tag}.${timeStr}`; } main(); \ No newline at end of file From 6b9ea7cab8158ed423a711ae759271277848dde7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 19 Jan 2018 16:03:02 -0800 Subject: [PATCH 2/2] configureNightly -> configurePrerelease --- .gitignore | 2 +- Jakefile.js | 20 +++++++++---------- ...igureNightly.ts => configurePrerelease.ts} | 0 3 files changed, 11 insertions(+), 11 deletions(-) rename scripts/{configureNightly.ts => configurePrerelease.ts} (100%) diff --git a/.gitignore b/.gitignore index 5125de360b8..2e90e788faa 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,7 @@ scripts/word2md.js scripts/buildProtocol.js scripts/ior.js scripts/authors.js -scripts/configureNightly.js +scripts/configurePrerelease.js scripts/processDiagnosticMessages.d.ts scripts/processDiagnosticMessages.js scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js diff --git a/Jakefile.js b/Jakefile.js index 54b7e3af94d..e8ba3f53de3 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -556,16 +556,16 @@ 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 configurePrereleaseJs = path.join(scriptsDirectory, "configurePrerelease.js"); +var configurePrereleaseTs = path.join(scriptsDirectory, "configurePrerelease.ts"); var packageJson = "package.json"; var versionFile = path.join(compilerDirectory, "core.ts"); -file(configureNightlyTs); +file(configurePrereleaseTs); -compileFile(/*outfile*/configureNightlyJs, - /*sources*/[configureNightlyTs], - /*prereqs*/[configureNightlyTs], +compileFile(/*outfile*/configurePrereleaseJs, + /*sources*/[configurePrereleaseTs], + /*prereqs*/[configurePrereleaseTs], /*prefixes*/[], /*useBuiltCompiler*/ false, { noOutFile: false, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false }); @@ -574,8 +574,8 @@ task("setDebugMode", function () { useDebugMode = true; }); -task("configure-nightly", [configureNightlyJs], function () { - var cmd = host + " " + configureNightlyJs + " dev " + packageJson + " " + versionFile; +task("configure-nightly", [configurePrereleaseJs], function () { + var cmd = host + " " + configurePrereleaseJs + " dev " + packageJson + " " + versionFile; console.log(cmd); exec(cmd); }, { async: true }); @@ -587,8 +587,8 @@ task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "r exec(cmd); }); -task("configure-insiders", [configureNightlyJs], function () { - var cmd = host + " " + configureNightlyJs + " insiders " + packageJson + " " + versionFile; +task("configure-insiders", [configurePrereleaseJs], function () { + var cmd = host + " " + configurePrereleaseJs + " insiders " + packageJson + " " + versionFile; console.log(cmd); exec(cmd); }, { async: true }); diff --git a/scripts/configureNightly.ts b/scripts/configurePrerelease.ts similarity index 100% rename from scripts/configureNightly.ts rename to scripts/configurePrerelease.ts