Ensure all scripts are checked, fix errors (#50326)

This commit is contained in:
Jake Bailey 2022-08-17 16:42:50 -07:00 committed by GitHub
parent 15f7b6f687
commit 66d8b95941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 51 additions and 42 deletions

1
.gitignore vendored
View File

@ -54,6 +54,7 @@ scripts/produceLKG.js
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
scripts/generateLocalizedDiagnosticMessages.js
scripts/request-pr-review.js
scripts/errorCheck.js
scripts/*.js.map
scripts/typings/
coverage/

13
package-lock.json generated
View File

@ -14,6 +14,7 @@
},
"devDependencies": {
"@octokit/rest": "latest",
"@types/async": "latest",
"@types/chai": "latest",
"@types/convert-source-map": "latest",
"@types/fs-extra": "^9.0.13",
@ -435,6 +436,12 @@
"@octokit/openapi-types": "^13.1.0"
}
},
"node_modules/@types/async": {
"version": "3.2.15",
"resolved": "https://registry.npmjs.org/@types/async/-/async-3.2.15.tgz",
"integrity": "sha512-PAmPfzvFA31mRoqZyTVsgJMsvbynR429UTTxhmfsUCrWGh3/fxOrzqBtaTPJsn4UtzTv4Vb0+/O7CARWb69N4g==",
"dev": true
},
"node_modules/@types/chai": {
"version": "4.3.3",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz",
@ -8884,6 +8891,12 @@
"@octokit/openapi-types": "^13.1.0"
}
},
"@types/async": {
"version": "3.2.15",
"resolved": "https://registry.npmjs.org/@types/async/-/async-3.2.15.tgz",
"integrity": "sha512-PAmPfzvFA31mRoqZyTVsgJMsvbynR429UTTxhmfsUCrWGh3/fxOrzqBtaTPJsn4UtzTv4Vb0+/O7CARWb69N4g==",
"dev": true
},
"@types/chai": {
"version": "4.3.3",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz",

View File

@ -30,6 +30,7 @@
},
"devDependencies": {
"@octokit/rest": "latest",
"@types/async": "latest",
"@types/chai": "latest",
"@types/convert-source-map": "latest",
"@types/fs-extra": "^9.0.13",

View File

@ -1,6 +1,6 @@
import fs = require("fs");
import path = require("path");
import childProcess = require("child_process");
import * as fs from "fs";
import * as path from "path";
import * as childProcess from "child_process";
interface Author {
displayNames: string[];
@ -120,10 +120,10 @@ namespace Commands {
const authors: { name: string, email: string, knownAuthor?: Author }[] = [];
const {output: [error, stdout, stderr]} = childProcess.spawnSync(`git`, ["shortlog", "-se", ...specs], { cwd: path.resolve(__dirname, "../") });
if (error) {
console.log(stderr.toString());
console.log(stderr!.toString());
}
else {
const output = stdout.toString();
const output = stdout!.toString();
const lines = output.split("\n");
lines.forEach(line => {
if (line) {

View File

@ -1,7 +1,7 @@
/// <reference types="node"/>
import { normalize, dirname, join } from "path";
import { readFileSync, writeFileSync, unlinkSync, existsSync } from "fs";
import assert = require("assert");
import * as assert from "assert";
import { execSync } from "child_process";
const args = process.argv.slice(2);
@ -10,11 +10,11 @@ const args = process.argv.slice(2);
*/
interface PackageJson {
name: string;
bin: {};
bin?: {};
main: string;
scripts: {
prepare: string
postpublish: string
prepare?: string
postpublish?: string
}
}

View File

@ -1,6 +1,6 @@
/// <reference types="node"/>
import { normalize, relative } from "path";
import assert = require("assert");
import * as assert from "assert";
import { readFileSync, writeFileSync } from "fs";
/**

View File

@ -1,6 +1,6 @@
const fs = require("fs");
const async = require("async");
const glob = require("glob");
import * as fs from "fs";
import * as async from "async";
import * as glob from "glob";
fs.readFile("src/compiler/diagnosticMessages.json", "utf-8", (err, data) => {
if (err) {
@ -25,7 +25,7 @@ fs.readFile("src/compiler/diagnosticMessages.json", "utf-8", (err, data) => {
fs.readFile(baseDir + f, "utf-8", (err, baseline) => {
if (err) throw err;
let g: string[];
let g: RegExpExecArray | null;
while (g = errRegex.exec(baseline)) {
const errCode = +g[1];
const msg = keys.filter(k => messages[k].code === errCode)[0];
@ -53,7 +53,7 @@ fs.readFile("src/compiler/diagnosticMessages.json", "utf-8", (err, data) => {
fs.readFile("src/compiler/diagnosticInformationMap.generated.ts", "utf-8", (err, data) => {
const errorRegexp = /\s(\w+): \{ code/g;
const errorNames: string[] = [];
let errMatch: string[];
let errMatch: RegExpExecArray | null;
while (errMatch = errorRegexp.exec(data)) {
errorNames.push(errMatch[1]);
}

View File

@ -1,4 +1,4 @@
import Mocha = require("mocha");
import * as Mocha from "mocha";
export = FailedTestsReporter;

View File

@ -46,7 +46,7 @@ function copyFileSync(source: string, destination: string) {
fs.writeFileSync(destination, text);
}
function importDefinitelyTypedTest(tscPath: string, rwcTestPath: string, testCaseName: string, testFiles: string[], responseFile: string) {
function importDefinitelyTypedTest(tscPath: string, rwcTestPath: string, testCaseName: string, testFiles: string[], responseFile: string | undefined) {
let cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" ");
if (responseFile) {
cmd += " @" + responseFile;
@ -122,7 +122,7 @@ function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, defini
const tsFiles: string[] = [];
const testFiles: string[] = [];
let paramFile: string;
let paramFile: string | undefined;
for (const filePath of files.map(f => path.join(directoryPath, f))) {
if (filePathEndsWith(filePath, ".ts")) {

View File

@ -3,9 +3,9 @@
/// <reference types="node" />
import { Octokit } from "@octokit/rest";
const {runSequence} = require("./run-sequence");
import fs = require("fs");
import path = require("path");
import { runSequence } from "./run-sequence";
import * as fs from "fs";
import * as path from "path";
const userName = process.env.GH_USERNAME;
const reviewers = process.env.REQUESTING_USER ? [process.env.REQUESTING_USER] : ["weswigham", "RyanCavanaugh"];

View File

@ -2,7 +2,7 @@
/// <reference lib="es2015.promise" />
// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
import { Octokit } from "@octokit/rest";
const {runSequence} = require("./run-sequence");
import { runSequence } from "./run-sequence";
const userName = process.env.GH_USERNAME || "typescript-bot";
const reviewers = process.env.REQUESTING_USER ? [process.env.REQUESTING_USER] : ["weswigham", "sandersn", "RyanCavanaugh"];
@ -22,7 +22,7 @@ runSequence([
["node", ["./node_modules/gulp/bin/gulp.js", "baseline-accept"]], // accept baselines
["git", ["checkout", "-b", branchName]], // create a branch
["git", ["add", "."]], // Add all changes
["git", ["commit", "-m", `"Update user baselines${+process.env.SOURCE_ISSUE === 33716 ? " +cc @sandersn" : ""}"`]], // Commit all changes (ping nathan if we would post to CI thread)
["git", ["commit", "-m", `"Update user baselines${+process.env.SOURCE_ISSUE! === 33716 ? " +cc @sandersn" : ""}"`]], // Commit all changes (ping nathan if we would post to CI thread)
["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch
]);

View File

@ -1,5 +1,5 @@
import path = require("path");
import fs = require("fs");
import * as path from "path";
import * as fs from "fs";
interface DiagnosticDetails {
category: string;

View File

@ -1,9 +1,9 @@
/// <reference types="node" />
import childProcess = require("child_process");
import fs = require("fs-extra");
import path = require("path");
import glob = require("glob");
import * as childProcess from "child_process";
import * as fs from "fs-extra";
import * as path from "path";
import * as glob from "glob";
const root = path.join(__dirname, "..");
const source = path.join(root, "built/local");

View File

@ -1,8 +1,7 @@
/// <reference lib="esnext.asynciterable" />
/// <reference lib="es2015.promise" />
import octokit = require("@octokit/rest");
import Octokit = octokit.Octokit;
import minimist = require("minimist");
import { Octokit } from "@octokit/rest";
import * as minimist from "minimist";
const options = minimist(process.argv.slice(2), {
boolean: ["help"],
@ -70,4 +69,4 @@ options:
-h --help Prints this help message.
`);
return process.exit(exitCode);
}
}

3
scripts/run-sequence.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import { SpawnSyncOptions } from "child_process";
export function runSequence(tasks: [string, string[]][], opts?: SpawnSyncOptions): string;

View File

@ -11,13 +11,5 @@
"lib": ["es6", "scripthost"],
},
"include": [
"generateLocalizedDiagnosticMessages.ts",
"processDiagnosticMessages.ts",
"configurePrerelease.ts",
"buildProtocol.ts",
"produceLKG.ts",
"word2md.ts",
"request-pr-review.ts"
]
"include": ["*.ts"]
}