Vendor things

This commit is contained in:
John Doty 2024-03-08 11:03:01 -08:00
parent 5deceec006
commit 977e3c17e5
19434 changed files with 10682014 additions and 0 deletions

View file

@ -0,0 +1,25 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { Repos } from "./repos.ts";
import { $ } from "./deps.ts";
const repos = await Repos.load();
// Ensure repos are latest main
for (const repo of repos.nonDenoAstRepos()) {
$.logStep("Setting up", `${repo.name}...`);
if (await repo.hasLocalChanges()) {
throw new Error(
`Repo ${repo.name} had local changes. Please resolve this.`,
);
}
$.logGroup();
$.logStep("Switching to main...");
await repo.command("git switch main");
$.logStep("Pulling upstream main...");
await repo.command("git pull upstream main");
$.logGroupEnd();
}
// Update the repos to refer to local versions of each other
await repos.toLocalSource();

View file

@ -0,0 +1,11 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { Repos } from "./repos.ts";
import { $ } from "./deps.ts";
const repos = await Repos.load();
for (const crate of repos.getCrates()) {
$.logStep(`Building ${crate.name}...`);
await crate.build({ allFeatures: true });
}

View file

@ -0,0 +1,15 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { $ } from "./deps.ts";
import { Repos } from "./repos.ts";
const repos = await Repos.load();
let hadConfirmed = false;
for (const crate of repos.getCrates()) {
if (hadConfirmed || confirm(`Do you want to run tests for ${crate.name}?`)) {
hadConfirmed = true;
$.logStep("Running tests", `for ${crate.name}...`);
await crate.test({ allFeatures: true });
}
}

View file

@ -0,0 +1,83 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { $, Repo } from "./deps.ts";
import { Repos } from "./repos.ts";
const repos = await Repos.load();
const denoRepo = repos.get("deno");
const deno_ast = repos.getCrate("deno_ast");
const nonDenoRepos = repos.getRepos().filter((c) => c.name !== "deno");
// create a branch, commit, push for the non-deno repos
for (const repo of nonDenoRepos) {
if (!await repo.hasLocalChanges()) {
continue;
}
const currentBranch = await repo.gitCurrentBranch();
$.logStep("Analyzing", repo.name);
$.logLight("Branch:", currentBranch);
if (
confirm(
`Bump deps? (Note: do this after the dependency crates have PUBLISHED)`,
)
) {
await bumpDeps(repo);
for (const crate of repo.crates) {
await crate.cargoCheck();
}
if (
currentBranch === "main" &&
confirm(`Branch for ${repo.name}?`)
) {
await repo.gitBranch("deno_ast_" + deno_ast.version);
}
if (
await repo.hasLocalChanges() &&
confirm(`Commit and push for ${repo.name}?`)
) {
await repo.gitAdd();
await repo.gitCommit(`feat: upgrade deno_ast to ${deno_ast.version}`);
await repo.gitPush();
}
}
}
// now branch, commit, and push for the deno repo
$.logStep("Analyzing Deno");
const currentBranch = await denoRepo.gitCurrentBranch();
$.logLight("Branch:", currentBranch);
if (confirm(`Bump deps for deno?`)) {
await bumpDeps(denoRepo);
for (const crate of denoRepo.crates) {
await crate.cargoCheck();
}
if (
currentBranch === "main" &&
confirm(`Branch for deno?`)
) {
await denoRepo.gitBranch("deno_ast_" + deno_ast.version);
}
if (
await denoRepo.hasLocalChanges() && confirm(`Commit and push for deno?`)
) {
await denoRepo.gitAdd();
await denoRepo.gitCommit(
`chore: upgrade to deno_ast ${deno_ast.version}`,
);
await denoRepo.gitPush();
}
}
async function bumpDeps(repo: Repo) {
for (const crate of repo.crates) {
for (const depCrate of repos.getCrateLocalSourceCrates(crate)) {
await crate.revertLocalSource(depCrate);
const version = await depCrate.getLatestVersion();
if (version == null) {
throw new Error(`Did not find version for ${crate.name}`);
}
await crate.setDependencyVersion(depCrate.name, version);
}
}
}

View file

@ -0,0 +1,29 @@
# Scripts
These scripts provide a way to help upgrade, test, and open PRs in downstream
crates on an swc version bump.
## Setup
1. Ensure all repos are cloned into sibling directories:
- `./deno`
- `./deno_ast`
- `./deno_doc`
- `./deno_emit`
- `./deno_graph`
- `./deno_lint`
- `./dprint-plugin-typescript`
2. Ensure all repos have an `upstream` remote defined as the original repo.
## Overview
- `01_setup.ts` - Ensures all downstream crates are on the latest main, then
points them at local copies of each other.
- `02_build.ts` - Builds each crate. If you encounter any build errors, fix them
and keep running this until everything builds.
- `03_test.ts` - Tests each crate. If you encounter test failures, fix them and
keep running this until all the tests pass.
- `04_confirm.ts` - Updates the dependency versions, creates a branch, commits,
and pushes a branch for every selected repo.

View file

@ -0,0 +1,3 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
export * from "https://raw.githubusercontent.com/denoland/automation/0.19.2/mod.ts";

View file

@ -0,0 +1,149 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { $, Crate, Repo } from "./deps.ts";
export const rootDir = $.path.resolve(
$.path.join($.path.fromFileUrl(import.meta.url), "../../../../"),
);
const repoNames = [
"deno_ast",
"deno_graph",
"deno_lint",
"dprint-plugin-typescript",
"deno_doc",
"eszip",
"deno_emit",
"deno",
];
export class Repos {
#repos: readonly Repo[];
private constructor(repos: readonly Repo[]) {
this.#repos = repos;
}
static createWithoutLoading() {
return;
}
static async load({ skipLoadingCrates = false } = {}) {
if (!skipLoadingCrates) {
$.logStep("Loading repos...");
}
const repos = [];
for (const repoName of repoNames) {
$.logStep("Loading", repoName);
repos.push(await loadRepo(repoName));
}
return new Repos(repos);
function loadRepo(name: string) {
return Repo.load({
name,
path: $.path.join(rootDir, name),
skipLoadingCrates,
}).catch((err) => {
console.error(`Error loading: ${name}`);
throw err;
});
}
}
getRepos() {
return [...this.#repos];
}
getCrates() {
const crates = [];
for (const repo of this.#repos) {
if (repo.name === "deno") {
crates.push(repo.getCrate("deno"));
} else {
crates.push(
...repo.crates.filter((c) =>
c.name !== "eszip_wasm" && c.name !== "deno_emit_wasm"
),
);
}
}
return crates;
}
nonDenoAstRepos() {
return this.#repos.filter((c) => c.name !== "deno_ast");
}
get(name: string) {
const repo = this.#repos.find((c) => c.name === name);
if (repo == null) {
throw new Error(`Could not find repo with name ${name}.`);
}
return repo;
}
getCrate(name: string) {
for (const repo of this.#repos) {
for (const crate of repo.crates) {
if (crate.name === name) {
return crate;
}
}
}
throw new Error(`Could not find crate: ${name}`);
}
async toLocalSource() {
for (
const [workingCrate, otherCrate] of this.#getLocalSourceRelationships()
) {
await workingCrate.toLocalSource(otherCrate);
}
}
async revertLocalSource() {
for (
const [workingCrate, depCrate] of this.#getLocalSourceRelationships()
) {
await workingCrate.revertLocalSource(depCrate);
}
}
getCrateLocalSourceCrates(crate: Crate) {
return this.#getLocalSourceRelationships()
.filter(([workingCrate]) => workingCrate === crate)
.map(([_workingCrate, depCrate]) => depCrate);
}
#getLocalSourceRelationships() {
const deno_ast = this.getCrate("deno_ast");
const deno_graph = this.getCrate("deno_graph");
const deno_doc = this.getCrate("deno_doc");
const deno_lint = this.getCrate("deno_lint");
const dprint_plugin_typescript = this.getCrate("dprint-plugin-typescript");
const deno_cli = this.getCrate("deno");
const eszip = this.getCrate("eszip");
const deno_emit = this.getCrate("deno_emit");
return [
[deno_graph, deno_ast],
[deno_doc, deno_ast],
[deno_doc, deno_graph],
[eszip, deno_ast],
[eszip, deno_graph],
[deno_lint, deno_ast],
[dprint_plugin_typescript, deno_ast],
[deno_emit, deno_graph],
[deno_emit, deno_ast],
[deno_cli, deno_ast],
[deno_cli, deno_graph],
[deno_cli, deno_doc],
[deno_cli, deno_lint],
[deno_cli, eszip],
[deno_cli, dprint_plugin_typescript],
[deno_cli, deno_emit],
] as [Crate, Crate][];
}
}

View file

@ -0,0 +1,9 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { Repos } from "./repos.ts";
const repos = await Repos.load({ skipLoadingCrates: true });
if (confirm("Are you sure you want to git reset --hard all the repos?")) {
await Promise.all(repos.nonDenoAstRepos().map((c) => c.gitResetHard()));
}