summaryrefslogtreecommitdiff
path: root/tools/release/deno_workspace.ts
blob: 725d647df4b7b673830525bc03ec17926230b002 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.

import { path, Repo } from "./deps.ts";

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(
      await Repo.load("deno", DenoWorkspace.rootDirPath),
    );
  }

  private constructor(repo: Repo) {
    this.#repo = repo;
  }

  get repo() {
    return this.#repo;
  }

  get crates() {
    return this.#repo.crates;
  }

  /** Gets the dependency crates used for the first part of the release process. */
  getDependencyCrates() {
    return [
      this.getBenchUtilCrate(),
      this.getSerdeV8Crate(),
      this.getCoreCrate(),
      ...this.getExtCrates(),
      this.getRuntimeCrate(),
    ];
  }

  getSerdeV8Crate() {
    return this.getCrate("serde_v8");
  }

  getCliCrate() {
    return this.getCrate("deno");
  }

  getCoreCrate() {
    return this.getCrate("deno_core");
  }

  getRuntimeCrate() {
    return this.getCrate("deno_runtime");
  }

  getBenchUtilCrate() {
    return this.getCrate("deno_bench_util");
  }

  getExtCrates() {
    const extPath = path.join(this.#repo.folderPath, "ext");
    return this.crates.filter((c) => c.manifestPath.startsWith(extPath));
  }

  getCrate(name: string) {
    return this.#repo.getCrate(name);
  }
}