Skip to content

Commit

Permalink
Rename the smaller build to '@typescript/language-services' and have …
Browse files Browse the repository at this point in the history
…a separate build step for creating and publishing vs configuring the build
  • Loading branch information
orta committed Sep 26, 2019
1 parent 31c08b6 commit 92b3266
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ scripts/buildProtocol.js
scripts/ior.js
scripts/authors.js
scripts/configurePrerelease.js
scripts/configureTSCBuild.js
scripts/configureLanguageServiceBuild.js
scripts/createLanguageServiceBuild.js
scripts/open-user-pr.js
scripts/open-cherry-pick-pr.js
scripts/processDiagnosticMessages.d.ts
Expand Down
6 changes: 3 additions & 3 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ 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 configureTSCOnly = () => exec(process.execPath, ["scripts/configureTSCBuild.js", "package.json", "src/compiler/core.ts"]);
task("configure-tsc-only", series(buildScripts, configureNightly));
task("configure-tsc-only").description = "Runs scripts/configureTSCOnly.ts to prepare a build for build which only has tsc ";
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));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"scripts": {
"prepare": "gulp build-eslint-rules",
"pretest": "gulp tests",
"postpublish": "gulp configure-tsc-only",
"postpublish": "gulp create-language-services-build",
"test": "gulp runtests-parallel --light=false",
"test:eslint-rules": "gulp run-eslint-rules-tests",
"build": "npm run build:compiler && npm run build:tests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function main(): void {
delete packageJsonValue.scripts.postpublish;

// Set the new name
packageJsonValue.name = "@orta/language-services";
packageJsonValue.name = "@typescript/language-services";

writeFileSync(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4));

Expand Down Expand Up @@ -74,10 +74,10 @@ function main(): void {

// This section verifies that the build of TypeScript compiles and emits

const ts = require("../" + lib);
const ts = require(lib);
const source = "let x: string = 'string'";

const results =ts.transpileModule(source, {
const results = ts.transpileModule(source, {
compilerOptions: { module: ts.ModuleKind.CommonJS }
});

Expand Down
46 changes: 46 additions & 0 deletions scripts/createLanguageServiceBuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/// <reference types="node"/>
import { join } from "path";
import { readFileSync, unlinkSync } from "fs";
import { tmpdir } from "os";
import { execSync, ExecSyncOptions } from "child_process";
import chalk from "chalk";

interface PackageJson {
name: string;
version: string
}

const exec = (cmd: string, opts?: ExecSyncOptions) => {
console.log(chalk.gray(`> ${cmd} ${opts ? JSON.stringify(opts) : ""}`));
execSync(cmd, opts);
};

const step = (msg: string) => {
console.log("\n\n" + chalk.bold("- ") + msg);
};

function main(): void {
console.log(chalk.bold("## Creating the language services build of TypeScript"));
process.stdout.write(chalk.grey("> node /scripts/createLanguageServiceBuild.ts"));

// Create a tarball of the current version
step("Packing the current TypeScript via npm.");
exec("npm pack");

const packageJsonValue: PackageJson = JSON.parse(readFileSync("package.json", "utf8"));
const tarballFileName = `${packageJsonValue.name}-${packageJsonValue.version}.tgz`;

const unzipDir = tmpdir();
step(`Extracting the built version into a temporary folder. ${unzipDir}/package`);
exec(`tar -xvzf ${tarballFileName} -C ${unzipDir}`);
unlinkSync(tarballFileName);

step(`Updating the build metadata`);
const packagePath = join(unzipDir, "package");
exec(`node scripts/configureLanguageServiceBuild.js ${join(packagePath, "package.json")}`);

step(`Deploying the language service`);
exec("npm publish --access public", { cwd: packagePath });
}

main();

0 comments on commit 92b3266

Please sign in to comment.