From e5876969229760fb4f44c4b847f10d01640c8e80 Mon Sep 17 00:00:00 2001
From: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
Date: Mon, 3 Oct 2022 15:47:18 -0700
Subject: [PATCH 1/2] Remove configureLanguageServiceBuild
---
Gulpfile.js | 4 --
scripts/configureLanguageServiceBuild.ts | 87 ------------------------
2 files changed, 91 deletions(-)
delete mode 100644 scripts/configureLanguageServiceBuild.ts
diff --git a/Gulpfile.js b/Gulpfile.js
index 5f4f365915dda..07d2d838753b5 100644
--- a/Gulpfile.js
+++ b/Gulpfile.js
@@ -577,10 +577,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";
diff --git a/scripts/configureLanguageServiceBuild.ts b/scripts/configureLanguageServiceBuild.ts
deleted file mode 100644
index 41d189f5b859d..0000000000000
--- a/scripts/configureLanguageServiceBuild.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-///
-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 ");
- 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();
From 3264d61f3010ca9311ddd9d20af12ed596a96887 Mon Sep 17 00:00:00 2001
From: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
Date: Mon, 3 Oct 2022 15:48:23 -0700
Subject: [PATCH 2/2] Remove instrumenter
---
Gulpfile.js | 15 -------
src/instrumenter/instrumenter.ts | 43 ---------------------
src/instrumenter/tsconfig.json | 16 --------
src/loggedIO/tsconfig-tsc-instrumented.json | 25 ------------
4 files changed, 99 deletions(-)
delete mode 100644 src/instrumenter/instrumenter.ts
delete mode 100644 src/instrumenter/tsconfig.json
delete mode 100644 src/loggedIO/tsconfig-tsc-instrumented.json
diff --git a/Gulpfile.js b/Gulpfile.js
index 07d2d838753b5..ead6442b81cbb 100644
--- a/Gulpfile.js
+++ b/Gulpfile.js
@@ -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=": "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"])
diff --git a/src/instrumenter/instrumenter.ts b/src/instrumenter/instrumenter.ts
deleted file mode 100644
index c7cbb8d3ec855..0000000000000
--- a/src/instrumenter/instrumenter.ts
+++ /dev/null
@@ -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);
-}
diff --git a/src/instrumenter/tsconfig.json b/src/instrumenter/tsconfig.json
deleted file mode 100644
index 2f5b33f9e7f50..0000000000000
--- a/src/instrumenter/tsconfig.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "compilerOptions": {
- "module": "commonjs",
- "target": "es5",
- "lib": [
- "es6",
- "dom",
- "scripthost"
- ],
- "outDir": "../../built/local",
- "sourceMap": true
- },
- "files": [
- "instrumenter.ts"
- ]
-}
\ No newline at end of file
diff --git a/src/loggedIO/tsconfig-tsc-instrumented.json b/src/loggedIO/tsconfig-tsc-instrumented.json
deleted file mode 100644
index 4a0939cfc4133..0000000000000
--- a/src/loggedIO/tsconfig-tsc-instrumented.json
+++ /dev/null
@@ -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"
- ]
-}