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]!;
11
12it.layer(NodeServices.layer)("sync-reference-repos", (it) => {
13 it.effect("resolves the effect-smol tag from the root catalog", () =>
14 Effect.gen(function* () {
15 const fs = yield* FileSystem.FileSystem;
16 const path = yield* Path.Path;
17 const rootDir = yield* fs.makeTempDirectoryScoped({
18 prefix: "sync-reference-repos-version-",
19 });
20 yield* fs.writeFileString(
21 path.join(rootDir, "pnpm-workspace.yaml"),
22 "catalog:\n effect: 4.0.0-beta.73\n",
23 );
24
25 assert.equal(
26 yield* resolveReferenceRepoRef(effectSmol, rootDir, false),
27 "effect@4.0.0-beta.73",
28 );
29 }),
30 );
31
32 it.effect("plans an add for a missing subtree and a pull for an existing subtree", () =>
33 Effect.gen(function* () {
34 const fs = yield* FileSystem.FileSystem;
35 const path = yield* Path.Path;
36 const rootDir = yield* fs.makeTempDirectoryScoped({
37 prefix: "sync-reference-repos-plan-",
38 });
39 yield* fs.writeFileString(
40 path.join(rootDir, "pnpm-workspace.yaml"),
41 "catalog:\n effect: 4.0.0-beta.73\n",
42 );
43
44 const addPlan = yield* planReferenceRepoSync(effectSmol, rootDir, false);
45 assert.equal(addPlan.action, "add");
46 assert.deepStrictEqual(addPlan.args, [
47 "subtree",
48 "add",
49 "--prefix=.repos/effect-smol",
50 "https://github.com/Effect-TS/effect.git",
51 "effect@4.0.0-beta.73",
52 "--squash",
53 ]);
54
55 yield* fs.makeDirectory(path.join(rootDir, effectSmol.prefix), { recursive: true });
56 assert.equal((yield* planReferenceRepoSync(effectSmol, rootDir, false)).action, "pull");
57 }),
58 );
59});