@zibby/cli 0.1.44 → 0.1.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,20 @@
1
- import{spawn as w,execSync as P}from"child_process";import{join as m,dirname as y}from"path";import{readFileSync as C,writeFileSync as S,existsSync as f,mkdirSync as x}from"fs";import{homedir as $}from"os";import{createRequire as j}from"module";import t from"chalk";const h=j(import.meta.url);function B(){try{return y(h.resolve("@zibby/core/package.json"))}catch{return null}}function v(e){try{return P(`command -v ${e}`,{stdio:"pipe"}),!0}catch{return!1}}function E(){try{return h.resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js")}catch{return h.resolve("@playwright/mcp/cli.js")}}function a(e,r,o={}){return new Promise((s,n)=>{const i=w(e,r,{stdio:"inherit",...o});i.on("close",l=>s(l??1)),i.on("error",n)})}async function M(e){return v("playwright")?await a("playwright",["install","ffmpeg"],{cwd:e})===0:await a("npx",["--yes","playwright","install","ffmpeg"],{cwd:e})===0}function k({headed:e=!1,video:r="on",viewport:o=null}){const s=process.execPath,n=y(s),i=E(),l=Number(o?.width)||1280,b=Number(o?.height)||720,g=`${l}x${b}`,p=[`--viewport-size=${g}`,"--output-dir=test-results"];e||p.push("--headless"),r!=="off"&&p.unshift(`--save-video=${g}`);const d=m($(),".cursor"),u=m(d,"mcp.json");f(d)||x(d,{recursive:!0});let c={mcpServers:{}};if(f(u))try{c=JSON.parse(C(u,"utf-8")),(!c.mcpServers||typeof c.mcpServers!="object")&&(c.mcpServers={})}catch{c={mcpServers:{}}}c.mcpServers["playwright-official"]={command:s,args:[i,...p],env:{PATH:`${n}:/usr/bin:/bin:/usr/sbin:/sbin`},description:"Zibby MCP Browser - Playwright MCP with Zibby defaults"},S(u,`${JSON.stringify(c,null,2)}
2
- `,"utf-8")}async function z(){const e=B();if(!e)return;const r=m(e,"scripts","patch-cursor-mcp.js");if(f(r))try{await a(process.execPath,[r],{cwd:process.cwd()})}catch{}}async function N(e={}){const r=!!e.headed,o=e.video||"on",s=e.viewport||{width:1280,height:720};if(!process.execPath)throw new Error("Node.js runtime not found");const n=await M(process.cwd());if(console.log(n?t.gray(" \u2713 ffmpeg installed for Playwright video"):t.yellow(" \u26A0 Could not install ffmpeg (video may be unavailable)")),k({headed:r,video:o,viewport:s}),await z(),v("cursor-agent"))try{await a("cursor-agent",["mcp","list"],{cwd:process.cwd()})}catch{}else console.log(t.yellow(" \u26A0 cursor-agent not found; install it to use Cursor MCP tools"))}async function A(e){try{console.log(t.cyan(`
1
+ import{spawn as y,execSync as w}from"child_process";import{join as l,dirname as v,resolve as P}from"path";import{readFileSync as C,writeFileSync as S,existsSync as u,mkdirSync as x}from"fs";import{homedir as j}from"os";import{createRequire as A}from"module";import c from"chalk";const b=A(import.meta.url);function B(){try{return v(b.resolve("@zibby/core/package.json"))}catch{return null}}function $(e){try{return w(`command -v ${e}`,{stdio:"pipe"}),!0}catch{return!1}}function E(){try{const e=b.resolve("@zibby/mcp-browser/bin/mcp-browser-zibby.js");if(u(e))return e}catch{}try{const e=b.resolve("@playwright/mcp/package.json"),r=v(e),o=JSON.parse(C(e,"utf-8")),n=typeof o.bin=="string"?o.bin:o.bin?.["playwright-mcp"];if(n){const s=l(r,n);if(u(s))return s}const t=l(r,"cli.js");if(u(t))return t}catch{}return null}function k(e,r,o={}){return new Promise((n,t)=>{const s=y(e,r,{stdio:"inherit",...o});s.on("close",p=>n(p??1)),s.on("error",t)})}async function N(e){return $("playwright")?await k("playwright",["install","ffmpeg"],{cwd:e})===0:await k("npx",["--yes","playwright","install","ffmpeg"],{cwd:e})===0}function O({headed:e=!1,video:r="on",viewport:o=null}){const n=process.execPath,t=v(n),s=E(),p=Number(o?.width)||1280,d=Number(o?.height)||720,f=`${p}x${d}`,i=[];r!=="off"&&i.push(`--save-video=${f}`),i.push(`--viewport-size=${f}`,"--output-dir=test-results"),e||i.push("--headless");let g;s?g={command:n,args:[s,...i],env:{PATH:`${t}:/usr/bin:/bin:/usr/sbin:/sbin`}}:g={command:"npx",args:["-y","@playwright/mcp",...i],env:{PATH:`${t}:/usr/bin:/bin:/usr/sbin:/sbin`}},g.description="Zibby MCP Browser - Playwright MCP with Zibby defaults";const h=l(j(),".cursor"),m=l(h,"mcp.json");u(h)||x(h,{recursive:!0});let a={mcpServers:{}};if(u(m))try{a=JSON.parse(C(m,"utf-8")),(!a.mcpServers||typeof a.mcpServers!="object")&&(a.mcpServers={})}catch{a={mcpServers:{}}}a.mcpServers["playwright-official"]=g,S(m,`${JSON.stringify(a,null,2)}
2
+ `,"utf-8")}async function R(){const e=B();if(!e)return;const r=l(e,"scripts","patch-cursor-mcp.js");if(u(r))try{await new Promise((o,n)=>{const t=y(process.execPath,[r],{cwd:process.cwd(),stdio:"ignore"});t.on("close",s=>o(s??0)),t.on("error",n)})}catch{}}function z(e){return P(e).replace(/^\/+/,"").replace(/\//g,"-")}function J(e){const r=String(e||""),o=r.split(`
3
+ `).find(s=>/playwright-official/i.test(s)&&/APPROVAL|🔑/i.test(s));if(o){const s=o.match(/=>\s*(\S+)/);if(s)return s[1]}const n=r.match(/playwright-official[^=]*=>\s*(\S+)/);if(n)return n[1];const t=r.match(/playwright-official-[a-f0-9]+/i);return t?t[0]:null}function T(e,r){const o=z(e),n=l(j(),".cursor","projects",o);x(n,{recursive:!0});const t=l(n,"mcp-approvals.json");return S(t,`${JSON.stringify([r],null,2)}
4
+ `,"utf-8"),t}function M(e){try{return w("cursor-agent mcp list",{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:2*1024*1024})}catch(r){const o=r.stdout!=null?String(r.stdout):"",n=r.stderr!=null?String(r.stderr):"";return o+n}}function D(e){try{return w("cursor-agent mcp enable playwright-official",{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],env:process.env,maxBuffer:1024*1024}),!0}catch{return!1}}async function F(e={}){const r=!!e.headed,o=e.video||"on",n=e.viewport||{width:1280,height:720};if(!process.execPath)throw new Error("Node.js runtime not found");const t=await N(process.cwd());console.log(t?c.gray(" \u2713 ffmpeg installed for Playwright video"):c.yellow(" \u26A0 Could not install ffmpeg (video may be unavailable)")),O({headed:r,video:o,viewport:n}),await R();const s=P(process.cwd());if($("cursor-agent")){M(s);const p=D(s);p&&console.log(c.gray(" \u2713 cursor-agent: mcp enable playwright-official"));const d=M(s),f=J(d);if(f)try{const i=T(s,f);console.log(c.gray(` \u2713 MCP auto-approval key saved (${i})`))}catch(i){console.log(c.yellow(` \u26A0 Could not write mcp-approvals.json: ${i.message}`))}else p||(console.log(c.yellow(" \u26A0 Could not auto-approve MCP (mcp enable failed and no approval key in cursor-agent output)")),console.log(c.gray(" Try: cursor-agent mcp enable playwright-official")))}else console.log(c.yellow(" \u26A0 cursor-agent not found; install it to use Cursor MCP tools"))}async function L(e){try{console.log(c.cyan(`
3
5
  \u{1F680} Running CI setup...
4
- `)),await N({headed:!1,cloudSync:!0,video:"on",viewport:{width:1280,height:720}}),console.log(t.green(`
6
+ `)),await F({headed:!1,cloudSync:!0,video:"on",viewport:{width:1280,height:720}}),console.log(c.green(`
5
7
  \u2705 CI/CD setup complete!
6
- `))}catch(r){console.log(t.red(`
8
+ `))}catch(r){console.log(c.red(`
7
9
  \u274C Error: ${r.message}
8
- `)),process.exit(1)}}async function H(e,r){try{const o=["playwright","test",e||"tests/","--project=chromium"];r.headed&&o.push("--headed"),console.log(t.cyan(`
10
+ `)),process.exit(1)}}async function Z(e,r){try{const o=["playwright","test",e||"tests/","--project=chromium"];r.headed&&o.push("--headed"),console.log(c.cyan(`
9
11
  \u{1F3A5} Running tests with video recording...
10
- `)),console.log(t.gray("\u2501".repeat(50)));const s=w("npx",o,{cwd:process.cwd(),stdio:"inherit"});s.on("close",n=>{n===0?console.log(t.green(`
12
+ `)),console.log(c.gray("\u2501".repeat(50)));const n=y("npx",o,{cwd:process.cwd(),stdio:"inherit"});n.on("close",t=>{t===0?console.log(c.green(`
11
13
  \u2705 Tests complete!
12
- `)):(console.log(t.red(`
13
- \u274C Tests failed with code ${n}
14
- `)),process.exit(n))}),s.on("error",n=>{console.log(t.red(`
15
- \u274C Error: ${n.message}
16
- `)),process.exit(1)})}catch(o){console.log(t.red(`
14
+ `)):(console.log(c.red(`
15
+ \u274C Tests failed with code ${t}
16
+ `)),process.exit(t))}),n.on("error",t=>{console.log(c.red(`
17
+ \u274C Error: ${t.message}
18
+ `)),process.exit(1)})}catch(o){console.log(c.red(`
17
19
  \u274C Error: ${o.message}
18
- `)),process.exit(1)}}export{A as setupCiCommand,N as setupPlaywrightMcpCommand,H as testWithVideoCommand};
20
+ `)),process.exit(1)}}export{L as setupCiCommand,F as setupPlaywrightMcpCommand,Z as testWithVideoCommand};
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/cli",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "Zibby CLI - Test automation generator and runner",
5
5
  "type": "module",
6
6
  "bin": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/cli",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "Zibby CLI - Test automation generator and runner",
5
5
  "type": "module",
6
6
  "bin": {