@radhya/mach 2.4.1 → 2.4.2

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 +1 @@
1
- import{U as a,V as b,W as c}from"./chunk-2CYRG4WH.js";import"./chunk-LO6DP2SE.js";export{a as credentialsMainCommand,b as credentialsSetupCommand,c as downloadCredentialsCommand};
1
+ import{U as a,V as b,W as c}from"./chunk-UTHJDEP2.js";import"./chunk-LO6DP2SE.js";export{a as credentialsMainCommand,b as credentialsSetupCommand,c as downloadCredentialsCommand};
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{A as Wt,B as _o,C as wo,D as $o,E as Yt,F as qt,G as vo,H as Ro,I as Po,J as Oo,K as Do,L as ji,M as $t,N as Co,O as nt,P as To,Q as No,R as Hi,S as ko,T as xo,V as Jt,a as Ln,b as ve,c as go,d as gt,e as re,f as _e,g as Mn,h as Un,i as wt,j as ht,k as ho,l as yo,m as Mi,n as Ao,o as So,p as Fn,q as Bn,r as jn,s as Ui,t as Fi,u as Hn,v as Gn,w as bo,x as Io,y as Eo,z as Bi}from"./chunk-2CYRG4WH.js";import{a as f,b as fo,c as Ae,d as mo,e as _t,f as tt,g as He,h as w}from"./chunk-LO6DP2SE.js";import{Command as mg,Option as Ne}from"commander";import{configDotenv as gg}from"dotenv";import{intro as Z,outro as yd}from"@clack/prompts";import W from"chalk";var We=class extends Error{constructor(t){super(t),this.name="ProjectAccessError"}};function Gi(e){return typeof e!="string"?void 0:e.trim()||void 0}function Lo(e,t){return Gi(e?.projectId)||Gi(t?.projectId)}function Ed(e,t){if(Array.isArray(e))return e.find(n=>Gi(n?.projectId)===t)}function _d(e,t){let n=Ed(e,t);if(n)return n;throw new We(`The current ${f.name} account does not have access to the linked project (${t}).
2
+ import{A as Wt,B as _o,C as wo,D as $o,E as Yt,F as qt,G as vo,H as Ro,I as Po,J as Oo,K as Do,L as ji,M as $t,N as Co,O as nt,P as To,Q as No,R as Hi,S as ko,T as xo,V as Jt,a as Ln,b as ve,c as go,d as gt,e as re,f as _e,g as Mn,h as Un,i as wt,j as ht,k as ho,l as yo,m as Mi,n as Ao,o as So,p as Fn,q as Bn,r as jn,s as Ui,t as Fi,u as Hn,v as Gn,w as bo,x as Io,y as Eo,z as Bi}from"./chunk-UTHJDEP2.js";import{a as f,b as fo,c as Ae,d as mo,e as _t,f as tt,g as He,h as w}from"./chunk-LO6DP2SE.js";import{Command as mg,Option as Ne}from"commander";import{configDotenv as gg}from"dotenv";import{intro as Z,outro as yd}from"@clack/prompts";import W from"chalk";var We=class extends Error{constructor(t){super(t),this.name="ProjectAccessError"}};function Gi(e){return typeof e!="string"?void 0:e.trim()||void 0}function Lo(e,t){return Gi(e?.projectId)||Gi(t?.projectId)}function Ed(e,t){if(Array.isArray(e))return e.find(n=>Gi(n?.projectId)===t)}function _d(e,t){let n=Ed(e,t);if(n)return n;throw new We(`The current ${f.name} account does not have access to the linked project (${t}).
3
3
  Run \`${f.nameLower} logout\`, then \`${f.nameLower} login\` with a project member, or run \`${f.nameLower} link\` to select an accessible project.`)}async function Mo(e){try{let n=(await w.get("/projects")).data;if(n?.status!=="success"||!Array.isArray(n.projects))throw new We(`Could not verify access to the linked project before starting this command. Try \`${f.nameLower} login\` again.`);return _d(n.projects,e)}catch(t){throw t instanceof We?t:t?.response?.status===401?new We(`Could not verify access to the linked project because this ${f.name} session is no longer valid. Run \`${f.nameLower} login\` and try again.`):new We("Could not verify access to the linked project before starting this command. Check your connection and try again.")}}import{text as Uo,confirm as wd,spinner as $d,isCancel as Vi,cancel as Xt,note as vd,outro as Rd}from"@clack/prompts";import Zt from"chalk";async function Fo(){try{let e=await Uo({message:"Enter Bucket Name:",placeholder:"e.g. my-app-dev",validate(r){if(r.length===0)return"Bucket name is required"}});Vi(e)&&(Xt("Operation cancelled."),process.exit(0));let t=await Uo({message:"Enter Region:",initialValue:"ap-south-1"});Vi(t)&&(Xt("Operation cancelled."),process.exit(0));let n=await wd({message:"Do you want to create a CloudFront Distribution for this bucket?",initialValue:!0});Vi(n)&&(Xt("Operation cancelled."),process.exit(0));let i=$d();i.start("Setting up hosting infrastructure...");try{let r=await w.post("/hosting/setup",{bucketName:e,region:t,createCloudFront:n});if(r.data.status!=="success")throw new Error(r.data.message||"Hosting setup failed");i.stop("Hosting setup complete!");let o=r.data,s=`Bucket Name: ${Zt.cyan(o.bucketName)}
4
4
  `;s+=`Region: ${Zt.cyan(o.region)}
5
5
  `,s+=`S3 Website URL: ${Zt.blue(o.s3WebsiteUrl)}`,o.cloudFrontId&&(s+=`
@@ -2130,5 +2130,5 @@ module.exports = function withMachDeepLinks(config) {
2130
2130
  Running expo prebuild for deeper analysis...`));try{Qm("npx expo prebuild --no-install",{cwd:e,stdio:"pipe"})}catch{return Dn.warn($e.yellow("Prebuild failed \u2014 skipping manifest/plist checks.")),o}}else if(!l)return t.json||Dn.info($e.dim(`
2131
2131
  Skipping manifest/plist checks \u2014 no android/ios dirs. Use --prebuild to generate them.`)),o;for(let d of r){let c=rd();c.start($e.dim(`Running ${d.label}...`));try{let u=Date.now(),p=await d.fn(e,t);p.durationMs=Date.now()-u,o.push(p);let m=p.findings.length;c.stop(m>0?$e.yellow(`${d.label} \u2014 ${m} finding(s)`):$e.green(`${d.label} \u2014 clean`))}catch(u){c.stop($e.red(`${d.label} \u2014 error`)),o.push({category:d.category,label:d.label,findings:[],durationMs:0,error:u.message})}}}return o}import pe from"chalk";import{log as ae}from"@clack/prompts";var Gt={critical:pe.bgRed.white.bold,high:pe.red.bold,medium:pe.yellow.bold,low:pe.blue,info:pe.dim},xi={critical:0,high:1,medium:2,low:3,info:4};function tg(e,t){if(!t)return!0;let n=xi[t];return n===void 0?!0:xi[e]<=n}function ld(e,t){let n=0,i={critical:0,high:0,medium:0,low:0,info:0};for(let s of e){let a=s.findings.filter(d=>tg(d.severity,t));if(a.length===0&&!s.error)continue;if(ae.info(""),ae.info(pe.bold(` ${s.label}`)+pe.dim(` ${a.length} finding(s)`)),ae.info(pe.dim(" "+"\u2500".repeat(60))),s.error){ae.error(pe.red(` Error: ${s.error}`));continue}let l=[...a].sort((d,c)=>xi[d.severity]-xi[c.severity]);for(let d of l){let c=Gt[d.severity](` ${d.severity.toUpperCase()} `);ae.info(` ${c} ${pe.bold(d.id)} ${d.title}`),ae.info(pe.dim(` ${d.description}`)),d.file&&ae.info(pe.dim(` File: ${d.file}${d.line?`:${d.line}`:""}`)),ae.info(pe.cyan(` Fix: ${d.recommendation}`)),ae.info(""),i[d.severity]++,n++}}ae.info(""),ae.info(pe.bold(" Summary")),ae.info(pe.dim(" "+"\u2500".repeat(60))),ae.info(` Total: ${pe.bold(String(n))} finding(s)`),ae.info(` ${Gt.critical(` ${i.critical} Critical `)} ${Gt.high(` ${i.high} High `)} ${Gt.medium(` ${i.medium} Medium `)} ${Gt.low(` ${i.low} Low `)} ${Gt.info(` ${i.info} Info `)}`);let r=i.critical>0,o=i.high>0;r||o?(ae.info(""),ae.error(pe.red.bold(` FAIL \u2014 ${i.critical} critical, ${i.high} high issue(s) found`))):n>0?(ae.info(""),ae.warn(pe.yellow(" PASS (with warnings) \u2014 no critical or high issues"))):(ae.info(""),ae.success(pe.green.bold(" PASS \u2014 no issues found")))}function dd(e,t){let n=e.flatMap(r=>r.findings),i={};for(let r of Object.values(Ce))i[r]=n.filter(o=>o.severity===r).length;return{version:"1.0.0",timestamp:new Date().toISOString(),project:t.name||"unknown",projectVersion:t.version||"0.0.0",summary:{total:n.length,...i},passed:i.critical===0&&i.high===0,checks:e.map(r=>({category:r.category,label:r.label,findingCount:r.findings.length,durationMs:r.durationMs,error:r.error||null})),findings:n}}import{log as le,spinner as ng}from"@clack/prompts";import ie from"chalk";import et from"fs";import ig from"os";import Vt from"path";import{execSync as rg}from"child_process";var cd=16384,og=1,sg=Buffer.from([127,69,76,70]);async function ud(e){le.info(ie.bold.underline("16KB Page Alignment Check")),console.log("");let t=Vt.resolve(e);if(!et.existsSync(t))return le.error(ie.red(`APK file not found: ${t}`)),!1;if(!t.endsWith(".apk"))return le.error(ie.red("The provided file is not an APK file.")),!1;let n=ng();n.start("Extracting and analyzing native libraries...");let i=et.mkdtempSync(Vt.join(ig.tmpdir(),"mach-16kb-"));try{try{rg(`unzip -o -q "${t}" "lib/arm64-v8a/*.so" "lib/x86_64/*.so" -d "${i}" 2>/dev/null`,{encoding:"utf-8",maxBuffer:50*1024*1024})}catch{}let r=pd(Vt.join(i,"lib"));if(r.length===0)return n.stop("Analysis complete."),le.info(ie.yellow("No arm64-v8a or x86_64 native libraries found in the APK.")),le.info(ie.dim("16KB alignment check only applies to arm64-v8a and x86_64 architectures.")),!0;let o=[];for(let l of r){let d=Vt.relative(i,l),c=lg(d),u=Vt.basename(l),p=ag(l);p!==null&&o.push({name:u,filePath:d,arch:c,align:p,compatible:p>=cd})}if(n.stop("Analysis complete."),o.length===0)return le.info(ie.yellow("No valid ELF shared libraries found.")),!0;let s=o.filter(l=>!l.compatible),a=o.filter(l=>l.compatible);if(le.info(ie.dim(`Checked ${o.length} native librar${o.length===1?"y":"ies"}
2132
2132
  `)),s.length>0){le.info(ie.red.bold(`Incompatible libraries:
2133
- `));for(let l of s)le.error(ie.red(`${ie.bold(l.name)} ${ie.dim(`(${l.arch})`)}`)),le.info(ie.dim(` PT_LOAD alignment: 2**${Math.log2(l.align)} (${l.align} bytes, needs 2**14 = ${cd})`))}return a.length>0&&(console.log(""),le.success(ie.green(`${a.length} librar${a.length===1?"y":"ies"} correctly aligned (2**14 or higher).`))),console.log(""),s.length===0?(le.success(ie.green.bold("ELF Verification Successful. APK is 16KB compatible.")),!0):(le.error(ie.red.bold(`Found ${s.length} unaligned lib${s.length===1?"":"s"} (arm64-v8a/x86_64 libs need to be aligned).`)),console.log(""),le.info(ie.yellow("To fix this:")),le.info(ie.dim(" 1. Rebuild with NDK r28+ which defaults to 16KB page alignment")),le.info(ie.dim(" 2. Or set -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON in CMake")),le.info(ie.dim(" 3. Update third-party libraries that ship prebuilt .so files")),le.info(ie.dim(" 4. After rebuilding: zipalign -p -f -v 16 input.apk output.apk")),console.log(""),le.info(ie.dim("Reference: https://developer.android.com/guide/practices/page-sizes")),!1)}catch(r){return n.stop("Analysis failed."),le.error(ie.red(`Failed to analyze APK: ${r.message}`)),!1}finally{try{et.rmSync(i,{recursive:!0,force:!0})}catch{}}}function ag(e){let t=et.openSync(e,"r");try{let n=Buffer.alloc(64);if(et.readSync(t,n,0,64,0),!n.subarray(0,4).equals(sg))return null;let i=n[4]===2,r=n[5]===1,o=(p,m)=>r?p.readUInt16LE(m):p.readUInt16BE(m),s=(p,m)=>r?p.readUInt32LE(m):p.readUInt32BE(m),a=(p,m)=>Number(r?p.readBigUInt64LE(m):p.readBigUInt64BE(m)),l,d,c;i?(l=a(n,32),d=o(n,54),c=o(n,56)):(l=s(n,28),d=o(n,42),c=o(n,44));let u=null;for(let p=0;p<c;p++){let m=Buffer.alloc(d);if(et.readSync(t,m,0,d,l+p*d),s(m,0)!==og)continue;let g;i?g=a(m,48):g=s(m,28),g>0&&(u===null||g<u)&&(u=g)}return u??0}catch{return null}finally{et.closeSync(t)}}function pd(e){let t=[];if(!et.existsSync(e))return t;let n=et.readdirSync(e,{withFileTypes:!0});for(let i of n){let r=Vt.join(e,i.name);i.isDirectory()?t.push(...pd(r)):i.name.endsWith(".so")&&t.push(r)}return t}function lg(e){return e.includes("arm64-v8a")?"arm64-v8a":e.includes("x86_64")?"x86_64":"unknown"}var gd=async e=>{if(Ae()||(Te.error(je.red(`You are not logged in. Run \`${f.nameLower} login\` first.`)),process.exit(1)),e.apk){await ug(e);return}let n=process.cwd(),i=Li.join(n,"package.json");Cn.existsSync(i)||(Te.error(je.red("No package.json found. Run this command from a project root.")),process.exit(1));let r=JSON.parse(Cn.readFileSync(i,"utf-8")),o=!!(r.dependencies?.expo||r.devDependencies?.expo);e.json||(Te.info(je.dim(`Project: ${r.name||"unknown"} v${r.version||"0.0.0"}`)),Te.info(je.dim(`Type: ${o?"Expo":"Bare React Native"}`)),Te.info(""));let s={json:e.json,fix:e.fix,category:e.category,severity:e.severity,prebuild:e.prebuild},a=await ad(n,s);e.json?console.log(JSON.stringify(dd(a,r),null,2)):ld(a,e.severity);let l=a.some(c=>c.findings.some(u=>u.severity==="critical")),d=a.some(c=>c.findings.some(u=>u.severity==="high"));(l||d)&&process.exit(1)},fd=["16kb"];async function ug(e){let t=e.category?.toLowerCase();t&&!fd.includes(t)&&(Te.error(je.red(`Unknown APK check category: "${t}"`)),Te.info(je.dim(`Available APK checks: ${fd.join(", ")}`)),process.exit(1));let n=await pg(e.apk);n||process.exit(1);let i=!t,r=!1;(i||t==="16kb")&&(await ud(n)||(r=!0)),r&&process.exit(1)}async function pg(e){if(e.startsWith("build:")){let n=e.slice(6);return await fg(n)}if(e.startsWith("http://")||e.startsWith("https://"))return await hd(e);let t=Li.resolve(e);return Cn.existsSync(t)?t:(Te.error(je.red(`APK file not found: ${t}`)),null)}async function fg(e){let t=md();t.start(`Fetching APK from build ${e}...`);try{let n=await w.get(`/build/${e}`);if(n.data.status!=="success")throw new Error(n.data.message);let i=n.data.build;if(!i)throw new Error("Build not found");let r=i.artifacts?.find(o=>o.type?o.type==="apk":o.name?.endsWith(".apk")||o.url?.includes(".apk"));return!r||!r.url?(t.stop("No APK artifact found"),Te.error(je.red("This build does not have an APK artifact.")),Te.info(je.dim("Make sure the build produced an APK (not just an AAB).")),null):(t.stop(`Found build: ${i.buildId||e}`),await hd(r.url))}catch(n){return t.stop("Failed to fetch build"),Te.error(je.red(n.message)),null}}async function hd(e){let t=md();t.start("Downloading APK...");try{let n=Cn.mkdtempSync(Li.join(dg.tmpdir(),`${f.nameLower}-audit-`)),i=Li.join(n,"app.apk"),r=await cg.get(e,{responseType:"arraybuffer"});Cn.writeFileSync(i,r.data);let o=(r.data.length/(1024*1024)).toFixed(1);return t.stop(`Downloaded APK (${o} MB)`),i}catch(n){return t.stop("Download failed"),Te.error(je.red(`Failed to download APK: ${n.message}`)),null}}var hg=console.log;console.log=()=>{};gg();console.log=hg;Z(W.bgCyan.black(f.cliTag("Production Build Orchestrator")));var Tn=(e,t=[])=>t.concat(e),M=new mg;M.name(f.nameLower).description(`${f.name} CLI: Powerful Cloud Infrastructure Tools`).version(nt).option("-y, --yes","Automatically answer yes to all prompts",!1).option("--quiet","Suppress non-essential output",!1);M.command("agent").description("Manage local device discovery agent for the Install Hub (port 7070)").argument("[action]","start, run, install, status, restart, stop, or uninstall","start").action(async e=>{await Ca(e)});M.command("host").description("Setup AWS S3 static hosting and CloudFront").action(async()=>{Z(W.bgCyan.black(f.cliTag("Hosting"))),await Fo()});M.command("sitemap").description("Generate sitemap.xml from Expo Router app structure").option("-o, --output <path>","Output path for sitemap.xml","./public/sitemap.xml").action(async e=>{Z(W.bgCyan.black(f.cliTag("Sitemap Generator"))),await Go(e)});M.command("build").description("Run a build on a cloud provider (AWS Spot Instances)").argument("[platform]","Target platform (android, ios)").option("--platform <os>","Target platform alias (android, ios) [Optional]").option("--repo <url>","Git Repository URL").option("--branch <name>","Git Branch").option("--ami <id>","AMI ID").option("--bucket <name>","S3 Bucket for artifacts").option("--region <region>","AWS Region").option("--aws-profile <name>","AWS Credentials Profile").option("-p, --build-profile <name>","Build Profile (e.g. production, staging)").option("--profile <name>","Build Profile (alias for --build-profile)").option("--dry-run","Generate User Data script without launching").option("--keep-instance","Do not terminate the instance after build").option("--subnet <id>","VPC Subnet ID to launch the instance in").option("--security-group <id>","VPC Security Group ID to use").option("--ssh-host <host>","Remote host for iOS build (SSH)").option("--ssh-user <user>","SSH username for remote host").option("--ssh-key <path>","Path to private SSH key for remote host").option("--ios-scheme <scheme>","iOS Scheme to build").option("--ios-team-id <id>","Apple Development Team ID").option("--ios-configuration <config>","Xcode configuration (Release/Debug)").option("--ios-export-method <method>","Export method (ad-hoc, app-store, development, enterprise)").option("--ios-api-key-id <id>","App Store Connect API Key ID").option("--ios-api-key-issuer <id>","App Store Connect API Key Issuer ID").option("--ios-api-key-path <path>","Path to App Store Connect API Key (.p8) file").option("--simulator","Build for iOS Simulator (no signing required)").addOption(new Ne("--build-id <id>","Internal build ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--fail-only","Internal: mark an existing build failed").hideHelp()).addOption(new Ne("--error <message>","Internal failure message").hideHelp()).option("--local","Run build on local machine").option("--auto-version","Assign the next Android versionCode or iOS buildNumber from Mach").option("--auto-submit","Submit this build after it completes successfully").option("--submit-track <track>","Google Play track to use with --auto-submit").option("--submit-release-status <status>","Google Play release status to use with --auto-submit").option("--submit-rollout <fraction>","Google Play staged rollout fraction to use with --auto-submit").option("--submit-changes-not-sent-for-review","Commit Google Play changes without automatically sending them for review when using --auto-submit").option("--submit-credential-id <id>","Service credential ID to use with --auto-submit").option("--submit-json-output <path>","Write auto-submit metadata JSON to a file for CI/CD").option("--verbose","Enable verbose logging").option("--json-output <path>","Write build metadata JSON to a file for CI/CD").option("--maestro","Queue a managed Maestro test run after a successful build").option("--maestro-flows <path>","Maestro flow file or directory (default: .maestro)").option("--maestro-device <device>","Managed device profile id (run `mach maestro devices` to list)").option("--maestro-retries <n>","Retries for the Maestro run","1").option("--maestro-record","Enable screen recording where supported").option("--maestro-use-build-source","Use Maestro flows from the build source snapshot instead of uploading local flows").option("--maestro-env <name>","Forward an environment variable to the managed Maestro runner; repeat or comma-separate names",Tn,[]).option("-y, --yes","Automatically answer yes to all prompts",!1).option("--quiet","Suppress non-essential output",!1).action(async(e,t)=>{let n=M.opts();t.yes=t.yes||n.yes,t.quiet=t.quiet||n.quiet,t.platform=e||t.platform,t.buildProfile=t.profile||t.buildProfile,t.quiet||Z(W.bgCyan.black(f.cliTag("Cloud Build"))),await ei(t)});var yg=M.command("maestro").description("Run Maestro tests locally or with the managed Mach runner").option("--platform <os>","Target platform (android/ios)").option("-p, --profile <name>","Build profile to resolve when using --latest","production").option("--latest","Use the latest successful build for the platform/profile").option("--build-id <id>","Use a specific Mach build ID").option("--build-url <url>","Use a Mach build URL").option("--artifact-url <url>","Use a direct APK or iOS simulator app artifact URL").option("--local","Run Maestro on a connected local emulator/device instead of the managed runner").option("--maestro-flows <path>","Maestro flow file or directory (default: .maestro)").option("--maestro-device <device>","Managed device profile id (run `mach maestro devices` to list); local runs accept a device identifier").option("--maestro-retries <n>","Retries for the Maestro run","1").option("--maestro-record","Enable screen recording where supported").option("--maestro-use-build-source","Use Maestro flows from the build source snapshot instead of uploading local flows").option("--maestro-env <name>","Forward an environment variable to the managed Maestro runner; repeat or comma-separate names",Tn,[]).option("--wait","Wait for managed Maestro completion and exit non-zero on failure").option("--wait-timeout <minutes>","Maximum minutes to wait for managed Maestro completion","60").option("--wait-interval <seconds>","Polling interval while waiting for managed Maestro completion","15").option("--json-output <path>","Write test run metadata JSON to a file for CI/CD").addOption(new Ne("--local-runner","Internal: execute a managed Maestro run on this machine").hideHelp()).addOption(new Ne("--test-run-id <id>","Internal test run ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--runner-token <token>","Internal runner token").hideHelp()).action(async e=>{Z(W.bgCyan.black(f.cliTag("Maestro Testing"))),await ds(e)});yg.command("devices").description("List device profiles available on the managed Maestro runner fleet").option("--platform <os>","Filter to android or ios").option("--json","Print machine-readable JSON").action(async e=>{await cs(e)});var zt=e=>e.option("--platform <os>","Target platform: ios, android, or all","all").option("--channel <name>","OTA channel (for example: production, staging)").option("--branch <name>","Alias for --channel").option("--runtime-version <version>","Runtime version override").option("--message <text>","Release note/message for this OTA update").option("--framework <name>","Framework override: expo or react-native").option("--engine <name>","OTA engine override (currently expo-updates)").option("--url <url>","Mach OTA update URL override").option("--install-plugin","Install @radhya/mach locally for the Expo config plugin").option("--skip-install","Do not install local Expo plugin dependency").option("--update-id <id>","OTA update id for rollback/promote").option("--json","Print JSON output"),Kt=M.command("ota").description("Setup, publish, verify, and manage Mach OTA updates");zt(Kt.command("setup").description("Configure OTA for this project")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Setup"))),await dt("setup",{...e,yes:e.yes||t.yes})});zt(Kt.command("publish").description("Publish an OTA update")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Publish"))),await dt("publish",{...e,yes:e.yes||t.yes})});zt(Kt.command("verify").description("Verify OTA configuration")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Verify"))),await dt("verify",{...e,yes:e.yes||t.yes})});zt(Kt.command("list").description("List OTA updates for the linked project")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Updates"))),await dt("list",{...e,yes:e.yes||t.yes})});zt(Kt.command("rollback").description("Roll back an OTA update")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Rollback"))),await dt("rollback",{...e,yes:e.yes||t.yes})});zt(Kt.command("promote").description("Promote an OTA update")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Promote"))),await dt("promote",{...e,yes:e.yes||t.yes})});M.command("submit").description("Automated Store Submission (App Store / Google Play)").option("--platform <os>","Target platform (ios/android)").option("-p, --profile <name>","Build/submission profile to submit from (e.g. production, preprod)").option("--track <track>","Google Play Track (internal, alpha, beta, production)").option("--release-status <status>","Google Play release status (completed, draft, halted, inProgress)").option("--rollout <fraction>","Google Play staged rollout fraction for inProgress releases (example: 0.1)").option("--changes-not-sent-for-review","Commit Google Play changes without automatically sending them for review").option("--ssh-host <host>","Remote macOS host for iOS submission").option("--ssh-user <user>","SSH username for remote iOS submission").option("--ssh-key <path>","Path to private SSH key for remote iOS submission").option("--credential-id <id>","Service credential ID to use when multiple submission credentials exist").option("--local","Run submission on this machine (internal runner mode for iOS)").addOption(new Ne("--submit-id <id>","Internal submission ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--package-name <name>","Internal Android package name").hideHelp()).addOption(new Ne("--bundle-id <id>","Internal iOS bundle identifier").hideHelp()).option("--json-output <path>","Write submission metadata JSON to a file for CI/CD").option("--latest","Use the latest successful build for submission").option("--build-id <id>","Use a specific build ID for submission").action(async e=>{let t=M.opts();e.quiet=e.quiet||t.quiet,e.yes=e.yes||t.yes,Z(W.bgCyan.black(f.cliTag("Store Submission"))),await qn(e)});M.command("login").description(`Login to ${f.name} Dashboard`).action(async()=>{Z(W.bgCyan.black(f.cliTag("Login"))),await xa()});M.command("logout").description(`Logout from ${f.name} on this machine`).action(async()=>{Z(W.bgCyan.black(f.cliTag("Logout"))),await La()});M.command("link").description(`Link local directory to a ${f.name} Project`).action(async()=>{Z(W.bgCyan.black(f.cliTag("Link Project"))),await Ua()});M.command("me").description("Display currently logged in user details").action(async()=>{await ll()});M.command("init").description(`Create a new ${f.name} Project`).action(async()=>{Z(W.bgCyan.black(f.cliTag("Init Project"))),await Fa()});M.command("env").description("Manage Environment Variables").argument("<action>","Action to perform: set, list, pull, download, or export").argument("[args...]","Key=Value pairs for set action").option("-e, --environment <name>","Environment to pull/download","development").option("-o, --out <file>","Output file for pull/download",".env.local").option("--overwrite","Overwrite output file if it already exists").action(async(e,t,n)=>{Z(W.bgCyan.black(f.cliTag("Env Manager"))),await ja(e,t,n)});M.command("start").description("Start the development server (Metro)").option("-p, --build-profile <name>","Build profile (e.g. development, staging)","development").option("--tunnel","Use ngrok tunnel").option("--lan","Use LAN IP").option("--localhost","Use localhost").option("-c, --clear","Clear Metro cache").option("--port <number>","Port to listen on").option("--ios","Start on iOS").option("--android","Start on Android").option("--web","Start on Web").action(async e=>{Z(W.bgCyan.black(f.cliTag("Dev Server"))),await cl(e)});var Nn=M.command("push").description("Configure and send provider-direct APNs/FCM notifications");Nn.command("setup").description("Install and wire a working default push experience").option("--name <name>","Push app display name").option("--ios-bundle <id>","iOS bundle identifier").option("--android-package <name>","Android package name").option("-e, --environment <name>","development, preview, or production").option("--google-services-file <path>","Android google-services.json path").option("--skip-install","Generate setup without installing SDK dependencies").action(No);Nn.command("init").description("Create only the server-side push app (advanced)").option("--name <name>","Push app display name").option("--ios-bundle <id>","iOS bundle identifier").option("--android-package <name>","Android package name").option("-e, --environment <name>","development, preview, or production","production").option("--google-services-file <path>","Expo Android google-services.json path").action(To);var Ad=Nn.command("credentials").description("Configure provider credentials");Ad.command("apns").description("Configure an Apple APNs .p8 authentication key").requiredOption("--file <path>","APNs .p8 file").requiredOption("--team-id <id>","Apple Developer team ID").requiredOption("--key-id <id>","APNs key ID").option("--bundle-id <id>","iOS bundle identifier").option("--app <id>","MACH Push app ID").option("-e, --environment <name>","development, preview, or production").action(e=>Hi("apns",e));Ad.command("fcm").description("Configure a Firebase service-account JSON file").requiredOption("--file <path>","Firebase service-account JSON").option("--app <id>","MACH Push app ID").option("-e, --environment <name>","Deprecated; accepted for compatibility because FCM credentials are package-wide").action(e=>Hi("fcm",e));Nn.command("send").description("Queue one transient push notification").requiredOption("--title <text>","Notification title").requiredOption("--body <text>","Notification body").option("--app <id>","MACH Push app ID").option("-e, --environment <name>","development, preview, or production").option("--token <token>","MACH push token; repeatable",Tn,[]).option("--user <id>","Application user ID; repeatable",Tn,[]).option("--all","Send to all active devices").option("--platform <platform>","Limit --all to ios or android").option("--data <json>","String-to-string custom data JSON").option("--sound <name>","Provider sound name").option("--badge <number>","iOS badge count").option("--ttl <seconds>","Provider time-to-live").option("--collapse-key <key>","Provider collapse key").option("--android-channel-id <id>","Android notification channel").action(ko);Nn.command("status").description("Show aggregate push delivery counters").option("--days <number>","Statistics range, 1-90","30").action(xo);M.command("config").description("Show resolved configuration for a profile").option("-p, --profile <name>","Build profile to resolve","development").option("--json","Output as JSON").action(async e=>{await ul(e)});var Sd=M.command("version").description("Show or seed DB-owned native version counters"),bd=e=>e.requiredOption("--platform <os>","Target platform: ios or android").option("-p, --profile <name>","Build profile used to resolve package/bundle scope","production").option("--scope <value>","Counter scope override, usually package name or bundle identifier").option("--package <name>","Android package override").option("--bundle-id <id>","iOS bundle identifier override").option("--json","Print JSON output");bd(Sd.command("show").description("Show the current native version counter")).action(async e=>{Z(W.bgCyan.black(f.cliTag("Version Counter"))),await ao("show",e)});bd(Sd.command("seed").description("Seed the native version counter for an existing app").argument("[value]","Latest already-used value; the next build uses value + 1").option("--value <number>","Latest already-used value; the next build uses value + 1").option("--force","Allow lowering an existing counter")).action(async(e,t)=>{Z(W.bgCyan.black(f.cliTag("Version Counter"))),await ao("seed",{...t,value:t.value??e})});var Id=M.command("deeplink").description("Configure and verify app links, universal links, and URI schemes");Id.command("setup").description("Generate deep link config, hosted association files, and Expo plugin support").option("--domain <domain>","Associated domain, e.g. app.example.com").option("--base-url <url>","Base URL, e.g. https://app.example.com").option("-p, --profile <name>","Profile used for build/submit overrides").option("--platform <platform>","ios, android, or all").option("--framework <framework>","expo or react-native").option("--scheme <scheme>","URI scheme, e.g. myapp").option("--ios-bundle-id <id>","iOS bundle identifier").option("--android-package <name>","Android package name").option("--apple-team-id <id>","Apple Developer Team ID").option("--app-store-id <id>","App Store app ID for Smart App Banner").option("--android-fingerprint <sha256>","Android SHA256 signing certificate fingerprint; repeatable",Tn,[]).option("--output <dir>","Directory for hosted files, e.g. public or deep-links").option("--install-plugin","Install @radhya/mach locally so Expo can use the packaged config plugin").option("--no-install-plugin","Do not install @radhya/mach for Expo projects; use the local plugin fallback if the package is missing").option("-y, --yes","Automatically answer yes to prompts",!1).action(async e=>{let t=M.opts();e.yes=e.yes||t.yes,Z(W.bgCyan.black(f.cliTag("Deep Links"))),await Nl(e)});Id.command("verify").description("Verify local and optionally live deep link configuration").option("-p, --profile <name>","Profile used for build/submit overrides").option("--live","Check hosted files over HTTPS").option("--android-device","Print Android device verification commands").action(async e=>{Z(W.bgCyan.black(f.cliTag("Deep Link Verify"))),await kl(e)});M.command("credentials").description("Unified, interactive credential management (iOS/Android)").option("-p, --profile <name>","Build profile (production, staging, development)").option("--credential-type <type>","iOS signing type override: development, adhoc, or store").option("--force","Force recreate certificates (nuke existing on Apple Portal)",!1).action(async e=>{let{credentialsMainCommand:t}=await import("./credentials-ILTNQISL.js");await t(e)});M.command("credentials:setup").description("Automated credential provisioning (iOS/Android) [Legacy]").requiredOption("--platform <os>","Platform: ios or android").option("--profile <name>","Build profile (production, staging, development)").option("--credential-type <type>","iOS signing type override: development, adhoc, or store").option("--bundle-id <id>","Bundle ID / Package Name (optional, auto-detected)").option("--team-id <id>","Apple Team ID (iOS only)").option("--key-alias <alias>","Android keystore alias (optional, auto-generated)").option("--aws-profile <name>","AWS Credentials Profile (for S3 storage)").option("--force","Force recreate certificates (nuke existing on Apple Portal)",!1).action(async e=>{Z(W.bgCyan.black(f.cliTag("Credentials Setup"))),await Jt(e),yd(W.green("Done!"))});M.command("credentials:service").description("Upload Service Credentials (ASC API Key / Google Service JSON) [Legacy]").requiredOption("--platform <os>","Platform: ios or android").option("--file <path>","Path to credential file (.p8 or .json)").option("--issuer-id <id>","ASC API Key Issuer ID (iOS only)").option("--key-id <id>","ASC API Key ID (iOS only)").option("--bundle-id <id>","Bundle identifier / Android package name to attach this service credential to").option("--package-name <name>","Android package name to attach this service credential to").option("-p, --profile <name>","Build profile to resolve package/bundle identifier from config").action(async e=>{Z(W.bgCyan.black(f.cliTag("Service Credentials"))),await Co(e),yd(W.green("Done!"))});var po=M.command("device").description("Manage registered iOS test devices");po.command("register").description("Register a connected iOS device or enter UDID manually").option("--udid <udid>","Device UDID (skip auto-detection)").option("--name <name>","Device name").option("--team-id <id>","Apple Developer Team ID for this device").action(async e=>{await vi("register",e)});po.command("list").description("List all registered devices").option("--team-id <id>","Filter by Apple Developer Team ID").action(async e=>{await vi("list",e)});po.command("remove").description("Remove a registered device").option("--udid <udid>","Device UDID to remove").option("--team-id <id>","Apple Developer Team ID for this device").action(async e=>{await vi("remove",e)});M.command("audit").description("Run automated security audit on the project or APK").option("--apk <path>","Path to APK file (runs APK diagnostics like 16KB alignment)").option("--json","Output results as JSON (for CI/CD)").option("--fix","Auto-apply fixes where possible").option("--category <name>","Run only a specific check category (e.g. 16kb, permissions, secrets)").option("--severity <level>","Minimum severity to display (critical, high, medium, low, info)").option("--prebuild","Run expo prebuild for deeper manifest/plist analysis").action(async e=>{Z(W.bgCyan.black(f.cliTag(e.apk?"APK Audit":"Security Audit"))),await gd(e)});var Ag=new Set(["login","logout","agent"]),Sg=new Set(["build","credentials","credentials:service","credentials:setup","env","push","submit","version"]),bg=new Set(["publish","list","rollback","promote"]);function Ig(e){let t=[],n=e;for(;n&&n!==M;)t.unshift(n.name()),n=n.parent;return t}function Eg(e,t){let[n,i]=Ig(e);return Sg.has(n)?!0:n==="ota"?bg.has(i):n==="maestro"?i!=="devices"&&!t.local&&!t.localRunner:!1}M.hook("preAction",async(e,t)=>{let n=t.name(),i=t.opts?.()||{};if(n==="maestro"&&(i.local||i.localRunner)||t.parent?.name()==="deeplink"||Ag.has(n)||(_t(),!Eg(t,i)))return;let r=Lo(i,re());if(!r)throw new We(`No linked ${f.name} project was found. Run \`${f.nameLower} link\` before using this command.`);await Mo(r)});M.on("command:*",()=>{console.error(`Invalid command: %s
2133
+ `));for(let l of s)le.error(ie.red(`${ie.bold(l.name)} ${ie.dim(`(${l.arch})`)}`)),le.info(ie.dim(` PT_LOAD alignment: 2**${Math.log2(l.align)} (${l.align} bytes, needs 2**14 = ${cd})`))}return a.length>0&&(console.log(""),le.success(ie.green(`${a.length} librar${a.length===1?"y":"ies"} correctly aligned (2**14 or higher).`))),console.log(""),s.length===0?(le.success(ie.green.bold("ELF Verification Successful. APK is 16KB compatible.")),!0):(le.error(ie.red.bold(`Found ${s.length} unaligned lib${s.length===1?"":"s"} (arm64-v8a/x86_64 libs need to be aligned).`)),console.log(""),le.info(ie.yellow("To fix this:")),le.info(ie.dim(" 1. Rebuild with NDK r28+ which defaults to 16KB page alignment")),le.info(ie.dim(" 2. Or set -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON in CMake")),le.info(ie.dim(" 3. Update third-party libraries that ship prebuilt .so files")),le.info(ie.dim(" 4. After rebuilding: zipalign -p -f -v 16 input.apk output.apk")),console.log(""),le.info(ie.dim("Reference: https://developer.android.com/guide/practices/page-sizes")),!1)}catch(r){return n.stop("Analysis failed."),le.error(ie.red(`Failed to analyze APK: ${r.message}`)),!1}finally{try{et.rmSync(i,{recursive:!0,force:!0})}catch{}}}function ag(e){let t=et.openSync(e,"r");try{let n=Buffer.alloc(64);if(et.readSync(t,n,0,64,0),!n.subarray(0,4).equals(sg))return null;let i=n[4]===2,r=n[5]===1,o=(p,m)=>r?p.readUInt16LE(m):p.readUInt16BE(m),s=(p,m)=>r?p.readUInt32LE(m):p.readUInt32BE(m),a=(p,m)=>Number(r?p.readBigUInt64LE(m):p.readBigUInt64BE(m)),l,d,c;i?(l=a(n,32),d=o(n,54),c=o(n,56)):(l=s(n,28),d=o(n,42),c=o(n,44));let u=null;for(let p=0;p<c;p++){let m=Buffer.alloc(d);if(et.readSync(t,m,0,d,l+p*d),s(m,0)!==og)continue;let g;i?g=a(m,48):g=s(m,28),g>0&&(u===null||g<u)&&(u=g)}return u??0}catch{return null}finally{et.closeSync(t)}}function pd(e){let t=[];if(!et.existsSync(e))return t;let n=et.readdirSync(e,{withFileTypes:!0});for(let i of n){let r=Vt.join(e,i.name);i.isDirectory()?t.push(...pd(r)):i.name.endsWith(".so")&&t.push(r)}return t}function lg(e){return e.includes("arm64-v8a")?"arm64-v8a":e.includes("x86_64")?"x86_64":"unknown"}var gd=async e=>{if(Ae()||(Te.error(je.red(`You are not logged in. Run \`${f.nameLower} login\` first.`)),process.exit(1)),e.apk){await ug(e);return}let n=process.cwd(),i=Li.join(n,"package.json");Cn.existsSync(i)||(Te.error(je.red("No package.json found. Run this command from a project root.")),process.exit(1));let r=JSON.parse(Cn.readFileSync(i,"utf-8")),o=!!(r.dependencies?.expo||r.devDependencies?.expo);e.json||(Te.info(je.dim(`Project: ${r.name||"unknown"} v${r.version||"0.0.0"}`)),Te.info(je.dim(`Type: ${o?"Expo":"Bare React Native"}`)),Te.info(""));let s={json:e.json,fix:e.fix,category:e.category,severity:e.severity,prebuild:e.prebuild},a=await ad(n,s);e.json?console.log(JSON.stringify(dd(a,r),null,2)):ld(a,e.severity);let l=a.some(c=>c.findings.some(u=>u.severity==="critical")),d=a.some(c=>c.findings.some(u=>u.severity==="high"));(l||d)&&process.exit(1)},fd=["16kb"];async function ug(e){let t=e.category?.toLowerCase();t&&!fd.includes(t)&&(Te.error(je.red(`Unknown APK check category: "${t}"`)),Te.info(je.dim(`Available APK checks: ${fd.join(", ")}`)),process.exit(1));let n=await pg(e.apk);n||process.exit(1);let i=!t,r=!1;(i||t==="16kb")&&(await ud(n)||(r=!0)),r&&process.exit(1)}async function pg(e){if(e.startsWith("build:")){let n=e.slice(6);return await fg(n)}if(e.startsWith("http://")||e.startsWith("https://"))return await hd(e);let t=Li.resolve(e);return Cn.existsSync(t)?t:(Te.error(je.red(`APK file not found: ${t}`)),null)}async function fg(e){let t=md();t.start(`Fetching APK from build ${e}...`);try{let n=await w.get(`/build/${e}`);if(n.data.status!=="success")throw new Error(n.data.message);let i=n.data.build;if(!i)throw new Error("Build not found");let r=i.artifacts?.find(o=>o.type?o.type==="apk":o.name?.endsWith(".apk")||o.url?.includes(".apk"));return!r||!r.url?(t.stop("No APK artifact found"),Te.error(je.red("This build does not have an APK artifact.")),Te.info(je.dim("Make sure the build produced an APK (not just an AAB).")),null):(t.stop(`Found build: ${i.buildId||e}`),await hd(r.url))}catch(n){return t.stop("Failed to fetch build"),Te.error(je.red(n.message)),null}}async function hd(e){let t=md();t.start("Downloading APK...");try{let n=Cn.mkdtempSync(Li.join(dg.tmpdir(),`${f.nameLower}-audit-`)),i=Li.join(n,"app.apk"),r=await cg.get(e,{responseType:"arraybuffer"});Cn.writeFileSync(i,r.data);let o=(r.data.length/(1024*1024)).toFixed(1);return t.stop(`Downloaded APK (${o} MB)`),i}catch(n){return t.stop("Download failed"),Te.error(je.red(`Failed to download APK: ${n.message}`)),null}}var hg=console.log;console.log=()=>{};gg();console.log=hg;Z(W.bgCyan.black(f.cliTag("Production Build Orchestrator")));var Tn=(e,t=[])=>t.concat(e),M=new mg;M.name(f.nameLower).description(`${f.name} CLI: Powerful Cloud Infrastructure Tools`).version(nt).option("-y, --yes","Automatically answer yes to all prompts",!1).option("--quiet","Suppress non-essential output",!1);M.command("agent").description("Manage local device discovery agent for the Install Hub (port 7070)").argument("[action]","start, run, install, status, restart, stop, or uninstall","start").action(async e=>{await Ca(e)});M.command("host").description("Setup AWS S3 static hosting and CloudFront").action(async()=>{Z(W.bgCyan.black(f.cliTag("Hosting"))),await Fo()});M.command("sitemap").description("Generate sitemap.xml from Expo Router app structure").option("-o, --output <path>","Output path for sitemap.xml","./public/sitemap.xml").action(async e=>{Z(W.bgCyan.black(f.cliTag("Sitemap Generator"))),await Go(e)});M.command("build").description("Run a build on a cloud provider (AWS Spot Instances)").argument("[platform]","Target platform (android, ios)").option("--platform <os>","Target platform alias (android, ios) [Optional]").option("--repo <url>","Git Repository URL").option("--branch <name>","Git Branch").option("--ami <id>","AMI ID").option("--bucket <name>","S3 Bucket for artifacts").option("--region <region>","AWS Region").option("--aws-profile <name>","AWS Credentials Profile").option("-p, --build-profile <name>","Build Profile (e.g. production, staging)").option("--profile <name>","Build Profile (alias for --build-profile)").option("--dry-run","Generate User Data script without launching").option("--keep-instance","Do not terminate the instance after build").option("--subnet <id>","VPC Subnet ID to launch the instance in").option("--security-group <id>","VPC Security Group ID to use").option("--ssh-host <host>","Remote host for iOS build (SSH)").option("--ssh-user <user>","SSH username for remote host").option("--ssh-key <path>","Path to private SSH key for remote host").option("--ios-scheme <scheme>","iOS Scheme to build").option("--ios-team-id <id>","Apple Development Team ID").option("--ios-configuration <config>","Xcode configuration (Release/Debug)").option("--ios-export-method <method>","Export method (ad-hoc, app-store, development, enterprise)").option("--ios-api-key-id <id>","App Store Connect API Key ID").option("--ios-api-key-issuer <id>","App Store Connect API Key Issuer ID").option("--ios-api-key-path <path>","Path to App Store Connect API Key (.p8) file").option("--simulator","Build for iOS Simulator (no signing required)").addOption(new Ne("--build-id <id>","Internal build ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--fail-only","Internal: mark an existing build failed").hideHelp()).addOption(new Ne("--error <message>","Internal failure message").hideHelp()).option("--local","Run build on local machine").option("--auto-version","Assign the next Android versionCode or iOS buildNumber from Mach").option("--auto-submit","Submit this build after it completes successfully").option("--submit-track <track>","Google Play track to use with --auto-submit").option("--submit-release-status <status>","Google Play release status to use with --auto-submit").option("--submit-rollout <fraction>","Google Play staged rollout fraction to use with --auto-submit").option("--submit-changes-not-sent-for-review","Commit Google Play changes without automatically sending them for review when using --auto-submit").option("--submit-credential-id <id>","Service credential ID to use with --auto-submit").option("--submit-json-output <path>","Write auto-submit metadata JSON to a file for CI/CD").option("--verbose","Enable verbose logging").option("--json-output <path>","Write build metadata JSON to a file for CI/CD").option("--maestro","Queue a managed Maestro test run after a successful build").option("--maestro-flows <path>","Maestro flow file or directory (default: .maestro)").option("--maestro-device <device>","Managed device profile id (run `mach maestro devices` to list)").option("--maestro-retries <n>","Retries for the Maestro run","1").option("--maestro-record","Enable screen recording where supported").option("--maestro-use-build-source","Use Maestro flows from the build source snapshot instead of uploading local flows").option("--maestro-env <name>","Forward an environment variable to the managed Maestro runner; repeat or comma-separate names",Tn,[]).option("-y, --yes","Automatically answer yes to all prompts",!1).option("--quiet","Suppress non-essential output",!1).action(async(e,t)=>{let n=M.opts();t.yes=t.yes||n.yes,t.quiet=t.quiet||n.quiet,t.platform=e||t.platform,t.buildProfile=t.profile||t.buildProfile,t.quiet||Z(W.bgCyan.black(f.cliTag("Cloud Build"))),await ei(t)});var yg=M.command("maestro").description("Run Maestro tests locally or with the managed Mach runner").option("--platform <os>","Target platform (android/ios)").option("-p, --profile <name>","Build profile to resolve when using --latest","production").option("--latest","Use the latest successful build for the platform/profile").option("--build-id <id>","Use a specific Mach build ID").option("--build-url <url>","Use a Mach build URL").option("--artifact-url <url>","Use a direct APK or iOS simulator app artifact URL").option("--local","Run Maestro on a connected local emulator/device instead of the managed runner").option("--maestro-flows <path>","Maestro flow file or directory (default: .maestro)").option("--maestro-device <device>","Managed device profile id (run `mach maestro devices` to list); local runs accept a device identifier").option("--maestro-retries <n>","Retries for the Maestro run","1").option("--maestro-record","Enable screen recording where supported").option("--maestro-use-build-source","Use Maestro flows from the build source snapshot instead of uploading local flows").option("--maestro-env <name>","Forward an environment variable to the managed Maestro runner; repeat or comma-separate names",Tn,[]).option("--wait","Wait for managed Maestro completion and exit non-zero on failure").option("--wait-timeout <minutes>","Maximum minutes to wait for managed Maestro completion","60").option("--wait-interval <seconds>","Polling interval while waiting for managed Maestro completion","15").option("--json-output <path>","Write test run metadata JSON to a file for CI/CD").addOption(new Ne("--local-runner","Internal: execute a managed Maestro run on this machine").hideHelp()).addOption(new Ne("--test-run-id <id>","Internal test run ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--runner-token <token>","Internal runner token").hideHelp()).action(async e=>{Z(W.bgCyan.black(f.cliTag("Maestro Testing"))),await ds(e)});yg.command("devices").description("List device profiles available on the managed Maestro runner fleet").option("--platform <os>","Filter to android or ios").option("--json","Print machine-readable JSON").action(async e=>{await cs(e)});var zt=e=>e.option("--platform <os>","Target platform: ios, android, or all","all").option("--channel <name>","OTA channel (for example: production, staging)").option("--branch <name>","Alias for --channel").option("--runtime-version <version>","Runtime version override").option("--message <text>","Release note/message for this OTA update").option("--framework <name>","Framework override: expo or react-native").option("--engine <name>","OTA engine override (currently expo-updates)").option("--url <url>","Mach OTA update URL override").option("--install-plugin","Install @radhya/mach locally for the Expo config plugin").option("--skip-install","Do not install local Expo plugin dependency").option("--update-id <id>","OTA update id for rollback/promote").option("--json","Print JSON output"),Kt=M.command("ota").description("Setup, publish, verify, and manage Mach OTA updates");zt(Kt.command("setup").description("Configure OTA for this project")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Setup"))),await dt("setup",{...e,yes:e.yes||t.yes})});zt(Kt.command("publish").description("Publish an OTA update")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Publish"))),await dt("publish",{...e,yes:e.yes||t.yes})});zt(Kt.command("verify").description("Verify OTA configuration")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Verify"))),await dt("verify",{...e,yes:e.yes||t.yes})});zt(Kt.command("list").description("List OTA updates for the linked project")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Updates"))),await dt("list",{...e,yes:e.yes||t.yes})});zt(Kt.command("rollback").description("Roll back an OTA update")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Rollback"))),await dt("rollback",{...e,yes:e.yes||t.yes})});zt(Kt.command("promote").description("Promote an OTA update")).action(async e=>{let t=M.opts();Z(W.bgCyan.black(f.cliTag("OTA Promote"))),await dt("promote",{...e,yes:e.yes||t.yes})});M.command("submit").description("Automated Store Submission (App Store / Google Play)").option("--platform <os>","Target platform (ios/android)").option("-p, --profile <name>","Build/submission profile to submit from (e.g. production, preprod)").option("--track <track>","Google Play Track (internal, alpha, beta, production)").option("--release-status <status>","Google Play release status (completed, draft, halted, inProgress)").option("--rollout <fraction>","Google Play staged rollout fraction for inProgress releases (example: 0.1)").option("--changes-not-sent-for-review","Commit Google Play changes without automatically sending them for review").option("--ssh-host <host>","Remote macOS host for iOS submission").option("--ssh-user <user>","SSH username for remote iOS submission").option("--ssh-key <path>","Path to private SSH key for remote iOS submission").option("--credential-id <id>","Service credential ID to use when multiple submission credentials exist").option("--local","Run submission on this machine (internal runner mode for iOS)").addOption(new Ne("--submit-id <id>","Internal submission ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--package-name <name>","Internal Android package name").hideHelp()).addOption(new Ne("--bundle-id <id>","Internal iOS bundle identifier").hideHelp()).option("--json-output <path>","Write submission metadata JSON to a file for CI/CD").option("--latest","Use the latest successful build for submission").option("--build-id <id>","Use a specific build ID for submission").action(async e=>{let t=M.opts();e.quiet=e.quiet||t.quiet,e.yes=e.yes||t.yes,Z(W.bgCyan.black(f.cliTag("Store Submission"))),await qn(e)});M.command("login").description(`Login to ${f.name} Dashboard`).action(async()=>{Z(W.bgCyan.black(f.cliTag("Login"))),await xa()});M.command("logout").description(`Logout from ${f.name} on this machine`).action(async()=>{Z(W.bgCyan.black(f.cliTag("Logout"))),await La()});M.command("link").description(`Link local directory to a ${f.name} Project`).action(async()=>{Z(W.bgCyan.black(f.cliTag("Link Project"))),await Ua()});M.command("me").description("Display currently logged in user details").action(async()=>{await ll()});M.command("init").description(`Create a new ${f.name} Project`).action(async()=>{Z(W.bgCyan.black(f.cliTag("Init Project"))),await Fa()});M.command("env").description("Manage Environment Variables").argument("<action>","Action to perform: set, list, pull, download, or export").argument("[args...]","Key=Value pairs for set action").option("-e, --environment <name>","Environment to pull/download","development").option("-o, --out <file>","Output file for pull/download",".env.local").option("--overwrite","Overwrite output file if it already exists").action(async(e,t,n)=>{Z(W.bgCyan.black(f.cliTag("Env Manager"))),await ja(e,t,n)});M.command("start").description("Start the development server (Metro)").option("-p, --build-profile <name>","Build profile (e.g. development, staging)","development").option("--tunnel","Use ngrok tunnel").option("--lan","Use LAN IP").option("--localhost","Use localhost").option("-c, --clear","Clear Metro cache").option("--port <number>","Port to listen on").option("--ios","Start on iOS").option("--android","Start on Android").option("--web","Start on Web").action(async e=>{Z(W.bgCyan.black(f.cliTag("Dev Server"))),await cl(e)});var Nn=M.command("push").description("Configure and send provider-direct APNs/FCM notifications");Nn.command("setup").description("Install and wire a working default push experience").option("--name <name>","Push app display name").option("--ios-bundle <id>","iOS bundle identifier").option("--android-package <name>","Android package name").option("-e, --environment <name>","development, preview, or production").option("--google-services-file <path>","Android google-services.json path").option("--skip-install","Generate setup without installing SDK dependencies").action(No);Nn.command("init").description("Create only the server-side push app (advanced)").option("--name <name>","Push app display name").option("--ios-bundle <id>","iOS bundle identifier").option("--android-package <name>","Android package name").option("-e, --environment <name>","development, preview, or production","production").option("--google-services-file <path>","Expo Android google-services.json path").action(To);var Ad=Nn.command("credentials").description("Configure provider credentials");Ad.command("apns").description("Configure an Apple APNs .p8 authentication key").requiredOption("--file <path>","APNs .p8 file").requiredOption("--team-id <id>","Apple Developer team ID").requiredOption("--key-id <id>","APNs key ID").option("--bundle-id <id>","iOS bundle identifier").option("--app <id>","MACH Push app ID").option("-e, --environment <name>","development, preview, or production").action(e=>Hi("apns",e));Ad.command("fcm").description("Configure a Firebase service-account JSON file").requiredOption("--file <path>","Firebase service-account JSON").option("--app <id>","MACH Push app ID").option("-e, --environment <name>","Deprecated; accepted for compatibility because FCM credentials are package-wide").action(e=>Hi("fcm",e));Nn.command("send").description("Queue one transient push notification").requiredOption("--title <text>","Notification title").requiredOption("--body <text>","Notification body").option("--app <id>","MACH Push app ID").option("-e, --environment <name>","development, preview, or production").option("--token <token>","MACH push token; repeatable",Tn,[]).option("--user <id>","Application user ID; repeatable",Tn,[]).option("--all","Send to all active devices").option("--platform <platform>","Limit --all to ios or android").option("--data <json>","String-to-string custom data JSON").option("--sound <name>","Provider sound name").option("--badge <number>","iOS badge count").option("--ttl <seconds>","Provider time-to-live").option("--collapse-key <key>","Provider collapse key").option("--android-channel-id <id>","Android notification channel").action(ko);Nn.command("status").description("Show aggregate push delivery counters").option("--days <number>","Statistics range, 1-90","30").action(xo);M.command("config").description("Show resolved configuration for a profile").option("-p, --profile <name>","Build profile to resolve","development").option("--json","Output as JSON").action(async e=>{await ul(e)});var Sd=M.command("version").description("Show or seed DB-owned native version counters"),bd=e=>e.requiredOption("--platform <os>","Target platform: ios or android").option("-p, --profile <name>","Build profile used to resolve package/bundle scope","production").option("--scope <value>","Counter scope override, usually package name or bundle identifier").option("--package <name>","Android package override").option("--bundle-id <id>","iOS bundle identifier override").option("--json","Print JSON output");bd(Sd.command("show").description("Show the current native version counter")).action(async e=>{Z(W.bgCyan.black(f.cliTag("Version Counter"))),await ao("show",e)});bd(Sd.command("seed").description("Seed the native version counter for an existing app").argument("[value]","Latest already-used value; the next build uses value + 1").option("--value <number>","Latest already-used value; the next build uses value + 1").option("--force","Allow lowering an existing counter")).action(async(e,t)=>{Z(W.bgCyan.black(f.cliTag("Version Counter"))),await ao("seed",{...t,value:t.value??e})});var Id=M.command("deeplink").description("Configure and verify app links, universal links, and URI schemes");Id.command("setup").description("Generate deep link config, hosted association files, and Expo plugin support").option("--domain <domain>","Associated domain, e.g. app.example.com").option("--base-url <url>","Base URL, e.g. https://app.example.com").option("-p, --profile <name>","Profile used for build/submit overrides").option("--platform <platform>","ios, android, or all").option("--framework <framework>","expo or react-native").option("--scheme <scheme>","URI scheme, e.g. myapp").option("--ios-bundle-id <id>","iOS bundle identifier").option("--android-package <name>","Android package name").option("--apple-team-id <id>","Apple Developer Team ID").option("--app-store-id <id>","App Store app ID for Smart App Banner").option("--android-fingerprint <sha256>","Android SHA256 signing certificate fingerprint; repeatable",Tn,[]).option("--output <dir>","Directory for hosted files, e.g. public or deep-links").option("--install-plugin","Install @radhya/mach locally so Expo can use the packaged config plugin").option("--no-install-plugin","Do not install @radhya/mach for Expo projects; use the local plugin fallback if the package is missing").option("-y, --yes","Automatically answer yes to prompts",!1).action(async e=>{let t=M.opts();e.yes=e.yes||t.yes,Z(W.bgCyan.black(f.cliTag("Deep Links"))),await Nl(e)});Id.command("verify").description("Verify local and optionally live deep link configuration").option("-p, --profile <name>","Profile used for build/submit overrides").option("--live","Check hosted files over HTTPS").option("--android-device","Print Android device verification commands").action(async e=>{Z(W.bgCyan.black(f.cliTag("Deep Link Verify"))),await kl(e)});M.command("credentials").description("Unified, interactive credential management (iOS/Android)").option("-p, --profile <name>","Build profile (production, staging, development)").option("--credential-type <type>","iOS signing type override: development, adhoc, or store").option("--force","Force recreate certificates (nuke existing on Apple Portal)",!1).action(async e=>{let{credentialsMainCommand:t}=await import("./credentials-JDCLQSEX.js");await t(e)});M.command("credentials:setup").description("Automated credential provisioning (iOS/Android) [Legacy]").requiredOption("--platform <os>","Platform: ios or android").option("--profile <name>","Build profile (production, staging, development)").option("--credential-type <type>","iOS signing type override: development, adhoc, or store").option("--bundle-id <id>","Bundle ID / Package Name (optional, auto-detected)").option("--team-id <id>","Apple Team ID (iOS only)").option("--key-alias <alias>","Android keystore alias (optional, auto-generated)").option("--aws-profile <name>","AWS Credentials Profile (for S3 storage)").option("--force","Force recreate certificates (nuke existing on Apple Portal)",!1).action(async e=>{Z(W.bgCyan.black(f.cliTag("Credentials Setup"))),await Jt(e),yd(W.green("Done!"))});M.command("credentials:service").description("Upload Service Credentials (ASC API Key / Google Service JSON) [Legacy]").requiredOption("--platform <os>","Platform: ios or android").option("--file <path>","Path to credential file (.p8 or .json)").option("--issuer-id <id>","ASC API Key Issuer ID (iOS only)").option("--key-id <id>","ASC API Key ID (iOS only)").option("--bundle-id <id>","Bundle identifier / Android package name to attach this service credential to").option("--package-name <name>","Android package name to attach this service credential to").option("-p, --profile <name>","Build profile to resolve package/bundle identifier from config").action(async e=>{Z(W.bgCyan.black(f.cliTag("Service Credentials"))),await Co(e),yd(W.green("Done!"))});var po=M.command("device").description("Manage registered iOS test devices");po.command("register").description("Register a connected iOS device or enter UDID manually").option("--udid <udid>","Device UDID (skip auto-detection)").option("--name <name>","Device name").option("--team-id <id>","Apple Developer Team ID for this device").action(async e=>{await vi("register",e)});po.command("list").description("List all registered devices").option("--team-id <id>","Filter by Apple Developer Team ID").action(async e=>{await vi("list",e)});po.command("remove").description("Remove a registered device").option("--udid <udid>","Device UDID to remove").option("--team-id <id>","Apple Developer Team ID for this device").action(async e=>{await vi("remove",e)});M.command("audit").description("Run automated security audit on the project or APK").option("--apk <path>","Path to APK file (runs APK diagnostics like 16KB alignment)").option("--json","Output results as JSON (for CI/CD)").option("--fix","Auto-apply fixes where possible").option("--category <name>","Run only a specific check category (e.g. 16kb, permissions, secrets)").option("--severity <level>","Minimum severity to display (critical, high, medium, low, info)").option("--prebuild","Run expo prebuild for deeper manifest/plist analysis").action(async e=>{Z(W.bgCyan.black(f.cliTag(e.apk?"APK Audit":"Security Audit"))),await gd(e)});var Ag=new Set(["login","logout","agent"]),Sg=new Set(["build","credentials","credentials:service","credentials:setup","env","push","submit","version"]),bg=new Set(["publish","list","rollback","promote"]);function Ig(e){let t=[],n=e;for(;n&&n!==M;)t.unshift(n.name()),n=n.parent;return t}function Eg(e,t){let[n,i]=Ig(e);return Sg.has(n)?!0:n==="ota"?bg.has(i):n==="maestro"?i!=="devices"&&!t.local&&!t.localRunner:!1}M.hook("preAction",async(e,t)=>{let n=t.name(),i=t.opts?.()||{};if(n==="maestro"&&(i.local||i.localRunner)||t.parent?.name()==="deeplink"||Ag.has(n)||(_t(),!Eg(t,i)))return;let r=Lo(i,re());if(!r)throw new We(`No linked ${f.name} project was found. Run \`${f.nameLower} link\` before using this command.`);await Mo(r)});M.on("command:*",()=>{console.error(`Invalid command: %s
2134
2134
  See --help for a list of available commands.`,M.args.join(" ")),process.exit(1)});process.argv.slice(2).length||M.help();M.parseAsync(process.argv).catch(e=>{let t=e instanceof Error?e.message:String(e);console.error(W.red(t)),process.exitCode=1});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radhya/mach",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "Mach CLI: Cloud Build Orchestrator for React Native & Expo",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",