@@ -2058,6 +2058,8 @@ const updatesIssue_1 = __webpack_require__(700);
2058
2058
const runTwoslashRuns_1 = __webpack_require__(303);
2059
2059
const api_1 = __webpack_require__(105);
2060
2060
const downloadTSVersions_1 = __webpack_require__(580);
2061
+ const getPreviousRunInfo_1 = __webpack_require__(707);
2062
+ const setupBreakingInfo_1 = __webpack_require__(406);
2061
2063
async function run() {
2062
2064
const ctx = (0, getContext_1.getContext)();
2063
2065
console.log(`Context: ${JSON.stringify(ctx, null, ' ')}`);
@@ -2070,8 +2072,10 @@ async function run() {
2070
2072
console.log('');
2071
2073
const runs = (0, issuesToTwoslashRuns_1.issueToTwoslashRun)(ctx)(issue);
2072
2074
const results = (0, runTwoslashRuns_1.runTwoslashRuns)(issue, runs);
2075
+ const runInfo = (0, getPreviousRunInfo_1.getPreviousRunInfo)(issue);
2076
+ const breakage = (runInfo && runInfo.breakageInfo) || (await (0, setupBreakingInfo_1.getBreakageInfo)(runs, results));
2073
2077
const api = (0, api_1.createAPI)(ctx);
2074
- await (0, updatesIssue_1.updateIssue)(ctx, issue, results, api);
2078
+ await (0, updatesIssue_1.updateIssue)(ctx, issue, results, breakage, api);
2075
2079
}
2076
2080
}
2077
2081
process.stdout.write('.');
@@ -4195,7 +4199,7 @@ exports.paginateRest = paginateRest;
4195
4199
"use strict";
4196
4200
4197
4201
Object.defineProperty(exports, "__esModule", { value: true });
4198
- exports.runTwoSlash = exports.runTwoSlashOnOlderVersions = exports.runTwoslashRuns = void 0;
4202
+ exports.runTwoSlash = exports.runTwoSlashOnOlderVersions = exports.requireTS = exports. runTwoslashRuns = void 0;
4199
4203
const twoslash_1 = __webpack_require__(689);
4200
4204
const fs_1 = __webpack_require__(747);
4201
4205
const path_1 = __webpack_require__(622);
@@ -4214,6 +4218,13 @@ function runTwoslashRuns(issue, runs) {
4214
4218
}
4215
4219
}
4216
4220
exports.runTwoslashRuns = runTwoslashRuns;
4221
+ const requireTS = (version) => {
4222
+ // dev prod
4223
+ const possibleTSRoots = [(0, path_1.join)(__dirname, '..', 'dist', 'ts'), (0, path_1.join)(__dirname, 'ts')];
4224
+ const tsRoot = possibleTSRoots.find(f => (0, fs_1.existsSync)(f));
4225
+ return require((0, path_1.join)(tsRoot, version));
4226
+ };
4227
+ exports.requireTS = requireTS;
4217
4228
const runTwoSlashOnOlderVersions = (run) => {
4218
4229
// dev prod
4219
4230
const possibleTSRoots = [(0, path_1.join)(__dirname, '..', 'dist', 'ts'), (0, path_1.join)(__dirname, 'ts')];
@@ -7322,6 +7333,91 @@ exports.knownLibFilesForCompilerOptions = knownLibFilesForCompilerOptions;
7322
7333
//# sourceMappingURL=vfs.cjs.development.js.map
7323
7334
7324
7335
7336
+ /***/ }),
7337
+
7338
+ /***/ 406:
7339
+ /***/ (function(__unusedmodule, exports, __webpack_require__) {
7340
+
7341
+ "use strict";
7342
+
7343
+ Object.defineProperty(exports, "__esModule", { value: true });
7344
+ exports.getBreakageInfo = exports.binarySearch = exports.extractDateAndVersionMetadata = void 0;
7345
+ const downloadTSVersions_1 = __webpack_require__(580);
7346
+ const runTwoslashRuns_1 = __webpack_require__(303);
7347
+ // Grab every version of TypeScript
7348
+ const downloadAllTSVersions = async () => {
7349
+ const response = await fetch('http://registry.npmjs.org/typescript');
7350
+ const json = await response.json();
7351
+ return (0, exports.extractDateAndVersionMetadata)(json);
7352
+ };
7353
+ /** So we can have much less of that 14mb json file in memory */
7354
+ const extractDateAndVersionMetadata = (packument) => {
7355
+ const time = packument.time;
7356
+ delete time['modified'];
7357
+ delete time['created'];
7358
+ return Object.keys(time).map(key => [key, time[key]]);
7359
+ };
7360
+ exports.extractDateAndVersionMetadata = extractDateAndVersionMetadata;
7361
+ async function binarySearch(ar, func) {
7362
+ var m = 0;
7363
+ var n = ar.length - 1;
7364
+ while (m <= n) {
7365
+ var k = (n + m) >> 1;
7366
+ var cmp = await func(ar[k]);
7367
+ if (cmp > 0) {
7368
+ m = k + 1;
7369
+ }
7370
+ else if (cmp < 0) {
7371
+ n = k - 1;
7372
+ }
7373
+ else {
7374
+ return ar[k];
7375
+ }
7376
+ }
7377
+ return ar[m - 1];
7378
+ }
7379
+ exports.binarySearch = binarySearch;
7380
+ const compareResults = (run, todaysResult) => async (version) => {
7381
+ (0, downloadTSVersions_1.ensureTSVersionExists)(version[0]);
7382
+ const ts = (0, runTwoslashRuns_1.requireTS)(version[0]);
7383
+ const newResults = run.codeBlocksToRun.map(code => (0, runTwoslashRuns_1.runTwoSlash)('Check for breakage')(code, ts));
7384
+ let same = true;
7385
+ // Look to make sure that every result from today's run include a corresponding result for yesterday's run
7386
+ newResults.forEach(res => {
7387
+ if (!todaysResult.some(todays => resultsSame(res, todays))) {
7388
+ same = false;
7389
+ }
7390
+ });
7391
+ return same === true ? 1 : -1;
7392
+ };
7393
+ const getBreakageInfo = async (run, results) => {
7394
+ const latestResults = getLatest(results);
7395
+ const allVersions = await downloadAllTSVersions();
7396
+ const comparer = compareResults(run, latestResults);
7397
+ const version = await binarySearch(allVersions, comparer);
7398
+ const info = {
7399
+ estimatedVersion: version[0],
7400
+ estimatedDate: version[1]
7401
+ };
7402
+ return info;
7403
+ };
7404
+ exports.getBreakageInfo = getBreakageInfo;
7405
+ const getLatest = (runs) => runs.filter(r => r.label === 'Nightly');
7406
+ const resultsSame = (lhs, rhs) => {
7407
+ if (lhs.description != rhs.description)
7408
+ return false;
7409
+ if (lhs.state != rhs.state)
7410
+ return false;
7411
+ if (lhs.fails != rhs.fails)
7412
+ return false;
7413
+ if (lhs.assertions != rhs.assertions)
7414
+ return false;
7415
+ if (lhs.exception != rhs.exception)
7416
+ return false;
7417
+ return true;
7418
+ };
7419
+
7420
+
7325
7421
/***/ }),
7326
7422
7327
7423
/***/ 408:
@@ -11683,7 +11779,7 @@ const github_1 = __webpack_require__(469);
11683
11779
async function getIssues(context) {
11684
11780
const octokit = (0, github_1.getOctokit)(context.token);
11685
11781
const req = issuesQuery(context.owner, context.name, context.label);
11686
- const initialIssues = (await octokit.graphql(req.query, Object.assign({}, req.vars) ));
11782
+ const initialIssues = (await octokit.graphql(req.query, { ... req.vars } ));
11687
11783
// TODO: check if nodes length == 100, then start looping
11688
11784
return initialIssues.repository.issues.nodes;
11689
11785
}
@@ -12794,7 +12890,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12794
12890
return (mod && mod.__esModule) ? mod : { "default": mod };
12795
12891
};
12796
12892
Object.defineProperty(exports, "__esModule", { value: true });
12797
- exports.downloadTypeScriptVersions = void 0;
12893
+ exports.ensureTSVersionExists = exports.downloadTSVersion = exports. downloadTypeScriptVersions = void 0;
12798
12894
const child_process_1 = __webpack_require__(129);
12799
12895
const fs_1 = __webpack_require__(747);
12800
12896
const node_fetch_1 = __importDefault(__webpack_require__(454));
@@ -12804,10 +12900,9 @@ const downloadTypeScriptVersions = async () => {
12804
12900
const releases = await downloadReleases();
12805
12901
const usableReleases = reduceToMajMin(releases);
12806
12902
const mostRecentFive = usableReleases.sort().reverse().slice(0, 5);
12807
- console.log('Grabbing at : ', mostRecentFive);
12903
+ console.log('Grabbing: ', mostRecentFive);
12808
12904
for (const version of mostRecentFive) {
12809
- downloadTSVersion(version);
12810
- extractTSVersion(version);
12905
+ (0, exports.ensureTSVersionExists)(version);
12811
12906
}
12812
12907
};
12813
12908
exports.downloadTypeScriptVersions = downloadTypeScriptVersions;
@@ -12828,6 +12923,14 @@ const downloadTSVersion = (version) => {
12828
12923
const toFile = (0, path_1.join)(zips, version + '.tgz');
12829
12924
(0, child_process_1.execSync)(`curl ${url} > ${toFile}`);
12830
12925
};
12926
+ exports.downloadTSVersion = downloadTSVersion;
12927
+ const ensureTSVersionExists = (version) => {
12928
+ if ((0, fs_1.existsSync)((0, path_1.join)(__dirname, '..', 'dist', version)))
12929
+ return;
12930
+ (0, exports.downloadTSVersion)(version);
12931
+ extractTSVersion(version);
12932
+ };
12933
+ exports.ensureTSVersionExists = ensureTSVersionExists;
12831
12934
// Grab the versions the playground uses
12832
12935
const downloadReleases = async () => {
12833
12936
const response = await (0, node_fetch_1.default)('https://typescript.azureedge.net/indexes/releases.json');
@@ -14213,29 +14316,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
14213
14316
exports.makeMessageForMainRuns = exports.updateIssue = void 0;
14214
14317
const getPreviousRunInfo_1 = __webpack_require__(707);
14215
14318
const getTypeScriptMeta_1 = __webpack_require__(772);
14216
- const updateIssue = async (_ctx, issue, newRuns, api) => {
14319
+ const updateIssue = async (_ctx, issue, newRuns, breakage, api) => {
14217
14320
process.stdout.write(`\nUpdating issue ${issue.number}: `);
14218
14321
if (newRuns.length === 0)
14219
14322
return;
14220
- await updateMainComment(newRuns, api, issue);
14323
+ await updateMainComment(newRuns, breakage, api, issue);
14221
14324
};
14222
14325
exports.updateIssue = updateIssue;
14223
- async function updateMainComment(newRuns, api, issue) {
14326
+ async function updateMainComment(newRuns, breakage, api, issue) {
14224
14327
const nightlyNew = getLatest(newRuns);
14225
14328
const runInfo = (0, getPreviousRunInfo_1.getPreviousRunInfo)(issue);
14226
14329
const introduction = intro(nightlyNew.length);
14227
14330
const above = (0, exports.makeMessageForMainRuns)(nightlyNew);
14228
14331
const groupedBySource = groupBy(newRuns, ts => ts.commentID || '__body');
14229
14332
const bottom = makeMessageForOlderRuns(groupedBySource);
14230
14333
const newTSMeta = await (0, getTypeScriptMeta_1.getTypeScriptMeta)();
14334
+ const commentID = runInfo && runInfo.commentID;
14231
14335
const embedded = (0, getPreviousRunInfo_1.runInfoString)({
14232
14336
runs: newRuns,
14233
- commentID: runInfo === null || runInfo === void 0 ? void 0 : runInfo.commentID ,
14337
+ commentID,
14234
14338
typescriptNightlyVersion: newTSMeta.version,
14235
14339
typescriptSHA: newTSMeta.sha
14236
14340
});
14237
14341
const msg = `${introduction}\n\n${above}\n\n${bottom}\n\n${embedded}`;
14238
- await api.editOrCreateComment(issue.id, runInfo === null || runInfo === void 0 ? void 0 : runInfo. commentID, msg);
14342
+ await api.editOrCreateComment(issue.id, commentID, msg);
14239
14343
}
14240
14344
const intro = (runLength) => {
14241
14345
const repros = runLength === 1 ? 'repro' : `${runLength} repros`;
@@ -14360,7 +14464,10 @@ const getPreviousRunInfo = (issue) => {
14360
14464
const json = JSON.parse(jsonString);
14361
14465
if ("typescriptNightlyVersion" in json === false)
14362
14466
return undefined;
14363
- return Object.assign(Object.assign({}, json), { commentID: botComment.id });
14467
+ return {
14468
+ ...json,
14469
+ commentID: botComment.id
14470
+ };
14364
14471
}
14365
14472
catch (error) {
14366
14473
return undefined;
0 commit comments