Open History to see the last commit
1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { assert, it } from "@effect/vitest";
3import * as Effect from "effect/Effect";
4import * as FileSystem from "effect/FileSystem";
5import * as Path from "effect/Path";
6
7import { referenceRepos } from "./lib/reference-repos.ts";
8import { planReferenceRepoSync, resolveReferenceRepoRef } from "./sync-reference-repos.ts";
9
10const effectSmol = referenceRepos[0]!;
11const alchemyEffect = referenceRepos[1]!;
12
13it.layer(NodeServices.layer)("sync-reference-repos", (it) => {
14 it.effect("resolves reference tags from the root catalog", () =>
15 Effect.gen(function* () {
16 const fs = yield* FileSystem.FileSystem;
17 const path = yield* Path.Path;
18 const rootDir = yield* fs.makeTempDirectoryScoped({
19 prefix: "sync-reference-repos-version-",
20 });
21 yield* fs.writeFileString(
22 path.join(rootDir, "pnpm-workspace.yaml"),
23 "catalog:\n alchemy: 2.0.0-beta.84\n effect: 4.0.0-beta.73\n",
24 );
25
26 assert.equal(
27 yield* resolveReferenceRepoRef(effectSmol, rootDir, false),
28 "effect@4.0.0-beta.73",
29 );
30 assert.equal(yield* resolveReferenceRepoRef(alchemyEffect, rootDir, false), "v2.0.0-beta.84");
31 }),
32 );
33
34 it.effect("plans an add for a missing subtree and a pull for an existing subtree", () =>
35 Effect.gen(function* () {
36 const fs = yield* FileSystem.FileSystem;
37 const path = yield* Path.Path;
38 const rootDir = yield* fs.makeTempDirectoryScoped({
39 prefix: "sync-reference-repos-plan-",
40 });
41 yield* fs.writeFileString(
42 path.join(rootDir, "pnpm-workspace.yaml"),
43 "catalog:\n effect: 4.0.0-beta.73\n",
44 );
45
46 const addPlan = yield* planReferenceRepoSync(effectSmol, rootDir, false);
47 assert.equal(addPlan.action, "add");
48 assert.deepStrictEqual(addPlan.args, [
49 "subtree",
50 "add",
51 "--prefix=.repos/effect-smol",
52 "https://github.com/Effect-TS/effect.git",
53 "effect@4.0.0-beta.73",
54 "--squash",
55 ]);
56
57 yield* fs.makeDirectory(path.join(rootDir, effectSmol.prefix), { recursive: true });
58 assert.equal((yield* planReferenceRepoSync(effectSmol, rootDir, false)).action, "pull");
59 }),
60 );
61});