From 91b25ac37f351d36a3a909ad9088cb8fd42ee2e4 Mon Sep 17 00:00:00 2001 From: SuperCLI Dev Date: Mon, 13 Jul 2026 13:22:26 +0000 Subject: [PATCH 1/3] test: add plugin routing tests for bundled chainloop plugin --- __tests__/chainloop-plugin.test.js | 81 ++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 __tests__/chainloop-plugin.test.js diff --git a/__tests__/chainloop-plugin.test.js b/__tests__/chainloop-plugin.test.js new file mode 100644 index 000000000..237734084 --- /dev/null +++ b/__tests__/chainloop-plugin.test.js @@ -0,0 +1,81 @@ +const fs = require("fs") +const os = require("os") +const path = require("path") +const { execSync } = require("child_process") + +const CLI = path.join(__dirname, "..", "cli", "supercli.js") + +function runNoServer(args, options = {}) { + try { + const env = { ...process.env } + delete env.SUPERCLI_SERVER + const out = execSync(`node ${CLI} ${args}`, { + encoding: "utf-8", + timeout: 15000, + env: { ...env, ...(options.env || {}) } + }) + return { ok: true, output: out.trim(), code: 0 } + } catch (err) { + return { + ok: false, + output: (err.stdout || "").trim(), + stderr: (err.stderr || "").trim(), + code: err.status + } + } +} + +function writeFakeChainloopBinary(dir) { + const bin = path.join(dir, "chainloop") + fs.writeFileSync(bin, [ + "#!/usr/bin/env node", + "const args = process.argv.slice(2);", + "if (args[0] === 'version') { console.log('chainloop 0.1.0-test'); process.exit(0); }", + "console.log(JSON.stringify({ ok: true, args }));" + ].join("\n"), "utf-8") + fs.chmodSync(bin, 0o755) + return bin +} + +describe("chainloop plugin", () => { + const fakeDir = fs.mkdtempSync(path.join(os.tmpdir(), "dcli-chainloop-")) + const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "dcli-home-chainloop-")) + writeFakeChainloopBinary(fakeDir) + const env = { ...process.env, PATH: `${fakeDir}:${process.env.PATH || ""}`, SUPERCLI_HOME: tempHome } + + beforeAll(() => { + runNoServer("plugins install ./plugins/chainloop --on-conflict replace --json", { env }) + }) + + afterAll(() => { + runNoServer("plugins remove chainloop --json", { env }) + fs.rmSync(fakeDir, { recursive: true, force: true }) + fs.rmSync(tempHome, { recursive: true, force: true }) + }) + + test("routes namespace passthrough to the chainloop binary", () => { + const r = runNoServer("chainloop version --json", { env }) + expect(r.ok).toBe(true) + const data = JSON.parse(r.output) + expect(data.command).toBe("chainloop.passthrough") + expect(data.data.raw).toBe("chainloop 0.1.0-test") + }) + + test("forwards arbitrary flags through passthrough", () => { + const r = runNoServer("chainloop workflow list --output json", { env }) + expect(r.ok).toBe(true) + const data = JSON.parse(r.output) + expect(data.command).toBe("chainloop.passthrough") + expect(data.data.args).toContain("workflow") + expect(data.data.args).toContain("list") + expect(data.data.args).toContain("--output") + }) + + test("doctor reports chainloop dependency as healthy", () => { + const r = runNoServer("plugins doctor chainloop --json", { env }) + expect(r.ok).toBe(true) + const data = JSON.parse(r.output) + expect(data.ok).toBe(true) + expect(data.checks.some(c => c.type === "binary" && c.binary === "chainloop" && c.ok === true)).toBe(true) + }) +}) From e8c6b6438bfc45cd53d3d5b69f06d14c2b406c21 Mon Sep 17 00:00:00 2001 From: SuperCLI Dev Date: Mon, 13 Jul 2026 13:23:17 +0000 Subject: [PATCH 2/3] test: add plugin routing tests for bundled overmind plugin --- __tests__/overmind-plugin.test.js | 81 +++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 __tests__/overmind-plugin.test.js diff --git a/__tests__/overmind-plugin.test.js b/__tests__/overmind-plugin.test.js new file mode 100644 index 000000000..04ae49912 --- /dev/null +++ b/__tests__/overmind-plugin.test.js @@ -0,0 +1,81 @@ +const fs = require("fs") +const os = require("os") +const path = require("path") +const { execSync } = require("child_process") + +const CLI = path.join(__dirname, "..", "cli", "supercli.js") + +function runNoServer(args, options = {}) { + try { + const env = { ...process.env } + delete env.SUPERCLI_SERVER + const out = execSync(`node ${CLI} ${args}`, { + encoding: "utf-8", + timeout: 15000, + env: { ...env, ...(options.env || {}) } + }) + return { ok: true, output: out.trim(), code: 0 } + } catch (err) { + return { + ok: false, + output: (err.stdout || "").trim(), + stderr: (err.stderr || "").trim(), + code: err.status + } + } +} + +function writeFakeOvermindBinary(dir) { + const bin = path.join(dir, "overmind") + fs.writeFileSync(bin, [ + "#!/usr/bin/env node", + "const args = process.argv.slice(2);", + "if (args[0] === 'version') { console.log('overmind 2.5.1-test'); process.exit(0); }", + "console.log(JSON.stringify({ ok: true, args }));" + ].join("\n"), "utf-8") + fs.chmodSync(bin, 0o755) + return bin +} + +describe("overmind plugin", () => { + const fakeDir = fs.mkdtempSync(path.join(os.tmpdir(), "dcli-overmind-")) + const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "dcli-home-overmind-")) + writeFakeOvermindBinary(fakeDir) + const env = { ...process.env, PATH: `${fakeDir}:${process.env.PATH || ""}`, SUPERCLI_HOME: tempHome } + + beforeAll(() => { + runNoServer("plugins install ./plugins/overmind --on-conflict replace --json", { env }) + }) + + afterAll(() => { + runNoServer("plugins remove overmind --json", { env }) + fs.rmSync(fakeDir, { recursive: true, force: true }) + fs.rmSync(tempHome, { recursive: true, force: true }) + }) + + test("routes namespace passthrough to the overmind binary", () => { + const r = runNoServer("overmind version --json", { env }) + expect(r.ok).toBe(true) + const data = JSON.parse(r.output) + expect(data.command).toBe("overmind.passthrough") + expect(data.data.raw).toBe("overmind 2.5.1-test") + }) + + test("forwards subcommands and flags through passthrough", () => { + const r = runNoServer("overmind start -f ./Procfile.dev", { env }) + expect(r.ok).toBe(true) + const data = JSON.parse(r.output) + expect(data.command).toBe("overmind.passthrough") + expect(data.data.args).toContain("start") + expect(data.data.args).toContain("-f") + expect(data.data.args).toContain("./Procfile.dev") + }) + + test("doctor reports overmind dependency as healthy", () => { + const r = runNoServer("plugins doctor overmind --json", { env }) + expect(r.ok).toBe(true) + const data = JSON.parse(r.output) + expect(data.ok).toBe(true) + expect(data.checks.some(c => c.type === "binary" && c.binary === "overmind" && c.ok === true)).toBe(true) + }) +}) From 3960444728fc1a447d0a3dc050bd5ede619affa7 Mon Sep 17 00:00:00 2001 From: SuperCLI Dev Date: Mon, 13 Jul 2026 13:23:41 +0000 Subject: [PATCH 3/3] test: add plugin routing tests for bundled resvg plugin --- __tests__/resvg-plugin.test.js | 81 ++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 __tests__/resvg-plugin.test.js diff --git a/__tests__/resvg-plugin.test.js b/__tests__/resvg-plugin.test.js new file mode 100644 index 000000000..afee384df --- /dev/null +++ b/__tests__/resvg-plugin.test.js @@ -0,0 +1,81 @@ +const fs = require("fs") +const os = require("os") +const path = require("path") +const { execSync } = require("child_process") + +const CLI = path.join(__dirname, "..", "cli", "supercli.js") + +function runNoServer(args, options = {}) { + try { + const env = { ...process.env } + delete env.SUPERCLI_SERVER + const out = execSync(`node ${CLI} ${args}`, { + encoding: "utf-8", + timeout: 15000, + env: { ...env, ...(options.env || {}) } + }) + return { ok: true, output: out.trim(), code: 0 } + } catch (err) { + return { + ok: false, + output: (err.stdout || "").trim(), + stderr: (err.stderr || "").trim(), + code: err.status + } + } +} + +function writeFakeResvgBinary(dir) { + const bin = path.join(dir, "resvg") + fs.writeFileSync(bin, [ + "#!/usr/bin/env node", + "const args = process.argv.slice(2);", + "if (args[0] === 'version') { console.log('resvg 0.44.0-test'); process.exit(0); }", + "console.log(JSON.stringify({ ok: true, args }));" + ].join("\n"), "utf-8") + fs.chmodSync(bin, 0o755) + return bin +} + +describe("resvg plugin", () => { + const fakeDir = fs.mkdtempSync(path.join(os.tmpdir(), "dcli-resvg-")) + const tempHome = fs.mkdtempSync(path.join(os.tmpdir(), "dcli-home-resvg-")) + writeFakeResvgBinary(fakeDir) + const env = { ...process.env, PATH: `${fakeDir}:${process.env.PATH || ""}`, SUPERCLI_HOME: tempHome } + + beforeAll(() => { + runNoServer("plugins install ./plugins/resvg --on-conflict replace --json", { env }) + }) + + afterAll(() => { + runNoServer("plugins remove resvg --json", { env }) + fs.rmSync(fakeDir, { recursive: true, force: true }) + fs.rmSync(tempHome, { recursive: true, force: true }) + }) + + test("routes namespace passthrough to the resvg binary", () => { + const r = runNoServer("resvg version --json", { env }) + expect(r.ok).toBe(true) + const data = JSON.parse(r.output) + expect(data.command).toBe("resvg.passthrough") + expect(data.data.raw).toBe("resvg 0.44.0-test") + }) + + test("forwards conversion arguments through passthrough", () => { + const r = runNoServer("resvg input.svg output.png --width 512", { env }) + expect(r.ok).toBe(true) + const data = JSON.parse(r.output) + expect(data.command).toBe("resvg.passthrough") + expect(data.data.args).toContain("input.svg") + expect(data.data.args).toContain("output.png") + expect(data.data.args).toContain("--width") + }) + + test("doctor reports resvg dependency as healthy", () => { + const r = runNoServer("plugins doctor resvg --json", { env }) + expect(r.ok).toBe(true) + const data = JSON.parse(r.output) + expect(data.ok).toBe(true) + expect(data.checks.some(c => c.type === "binary" && c.binary === "resvg" && c.ok === true)).toBe(true) + }) +})