2022-03-01 15:40:32 -05:00
|
|
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
2022-04-02 11:25:12 -04:00
|
|
|
import { path, ReleasesMdFile, Repo } from "./deps.ts";
|
2022-03-01 15:40:32 -05:00
|
|
|
|
|
|
|
export class DenoWorkspace {
|
|
|
|
#repo: Repo;
|
|
|
|
|
|
|
|
static get rootDirPath() {
|
|
|
|
const currentDirPath = path.dirname(path.fromFileUrl(import.meta.url));
|
|
|
|
return path.resolve(currentDirPath, "../../");
|
|
|
|
}
|
|
|
|
|
|
|
|
static async load(): Promise<DenoWorkspace> {
|
|
|
|
return new DenoWorkspace(
|
2022-03-30 16:37:00 -04:00
|
|
|
await Repo.load({
|
|
|
|
name: "deno",
|
|
|
|
path: DenoWorkspace.rootDirPath,
|
|
|
|
}),
|
2022-03-01 15:40:32 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private constructor(repo: Repo) {
|
|
|
|
this.#repo = repo;
|
|
|
|
}
|
|
|
|
|
|
|
|
get repo() {
|
|
|
|
return this.#repo;
|
|
|
|
}
|
|
|
|
|
|
|
|
get crates() {
|
|
|
|
return this.#repo.crates;
|
|
|
|
}
|
|
|
|
|
2022-03-16 20:33:14 -04:00
|
|
|
/** Gets the CLI dependency crates that should be published. */
|
|
|
|
getCliDependencyCrates() {
|
|
|
|
return this.getCliCrate()
|
|
|
|
.descendantDependenciesInRepo()
|
|
|
|
.filter((c) => c.name !== "test_util");
|
2022-03-01 15:40:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
getCliCrate() {
|
|
|
|
return this.getCrate("deno");
|
|
|
|
}
|
|
|
|
|
|
|
|
getCrate(name: string) {
|
|
|
|
return this.#repo.getCrate(name);
|
|
|
|
}
|
2022-03-04 22:28:23 -05:00
|
|
|
|
2022-04-02 11:25:12 -04:00
|
|
|
getReleasesMdFile() {
|
|
|
|
return new ReleasesMdFile(
|
|
|
|
path.join(DenoWorkspace.rootDirPath, "Releases.md"),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-03-04 22:28:23 -05:00
|
|
|
runFormatter() {
|
|
|
|
return this.#repo.runCommandWithOutput([
|
|
|
|
"deno",
|
|
|
|
"run",
|
|
|
|
"--allow-write",
|
|
|
|
"--allow-read",
|
|
|
|
"--allow-run",
|
|
|
|
"./tools/format.js",
|
|
|
|
]);
|
|
|
|
}
|
2022-03-01 15:40:32 -05:00
|
|
|
}
|