Remove configureLanguageServiceBuild, instrumenter (#51048)

This commit is contained in:
Jake Bailey 2022-10-04 10:36:57 -07:00 committed by GitHub
parent 9dfffd0fbb
commit 49533168db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 190 deletions

View File

@ -486,21 +486,6 @@ task("baseline-accept").description = "Makes the most recent test results the ne
task("baseline-accept-rwc", () => baselineAccept(localRwcBaseline, refRwcBaseline));
task("baseline-accept-rwc").description = "Makes the most recent rwc test results the new baseline, overwriting the old baseline";
const buildLoggedIO = () => buildProject("src/loggedIO/tsconfig-tsc-instrumented.json");
const cleanLoggedIO = () => del("built/local/loggedIO.js");
cleanTasks.push(cleanLoggedIO);
const buildInstrumenter = () => buildProject("src/instrumenter");
const cleanInstrumenter = () => cleanProject("src/instrumenter");
cleanTasks.push(cleanInstrumenter);
const tscInstrumented = () => exec(process.execPath, ["built/local/instrumenter.js", "record", cmdLineOptions.tests || "iocapture", "built/local/tsc.js"]);
task("tsc-instrumented", series(lkgPreBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildLoggedIO, buildInstrumenter), tscInstrumented));
task("tsc-instrumented").description = "Builds an instrumented tsc.js";
task("tsc-instrumented").flags = {
"-t --tests=<testname>": "The test to run."
};
// TODO(rbuckton): Determine if we still need this task. Depending on a relative
// path here seems like a bad idea.
const updateSublime = () => src(["built/local/tsserver.js", "built/local/tsserver.js.map"])
@ -577,10 +562,6 @@ const configureExperimental = () => exec(process.execPath, ["scripts/configurePr
task("configure-experimental", series(buildScripts, configureExperimental));
task("configure-experimental").description = "Runs scripts/configurePrerelease.ts to prepare a build for experimental publishing";
const createLanguageServicesBuild = () => exec(process.execPath, ["scripts/createLanguageServicesBuild.js"]);
task("create-language-services-build", series(buildScripts, createLanguageServicesBuild));
task("create-language-services-build").description = "Runs scripts/createLanguageServicesBuild.ts to prepare a build which only has the require('typescript') JS.";
const publishNightly = () => exec("npm", ["publish", "--tag", "next"]);
task("publish-nightly", series(task("clean"), task("LKG"), task("clean"), task("runtests-parallel"), publishNightly));
task("publish-nightly").description = "Runs `npm publish --tag next` to create a new nightly build on npm";

View File

@ -1,87 +0,0 @@
/// <reference types="node"/>
import { normalize, dirname, join } from "path";
import { readFileSync, writeFileSync, unlinkSync, existsSync } from "fs";
import * as assert from "assert";
import { execSync } from "child_process";
const args = process.argv.slice(2);
/**
* A minimal description for a parsed package.json object.
*/
interface PackageJson {
name: string;
bin?: {};
main: string;
scripts: {
prepare?: string
postpublish?: string
}
}
function main(): void {
if (args.length < 1) {
console.log("Usage:");
console.log("\tnode configureTSCBuild.js <package.json location>");
return;
}
// Acquire the version from the package.json file and modify it appropriately.
const packageJsonFilePath = normalize(args[0]);
const packageJsonValue: PackageJson = JSON.parse(readFileSync(packageJsonFilePath).toString());
// Remove the bin section from the current package
delete packageJsonValue.bin;
// We won't be running eslint which would run before publishing
delete packageJsonValue.scripts.prepare;
// No infinite loops
delete packageJsonValue.scripts.postpublish;
// Set the new name
packageJsonValue.name = "@typescript/language-services";
writeFileSync(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4));
// Remove the files which aren't use when just using the API
const toRemove = [
// JS Files
"tsserver.js",
"tsserverlibrary.js",
"typescriptServices.js",
"typingsInstaller.js",
"tsc.js",
// DTS files
"typescriptServices.d.ts",
"tsserverlibrary.d.ts"
];
// Get a link to the main dependency JS file
const lib = join(dirname(packageJsonFilePath), packageJsonValue.main);
const libPath = dirname(lib);
// Remove the sibling JS large files referenced above
toRemove.forEach(file => {
const path = join(libPath, file);
if (existsSync(path)) unlinkSync(path);
});
// Remove VS-specific localization keys
execSync("rm -rf loc", { cwd: dirname(packageJsonFilePath) });
// Remove runnable file reference
execSync("rm -rf bin", { cwd: dirname(packageJsonFilePath) });
///////////////////////////////////
// This section verifies that the build of TypeScript compiles and emits
const ts = require(lib);
const source = "let x: string = 'string'";
const results = ts.transpileModule(source, {
compilerOptions: { module: ts.ModuleKind.CommonJS }
});
assert(results.outputText.trim() === "var x = 'string';", `Running typescript with ${packageJsonValue.name} did not return the expected results, got: ${results.outputText}`);
}
main();

View File

@ -1,43 +0,0 @@
import fs = require("fs");
import path = require("path");
function instrumentForRecording(fn: string, tscPath: string) {
instrument(tscPath, `
ts.sys = Playback.wrapSystem(ts.sys);
ts.sys.startRecord("${ fn }");`, `ts.sys.endRecord();`);
}
function instrumentForReplay(logFilename: string, tscPath: string) {
instrument(tscPath, `
ts.sys = Playback.wrapSystem(ts.sys);
ts.sys.startReplay("${ logFilename }");`);
}
function instrument(tscPath: string, prepareCode: string, cleanupCode = "") {
const bak = `${tscPath}.bak`;
const filename = fs.existsSync(bak) ? bak : tscPath;
const tscContent = fs.readFileSync(filename, "utf-8");
fs.writeFileSync(bak, tscContent);
const loggerContent = fs.readFileSync(path.resolve(path.dirname(tscPath) + "/loggedIO.js"), "utf-8");
const invocationLine = "ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);";
const index1 = tscContent.indexOf(invocationLine);
if (index1 < 0) {
throw new Error(`Could not find ${invocationLine}`);
}
const index2 = index1 + invocationLine.length;
const newContent = tscContent.substr(0, index1) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent.substr(index2) + "\r\n";
fs.writeFileSync(tscPath, newContent);
}
const isJson = (arg: string) => arg.indexOf(".json") > 0;
const record = process.argv.indexOf("record");
const tscPath = process.argv[process.argv.length - 1];
if (record >= 0) {
console.log(`Instrumenting ${tscPath} for recording`);
instrumentForRecording(process.argv[record + 1], tscPath);
}
else if (process.argv.some(isJson)) {
const filename = process.argv.filter(isJson)[0];
instrumentForReplay(filename, tscPath);
}

View File

@ -1,16 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"es6",
"dom",
"scripthost"
],
"outDir": "../../built/local",
"sourceMap": true
},
"files": [
"instrumenter.ts"
]
}

View File

@ -1,25 +0,0 @@
{
"extends": "../tsconfig-base",
"compilerOptions": {
"outFile": "../../built/local/loggedIO.js",
"types": [
"node", "mocha", "chai"
],
"lib": [
"es6",
"scripthost"
]
},
"references": [
{ "path": "../compiler", "prepend": true },
{ "path": "../services", "prepend": true },
{ "path": "../jsTyping", "prepend": true },
{ "path": "../server", "prepend": true },
{ "path": "../typingsInstallerCore", "prepend": true },
{ "path": "../harness", "prepend": true },
],
"files": [
"loggedIO.ts"
]
}