Initial commit

This commit is contained in:
Alejandro Martinez
2026-02-12 02:04:10 +01:00
commit f09af719cf
13433 changed files with 2193445 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
function getYarnOutputDepVersion(dependency, outputLine) {
const parsed = JSON.parse(outputLine);
for (const [key, value] of Object.entries(parsed.children)) {
if (key.startsWith(`${dependency}@`)) {
return `v${value.locator.split(":").pop()}`;
}
}
}
class YarnPackageManager {
name = "yarn";
#commandExecutor;
constructor({ commandExecutor }) {
this.#commandExecutor = commandExecutor;
}
async getPackageVersion(name) {
try {
const { stdout } = await this.#commandExecutor.execute("yarn", ["why", name, "--json"], {
shell: true
});
const hasUserDefinition = stdout.includes("workspace:.");
for (const line of stdout.split("\n")) {
if (hasUserDefinition && line.includes("workspace:."))
return getYarnOutputDepVersion(name, line);
if (!hasUserDefinition && line.includes("astro@"))
return getYarnOutputDepVersion(name, line);
}
} catch {
return void 0;
}
}
}
export {
YarnPackageManager
};