@taqwright/lime-cli 0.8.2 → 0.8.3

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var R=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Me=R((Fi,Un)=>{Un.exports={name:"@taqwright/lime-cli",version:"0.8.2",description:"Thin CLI client for the LIME server \u2014 fire a natural-language QA Agent goal against a connected device and write back a taqwright spec.",license:"SEE LICENSE IN LICENSE",author:"Taqwright",homepage:"https://www.taqwright.ai",bugs:{url:"https://www.taqwright.ai/contact"},keywords:["appium","mobile-testing","e2e","qa","test-automation","taqwright","lime","cli"],bin:{"lime-cli":"dist/index.js"},main:"dist/index.js",files:["dist"],publishConfig:{access:"public"},scripts:{"lime-cli":"node src/index.js",start:"node src/index.js",test:"node --test test/*.test.js",bundle:"esbuild src/index.js --bundle --platform=node --target=node18 --minify --outfile=dist/index.js",prepack:"npm run bundle",prepublishOnly:"npm test"},engines:{node:">=18"},devDependencies:{esbuild:"^0.28.1"}}});var D=R((Ki,Ue)=>{"use strict";var Bn="https://www.taqwright.ai";Ue.exports={POLL_INTERVAL_MS:1e3,POLL_TIMEOUT_MS:18e5,BOOT_POLL_INTERVAL_MS:5e3,BOOT_TIMEOUT_MS:3e5,CONNECT_POLL_INTERVAL_MS:2e3,CONNECT_TIMEOUT_MS:3e5,DEFAULT_SERVER:Bn,HTTP_TIMEOUT_MS:3e5,MAX_RESPONSE_BYTES:52428800}});var ee=R((Yi,He)=>{"use strict";var{URL:Fn}=require("url"),{HTTP_TIMEOUT_MS:Be,MAX_RESPONSE_BYTES:Fe}=D();function Ke(e){let t=String(e||"").replace(/^\[|\]$/g,"").toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t.endsWith(".localhost")}var Kn=["just a moment","attention required! | cloudflare","checking your browser","/cdn-cgi/challenge-platform","cf-error-details","cf-browser-verification","_incapsula_resource"];function Ye(e,t){if(!t||typeof t!="string")return null;let n=t.slice(0,4e3).toLowerCase();return Kn.some(r=>n.includes(r))?`the LIME server is behind a bot challenge that blocked this request (HTTP ${e}). The request never reached LIME \u2014 it was stopped at the edge, so your token and arguments are probably fine. CI runners use datacenter IPs, which Cloudflare's Bot Fight Mode challenges by default; it cannot be excepted with a WAF skip rule, so the server's operator has to turn it off or move to Super Bot Fight Mode (which supports skip rules) for the /api/ paths.`:null}var he=class{constructor(t,n){this.server=t,this.token=n}_url(t){return/^https?:\/\//i.test(t)?t:`${this.server}${t}`}json(t,n,r,s={}){let i=r?JSON.stringify(r):null,o={...s};return i&&(o["Content-Type"]="application/json",o["Content-Length"]=Buffer.byteLength(i)),this._send(t,this._url(n),o,i)}raw(t,n,r,s={}){let i={...s,"Content-Type":"application/octet-stream","Content-Length":r.length};return this._send(t,this._url(n),i,r)}_send(t,n,r,s){let i=new Fn(n);if(i.protocol==="http:"&&!Ke(i.hostname))return Promise.reject(new Error(`refusing to send your LIME_CI_TOKEN over cleartext http to ${i.hostname} \u2014 use https (http is allowed only for localhost).`));let o=i.protocol==="https:"?require("https"):require("http"),a={method:t,hostname:i.hostname,port:i.port||(i.protocol==="https:"?443:80),path:i.pathname+(i.search||""),headers:{...r,Authorization:`Bearer ${this.token}`,Origin:`${i.protocol}//${i.host}`}};return new Promise((c,u)=>{let l=o.request(a,d=>{let p="",m=0;d.setEncoding("utf8"),d.on("data",y=>{if(m+=Buffer.byteLength(y),m>Fe){l.destroy(new Error(`Server response exceeded ${Fe} bytes`));return}p+=y}),d.on("end",()=>{let y;try{y=p?JSON.parse(p):{}}catch{let S=Ye(d.statusCode,p);return u(new Error(S||`Server returned non-JSON (${d.statusCode}): ${p.substring(0,200)}`))}c({status:d.statusCode,body:y})})});l.setTimeout(Be,()=>{l.destroy(new Error(`request timed out after ${Be/1e3}s`))}),l.on("error",u),s&&l.write(s),l.end()})}};function Yn(e,t){if(!e.body||!e.body.success)throw new Error(`${t} \u2014 ${e.body&&e.body.error||"unknown"}`);return e.body}He.exports={isLoopbackHost:Ke,HttpClient:he,expectSuccess:Yn,describeEdgeBlock:Ye}});var q=R((Hi,We)=>{"use strict";var Hn={browserstack:{label:"BrowserStack",envUsername:"BROWSERSTACK_USERNAME",envAccessKey:"BROWSERSTACK_ACCESS_KEY",hubHost:"hub.browserstack.com"},lambdatest:{label:"LambdaTest",envUsername:"LT_USERNAME",envAccessKey:"LT_ACCESS_KEY",hubHost:"mobile-hub.lambdatest.com"}};function Wn({provider:e,platform:t,device:n,os:r,appUrl:s,username:i,accessKey:o,capabilities:a}){let c={connectionMode:"cloud",cloudProvider:e||"browserstack",cloudUsername:i,cloudAccessKey:o,platform:t,deviceName:n,deviceOsVersion:r,cloudAppUrl:s,automationName:t==="ios"?"XCUITest":"UiAutomator2"};return a&&(c.cloudCapabilities=a),c}We.exports={CLOUD_PROVIDERS:Hn,buildCloudSettingsPayload:Wn}});var ge=R((Wi,Ge)=>{"use strict";var te=require("fs"),fe=require("path"),Vn=["taqwright","webdriverio-js","appium-java-junit5","appium-python-pytest","appium-ruby-rspec","appium-csharp-nunit"],Gn={taqwright:"deterministic","webdriverio-js":"gemini","appium-java-junit5":"gemini","appium-python-pytest":"gemini","appium-ruby-rspec":"gemini","appium-csharp-nunit":"gemini"},P={taqwright:"taqwright (native)","webdriverio-js":"WebdriverIO (JavaScript)","appium-java-junit5":"Appium Java (JUnit 5)","appium-python-pytest":"Appium Python (pytest)","appium-ruby-rspec":"Appium Ruby (RSpec)","appium-csharp-nunit":"Appium C# (NUnit)"},Jn=5*1024*1024,me={exists:e=>te.existsSync(e),readText:e=>{try{return te.statSync(e).size>Jn?null:te.readFileSync(e,"utf8")}catch{return null}},list:e=>{try{return te.readdirSync(e)}catch{return[]}}};function Xn(e,t){let n=e.readText(fe.join(t,"package.json"));if(!n)return{};try{let r=JSON.parse(n);return{...r.dependencies||{},...r.devDependencies||{}}}catch{return{}}}var zn=new Set(["node_modules","dist","build","target","bin","obj","vendor","out","coverage"]);function Qn(e,t){let n=new Set([""]),r=[];try{r=e.list(t)}catch{r=[]}for(let s of r)s.startsWith(".")||zn.has(s)||n.add(s);return[...n]}function Zn(e,t,n){let r=n?fe.join(t,n):t,s=d=>fe.join(r,d),i=d=>n?`${n}/${d}`:d,o=[],a=Xn(e,r),c=[];try{c=e.list(r)}catch{c=[]}(a["@taqwright/taqwright"]||a.taqwright||e.exists(s("taqwright.config.ts"))||e.exists(s("taqwright.config.js")))&&o.push({id:"taqwright",label:P.taqwright,reason:"taqwright dependency/config found",manifest:i("package.json")});let u=c.some(d=>/^wdio\.conf\.(js|ts|mjs|cjs)$/.test(d));(a.webdriverio||a["@wdio/cli"]||u)&&o.push({id:"webdriverio-js",label:P["webdriverio-js"],reason:u?"wdio.conf.* found":"webdriverio dependency found",manifest:i("package.json")});for(let d of["pom.xml","build.gradle","build.gradle.kts"]){let p=e.readText(s(d));if(p&&/io\.appium|java-client/.test(p)){o.push({id:"appium-java-junit5",label:P["appium-java-junit5"],reason:`io.appium:java-client in ${i(d)}`,manifest:i(d)});break}}for(let d of["requirements.txt","pyproject.toml"]){let p=e.readText(s(d));if(p&&/appium-python-client/i.test(p)){o.push({id:"appium-python-pytest",label:P["appium-python-pytest"],reason:`Appium-Python-Client in ${i(d)}`,manifest:i(d)});break}}let l=e.readText(s("Gemfile"));l&&/appium_lib(_core)?/.test(l)&&o.push({id:"appium-ruby-rspec",label:P["appium-ruby-rspec"],reason:"appium_lib in Gemfile",manifest:i("Gemfile")});for(let d of c){if(!/\.csproj$/i.test(d))continue;let p=e.readText(s(d));if(p&&/Appium\.WebDriver/i.test(p)){o.push({id:"appium-csharp-nunit",label:P["appium-csharp-nunit"],reason:`Appium.WebDriver in ${i(d)}`,manifest:i(d)});break}}return o}function Ve(e,t=me){let n=new Map;for(let r of Qn(t,e))for(let s of Zn(t,e,r))n.has(s.id)||n.set(s.id,s);return[...n.values()]}function er(e,t=me){let n=Ve(e,t);return n.some(r=>r.id==="taqwright")||n.push({id:"taqwright",label:P.taqwright,reason:"default output"}),n}function tr(e){let{requested:t,configured:n,remembered:r,offeredIds:s,detectedRealIds:i,taqwrightDetected:o,javaSignal:a}=e,c=u=>!!u&&s.includes(u);return c(t)?t:c(n)?n:c(r)&&(i.includes(r)||r==="taqwright"&&o)?r:i.length?i[0]:o?"taqwright":a?"appium-java-junit5":"taqwright"}Ge.exports={FRAMEWORK_IDS:Vn,FRAMEWORK_ENGINES:Gn,FRAMEWORK_LABELS:P,nodeFs:me,detectFrameworks:Ve,rankFrameworks:er,pickDefaultFramework:tr}});var Se=R((Vi,Ze)=>{"use strict";var we=require("path"),{nodeFs:nr}=ge(),Je={taqwright:"tests","webdriverio-js":"test/specs","appium-java-junit5":"src/test/java","appium-python-pytest":"tests","appium-ruby-rspec":"spec","appium-csharp-nunit":"Tests"},rr="tests",sr={taqwright:".spec.ts","webdriverio-js":".spec.ts","appium-java-junit5":".java","appium-python-pytest":".py","appium-ruby-rspec":"_spec.rb","appium-csharp-nunit":".cs"},ir=new Set(["appium-python-pytest","appium-ruby-rspec"]);function ye(e){return Je[e]||rr}function be(e){let t=(e||"").split(/[^A-Za-z0-9]+/).filter(Boolean);return t.length?t.map(n=>/^[A-Z0-9]+$/.test(n)?n[0]+n.slice(1).toLowerCase():n[0].toUpperCase()+n.slice(1)).join(""):""}function Ee(e){return(e||"").replace(/([a-z0-9])([A-Z])/g,"$1_$2").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toLowerCase()}function or(e){return Ee(e).split("_").filter(Boolean).join("-")}var ar=6,cr=new Set(["and","or","the","a","an","to","of","in","on","at","as","with","for","then","into","from","by","that","is"]),lr=/@|\d{6,}/;function ur(e){let t=String(e||"").trim().split(/\s+/).filter(Boolean).filter(n=>!lr.test(n)).slice(0,ar);for(;t.length>1&&cr.has(t[t.length-1].toLowerCase());)t.pop();return be(t.join(" "))||"RecordedTest"}function dr(e){let t=String(e||"").trim();return t?/[A-Za-z]/.test(t)?t.length>80?"Keep the name under 80 characters.":/[/\\]/.test(t)?"Use the destination field for the folder.":null:"Use at least one letter.":"Enter a test name."}function pr(e){if(e==null||e==="")return null;let t=String(e);return t!==t.trim()?"must not have leading or trailing spaces.":t.length>120?"is longer than any key LIME mints (120 characters).":/^[a-z0-9][a-z0-9._/:-]*$/.test(t)?t.includes("..")?'must not contain "..".':null:"is not a scenario key \u2014 expected lower-case letters, digits and . _ - / : only."}function Xe(e,t){let n;return ir.has(e)?n=Ee(t):n=be(t),`${n}${sr[e]||""}`}function H(e){return String(e||"").split(/[/\\]+/).filter(t=>t&&t!=="."&&t!=="..").join("/")}function hr(e){if(e==null)return null;let t=String(e);return t.trim()===""?null:/^([A-Za-z]:)?[/\\]/.test(t)?"must be a path inside the project, not an absolute path.":t.split(/[/\\]+/).includes("..")?'must not contain ".." \u2014 the test belongs inside the project.':null}function ve(e){let t=H(e).split("/");return t.pop(),t.join("/")}function ze(e){let t=/(?:^|\/)src\/(?:test|main)\/java\/(.+)$/.exec(H(e));return t&&t[1].split("/").filter(Boolean).join(".")||void 0}function fr(e){let t=H(e),n=t.search(/\/src\/(?:test|main)\/java(?:\/|$)/);return n>0?t.slice(0,n):""}function mr(e){let t=new Map;for(let r of e){let s=ve(r);t.set(s,(t.get(s)||0)+1)}if(!t.size)return null;let n=[...t.entries()].sort((r,s)=>s[1]-r[1]||r[0].localeCompare(s[0]));return{dir:n[0][0],count:n[0][1]}}var Qe={taqwright:{segment:"tests",file:/\.spec\.(ts|js)$/},"webdriverio-js":{segment:"test/specs",file:/\.(ts|js)$/},"appium-java-junit5":{segment:"src/test/java",file:/\.java$/},"appium-python-pytest":{segment:"tests",file:/^(test_.+|.+_test)\.py$/},"appium-ruby-rspec":{segment:"spec",file:/_spec\.rb$/},"appium-csharp-nunit":{segment:"",file:/Tests\.cs$/}},gr=new Set(["node_modules","dist","build","target","bin","obj","vendor","out","coverage",".git"]),wr=2e4;function yr(e,t,n=nr){let r=Qe[t];if(!r)return[];let s=[],i=wr,o=a=>{if(i<=0)return;let c=a?we.join(e,a):e,u=[];try{u=n.list(c)}catch{return}for(let l of u){if(i--<=0)return;if(l.startsWith(".")||gr.has(l))continue;let d=a?`${a}/${l}`:l;if(n.isDir?n.isDir(we.join(e,d)):n.list(we.join(e,d)).length>0){o(d);continue}r.file.test(l)&&(r.segment&&!`/${ve(d)}/`.includes(`/${r.segment}/`)||s.push(d))}};return o(""),s.sort()}function br(e){let{framework:t,testName:n}=e,r=Xe(t,n),s=(a,c,u=0)=>{let l=H(a),d=t==="appium-java-junit5"?ze(l):void 0;return{dir:l,fileName:r,...d?{packageName:d}:{},source:c,neighbourCount:u}};if(e.remembered!=null)return s(e.remembered,"remembered");let i=mr(e.existingTests||[]);if(i&&i.dir)return s(i.dir,"existing",i.count);let o=e.detection&&e.detection.manifest?ve(e.detection.manifest):"";return o?s(`${o}/${ye(t)}`,"module"):s(ye(t),"convention")}Ze.exports={CONVENTIONAL_DIRS:Je,TEST_PATTERNS:Qe,conventionalDir:ye,pascalCase:be,snakeCase:Ee,kebabCase:or,testNameFromGoal:ur,validateTestName:dr,validateDest:hr,validateScenarioKey:pr,fileNameFor:Xe,normalizeDir:H,javaPackageOf:ze,moduleRootOf:fr,findExistingTests:yr,resolveExportTarget:br}});var rt=R((Gi,nt)=>{"use strict";var{CLOUD_PROVIDERS:ne}=q(),{validateScenarioKey:Er}=Se();function vr(e){let t=Object.create(null);for(let n=0;n<e.length;n++){let r=e[n];if(!r.startsWith("--"))continue;let s=r.slice(2),i=e[n+1];i===void 0||i.startsWith("--")?t[s]=!0:(t[s]=i,n++)}return t}var tt=["export","adapt","verify","check-locators","check-pom","disconnect","report"];function Sr(e){let t=Array.isArray(e)?e:[],n=[];for(let r=0;r<t.length;r+=1){let s=String(t[r]==null?"":t[r]);!s||s.startsWith("-")||(r>0?String(t[r-1]||""):"").startsWith("--")||n.push(s)}return n}function Tr(e){let t=e[0];return t&&tt.includes(t)?{command:t,rest:e.slice(1)}:{command:"run",rest:e}}function Ar(e="taqwright"){return e==="json"?"recorded-steps.json":"RecordedTest.spec.ts"}function kr(e,t=process.env){let n=[],r=!!e["list-devices"],s=!!e["keep-session"],i=!!e["no-boot"],o=e["lime-dir"]===!0?".lime":typeof e["lime-dir"]=="string"&&e["lime-dir"].trim()?e["lime-dir"].trim():void 0,a=e.format?String(e.format).toLowerCase():"taqwright";if(["taqwright","json"].includes(a)||n.push(`--format must be taqwright or json (got "${e.format}")`),r)return{errors:n,listDevices:r,keepSession:s,noBoot:i,format:a,limeDir:o};(!e.goal||typeof e.goal!="string"||!e.goal.trim())&&n.push("--goal is required");let c;e.project!==void 0&&(typeof e.project!="string"||!e.project.trim()?n.push("--project requires a project name"):c=e.project.trim());let u;if(e.scenario!==void 0){let h=typeof e.scenario=="string"?e.scenario.trim():"",A=h?Er(h):"requires a scenario key";A?n.push(`--scenario ${A}`):u=h}let l,d;e["gemini-key"]!==void 0&&(typeof e["gemini-key"]!="string"||!e["gemini-key"].trim()?n.push("--gemini-key requires a value (or set GEMINI_API_KEY)"):(l=e["gemini-key"].trim(),d="flag")),!l&&typeof t.GEMINI_API_KEY=="string"&&t.GEMINI_API_KEY.trim()&&(l=t.GEMINI_API_KEY.trim(),d="env");let p,m;if(e["qwen-key"]!==void 0&&(typeof e["qwen-key"]!="string"||!e["qwen-key"].trim()?n.push("--qwen-key requires a value (or set QWEN_API_KEY)"):(p=e["qwen-key"].trim(),m="flag")),!p&&typeof t.QWEN_API_KEY=="string"&&t.QWEN_API_KEY.trim()&&(p=t.QWEN_API_KEY.trim(),m="env"),e["max-steps"]!==void 0){let h=Number(e["max-steps"]);(!Number.isFinite(h)||h<1||h>200)&&n.push("--max-steps must be a number between 1 and 200")}let y;e.platform&&(y=String(e.platform).toLowerCase(),["android","ios"].includes(y)||n.push(`--platform must be android or ios (got "${e.platform}")`));let I=!!e.cloud,S=typeof e.os=="string"?e.os:void 0,T=typeof e["app-url"]=="string"?e["app-url"]:void 0,w=typeof e.app=="string"?e.app:void 0,g=typeof e.caps=="string"&&e.caps.trim()?e.caps.trim():void 0,b,v,E;if(I&&(b=e.cloud===!0?"browserstack":String(e.cloud).toLowerCase(),ne[b]||n.push(`--cloud must be ${Object.keys(ne).join(" or ")} (got "${e.cloud}")`)),I){(!e.device||typeof e.device!="string")&&n.push('--cloud requires --device (the cloud device name, e.g. "Google Pixel 8")'),y||n.push("--cloud requires --platform (android or ios)"),S||n.push("--cloud requires --os (the device OS version, e.g. 14.0)"),w?n.push("--app is not supported for cloud runs. Upload the build to your provider \u2014 LambdaTest: POST https://manual-api.lambdatest.com/app/upload/realDevice (-F appFile=@<file>), BrowserStack: POST https://api-cloud.browserstack.com/app-automate/upload (-F file=@<file>) \u2014 then pass the returned id with --app-url. (--app is still supported for local runs, where it clean-reinstalls on the agent device.)"):T||n.push("--cloud requires --app-url <bs://\u2026 | lt://\u2026> (the id from your provider\u2019s app upload API)"),e["app-url"]!==void 0&&(typeof e["app-url"]!="string"||!e["app-url"].trim())&&n.push("--app-url requires a bs:// or lt:// app id"),T&&ne[b]&&(b==="browserstack"&&T.startsWith("lt://")?n.push(`--app-url "${T}" is a LambdaTest app id, but the provider is browserstack`):b==="lambdatest"&&T.startsWith("bs://")&&n.push(`--app-url "${T}" is a BrowserStack app id, but the provider is lambdatest`)),e["cloud-username"]!==void 0&&(typeof e["cloud-username"]!="string"||!e["cloud-username"].trim())&&n.push("--cloud-username requires a value"),e["cloud-access-key"]!==void 0&&(typeof e["cloud-access-key"]!="string"||!e["cloud-access-key"].trim())&&n.push("--cloud-access-key requires a value"),e.caps!==void 0&&(typeof e.caps!="string"||!e.caps.trim())&&n.push("--caps requires a path to a JSON file");let h=ne[b];h&&(v=typeof e["cloud-username"]=="string"&&e["cloud-username"].trim()||t[h.envUsername]||void 0,E=typeof e["cloud-access-key"]=="string"&&e["cloud-access-key"].trim()||t[h.envAccessKey]||void 0,v||n.push(`cloud runs require a username \u2014 pass --cloud-username or set ${h.envUsername} (credentials are never read from your LIME account for CLI runs)`),E||n.push(`cloud runs require an access key \u2014 pass --cloud-access-key or set ${h.envAccessKey}`))}else e.app!==void 0&&(typeof e.app!="string"||!e.app.trim()?n.push("--app requires a path to an APK"):e.device?y&&y!=="android"&&n.push("--app is Android only"):n.push("--app requires --device (lime-cli must connect to a device to reinstall the app)")),e["app-url"]!==void 0&&n.push("--app-url requires --cloud"),e.os!==void 0&&n.push("--os requires --cloud"),e["cloud-username"]!==void 0&&n.push("--cloud-username requires --cloud"),e["cloud-access-key"]!==void 0&&n.push("--cloud-access-key requires --cloud"),e.caps!==void 0&&n.push("--caps requires --cloud");return{errors:n,listDevices:r,keepSession:s,noBoot:i,limeDir:o,device:e.device,platform:y,projectName:c,scenarioKey:u,geminiKey:l,geminiKeySource:d,qwenKey:p,qwenKeySource:m,app:w,cloud:I,cloudProvider:b,cloudUsername:v,cloudAccessKey:E,os:S,appUrl:T,capsPath:g,format:a}}var et=["browserstack","lambdatest","appium"];function Ir(e){let t=[],n=[];for(let[r,s]of Object.entries(e||{}))!s||typeof s!="object"||Array.isArray(s)?t.push(`--caps block "${r}" must be a JSON object, e.g. { "${r}": { "someCap": true } }`):et.includes(r)||n.push(`--caps block "${r}" is not one of ${et.join("/")} \u2014 it will be ignored (typo?)`);return{errors:t,warnings:n}}nt.exports={parseArgs:vr,parseCommand:Tr,positionalPaths:Sr,validateArgs:kr,extToFilename:Ar,validateCapsObject:Ir,COMMANDS:tt}});var ot=R((Ji,it)=>{"use strict";var{DEFAULT_SERVER:_r}=D(),st={export:`lime-cli export \u2014 work out what this repo is, and where the test belongs.
2
+ "use strict";var R=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Me=R((Fi,Un)=>{Un.exports={name:"@taqwright/lime-cli",version:"0.8.3",description:"Thin CLI client for the LIME server \u2014 fire a natural-language QA Agent goal against a connected device and write back a taqwright spec.",license:"SEE LICENSE IN LICENSE",author:"Taqwright",homepage:"https://www.taqwright.ai",bugs:{url:"https://www.taqwright.ai/contact"},keywords:["appium","mobile-testing","e2e","qa","test-automation","taqwright","lime","cli"],bin:{"lime-cli":"dist/index.js"},main:"dist/index.js",files:["dist"],publishConfig:{access:"public"},scripts:{"lime-cli":"node src/index.js",start:"node src/index.js",test:"node --test test/*.test.js",bundle:"esbuild src/index.js --bundle --platform=node --target=node18 --minify --outfile=dist/index.js",prepack:"npm run bundle",prepublishOnly:"npm test"},engines:{node:">=18"},devDependencies:{esbuild:"^0.28.1"}}});var D=R((Ki,Ue)=>{"use strict";var Bn="https://www.taqwright.ai";Ue.exports={POLL_INTERVAL_MS:1e3,POLL_TIMEOUT_MS:18e5,BOOT_POLL_INTERVAL_MS:5e3,BOOT_TIMEOUT_MS:3e5,CONNECT_POLL_INTERVAL_MS:2e3,CONNECT_TIMEOUT_MS:3e5,DEFAULT_SERVER:Bn,HTTP_TIMEOUT_MS:3e5,MAX_RESPONSE_BYTES:52428800}});var ee=R((Yi,He)=>{"use strict";var{URL:Fn}=require("url"),{HTTP_TIMEOUT_MS:Be,MAX_RESPONSE_BYTES:Fe}=D();function Ke(e){let t=String(e||"").replace(/^\[|\]$/g,"").toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t.endsWith(".localhost")}var Kn=["just a moment","attention required! | cloudflare","checking your browser","/cdn-cgi/challenge-platform","cf-error-details","cf-browser-verification","_incapsula_resource"];function Ye(e,t){if(!t||typeof t!="string")return null;let n=t.slice(0,4e3).toLowerCase();return Kn.some(r=>n.includes(r))?`the LIME server is behind a bot challenge that blocked this request (HTTP ${e}). The request never reached LIME \u2014 it was stopped at the edge, so your token and arguments are probably fine. CI runners use datacenter IPs, which Cloudflare's Bot Fight Mode challenges by default; it cannot be excepted with a WAF skip rule, so the server's operator has to turn it off or move to Super Bot Fight Mode (which supports skip rules) for the /api/ paths.`:null}var he=class{constructor(t,n){this.server=t,this.token=n}_url(t){return/^https?:\/\//i.test(t)?t:`${this.server}${t}`}json(t,n,r,s={}){let i=r?JSON.stringify(r):null,o={...s};return i&&(o["Content-Type"]="application/json",o["Content-Length"]=Buffer.byteLength(i)),this._send(t,this._url(n),o,i)}raw(t,n,r,s={}){let i={...s,"Content-Type":"application/octet-stream","Content-Length":r.length};return this._send(t,this._url(n),i,r)}_send(t,n,r,s){let i=new Fn(n);if(i.protocol==="http:"&&!Ke(i.hostname))return Promise.reject(new Error(`refusing to send your LIME_CI_TOKEN over cleartext http to ${i.hostname} \u2014 use https (http is allowed only for localhost).`));let o=i.protocol==="https:"?require("https"):require("http"),a={method:t,hostname:i.hostname,port:i.port||(i.protocol==="https:"?443:80),path:i.pathname+(i.search||""),headers:{...r,Authorization:`Bearer ${this.token}`,Origin:`${i.protocol}//${i.host}`}};return new Promise((c,u)=>{let l=o.request(a,d=>{let p="",m=0;d.setEncoding("utf8"),d.on("data",y=>{if(m+=Buffer.byteLength(y),m>Fe){l.destroy(new Error(`Server response exceeded ${Fe} bytes`));return}p+=y}),d.on("end",()=>{let y;try{y=p?JSON.parse(p):{}}catch{let S=Ye(d.statusCode,p);return u(new Error(S||`Server returned non-JSON (${d.statusCode}): ${p.substring(0,200)}`))}c({status:d.statusCode,body:y})})});l.setTimeout(Be,()=>{l.destroy(new Error(`request timed out after ${Be/1e3}s`))}),l.on("error",u),s&&l.write(s),l.end()})}};function Yn(e,t){if(!e.body||!e.body.success)throw new Error(`${t} \u2014 ${e.body&&e.body.error||"unknown"}`);return e.body}He.exports={isLoopbackHost:Ke,HttpClient:he,expectSuccess:Yn,describeEdgeBlock:Ye}});var q=R((Hi,We)=>{"use strict";var Hn={browserstack:{label:"BrowserStack",envUsername:"BROWSERSTACK_USERNAME",envAccessKey:"BROWSERSTACK_ACCESS_KEY",hubHost:"hub.browserstack.com"},lambdatest:{label:"LambdaTest",envUsername:"LT_USERNAME",envAccessKey:"LT_ACCESS_KEY",hubHost:"mobile-hub.lambdatest.com"}};function Wn({provider:e,platform:t,device:n,os:r,appUrl:s,username:i,accessKey:o,capabilities:a}){let c={connectionMode:"cloud",cloudProvider:e||"browserstack",cloudUsername:i,cloudAccessKey:o,platform:t,deviceName:n,deviceOsVersion:r,cloudAppUrl:s,automationName:t==="ios"?"XCUITest":"UiAutomator2"};return a&&(c.cloudCapabilities=a),c}We.exports={CLOUD_PROVIDERS:Hn,buildCloudSettingsPayload:Wn}});var ge=R((Wi,Ge)=>{"use strict";var te=require("fs"),fe=require("path"),Vn=["taqwright","webdriverio-js","appium-java-junit5","appium-python-pytest","appium-ruby-rspec","appium-csharp-nunit"],Gn={taqwright:"deterministic","webdriverio-js":"gemini","appium-java-junit5":"gemini","appium-python-pytest":"gemini","appium-ruby-rspec":"gemini","appium-csharp-nunit":"gemini"},P={taqwright:"taqwright (native)","webdriverio-js":"WebdriverIO (JavaScript)","appium-java-junit5":"Appium Java (JUnit 5)","appium-python-pytest":"Appium Python (pytest)","appium-ruby-rspec":"Appium Ruby (RSpec)","appium-csharp-nunit":"Appium C# (NUnit)"},Jn=5*1024*1024,me={exists:e=>te.existsSync(e),readText:e=>{try{return te.statSync(e).size>Jn?null:te.readFileSync(e,"utf8")}catch{return null}},list:e=>{try{return te.readdirSync(e)}catch{return[]}}};function Xn(e,t){let n=e.readText(fe.join(t,"package.json"));if(!n)return{};try{let r=JSON.parse(n);return{...r.dependencies||{},...r.devDependencies||{}}}catch{return{}}}var zn=new Set(["node_modules","dist","build","target","bin","obj","vendor","out","coverage"]);function Qn(e,t){let n=new Set([""]),r=[];try{r=e.list(t)}catch{r=[]}for(let s of r)s.startsWith(".")||zn.has(s)||n.add(s);return[...n]}function Zn(e,t,n){let r=n?fe.join(t,n):t,s=d=>fe.join(r,d),i=d=>n?`${n}/${d}`:d,o=[],a=Xn(e,r),c=[];try{c=e.list(r)}catch{c=[]}(a["@taqwright/taqwright"]||a.taqwright||e.exists(s("taqwright.config.ts"))||e.exists(s("taqwright.config.js")))&&o.push({id:"taqwright",label:P.taqwright,reason:"taqwright dependency/config found",manifest:i("package.json")});let u=c.some(d=>/^wdio\.conf\.(js|ts|mjs|cjs)$/.test(d));(a.webdriverio||a["@wdio/cli"]||u)&&o.push({id:"webdriverio-js",label:P["webdriverio-js"],reason:u?"wdio.conf.* found":"webdriverio dependency found",manifest:i("package.json")});for(let d of["pom.xml","build.gradle","build.gradle.kts"]){let p=e.readText(s(d));if(p&&/io\.appium|java-client/.test(p)){o.push({id:"appium-java-junit5",label:P["appium-java-junit5"],reason:`io.appium:java-client in ${i(d)}`,manifest:i(d)});break}}for(let d of["requirements.txt","pyproject.toml"]){let p=e.readText(s(d));if(p&&/appium-python-client/i.test(p)){o.push({id:"appium-python-pytest",label:P["appium-python-pytest"],reason:`Appium-Python-Client in ${i(d)}`,manifest:i(d)});break}}let l=e.readText(s("Gemfile"));l&&/appium_lib(_core)?/.test(l)&&o.push({id:"appium-ruby-rspec",label:P["appium-ruby-rspec"],reason:"appium_lib in Gemfile",manifest:i("Gemfile")});for(let d of c){if(!/\.csproj$/i.test(d))continue;let p=e.readText(s(d));if(p&&/Appium\.WebDriver/i.test(p)){o.push({id:"appium-csharp-nunit",label:P["appium-csharp-nunit"],reason:`Appium.WebDriver in ${i(d)}`,manifest:i(d)});break}}return o}function Ve(e,t=me){let n=new Map;for(let r of Qn(t,e))for(let s of Zn(t,e,r))n.has(s.id)||n.set(s.id,s);return[...n.values()]}function er(e,t=me){let n=Ve(e,t);return n.some(r=>r.id==="taqwright")||n.push({id:"taqwright",label:P.taqwright,reason:"default output"}),n}function tr(e){let{requested:t,configured:n,remembered:r,offeredIds:s,detectedRealIds:i,taqwrightDetected:o,javaSignal:a}=e,c=u=>!!u&&s.includes(u);return c(t)?t:c(n)?n:c(r)&&(i.includes(r)||r==="taqwright"&&o)?r:i.length?i[0]:o?"taqwright":a?"appium-java-junit5":"taqwright"}Ge.exports={FRAMEWORK_IDS:Vn,FRAMEWORK_ENGINES:Gn,FRAMEWORK_LABELS:P,nodeFs:me,detectFrameworks:Ve,rankFrameworks:er,pickDefaultFramework:tr}});var Se=R((Vi,Ze)=>{"use strict";var we=require("path"),{nodeFs:nr}=ge(),Je={taqwright:"tests","webdriverio-js":"test/specs","appium-java-junit5":"src/test/java","appium-python-pytest":"tests","appium-ruby-rspec":"spec","appium-csharp-nunit":"Tests"},rr="tests",sr={taqwright:".spec.ts","webdriverio-js":".spec.ts","appium-java-junit5":".java","appium-python-pytest":".py","appium-ruby-rspec":"_spec.rb","appium-csharp-nunit":".cs"},ir=new Set(["appium-python-pytest","appium-ruby-rspec"]);function ye(e){return Je[e]||rr}function be(e){let t=(e||"").split(/[^A-Za-z0-9]+/).filter(Boolean);return t.length?t.map(n=>/^[A-Z0-9]+$/.test(n)?n[0]+n.slice(1).toLowerCase():n[0].toUpperCase()+n.slice(1)).join(""):""}function Ee(e){return(e||"").replace(/([a-z0-9])([A-Z])/g,"$1_$2").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toLowerCase()}function or(e){return Ee(e).split("_").filter(Boolean).join("-")}var ar=6,cr=new Set(["and","or","the","a","an","to","of","in","on","at","as","with","for","then","into","from","by","that","is"]),lr=/@|\d{6,}/;function ur(e){let t=String(e||"").trim().split(/\s+/).filter(Boolean).filter(n=>!lr.test(n)).slice(0,ar);for(;t.length>1&&cr.has(t[t.length-1].toLowerCase());)t.pop();return be(t.join(" "))||"RecordedTest"}function dr(e){let t=String(e||"").trim();return t?/[A-Za-z]/.test(t)?t.length>80?"Keep the name under 80 characters.":/[/\\]/.test(t)?"Use the destination field for the folder.":null:"Use at least one letter.":"Enter a test name."}function pr(e){if(e==null||e==="")return null;let t=String(e);return t!==t.trim()?"must not have leading or trailing spaces.":t.length>120?"is longer than any key LIME mints (120 characters).":/^[a-z0-9][a-z0-9._/:-]*$/.test(t)?t.includes("..")?'must not contain "..".':null:"is not a scenario key \u2014 expected lower-case letters, digits and . _ - / : only."}function Xe(e,t){let n;return ir.has(e)?n=Ee(t):n=be(t),`${n}${sr[e]||""}`}function H(e){return String(e||"").split(/[/\\]+/).filter(t=>t&&t!=="."&&t!=="..").join("/")}function hr(e){if(e==null)return null;let t=String(e);return t.trim()===""?null:/^([A-Za-z]:)?[/\\]/.test(t)?"must be a path inside the project, not an absolute path.":t.split(/[/\\]+/).includes("..")?'must not contain ".." \u2014 the test belongs inside the project.':null}function ve(e){let t=H(e).split("/");return t.pop(),t.join("/")}function ze(e){let t=/(?:^|\/)src\/(?:test|main)\/java\/(.+)$/.exec(H(e));return t&&t[1].split("/").filter(Boolean).join(".")||void 0}function fr(e){let t=H(e),n=t.search(/\/src\/(?:test|main)\/java(?:\/|$)/);return n>0?t.slice(0,n):""}function mr(e){let t=new Map;for(let r of e){let s=ve(r);t.set(s,(t.get(s)||0)+1)}if(!t.size)return null;let n=[...t.entries()].sort((r,s)=>s[1]-r[1]||r[0].localeCompare(s[0]));return{dir:n[0][0],count:n[0][1]}}var Qe={taqwright:{segment:"tests",file:/\.spec\.(ts|js)$/},"webdriverio-js":{segment:"test/specs",file:/\.(ts|js)$/},"appium-java-junit5":{segment:"src/test/java",file:/\.java$/},"appium-python-pytest":{segment:"tests",file:/^(test_.+|.+_test)\.py$/},"appium-ruby-rspec":{segment:"spec",file:/_spec\.rb$/},"appium-csharp-nunit":{segment:"",file:/Tests\.cs$/}},gr=new Set(["node_modules","dist","build","target","bin","obj","vendor","out","coverage",".git"]),wr=2e4;function yr(e,t,n=nr){let r=Qe[t];if(!r)return[];let s=[],i=wr,o=a=>{if(i<=0)return;let c=a?we.join(e,a):e,u=[];try{u=n.list(c)}catch{return}for(let l of u){if(i--<=0)return;if(l.startsWith(".")||gr.has(l))continue;let d=a?`${a}/${l}`:l;if(n.isDir?n.isDir(we.join(e,d)):n.list(we.join(e,d)).length>0){o(d);continue}r.file.test(l)&&(r.segment&&!`/${ve(d)}/`.includes(`/${r.segment}/`)||s.push(d))}};return o(""),s.sort()}function br(e){let{framework:t,testName:n}=e,r=Xe(t,n),s=(a,c,u=0)=>{let l=H(a),d=t==="appium-java-junit5"?ze(l):void 0;return{dir:l,fileName:r,...d?{packageName:d}:{},source:c,neighbourCount:u}};if(e.remembered!=null)return s(e.remembered,"remembered");let i=mr(e.existingTests||[]);if(i&&i.dir)return s(i.dir,"existing",i.count);let o=e.detection&&e.detection.manifest?ve(e.detection.manifest):"";return o?s(`${o}/${ye(t)}`,"module"):s(ye(t),"convention")}Ze.exports={CONVENTIONAL_DIRS:Je,TEST_PATTERNS:Qe,conventionalDir:ye,pascalCase:be,snakeCase:Ee,kebabCase:or,testNameFromGoal:ur,validateTestName:dr,validateDest:hr,validateScenarioKey:pr,fileNameFor:Xe,normalizeDir:H,javaPackageOf:ze,moduleRootOf:fr,findExistingTests:yr,resolveExportTarget:br}});var rt=R((Gi,nt)=>{"use strict";var{CLOUD_PROVIDERS:ne}=q(),{validateScenarioKey:Er}=Se();function vr(e){let t=Object.create(null);for(let n=0;n<e.length;n++){let r=e[n];if(!r.startsWith("--"))continue;let s=r.slice(2),i=e[n+1];i===void 0||i.startsWith("--")?t[s]=!0:(t[s]=i,n++)}return t}var tt=["export","adapt","verify","check-locators","check-pom","disconnect","report"];function Sr(e){let t=Array.isArray(e)?e:[],n=[];for(let r=0;r<t.length;r+=1){let s=String(t[r]==null?"":t[r]);!s||s.startsWith("-")||(r>0?String(t[r-1]||""):"").startsWith("--")||n.push(s)}return n}function Tr(e){let t=e[0];return t&&tt.includes(t)?{command:t,rest:e.slice(1)}:{command:"run",rest:e}}function Ar(e="taqwright"){return e==="json"?"recorded-steps.json":"RecordedTest.spec.ts"}function kr(e,t=process.env){let n=[],r=!!e["list-devices"],s=!!e["keep-session"],i=!!e["no-boot"],o=e["lime-dir"]===!0?".lime":typeof e["lime-dir"]=="string"&&e["lime-dir"].trim()?e["lime-dir"].trim():void 0,a=e.format?String(e.format).toLowerCase():"taqwright";if(["taqwright","json"].includes(a)||n.push(`--format must be taqwright or json (got "${e.format}")`),r)return{errors:n,listDevices:r,keepSession:s,noBoot:i,format:a,limeDir:o};(!e.goal||typeof e.goal!="string"||!e.goal.trim())&&n.push("--goal is required");let c;e.project!==void 0&&(typeof e.project!="string"||!e.project.trim()?n.push("--project requires a project name"):c=e.project.trim());let u;if(e.scenario!==void 0){let h=typeof e.scenario=="string"?e.scenario.trim():"",A=h?Er(h):"requires a scenario key";A?n.push(`--scenario ${A}`):u=h}let l,d;e["gemini-key"]!==void 0&&(typeof e["gemini-key"]!="string"||!e["gemini-key"].trim()?n.push("--gemini-key requires a value (or set GEMINI_API_KEY)"):(l=e["gemini-key"].trim(),d="flag")),!l&&typeof t.GEMINI_API_KEY=="string"&&t.GEMINI_API_KEY.trim()&&(l=t.GEMINI_API_KEY.trim(),d="env");let p,m;if(e["qwen-key"]!==void 0&&(typeof e["qwen-key"]!="string"||!e["qwen-key"].trim()?n.push("--qwen-key requires a value (or set QWEN_API_KEY)"):(p=e["qwen-key"].trim(),m="flag")),!p&&typeof t.QWEN_API_KEY=="string"&&t.QWEN_API_KEY.trim()&&(p=t.QWEN_API_KEY.trim(),m="env"),e["max-steps"]!==void 0){let h=Number(e["max-steps"]);(!Number.isFinite(h)||h<1||h>200)&&n.push("--max-steps must be a number between 1 and 200")}let y;e.platform&&(y=String(e.platform).toLowerCase(),["android","ios"].includes(y)||n.push(`--platform must be android or ios (got "${e.platform}")`));let I=!!e.cloud,S=typeof e.os=="string"?e.os:void 0,T=typeof e["app-url"]=="string"?e["app-url"]:void 0,w=typeof e.app=="string"?e.app:void 0,g=typeof e.caps=="string"&&e.caps.trim()?e.caps.trim():void 0,b,v,E;if(I&&(b=e.cloud===!0?"browserstack":String(e.cloud).toLowerCase(),ne[b]||n.push(`--cloud must be ${Object.keys(ne).join(" or ")} (got "${e.cloud}")`)),I){(!e.device||typeof e.device!="string")&&n.push('--cloud requires --device (the cloud device name, e.g. "Google Pixel 8")'),y||n.push("--cloud requires --platform (android or ios)"),S||n.push("--cloud requires --os (the device OS version, e.g. 14.0)"),w?n.push("--app is not supported for cloud runs. Upload the build to your provider \u2014 LambdaTest: POST https://manual-api.lambdatest.com/app/upload/realDevice (-F appFile=@<file>), BrowserStack: POST https://api-cloud.browserstack.com/app-automate/upload (-F file=@<file>) \u2014 then pass the returned id with --app-url. (--app is still supported for local runs, where it clean-reinstalls on the agent device.)"):T||n.push("--cloud requires --app-url <bs://\u2026 | lt://\u2026> (the id from your provider\u2019s app upload API)"),e["app-url"]!==void 0&&(typeof e["app-url"]!="string"||!e["app-url"].trim())&&n.push("--app-url requires a bs:// or lt:// app id"),T&&ne[b]&&(b==="browserstack"&&T.startsWith("lt://")?n.push(`--app-url "${T}" is a LambdaTest app id, but the provider is browserstack`):b==="lambdatest"&&T.startsWith("bs://")&&n.push(`--app-url "${T}" is a BrowserStack app id, but the provider is lambdatest`)),e["cloud-username"]!==void 0&&(typeof e["cloud-username"]!="string"||!e["cloud-username"].trim())&&n.push("--cloud-username requires a value"),e["cloud-access-key"]!==void 0&&(typeof e["cloud-access-key"]!="string"||!e["cloud-access-key"].trim())&&n.push("--cloud-access-key requires a value"),e.caps!==void 0&&(typeof e.caps!="string"||!e.caps.trim())&&n.push("--caps requires a path to a JSON file");let h=ne[b];h&&(v=typeof e["cloud-username"]=="string"&&e["cloud-username"].trim()||t[h.envUsername]||void 0,E=typeof e["cloud-access-key"]=="string"&&e["cloud-access-key"].trim()||t[h.envAccessKey]||void 0,v||n.push(`cloud runs require a username \u2014 pass --cloud-username or set ${h.envUsername} (credentials are never read from your LIME account for CLI runs)`),E||n.push(`cloud runs require an access key \u2014 pass --cloud-access-key or set ${h.envAccessKey}`))}else e.app!==void 0&&(typeof e.app!="string"||!e.app.trim()?n.push("--app requires a path to an APK"):e.device?y&&y!=="android"&&n.push("--app is Android only"):n.push("--app requires --device (lime-cli must connect to a device to reinstall the app)")),e["app-url"]!==void 0&&n.push("--app-url requires --cloud"),e.os!==void 0&&n.push("--os requires --cloud"),e["cloud-username"]!==void 0&&n.push("--cloud-username requires --cloud"),e["cloud-access-key"]!==void 0&&n.push("--cloud-access-key requires --cloud"),e.caps!==void 0&&n.push("--caps requires --cloud");return{errors:n,listDevices:r,keepSession:s,noBoot:i,limeDir:o,device:e.device,platform:y,projectName:c,scenarioKey:u,geminiKey:l,geminiKeySource:d,qwenKey:p,qwenKeySource:m,app:w,cloud:I,cloudProvider:b,cloudUsername:v,cloudAccessKey:E,os:S,appUrl:T,capsPath:g,format:a}}var et=["browserstack","lambdatest","appium"];function Ir(e){let t=[],n=[];for(let[r,s]of Object.entries(e||{}))!s||typeof s!="object"||Array.isArray(s)?t.push(`--caps block "${r}" must be a JSON object, e.g. { "${r}": { "someCap": true } }`):et.includes(r)||n.push(`--caps block "${r}" is not one of ${et.join("/")} \u2014 it will be ignored (typo?)`);return{errors:t,warnings:n}}nt.exports={parseArgs:vr,parseCommand:Tr,positionalPaths:Sr,validateArgs:kr,extToFilename:Ar,validateCapsObject:Ir,COMMANDS:tt}});var ot=R((Ji,it)=>{"use strict";var{DEFAULT_SERVER:_r}=D(),st={export:`lime-cli export \u2014 work out what this repo is, and where the test belongs.
3
3
 
4
4
  Detects the test framework from the project's own manifests (pytest, JUnit, RSpec, WebdriverIO,
5
5
  C#, taqwright), picks the directory its existing tests live in, and writes the adaptation brief.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqwright/lime-cli",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Thin CLI client for the LIME server — fire a natural-language QA Agent goal against a connected device and write back a taqwright spec.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Taqwright",