@radhya/mach 2.1.4 → 2.1.5

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{G as a,H as b,I as c}from"./chunk-LLUM6GHI.js";import"./chunk-S64YFTRR.js";export{a as credentialsMainCommand,b as credentialsSetupCommand,c as downloadCredentialsCommand};
1
+ import{G as a,H as b,I as c}from"./chunk-Y4SNUFBV.js";import"./chunk-S64YFTRR.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 et,B as So,C as Eo,D as Bi,E as Io,F as wo,H as jt,a as ft,b as fo,c as mo,d as Li,e as go,f as ho,g as Cn,h as Tn,i as kn,j as Mi,k as Ui,l as Nn,m as xn,n as yo,o as Fi,p as It,q as wt,r as $e,s as bo,t as mt,u as ce,v as Ie,w as Ln,x as Mn,y as vt,z as Ao}from"./chunk-LLUM6GHI.js";import{a as m,b as uo,c as be,d as po,e as Et,f as Qe,g as He,h as $}from"./chunk-S64YFTRR.js";import{Command as eg,Option as Te}from"commander";import{configDotenv as tg}from"dotenv";import{intro as X,outro as nd}from"@clack/prompts";import J from"chalk";import{text as vo,confirm as ad,spinner as ld,isCancel as ji,cancel as Ht,note as dd,outro as cd}from"@clack/prompts";import Gt from"chalk";async function _o(){try{let e=await vo({message:"Enter Bucket Name:",placeholder:"e.g. my-app-dev",validate(r){if(r.length===0)return"Bucket name is required"}});ji(e)&&(Ht("Operation cancelled."),process.exit(0));let t=await vo({message:"Enter Region:",initialValue:"ap-south-1"});ji(t)&&(Ht("Operation cancelled."),process.exit(0));let n=await ad({message:"Do you want to create a CloudFront Distribution for this bucket?",initialValue:!0});ji(n)&&(Ht("Operation cancelled."),process.exit(0));let i=ld();i.start("Setting up hosting infrastructure...");try{let r=await $.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: ${Gt.cyan(o.bucketName)}
2
+ import{A as et,B as So,C as Eo,D as Bi,E as Io,F as wo,H as jt,a as ft,b as fo,c as mo,d as Li,e as go,f as ho,g as Cn,h as Tn,i as kn,j as Mi,k as Ui,l as Nn,m as xn,n as yo,o as Fi,p as It,q as wt,r as $e,s as bo,t as mt,u as ce,v as Ie,w as Ln,x as Mn,y as vt,z as Ao}from"./chunk-Y4SNUFBV.js";import{a as m,b as uo,c as be,d as po,e as Et,f as Qe,g as He,h as $}from"./chunk-S64YFTRR.js";import{Command as eg,Option as Te}from"commander";import{configDotenv as tg}from"dotenv";import{intro as X,outro as nd}from"@clack/prompts";import J from"chalk";import{text as vo,confirm as ad,spinner as ld,isCancel as ji,cancel as Ht,note as dd,outro as cd}from"@clack/prompts";import Gt from"chalk";async function _o(){try{let e=await vo({message:"Enter Bucket Name:",placeholder:"e.g. my-app-dev",validate(r){if(r.length===0)return"Bucket name is required"}});ji(e)&&(Ht("Operation cancelled."),process.exit(0));let t=await vo({message:"Enter Region:",initialValue:"ap-south-1"});ji(t)&&(Ht("Operation cancelled."),process.exit(0));let n=await ad({message:"Do you want to create a CloudFront Distribution for this bucket?",initialValue:!0});ji(n)&&(Ht("Operation cancelled."),process.exit(0));let i=ld();i.start("Setting up hosting infrastructure...");try{let r=await $.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: ${Gt.cyan(o.bucketName)}
3
3
  `;s+=`Region: ${Gt.cyan(o.region)}
4
4
  `,s+=`S3 Website URL: ${Gt.blue(o.s3WebsiteUrl)}`,o.cloudFrontId&&(s+=`
5
5
 
@@ -1766,5 +1766,5 @@ module.exports = function withMachDeepLinks(config) {
1766
1766
  Running expo prebuild for deeper analysis...`));try{Fm("npx expo prebuild --no-install",{cwd:e,stdio:"pipe"})}catch{return $n.warn(_e.yellow("Prebuild failed \u2014 skipping manifest/plist checks.")),o}}else if(!l)return t.json||$n.info(_e.dim(`
1767
1767
  Skipping manifest/plist checks \u2014 no android/ios dirs. Use --prebuild to generate them.`)),o;for(let d of r){let c=Gl();c.start(_e.dim(`Running ${d.label}...`));try{let u=Date.now(),f=await d.fn(e,t);f.durationMs=Date.now()-u,o.push(f);let p=f.findings.length;c.stop(p>0?_e.yellow(`${d.label} \u2014 ${p} 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 fe from"chalk";import{log as le}from"@clack/prompts";var Mt={critical:fe.bgRed.white.bold,high:fe.red.bold,medium:fe.yellow.bold,low:fe.blue,info:fe.dim},Ci={critical:0,high:1,medium:2,low:3,info:4};function jm(e,t){if(!t)return!0;let n=Ci[t];return n===void 0?!0:Ci[e]<=n}function Wl(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=>jm(d.severity,t));if(a.length===0&&!s.error)continue;if(le.info(""),le.info(fe.bold(` ${s.label}`)+fe.dim(` ${a.length} finding(s)`)),le.info(fe.dim(" "+"\u2500".repeat(60))),s.error){le.error(fe.red(` Error: ${s.error}`));continue}let l=[...a].sort((d,c)=>Ci[d.severity]-Ci[c.severity]);for(let d of l){let c=Mt[d.severity](` ${d.severity.toUpperCase()} `);le.info(` ${c} ${fe.bold(d.id)} ${d.title}`),le.info(fe.dim(` ${d.description}`)),d.file&&le.info(fe.dim(` File: ${d.file}${d.line?`:${d.line}`:""}`)),le.info(fe.cyan(` Fix: ${d.recommendation}`)),le.info(""),i[d.severity]++,n++}}le.info(""),le.info(fe.bold(" Summary")),le.info(fe.dim(" "+"\u2500".repeat(60))),le.info(` Total: ${fe.bold(String(n))} finding(s)`),le.info(` ${Mt.critical(` ${i.critical} Critical `)} ${Mt.high(` ${i.high} High `)} ${Mt.medium(` ${i.medium} Medium `)} ${Mt.low(` ${i.low} Low `)} ${Mt.info(` ${i.info} Info `)}`);let r=i.critical>0,o=i.high>0;r||o?(le.info(""),le.error(fe.red.bold(` FAIL \u2014 ${i.critical} critical, ${i.high} high issue(s) found`))):n>0?(le.info(""),le.warn(fe.yellow(" PASS (with warnings) \u2014 no critical or high issues"))):(le.info(""),le.success(fe.green.bold(" PASS \u2014 no issues found")))}function ql(e,t){let n=e.flatMap(r=>r.findings),i={};for(let r of Object.values(Pe))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 de,spinner as Hm}from"@clack/prompts";import ie from"chalk";import Ze from"fs";import Gm from"os";import Ut from"path";import{execSync as Vm}from"child_process";var Jl=16384,zm=1,Km=Buffer.from([127,69,76,70]);async function Yl(e){de.info(ie.bold.underline("16KB Page Alignment Check")),console.log("");let t=Ut.resolve(e);if(!Ze.existsSync(t))return de.error(ie.red(`APK file not found: ${t}`)),!1;if(!t.endsWith(".apk"))return de.error(ie.red("The provided file is not an APK file.")),!1;let n=Hm();n.start("Extracting and analyzing native libraries...");let i=Ze.mkdtempSync(Ut.join(Gm.tmpdir(),"mach-16kb-"));try{try{Vm(`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=Xl(Ut.join(i,"lib"));if(r.length===0)return n.stop("Analysis complete."),de.info(ie.yellow("No arm64-v8a or x86_64 native libraries found in the APK.")),de.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=Ut.relative(i,l),c=qm(d),u=Ut.basename(l),f=Wm(l);f!==null&&o.push({name:u,filePath:d,arch:c,align:f,compatible:f>=Jl})}if(n.stop("Analysis complete."),o.length===0)return de.info(ie.yellow("No valid ELF shared libraries found.")),!0;let s=o.filter(l=>!l.compatible),a=o.filter(l=>l.compatible);if(de.info(ie.dim(`Checked ${o.length} native librar${o.length===1?"y":"ies"}
1768
1768
  `)),s.length>0){de.info(ie.red.bold(`Incompatible libraries:
1769
- `));for(let l of s)de.error(ie.red(`${ie.bold(l.name)} ${ie.dim(`(${l.arch})`)}`)),de.info(ie.dim(` PT_LOAD alignment: 2**${Math.log2(l.align)} (${l.align} bytes, needs 2**14 = ${Jl})`))}return a.length>0&&(console.log(""),de.success(ie.green(`${a.length} librar${a.length===1?"y":"ies"} correctly aligned (2**14 or higher).`))),console.log(""),s.length===0?(de.success(ie.green.bold("ELF Verification Successful. APK is 16KB compatible.")),!0):(de.error(ie.red.bold(`Found ${s.length} unaligned lib${s.length===1?"":"s"} (arm64-v8a/x86_64 libs need to be aligned).`)),console.log(""),de.info(ie.yellow("To fix this:")),de.info(ie.dim(" 1. Rebuild with NDK r28+ which defaults to 16KB page alignment")),de.info(ie.dim(" 2. Or set -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON in CMake")),de.info(ie.dim(" 3. Update third-party libraries that ship prebuilt .so files")),de.info(ie.dim(" 4. After rebuilding: zipalign -p -f -v 16 input.apk output.apk")),console.log(""),de.info(ie.dim("Reference: https://developer.android.com/guide/practices/page-sizes")),!1)}catch(r){return n.stop("Analysis failed."),de.error(ie.red(`Failed to analyze APK: ${r.message}`)),!1}finally{try{Ze.rmSync(i,{recursive:!0,force:!0})}catch{}}}function Wm(e){let t=Ze.openSync(e,"r");try{let n=Buffer.alloc(64);if(Ze.readSync(t,n,0,64,0),!n.subarray(0,4).equals(Km))return null;let i=n[4]===2,r=n[5]===1,o=(f,p)=>r?f.readUInt16LE(p):f.readUInt16BE(p),s=(f,p)=>r?f.readUInt32LE(p):f.readUInt32BE(p),a=(f,p)=>Number(r?f.readBigUInt64LE(p):f.readBigUInt64BE(p)),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 f=0;f<c;f++){let p=Buffer.alloc(d);if(Ze.readSync(t,p,0,d,l+f*d),s(p,0)!==zm)continue;let h;i?h=a(p,48):h=s(p,28),h>0&&(u===null||h<u)&&(u=h)}return u??0}catch{return null}finally{Ze.closeSync(t)}}function Xl(e){let t=[];if(!Ze.existsSync(e))return t;let n=Ze.readdirSync(e,{withFileTypes:!0});for(let i of n){let r=Ut.join(e,i.name);i.isDirectory()?t.push(...Xl(r)):i.name.endsWith(".so")&&t.push(r)}return t}function qm(e){return e.includes("arm64-v8a")?"arm64-v8a":e.includes("x86_64")?"x86_64":"unknown"}var ed=async e=>{if(be()||(Ce.error(Be.red(`You are not logged in. Run \`${m.nameLower} login\` first.`)),process.exit(1)),e.apk){await Xm(e);return}let n=process.cwd(),i=Ti.join(n,"package.json");Rn.existsSync(i)||(Ce.error(Be.red("No package.json found. Run this command from a project root.")),process.exit(1));let r=JSON.parse(Rn.readFileSync(i,"utf-8")),o=!!(r.dependencies?.expo||r.devDependencies?.expo);e.json||(Ce.info(Be.dim(`Project: ${r.name||"unknown"} v${r.version||"0.0.0"}`)),Ce.info(Be.dim(`Type: ${o?"Expo":"Bare React Native"}`)),Ce.info(""));let s={json:e.json,fix:e.fix,category:e.category,severity:e.severity,prebuild:e.prebuild},a=await Kl(n,s);e.json?console.log(JSON.stringify(ql(a,r),null,2)):Wl(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)},Zl=["16kb"];async function Xm(e){let t=e.category?.toLowerCase();t&&!Zl.includes(t)&&(Ce.error(Be.red(`Unknown APK check category: "${t}"`)),Ce.info(Be.dim(`Available APK checks: ${Zl.join(", ")}`)),process.exit(1));let n=await Zm(e.apk);n||process.exit(1);let i=!t,r=!1;(i||t==="16kb")&&(await Yl(n)||(r=!0)),r&&process.exit(1)}async function Zm(e){if(e.startsWith("build:")){let n=e.slice(6);return await Qm(n)}if(e.startsWith("http://")||e.startsWith("https://"))return await td(e);let t=Ti.resolve(e);return Rn.existsSync(t)?t:(Ce.error(Be.red(`APK file not found: ${t}`)),null)}async function Qm(e){let t=Ql();t.start(`Fetching APK from build ${e}...`);try{let n=await $.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"),Ce.error(Be.red("This build does not have an APK artifact.")),Ce.info(Be.dim("Make sure the build produced an APK (not just an AAB).")),null):(t.stop(`Found build: ${i.buildId||e}`),await td(r.url))}catch(n){return t.stop("Failed to fetch build"),Ce.error(Be.red(n.message)),null}}async function td(e){let t=Ql();t.start("Downloading APK...");try{let n=Rn.mkdtempSync(Ti.join(Jm.tmpdir(),`${m.nameLower}-audit-`)),i=Ti.join(n,"app.apk"),r=await Ym.get(e,{responseType:"arraybuffer"});Rn.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"),Ce.error(Be.red(`Failed to download APK: ${n.message}`)),null}}var ng=console.log;console.log=()=>{};tg();console.log=ng;X(J.bgCyan.black(m.cliTag("Production Build Orchestrator")));var On=(e,t=[])=>t.concat(e),M=new eg;M.name(m.nameLower).description(`${m.name} CLI: Powerful Cloud Infrastructure Tools`).version(et).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 ha(e)});M.command("host").description("Setup AWS S3 static hosting and CloudFront").action(async()=>{X(J.bgCyan.black(m.cliTag("Hosting"))),await _o()});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=>{X(J.bgCyan.black(m.cliTag("Sitemap Generator"))),await Do(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 Te("--build-id <id>","Internal build ID").hideHelp()).addOption(new Te("--project-id <id>","Internal project ID").hideHelp()).addOption(new Te("--fail-only","Internal: mark an existing build failed").hideHelp()).addOption(new Te("--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>","iOS simulator model or identifier (default: iPhone 17 Pro; managed Android uses Pixel 6)").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",On,[]).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||X(J.bgCyan.black(m.cliTag("Cloud Build"))),await Jn(t)});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>","iOS simulator model or identifier (default: iPhone 17 Pro; managed Android uses Pixel 6)").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",On,[]).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 Te("--local-runner","Internal: execute a managed Maestro run on this machine").hideHelp()).addOption(new Te("--test-run-id <id>","Internal test run ID").hideHelp()).addOption(new Te("--project-id <id>","Internal project ID").hideHelp()).addOption(new Te("--runner-token <token>","Internal runner token").hideHelp()).action(async e=>{X(J.bgCyan.black(m.cliTag("Maestro Testing"))),await Qo(e)});var Ft=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"),Bt=M.command("ota").description("Setup, publish, verify, and manage Mach OTA updates");Ft(Bt.command("setup").description("Configure OTA for this project")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Setup"))),await at("setup",{...e,yes:e.yes||t.yes})});Ft(Bt.command("publish").description("Publish an OTA update")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Publish"))),await at("publish",{...e,yes:e.yes||t.yes})});Ft(Bt.command("verify").description("Verify OTA configuration")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Verify"))),await at("verify",{...e,yes:e.yes||t.yes})});Ft(Bt.command("list").description("List OTA updates for the linked project")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Updates"))),await at("list",{...e,yes:e.yes||t.yes})});Ft(Bt.command("rollback").description("Roll back an OTA update")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Rollback"))),await at("rollback",{...e,yes:e.yes||t.yes})});Ft(Bt.command("promote").description("Promote an OTA update")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Promote"))),await at("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 Te("--submit-id <id>","Internal submission ID").hideHelp()).addOption(new Te("--project-id <id>","Internal project ID").hideHelp()).addOption(new Te("--package-name <name>","Internal Android package name").hideHelp()).addOption(new Te("--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,X(J.bgCyan.black(m.cliTag("Store Submission"))),await Vn(e)});M.command("login").description(`Login to ${m.name} Dashboard`).action(async()=>{X(J.bgCyan.black(m.cliTag("Login"))),await Sa()});M.command("logout").description(`Logout from ${m.name} on this machine`).action(async()=>{X(J.bgCyan.black(m.cliTag("Logout"))),await Ea()});M.command("link").description(`Link local directory to a ${m.name} Project`).action(async()=>{X(J.bgCyan.black(m.cliTag("Link Project"))),await wa()});M.command("me").description("Display currently logged in user details").action(async()=>{await Wa()});M.command("init").description(`Create a new ${m.name} Project`).action(async()=>{X(J.bgCyan.black(m.cliTag("Init Project"))),await va()});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)=>{X(J.bgCyan.black(m.cliTag("Env Manager"))),await $a(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=>{X(J.bgCyan.black(m.cliTag("Dev Server"))),await Ja(e)});var Dn=M.command("push").description("Configure and send provider-direct APNs/FCM notifications");Dn.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(Eo);Dn.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(So);var id=Dn.command("credentials").description("Configure provider credentials");id.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=>Bi("apns",e));id.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=>Bi("fcm",e));Dn.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",On,[]).option("--user <id>","Application user ID; repeatable",On,[]).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(Io);Dn.command("status").description("Show aggregate push delivery counters").option("--days <number>","Statistics range, 1-90","30").action(wo);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 Ya(e)});var rd=M.command("version").description("Show or seed DB-owned native version counters"),od=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");od(rd.command("show").description("Show the current native version counter")).action(async e=>{X(J.bgCyan.black(m.cliTag("Version Counter"))),await no("show",e)});od(rd.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)=>{X(J.bgCyan.black(m.cliTag("Version Counter"))),await no("seed",{...t,value:t.value??e})});var sd=M.command("deeplink").description("Configure and verify app links, universal links, and URI schemes");sd.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",On,[]).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,X(J.bgCyan.black(m.cliTag("Deep Links"))),await bl(e)});sd.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=>{X(J.bgCyan.black(m.cliTag("Deep Link Verify"))),await Al(e)});M.command("credentials").description("Unified, interactive credential management (iOS/Android)").option("-p, --profile <name>","Build profile (production, staging, development)").option("--force","Force recreate certificates (nuke existing on Apple Portal)",!1).action(async e=>{let{credentialsMainCommand:t}=await import("./credentials-MVI46MHG.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("--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=>{X(J.bgCyan.black(m.cliTag("Credentials Setup"))),await jt(e),nd(J.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=>{X(J.bgCyan.black(m.cliTag("Service Credentials"))),await Ao(e),nd(J.green("Done!"))});var so=M.command("device").description("Manage registered iOS test devices");so.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 Ii("register",e)});so.command("list").description("List all registered devices").option("--team-id <id>","Filter by Apple Developer Team ID").action(async e=>{await Ii("list",e)});so.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 Ii("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=>{X(J.bgCyan.black(m.cliTag(e.apk?"APK Audit":"Security Audit"))),await ed(e)});var ig=new Set(["login","logout","agent"]);M.hook("preAction",(e,t)=>{let n=t.name(),i=t.opts?.()||{};n==="maestro"&&(i.local||i.localRunner)||t.parent?.name()!=="deeplink"&&(ig.has(n)||Et())});M.on("command:*",()=>{console.error(`Invalid command: %s
1769
+ `));for(let l of s)de.error(ie.red(`${ie.bold(l.name)} ${ie.dim(`(${l.arch})`)}`)),de.info(ie.dim(` PT_LOAD alignment: 2**${Math.log2(l.align)} (${l.align} bytes, needs 2**14 = ${Jl})`))}return a.length>0&&(console.log(""),de.success(ie.green(`${a.length} librar${a.length===1?"y":"ies"} correctly aligned (2**14 or higher).`))),console.log(""),s.length===0?(de.success(ie.green.bold("ELF Verification Successful. APK is 16KB compatible.")),!0):(de.error(ie.red.bold(`Found ${s.length} unaligned lib${s.length===1?"":"s"} (arm64-v8a/x86_64 libs need to be aligned).`)),console.log(""),de.info(ie.yellow("To fix this:")),de.info(ie.dim(" 1. Rebuild with NDK r28+ which defaults to 16KB page alignment")),de.info(ie.dim(" 2. Or set -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON in CMake")),de.info(ie.dim(" 3. Update third-party libraries that ship prebuilt .so files")),de.info(ie.dim(" 4. After rebuilding: zipalign -p -f -v 16 input.apk output.apk")),console.log(""),de.info(ie.dim("Reference: https://developer.android.com/guide/practices/page-sizes")),!1)}catch(r){return n.stop("Analysis failed."),de.error(ie.red(`Failed to analyze APK: ${r.message}`)),!1}finally{try{Ze.rmSync(i,{recursive:!0,force:!0})}catch{}}}function Wm(e){let t=Ze.openSync(e,"r");try{let n=Buffer.alloc(64);if(Ze.readSync(t,n,0,64,0),!n.subarray(0,4).equals(Km))return null;let i=n[4]===2,r=n[5]===1,o=(f,p)=>r?f.readUInt16LE(p):f.readUInt16BE(p),s=(f,p)=>r?f.readUInt32LE(p):f.readUInt32BE(p),a=(f,p)=>Number(r?f.readBigUInt64LE(p):f.readBigUInt64BE(p)),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 f=0;f<c;f++){let p=Buffer.alloc(d);if(Ze.readSync(t,p,0,d,l+f*d),s(p,0)!==zm)continue;let h;i?h=a(p,48):h=s(p,28),h>0&&(u===null||h<u)&&(u=h)}return u??0}catch{return null}finally{Ze.closeSync(t)}}function Xl(e){let t=[];if(!Ze.existsSync(e))return t;let n=Ze.readdirSync(e,{withFileTypes:!0});for(let i of n){let r=Ut.join(e,i.name);i.isDirectory()?t.push(...Xl(r)):i.name.endsWith(".so")&&t.push(r)}return t}function qm(e){return e.includes("arm64-v8a")?"arm64-v8a":e.includes("x86_64")?"x86_64":"unknown"}var ed=async e=>{if(be()||(Ce.error(Be.red(`You are not logged in. Run \`${m.nameLower} login\` first.`)),process.exit(1)),e.apk){await Xm(e);return}let n=process.cwd(),i=Ti.join(n,"package.json");Rn.existsSync(i)||(Ce.error(Be.red("No package.json found. Run this command from a project root.")),process.exit(1));let r=JSON.parse(Rn.readFileSync(i,"utf-8")),o=!!(r.dependencies?.expo||r.devDependencies?.expo);e.json||(Ce.info(Be.dim(`Project: ${r.name||"unknown"} v${r.version||"0.0.0"}`)),Ce.info(Be.dim(`Type: ${o?"Expo":"Bare React Native"}`)),Ce.info(""));let s={json:e.json,fix:e.fix,category:e.category,severity:e.severity,prebuild:e.prebuild},a=await Kl(n,s);e.json?console.log(JSON.stringify(ql(a,r),null,2)):Wl(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)},Zl=["16kb"];async function Xm(e){let t=e.category?.toLowerCase();t&&!Zl.includes(t)&&(Ce.error(Be.red(`Unknown APK check category: "${t}"`)),Ce.info(Be.dim(`Available APK checks: ${Zl.join(", ")}`)),process.exit(1));let n=await Zm(e.apk);n||process.exit(1);let i=!t,r=!1;(i||t==="16kb")&&(await Yl(n)||(r=!0)),r&&process.exit(1)}async function Zm(e){if(e.startsWith("build:")){let n=e.slice(6);return await Qm(n)}if(e.startsWith("http://")||e.startsWith("https://"))return await td(e);let t=Ti.resolve(e);return Rn.existsSync(t)?t:(Ce.error(Be.red(`APK file not found: ${t}`)),null)}async function Qm(e){let t=Ql();t.start(`Fetching APK from build ${e}...`);try{let n=await $.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"),Ce.error(Be.red("This build does not have an APK artifact.")),Ce.info(Be.dim("Make sure the build produced an APK (not just an AAB).")),null):(t.stop(`Found build: ${i.buildId||e}`),await td(r.url))}catch(n){return t.stop("Failed to fetch build"),Ce.error(Be.red(n.message)),null}}async function td(e){let t=Ql();t.start("Downloading APK...");try{let n=Rn.mkdtempSync(Ti.join(Jm.tmpdir(),`${m.nameLower}-audit-`)),i=Ti.join(n,"app.apk"),r=await Ym.get(e,{responseType:"arraybuffer"});Rn.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"),Ce.error(Be.red(`Failed to download APK: ${n.message}`)),null}}var ng=console.log;console.log=()=>{};tg();console.log=ng;X(J.bgCyan.black(m.cliTag("Production Build Orchestrator")));var On=(e,t=[])=>t.concat(e),M=new eg;M.name(m.nameLower).description(`${m.name} CLI: Powerful Cloud Infrastructure Tools`).version(et).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 ha(e)});M.command("host").description("Setup AWS S3 static hosting and CloudFront").action(async()=>{X(J.bgCyan.black(m.cliTag("Hosting"))),await _o()});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=>{X(J.bgCyan.black(m.cliTag("Sitemap Generator"))),await Do(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 Te("--build-id <id>","Internal build ID").hideHelp()).addOption(new Te("--project-id <id>","Internal project ID").hideHelp()).addOption(new Te("--fail-only","Internal: mark an existing build failed").hideHelp()).addOption(new Te("--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>","iOS simulator model or identifier (default: iPhone 17 Pro; managed Android uses Pixel 6)").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",On,[]).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||X(J.bgCyan.black(m.cliTag("Cloud Build"))),await Jn(t)});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>","iOS simulator model or identifier (default: iPhone 17 Pro; managed Android uses Pixel 6)").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",On,[]).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 Te("--local-runner","Internal: execute a managed Maestro run on this machine").hideHelp()).addOption(new Te("--test-run-id <id>","Internal test run ID").hideHelp()).addOption(new Te("--project-id <id>","Internal project ID").hideHelp()).addOption(new Te("--runner-token <token>","Internal runner token").hideHelp()).action(async e=>{X(J.bgCyan.black(m.cliTag("Maestro Testing"))),await Qo(e)});var Ft=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"),Bt=M.command("ota").description("Setup, publish, verify, and manage Mach OTA updates");Ft(Bt.command("setup").description("Configure OTA for this project")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Setup"))),await at("setup",{...e,yes:e.yes||t.yes})});Ft(Bt.command("publish").description("Publish an OTA update")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Publish"))),await at("publish",{...e,yes:e.yes||t.yes})});Ft(Bt.command("verify").description("Verify OTA configuration")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Verify"))),await at("verify",{...e,yes:e.yes||t.yes})});Ft(Bt.command("list").description("List OTA updates for the linked project")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Updates"))),await at("list",{...e,yes:e.yes||t.yes})});Ft(Bt.command("rollback").description("Roll back an OTA update")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Rollback"))),await at("rollback",{...e,yes:e.yes||t.yes})});Ft(Bt.command("promote").description("Promote an OTA update")).action(async e=>{let t=M.opts();X(J.bgCyan.black(m.cliTag("OTA Promote"))),await at("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 Te("--submit-id <id>","Internal submission ID").hideHelp()).addOption(new Te("--project-id <id>","Internal project ID").hideHelp()).addOption(new Te("--package-name <name>","Internal Android package name").hideHelp()).addOption(new Te("--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,X(J.bgCyan.black(m.cliTag("Store Submission"))),await Vn(e)});M.command("login").description(`Login to ${m.name} Dashboard`).action(async()=>{X(J.bgCyan.black(m.cliTag("Login"))),await Sa()});M.command("logout").description(`Logout from ${m.name} on this machine`).action(async()=>{X(J.bgCyan.black(m.cliTag("Logout"))),await Ea()});M.command("link").description(`Link local directory to a ${m.name} Project`).action(async()=>{X(J.bgCyan.black(m.cliTag("Link Project"))),await wa()});M.command("me").description("Display currently logged in user details").action(async()=>{await Wa()});M.command("init").description(`Create a new ${m.name} Project`).action(async()=>{X(J.bgCyan.black(m.cliTag("Init Project"))),await va()});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)=>{X(J.bgCyan.black(m.cliTag("Env Manager"))),await $a(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=>{X(J.bgCyan.black(m.cliTag("Dev Server"))),await Ja(e)});var Dn=M.command("push").description("Configure and send provider-direct APNs/FCM notifications");Dn.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(Eo);Dn.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(So);var id=Dn.command("credentials").description("Configure provider credentials");id.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=>Bi("apns",e));id.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=>Bi("fcm",e));Dn.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",On,[]).option("--user <id>","Application user ID; repeatable",On,[]).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(Io);Dn.command("status").description("Show aggregate push delivery counters").option("--days <number>","Statistics range, 1-90","30").action(wo);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 Ya(e)});var rd=M.command("version").description("Show or seed DB-owned native version counters"),od=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");od(rd.command("show").description("Show the current native version counter")).action(async e=>{X(J.bgCyan.black(m.cliTag("Version Counter"))),await no("show",e)});od(rd.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)=>{X(J.bgCyan.black(m.cliTag("Version Counter"))),await no("seed",{...t,value:t.value??e})});var sd=M.command("deeplink").description("Configure and verify app links, universal links, and URI schemes");sd.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",On,[]).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,X(J.bgCyan.black(m.cliTag("Deep Links"))),await bl(e)});sd.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=>{X(J.bgCyan.black(m.cliTag("Deep Link Verify"))),await Al(e)});M.command("credentials").description("Unified, interactive credential management (iOS/Android)").option("-p, --profile <name>","Build profile (production, staging, development)").option("--force","Force recreate certificates (nuke existing on Apple Portal)",!1).action(async e=>{let{credentialsMainCommand:t}=await import("./credentials-MUSYHFWP.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("--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=>{X(J.bgCyan.black(m.cliTag("Credentials Setup"))),await jt(e),nd(J.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=>{X(J.bgCyan.black(m.cliTag("Service Credentials"))),await Ao(e),nd(J.green("Done!"))});var so=M.command("device").description("Manage registered iOS test devices");so.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 Ii("register",e)});so.command("list").description("List all registered devices").option("--team-id <id>","Filter by Apple Developer Team ID").action(async e=>{await Ii("list",e)});so.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 Ii("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=>{X(J.bgCyan.black(m.cliTag(e.apk?"APK Audit":"Security Audit"))),await ed(e)});var ig=new Set(["login","logout","agent"]);M.hook("preAction",(e,t)=>{let n=t.name(),i=t.opts?.()||{};n==="maestro"&&(i.local||i.localRunner)||t.parent?.name()!=="deeplink"&&(ig.has(n)||Et())});M.on("command:*",()=>{console.error(`Invalid command: %s
1770
1770
  See --help for a list of available commands.`,M.args.join(" ")),process.exit(1)});process.argv.slice(2).length||M.help();M.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radhya/mach",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "Mach CLI: Cloud Build Orchestrator for React Native & Expo",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",