import * as NodeServices from "@effect/platform-node/NodeServices";
import { assert, it } from "@effect/vitest";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";
import { referenceRepos } from "./lib/reference-repos.ts";
import { planReferenceRepoSync, resolveReferenceRepoRef } from "./sync-reference-repos.ts";
const effectRepo = referenceRepos[0]!;
const alchemyEffect = referenceRepos[1]!;
it.layer(NodeServices.layer)("sync-reference-repos", (it) => {
it.effect("resolves reference tags from the root catalog", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const rootDir = yield* fs.makeTempDirectoryScoped({
prefix: "sync-reference-repos-version-",
});
yield* fs.writeFileString(
path.join(rootDir, "pnpm-workspace.yaml"),
"catalog:\n alchemy: 2.0.0-beta.84\n effect: 4.0.0-beta.73\n",
);
assert.equal(
yield* resolveReferenceRepoRef(effectRepo, rootDir, false),
"effect@4.0.0-beta.73",
);
assert.equal(yield* resolveReferenceRepoRef(alchemyEffect, rootDir, false), "v2.0.0-beta.84");
}),
);
it.effect("plans a shallow, tagless clone of the resolved ref", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const rootDir = yield* fs.makeTempDirectoryScoped({
prefix: "sync-reference-repos-plan-",
});
yield* fs.writeFileString(
path.join(rootDir, "pnpm-workspace.yaml"),
"catalog:\n effect: 4.0.0-beta.73\n",
);
const plan = yield* planReferenceRepoSync(effectRepo, rootDir, false);
assert.equal(plan.ref, "effect@4.0.0-beta.73");
assert.deepStrictEqual(plan.cloneArgs, [
"clone",
"--quiet",
"--depth=1",
"--no-tags",
"--single-branch",
"--branch=effect@4.0.0-beta.73",
"https://github.com/Effect-TS/effect.git",
]);
}),
);
});