Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RC installation #678

Merged
merged 2 commits into from May 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 14 additions & 14 deletions packages/utils/src/typescript-installer.ts
Expand Up @@ -14,22 +14,32 @@ export async function installAllTypeScriptVersions() {
for (const v of TypeScriptVersion.shipped) {
await install(v);
}
if (TypeScriptVersion.shipped.length + 2 === TypeScriptVersion.supported.length) {
await install("rc");
}
await installTypeScriptNext();
}

export async function installTypeScriptNext() {
await install("next");
}

async function install(version: TsVersion | "next"): Promise<void> {
async function install(version: TsVersion | "next" | "rc"): Promise<void> {
jakebailey marked this conversation as resolved.
Show resolved Hide resolved
if (version === "local") {
return;
}
const dir = installDir(version);
if (!(await fs.pathExists(dir))) {
console.log(`Installing to ${dir}...`);
await fs.mkdirp(dir);
await fs.writeJson(path.join(dir, "package.json"), packageJson(version));
await fs.writeJson(path.join(dir, "package.json"), {
description: `Installs typescript@${version}`,
repository: "N/A",
license: "MIT",
dependencies: {
typescript: version,
},
});
await execAndThrowErrors("npm install --ignore-scripts --no-shrinkwrap --no-package-lock --no-bin-links", dir);
console.log("Installed!");
console.log("");
Expand All @@ -47,9 +57,10 @@ export function typeScriptPath(version: TsVersion, tsLocal: string | undefined):
return path.join(installDir(version), "node_modules", "typescript");
}

function installDir(version: TsVersion | "next"): string {
function installDir(version: TsVersion | "next" | "rc"): string {
assert(version !== "local");
if (version === "next") version = TypeScriptVersion.latest;
if (version === "rc") version = TypeScriptVersion.supported[TypeScriptVersion.supported.length - 2];
return path.join(installsDir, version);
}

Expand All @@ -74,14 +85,3 @@ async function execAndThrowErrors(cmd: string, cwd?: string): Promise<void> {
});
});
}

function packageJson(version: TsVersion | "next"): {} {
return {
description: `Installs typescript@${version}`,
repository: "N/A",
license: "MIT",
dependencies: {
typescript: version,
},
};
}