|
|
@@ -458,9 +458,15 @@ test("applies file substitutions when first identical token is in a commented li
|
|
|
test("loads managed tui config and gives it highest precedence", async () => {
|
|
|
await using tmp = await tmpdir({
|
|
|
init: async (dir) => {
|
|
|
- await Bun.write(path.join(dir, "tui.json"), JSON.stringify({ theme: "project-theme" }, null, 2))
|
|
|
+ await Bun.write(
|
|
|
+ path.join(dir, "tui.json"),
|
|
|
+ JSON.stringify({ theme: "project-theme", plugin: ["[email protected]"] }, null, 2),
|
|
|
+ )
|
|
|
await fs.mkdir(managedConfigDir, { recursive: true })
|
|
|
- await Bun.write(path.join(managedConfigDir, "tui.json"), JSON.stringify({ theme: "managed-theme" }, null, 2))
|
|
|
+ await Bun.write(
|
|
|
+ path.join(managedConfigDir, "tui.json"),
|
|
|
+ JSON.stringify({ theme: "managed-theme", plugin: ["[email protected]"] }, null, 2),
|
|
|
+ )
|
|
|
},
|
|
|
})
|
|
|
|
|
|
@@ -469,6 +475,13 @@ test("loads managed tui config and gives it highest precedence", async () => {
|
|
|
fn: async () => {
|
|
|
const config = await TuiConfig.get()
|
|
|
expect(config.theme).toBe("managed-theme")
|
|
|
+ expect(config.plugin).toEqual(["[email protected]"])
|
|
|
+ expect(config.plugin_meta).toEqual({
|
|
|
+ "shared-plugin": {
|
|
|
+ scope: "global",
|
|
|
+ source: path.join(managedConfigDir, "tui.json"),
|
|
|
+ },
|
|
|
+ })
|
|
|
},
|
|
|
})
|
|
|
})
|
|
|
@@ -526,6 +539,12 @@ test("supports tuple plugin specs with options in tui.json", async () => {
|
|
|
fn: async () => {
|
|
|
const config = await TuiConfig.get()
|
|
|
expect(config.plugin).toEqual([["[email protected]", { enabled: true, label: "demo" }]])
|
|
|
+ expect(config.plugin_meta).toEqual({
|
|
|
+ "acme-plugin": {
|
|
|
+ scope: "local",
|
|
|
+ source: path.join(tmp.path, "tui.json"),
|
|
|
+ },
|
|
|
+ })
|
|
|
},
|
|
|
})
|
|
|
})
|
|
|
@@ -559,6 +578,53 @@ test("deduplicates tuple plugin specs by name with higher precedence winning", a
|
|
|
["[email protected]", { source: "project" }],
|
|
|
["[email protected]", { source: "project" }],
|
|
|
])
|
|
|
+ expect(config.plugin_meta).toEqual({
|
|
|
+ "acme-plugin": {
|
|
|
+ scope: "local",
|
|
|
+ source: path.join(tmp.path, "tui.json"),
|
|
|
+ },
|
|
|
+ "second-plugin": {
|
|
|
+ scope: "local",
|
|
|
+ source: path.join(tmp.path, "tui.json"),
|
|
|
+ },
|
|
|
+ })
|
|
|
+ },
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+test("tracks global and local plugin metadata in merged tui config", async () => {
|
|
|
+ await using tmp = await tmpdir({
|
|
|
+ init: async (dir) => {
|
|
|
+ await Bun.write(
|
|
|
+ path.join(Global.Path.config, "tui.json"),
|
|
|
+ JSON.stringify({
|
|
|
+ plugin: ["[email protected]"],
|
|
|
+ }),
|
|
|
+ )
|
|
|
+ await Bun.write(
|
|
|
+ path.join(dir, "tui.json"),
|
|
|
+ JSON.stringify({
|
|
|
+ plugin: ["[email protected]"],
|
|
|
+ }),
|
|
|
+ )
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ await Instance.provide({
|
|
|
+ directory: tmp.path,
|
|
|
+ fn: async () => {
|
|
|
+ const config = await TuiConfig.get()
|
|
|
+ expect(config.plugin).toEqual(["[email protected]", "[email protected]"])
|
|
|
+ expect(config.plugin_meta).toEqual({
|
|
|
+ "global-plugin": {
|
|
|
+ scope: "global",
|
|
|
+ source: path.join(Global.Path.config, "tui.json"),
|
|
|
+ },
|
|
|
+ "local-plugin": {
|
|
|
+ scope: "local",
|
|
|
+ source: path.join(tmp.path, "tui.json"),
|
|
|
+ },
|
|
|
+ })
|
|
|
},
|
|
|
})
|
|
|
})
|