|
| 1 | +import { Option } from "effect" |
1 | 2 | import { expect, spyOn, test } from "bun:test" |
2 | 3 | import fs from "fs/promises" |
3 | 4 | import path from "path" |
4 | 5 | import { pathToFileURL } from "url" |
5 | 6 | import { tmpdir } from "../../fixture/fixture" |
6 | 7 | import { createTuiPluginApi } from "../../fixture/tui-plugin" |
7 | 8 | import { TuiConfig } from "../../../src/cli/cmd/tui/config/tui" |
8 | | -import { Npm } from "../../../src/npm" |
| 9 | +import { Npm } from "../../../src/npm/effect" |
9 | 10 |
|
10 | 11 | const { TuiPluginRuntime } = await import("../../../src/cli/cmd/tui/plugin/runtime") |
11 | 12 |
|
@@ -56,7 +57,7 @@ test("loads npm tui plugin from package ./tui export", async () => { |
56 | 57 | } |
57 | 58 | const wait = spyOn(TuiConfig, "waitForDependencies").mockResolvedValue() |
58 | 59 | const cwd = spyOn(process, "cwd").mockImplementation(() => tmp.path) |
59 | | - const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: tmp.extra.mod }) |
| 60 | + const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: Option.none() }) |
60 | 61 |
|
61 | 62 | try { |
62 | 63 | await TuiPluginRuntime.init({ api: createTuiPluginApi(), config }) |
@@ -117,7 +118,7 @@ test("does not use npm package exports dot for tui entry", async () => { |
117 | 118 | } |
118 | 119 | const wait = spyOn(TuiConfig, "waitForDependencies").mockResolvedValue() |
119 | 120 | const cwd = spyOn(process, "cwd").mockImplementation(() => tmp.path) |
120 | | - const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: tmp.extra.mod }) |
| 121 | + const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: Option.none() }) |
121 | 122 |
|
122 | 123 | try { |
123 | 124 | await TuiPluginRuntime.init({ api: createTuiPluginApi(), config }) |
@@ -179,7 +180,7 @@ test("rejects npm tui export that resolves outside plugin directory", async () = |
179 | 180 | } |
180 | 181 | const wait = spyOn(TuiConfig, "waitForDependencies").mockResolvedValue() |
181 | 182 | const cwd = spyOn(process, "cwd").mockImplementation(() => tmp.path) |
182 | | - const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: tmp.extra.mod }) |
| 183 | + const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: Option.none() }) |
183 | 184 |
|
184 | 185 | try { |
185 | 186 | await TuiPluginRuntime.init({ api: createTuiPluginApi(), config }) |
@@ -241,7 +242,7 @@ test("rejects npm tui plugin that exports server and tui together", async () => |
241 | 242 | } |
242 | 243 | const wait = spyOn(TuiConfig, "waitForDependencies").mockResolvedValue() |
243 | 244 | const cwd = spyOn(process, "cwd").mockImplementation(() => tmp.path) |
244 | | - const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: tmp.extra.mod }) |
| 245 | + const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: Option.none() }) |
245 | 246 |
|
246 | 247 | try { |
247 | 248 | await TuiPluginRuntime.init({ api: createTuiPluginApi(), config }) |
@@ -299,7 +300,7 @@ test("does not use npm package main for tui entry", async () => { |
299 | 300 | } |
300 | 301 | const wait = spyOn(TuiConfig, "waitForDependencies").mockResolvedValue() |
301 | 302 | const cwd = spyOn(process, "cwd").mockImplementation(() => tmp.path) |
302 | | - const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: tmp.extra.mod }) |
| 303 | + const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: Option.none() }) |
303 | 304 | const warn = spyOn(console, "warn").mockImplementation(() => {}) |
304 | 305 | const error = spyOn(console, "error").mockImplementation(() => {}) |
305 | 306 |
|
@@ -468,7 +469,7 @@ test("uses npm package name when tui plugin id is omitted", async () => { |
468 | 469 | } |
469 | 470 | const wait = spyOn(TuiConfig, "waitForDependencies").mockResolvedValue() |
470 | 471 | const cwd = spyOn(process, "cwd").mockImplementation(() => tmp.path) |
471 | | - const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: tmp.extra.mod }) |
| 472 | + const install = spyOn(Npm, "add").mockResolvedValue({ directory: tmp.extra.mod, entrypoint: Option.none() }) |
472 | 473 |
|
473 | 474 | try { |
474 | 475 | await TuiPluginRuntime.init({ api: createTuiPluginApi(), config }) |
|
0 commit comments