@definitelytyped/utils
Advanced tools
Comparing version 0.0.188 to 0.0.189
# @definitelytyped/utils | ||
## 0.0.189 | ||
### Patch Changes | ||
- f53f17f6: Use package dependencies to manage TypeScript, instead of `$HOME/.dts` | ||
- Updated dependencies [f53f17f6] | ||
- Updated dependencies [f53f17f6] | ||
- @definitelytyped/typescript-packages@0.0.2 | ||
## 0.0.188 | ||
@@ -4,0 +13,0 @@ |
import { TypeScriptVersion } from "@definitelytyped/typescript-versions"; | ||
export type TsVersion = TypeScriptVersion | "local"; | ||
export declare function installAllTypeScriptVersions(): Promise<void>; | ||
export declare function installTypeScriptNext(): Promise<void>; | ||
export declare function install(version: TsVersion | "next" | "rc"): Promise<void>; | ||
export declare function cleanTypeScriptInstalls(): Promise<void>; | ||
export declare function typeScriptPath(version: TsVersion | "next" | "rc", tsLocal: string | undefined): string; | ||
export declare function typeScriptPath(version: TsVersion, tsLocal: string | undefined): string; |
@@ -26,52 +26,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.typeScriptPath = exports.cleanTypeScriptInstalls = exports.install = exports.installTypeScriptNext = exports.installAllTypeScriptVersions = void 0; | ||
const assert = require("assert"); | ||
const child_process_1 = require("child_process"); | ||
const fs = __importStar(require("fs")); | ||
const os = __importStar(require("os")); | ||
const path = __importStar(require("path")); | ||
const process = __importStar(require("process")); | ||
const typescript_versions_1 = require("@definitelytyped/typescript-versions"); | ||
const installsDir = path.join(os.homedir(), ".dts", "typescript-installs"); | ||
async function installAllTypeScriptVersions() { | ||
for (const v of typescript_versions_1.TypeScriptVersion.shipped) { | ||
await install(v); | ||
} | ||
// `shipped + [rc, next] == supported` during the RC period. During that time, typescript@rc needs to be installed too. | ||
if (typescript_versions_1.TypeScriptVersion.shipped.length + 2 === typescript_versions_1.TypeScriptVersion.supported.length) { | ||
await install("rc"); | ||
} | ||
await installTypeScriptNext(); | ||
} | ||
exports.installAllTypeScriptVersions = installAllTypeScriptVersions; | ||
async function installTypeScriptNext() { | ||
await install("next"); | ||
} | ||
exports.installTypeScriptNext = installTypeScriptNext; | ||
async function install(version) { | ||
if (version === "local") { | ||
return; | ||
} | ||
const dir = installDir(version); | ||
if (!fs.existsSync(dir)) { | ||
console.log(`Installing to ${dir}...`); | ||
await fs.promises.mkdir(dir, { recursive: true }); | ||
await fs.promises.writeFile(path.join(dir, "package.json"), JSON.stringify({ | ||
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(""); | ||
} | ||
} | ||
exports.install = install; | ||
function cleanTypeScriptInstalls() { | ||
return fs.promises.rm(installsDir, { recursive: true, force: true }); | ||
} | ||
exports.cleanTypeScriptInstalls = cleanTypeScriptInstalls; | ||
exports.typeScriptPath = void 0; | ||
const typeScriptPackages = __importStar(require("@definitelytyped/typescript-packages")); | ||
function typeScriptPath(version, tsLocal) { | ||
@@ -81,34 +33,5 @@ if (version === "local") { | ||
} | ||
return path.join(installDir(version), "node_modules", "typescript"); | ||
return typeScriptPackages.resolve(version); | ||
} | ||
exports.typeScriptPath = typeScriptPath; | ||
function installDir(version) { | ||
assert(version !== "local"); | ||
if (version === "next") | ||
version = typescript_versions_1.TypeScriptVersion.latest; | ||
if (version === "rc") | ||
version = typescript_versions_1.TypeScriptVersion.supported[typescript_versions_1.TypeScriptVersion.supported.length - 2]; | ||
return path.join(installsDir, version); | ||
} | ||
/** Run a command and return the stdout, or if there was an error, throw. */ | ||
async function execAndThrowErrors(cmd, cwd) { | ||
// tslint:disable-next-line:promise-must-complete | ||
return new Promise((resolve, reject) => { | ||
const env = { ...process.env }; | ||
if (env.NODE_OPTIONS && env.NODE_OPTIONS.includes("--require")) { | ||
delete env.NODE_OPTIONS; | ||
} | ||
(0, child_process_1.exec)(cmd, { encoding: "utf8", cwd, env }, (err, _stdout, stderr) => { | ||
if (stderr) { | ||
console.error(stderr); | ||
} | ||
if (err) { | ||
reject(err); | ||
} | ||
else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
//# sourceMappingURL=typescript-installer.js.map |
{ | ||
"name": "@definitelytyped/utils", | ||
"version": "0.0.188", | ||
"version": "0.0.189", | ||
"description": "Shared utilities for DefinitelyTyped tools", | ||
@@ -25,3 +25,4 @@ "homepage": "https://github.com/microsoft/DefinitelyTyped-tools/tree/master/packages/utils#readme", | ||
"which": "^4.0.0", | ||
"@definitelytyped/typescript-versions": "0.0.182" | ||
"@definitelytyped/typescript-versions": "0.0.182", | ||
"@definitelytyped/typescript-packages": "0.0.2" | ||
}, | ||
@@ -28,0 +29,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
5
4
124305
9
1823
+ Added@definitelytyped/typescript-packages@0.0.2(transitive)
+ Addedtypescript@4.6.44.7.44.8.44.9.55.0.45.1.65.2.25.3.35.4.5(transitive)