UNPKG

@tsed/cli-core

Version:
50 lines (49 loc) 1.57 kB
import { __decorate } from "tslib"; import { join } from "node:path"; import { inject, Injectable } from "@tsed/di"; import { Observable } from "rxjs"; import { CliFs } from "../../services/CliFs.js"; import { CliYaml } from "../../services/CliYaml.js"; import { BaseManager } from "./BaseManager.js"; let YarnBerryManager = class YarnBerryManager extends BaseManager { constructor() { super(...arguments); this.name = "yarn_berry"; this.cmd = "yarn"; this.verboseOpt = ""; this.cliYaml = inject(CliYaml); this.fs = inject(CliFs); } async init(options) { const lockFile = join(String(options.cwd), "yarn.lock"); if (!this.fs.exists(lockFile)) { this.fs.writeFileSync(lockFile, ""); } // init yarn v1 try { await this.install(options).toPromise(); } catch (er) { } // then switch write file await this.cliYaml.write(join(String(options.cwd), ".yarnrc.yml"), { nodeLinker: "node-modules" }); // then switch to berry this.cliExeca.runSync(this.cmd, ["set", "version", "berry"]); } add(deps, options) { return this.run("add", [...deps], options); } addDev(deps, options) { return this.run("add", ["-D", ...deps], options); } install(options) { return this.run("install", [], options); } }; YarnBerryManager = __decorate([ Injectable({ type: "package:manager" }) ], YarnBerryManager); export { YarnBerryManager };