Skip to content

Commit 9db45df

Browse files
Create a 'configure-insiders' and 'publish-insiders' task.
1 parent eed8573 commit 9db45df

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

Jakefile.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ task("setDebugMode", function () {
575575
});
576576

577577
task("configure-nightly", [configureNightlyJs], function () {
578-
var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + versionFile;
578+
var cmd = host + " " + configureNightlyJs + " dev " + packageJson + " " + versionFile;
579579
console.log(cmd);
580580
exec(cmd);
581581
}, { async: true });
@@ -587,6 +587,19 @@ task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "r
587587
exec(cmd);
588588
});
589589

590+
task("configure-insiders", [configureNightlyJs], function () {
591+
var cmd = host + " " + configureNightlyJs + " insiders " + packageJson + " " + versionFile;
592+
console.log(cmd);
593+
exec(cmd);
594+
}, { async: true });
595+
596+
desc("Configure, build, test, and publish the insiders release.");
597+
task("publish-insiders", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests-parallel"], function () {
598+
var cmd = "npm publish --tag insiders";
599+
console.log(cmd);
600+
exec(cmd);
601+
});
602+
590603
var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDefinitelyTypedTests");
591604
var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js");
592605
var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts");

scripts/configureNightly.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,39 @@ interface PackageJson {
1111

1212
function main(): void {
1313
const sys = ts.sys;
14-
if (sys.args.length < 2) {
14+
if (sys.args.length < 3) {
1515
sys.write("Usage:" + sys.newLine)
16-
sys.write("\tnode configureNightly.js <package.json location> <file containing version>" + sys.newLine);
16+
sys.write("\tnode configureNightly.js <dev|insiders> <package.json location> <file containing version>" + sys.newLine);
1717
return;
1818
}
1919

20+
const tag = sys.args[0];
21+
if (tag !== "dev" && tag !== "insiders") {
22+
throw new Error(`Unexpected tag name '${tag}'.`);
23+
}
24+
2025
// Acquire the version from the package.json file and modify it appropriately.
21-
const packageJsonFilePath = ts.normalizePath(sys.args[0]);
26+
const packageJsonFilePath = ts.normalizePath(sys.args[1]);
2227
const packageJsonValue: PackageJson = JSON.parse(sys.readFile(packageJsonFilePath));
2328

2429
const { majorMinor, patch } = parsePackageJsonVersion(packageJsonValue.version);
25-
const nightlyPatch = getNightlyPatch(patch);
30+
const prereleasePatch = getPrereleasePatch(tag, patch);
2631

2732
// Acquire and modify the source file that exposes the version string.
28-
const tsFilePath = ts.normalizePath(sys.args[1]);
33+
const tsFilePath = ts.normalizePath(sys.args[2]);
2934
const tsFileContents = ts.sys.readFile(tsFilePath);
30-
const modifiedTsFileContents = updateTsFile(tsFilePath, tsFileContents, majorMinor, patch, nightlyPatch);
35+
const modifiedTsFileContents = updateTsFile(tsFilePath, tsFileContents, majorMinor, patch, prereleasePatch);
3136

3237
// Ensure we are actually changing something - the user probably wants to know that the update failed.
3338
if (tsFileContents === modifiedTsFileContents) {
34-
let err = `\n '${tsFilePath}' was not updated while configuring for a nightly publish.\n `;
39+
let err = `\n '${tsFilePath}' was not updated while configuring for a prerelease publish for '${tag}'.\n `;
3540
err += `Ensure that you have not already run this script; otherwise, erase your changes using 'git checkout -- "${tsFilePath}"'.`;
36-
throw err + "\n";
41+
throw new Error(err + "\n");
3742
}
3843

3944
// Finally write the changes to disk.
4045
// Modify the package.json structure
41-
packageJsonValue.version = `${majorMinor}.${nightlyPatch}`;
46+
packageJsonValue.version = `${majorMinor}.${prereleasePatch}`;
4247
sys.writeFile(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4))
4348
sys.writeFile(tsFilePath, modifiedTsFileContents);
4449
}
@@ -69,15 +74,15 @@ function parsePackageJsonVersion(versionString: string): { majorMinor: string, p
6974
}
7075

7176
/** e.g. 0-dev.20170707 */
72-
function getNightlyPatch(plainPatch: string): string {
77+
function getPrereleasePatch(tag: string, plainPatch: string): string {
7378
// We're going to append a representation of the current time at the end of the current version.
7479
// String.prototype.toISOString() returns a 24-character string formatted as 'YYYY-MM-DDTHH:mm:ss.sssZ',
7580
// but we'd prefer to just remove separators and limit ourselves to YYYYMMDD.
7681
// UTC time will always be implicit here.
7782
const now = new Date();
7883
const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8);
7984

80-
return `${plainPatch}-dev.${timeStr}`;
85+
return `${plainPatch}-${tag}.${timeStr}`;
8186
}
8287

8388
main();

0 commit comments

Comments
 (0)