diff --git a/.dockerignore b/.dockerignore index 1f64bbcee3236..85c3bb869a73f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -22,6 +22,7 @@ scripts/buildProtocol.js scripts/ior.js scripts/authors.js scripts/configurePrerelease.js +scripts/configureTSCBuild.js scripts/open-user-pr.js scripts/open-cherry-pick-pr.js scripts/processDiagnosticMessages.d.ts @@ -45,4 +46,4 @@ TEST-results.xml package-lock.json tests .vscode -.git \ No newline at end of file +.git diff --git a/.gitignore b/.gitignore index 4177c0e99cae1..beeaeb200ad5e 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ scripts/buildProtocol.js scripts/ior.js scripts/authors.js scripts/configurePrerelease.js +scripts/configureTSCBuild.js scripts/open-user-pr.js scripts/open-cherry-pick-pr.js scripts/processDiagnosticMessages.d.ts diff --git a/scripts/configureTSCBuild.js b/scripts/configureTSCBuild.js deleted file mode 100644 index 3eb7e9ee93595..0000000000000 --- a/scripts/configureTSCBuild.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -exports.__esModule = true; -/// -var path_1 = require("path"); -var fs_1 = require("fs"); -var assert = require("assert"); -var args = process.argv.slice(2); -// function exec(path: string, args: string[] = []) { -// const cmdLine = ["node", path, ...args].join(" "); -// console.log(cmdLine); -// execSync(cmdLine); -// } -function main() { - 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. - var packageJsonFilePath = path_1.normalize(args[0]); - var packageJsonValue = JSON.parse(fs_1.readFileSync(packageJsonFilePath).toString()); - // Remove the bin section from the current package - delete packageJsonValue.bin; - // Set the new name - packageJsonValue.name = "@orta/tsc"; - fs_1.writeFileSync(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4)); - // Remove the files which aren't use when just using the API - var 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, then remove the sibling JS files referenced above - var lib = path_1.join(path_1.dirname(packageJsonFilePath), packageJsonValue.main); - var libPath = path_1.dirname(lib); - toRemove.forEach(function (file) { - var path = path_1.join(libPath, file); - if (fs_1.existsSync(path)) - fs_1.unlinkSync(path); - }); - /////////////////////////////////// - // This section verifies that the build of TypeScript compiles and emits - var ts = require("../" + lib); - var source = "let x: string = 'string'"; - var results = ts.transpileModule(source, { - compilerOptions: { module: ts.ModuleKind.CommonJS } - }); - console.log(Object.keys(results)); - assert(results.outputText.trim() === "var x = 'string';", "Running typescript with " + packageJsonValue.name + " did not return the expected results, got: " + results.outputText); -} -main(); diff --git a/scripts/configureTSCBuild.ts b/scripts/configureTSCBuild.ts index 8fd76eab1bb99..491784d9350df 100644 --- a/scripts/configureTSCBuild.ts +++ b/scripts/configureTSCBuild.ts @@ -5,8 +5,6 @@ import assert = require("assert"); import { execSync } from "child_process"; const args = process.argv.slice(2); - - /** * A minimal description for a parsed package.json object. */ @@ -14,14 +12,12 @@ interface PackageJson { name: string; bin: {}; main: string; + scripts: { + prepare: string + postpublish: string + } } -// function exec(path: string, args: string[] = []) { -// const cmdLine = ["node", path, ...args].join(" "); -// console.log(cmdLine); -// execSync(cmdLine); -// } - function main(): void { if (args.length < 1) { console.log("Usage:"); @@ -35,9 +31,13 @@ function main(): void { // 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 = "@orta/tsc"; + packageJsonValue.name = "@orta/language-services"; writeFileSync(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4)); @@ -54,14 +54,22 @@ function main(): void { "tsserverlibrary.d.ts" ]; - // Get a link to the main dependency JS file, then remove the sibling JS files referenced above + // 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 @@ -72,11 +80,8 @@ function main(): void { const results =ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS } }); - console.log(Object.keys(results)); assert(results.outputText.trim() === "var x = 'string';", `Running typescript with ${packageJsonValue.name} did not return the expected results, got: ${results.outputText}`); - - } main();