@radhya/mach 2.3.6 → 2.4.0
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{R as a,S as b,T as c}from"./chunk-
|
|
1
|
+
import{R as a,S as b,T as c}from"./chunk-HOVFLQ4Y.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 Eo,C as _o,D as wo,E as Yt,F as qt,G as $o,H as vo,I as ji,J as $t,K as Ro,L as nt,M as Oo,N as Po,O as Hi,P as Do,Q as Co,S as Jt,a as Ln,b as ve,c as mo,d as gt,e as re,f as _e,g as Mn,h as Un,i as wt,j as ht,k as go,l as ho,m as Mi,n as Ao,o as yo,p as Fn,q as Bn,r as jn,s as Ui,t as Fi,u as Hn,v as Gn,w as So,x as bo,y as Io,z as Bi}from"./chunk-
|
|
2
|
+
import{A as Wt,B as Eo,C as _o,D as wo,E as Yt,F as qt,G as $o,H as vo,I as ji,J as $t,K as Ro,L as nt,M as Oo,N as Po,O as Hi,P as Do,Q as Co,S as Jt,a as Ln,b as ve,c as mo,d as gt,e as re,f as _e,g as Mn,h as Un,i as wt,j as ht,k as go,l as ho,m as Mi,n as Ao,o as yo,p as Fn,q as Bn,r as jn,s as Ui,t as Fi,u as Hn,v as Gn,w as So,x as bo,y as Io,z as Bi}from"./chunk-HOVFLQ4Y.js";import{a as m,b as po,c as ye,d as fo,e as _t,f as tt,g as He,h as w}from"./chunk-LO6DP2SE.js";import{Command as ag,Option as ke}from"commander";import{configDotenv as lg}from"dotenv";import{intro as X,outro as pd}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 To(e,t){return Gi(e?.projectId)||Gi(t?.projectId)}function Ad(e,t){if(Array.isArray(e))return e.find(n=>Gi(n?.projectId)===t)}function yd(e,t){let n=Ad(e,t);if(n)return n;throw new We(`The current ${m.name} account does not have access to the linked project (${t}).
|
|
3
3
|
Run \`${m.nameLower} logout\`, then \`${m.nameLower} login\` with a project member, or run \`${m.nameLower} link\` to select an accessible project.`)}async function ko(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 \`${m.nameLower} login\` again.`);return yd(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 ${m.name} session is no longer valid. Run \`${m.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 No,confirm as Sd,spinner as bd,isCancel as Vi,cancel as Xt,note as Id,outro as Ed}from"@clack/prompts";import Zt from"chalk";async function xo(){try{let e=await No({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 No({message:"Enter Region:",initialValue:"ap-south-1"});Vi(t)&&(Xt("Operation cancelled."),process.exit(0));let n=await Sd({message:"Do you want to create a CloudFront Distribution for this bucket?",initialValue:!0});Vi(n)&&(Xt("Operation cancelled."),process.exit(0));let i=bd();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+=`
|
|
@@ -2059,5 +2059,5 @@ module.exports = function withMachDeepLinks(config) {
|
|
|
2059
2059
|
Running expo prebuild for deeper analysis...`));try{Km("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(`
|
|
2060
2060
|
Skipping manifest/plist checks \u2014 no android/ios dirs. Use --prebuild to generate them.`)),o;for(let d of r){let c=Ql();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 ue from"chalk";import{log as ae}from"@clack/prompts";var Gt={critical:ue.bgRed.white.bold,high:ue.red.bold,medium:ue.yellow.bold,low:ue.blue,info:ue.dim},xi={critical:0,high:1,medium:2,low:3,info:4};function Ym(e,t){if(!t)return!0;let n=xi[t];return n===void 0?!0:xi[e]<=n}function id(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=>Ym(d.severity,t));if(a.length===0&&!s.error)continue;if(ae.info(""),ae.info(ue.bold(` ${s.label}`)+ue.dim(` ${a.length} finding(s)`)),ae.info(ue.dim(" "+"\u2500".repeat(60))),s.error){ae.error(ue.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} ${ue.bold(d.id)} ${d.title}`),ae.info(ue.dim(` ${d.description}`)),d.file&&ae.info(ue.dim(` File: ${d.file}${d.line?`:${d.line}`:""}`)),ae.info(ue.cyan(` Fix: ${d.recommendation}`)),ae.info(""),i[d.severity]++,n++}}ae.info(""),ae.info(ue.bold(" Summary")),ae.info(ue.dim(" "+"\u2500".repeat(60))),ae.info(` Total: ${ue.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(ue.red.bold(` FAIL \u2014 ${i.critical} critical, ${i.high} high issue(s) found`))):n>0?(ae.info(""),ae.warn(ue.yellow(" PASS (with warnings) \u2014 no critical or high issues"))):(ae.info(""),ae.success(ue.green.bold(" PASS \u2014 no issues found")))}function rd(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 qm}from"@clack/prompts";import ie from"chalk";import et from"fs";import Jm from"os";import Vt from"path";import{execSync as Xm}from"child_process";var od=16384,Zm=1,Qm=Buffer.from([127,69,76,70]);async function sd(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=qm();n.start("Extracting and analyzing native libraries...");let i=et.mkdtempSync(Vt.join(Jm.tmpdir(),"mach-16kb-"));try{try{Xm(`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=ad(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=tg(d),u=Vt.basename(l),f=eg(l);f!==null&&o.push({name:u,filePath:d,arch:c,align:f,compatible:f>=od})}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"}
|
|
2061
2061
|
`)),s.length>0){le.info(ie.red.bold(`Incompatible libraries:
|
|
2062
|
-
`));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 = ${od})`))}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 eg(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(Qm))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(et.readSync(t,p,0,d,l+f*d),s(p,0)!==Zm)continue;let g;i?g=a(p,48):g=s(p,28),g>0&&(u===null||g<u)&&(u=g)}return u??0}catch{return null}finally{et.closeSync(t)}}function ad(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(...ad(r)):i.name.endsWith(".so")&&t.push(r)}return t}function tg(e){return e.includes("arm64-v8a")?"arm64-v8a":e.includes("x86_64")?"x86_64":"unknown"}var cd=async e=>{if(ye()||(Te.error(je.red(`You are not logged in. Run \`${m.nameLower} login\` first.`)),process.exit(1)),e.apk){await rg(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 nd(n,s);e.json?console.log(JSON.stringify(rd(a,r),null,2)):id(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)},ld=["16kb"];async function rg(e){let t=e.category?.toLowerCase();t&&!ld.includes(t)&&(Te.error(je.red(`Unknown APK check category: "${t}"`)),Te.info(je.dim(`Available APK checks: ${ld.join(", ")}`)),process.exit(1));let n=await og(e.apk);n||process.exit(1);let i=!t,r=!1;(i||t==="16kb")&&(await sd(n)||(r=!0)),r&&process.exit(1)}async function og(e){if(e.startsWith("build:")){let n=e.slice(6);return await sg(n)}if(e.startsWith("http://")||e.startsWith("https://"))return await ud(e);let t=Li.resolve(e);return Cn.existsSync(t)?t:(Te.error(je.red(`APK file not found: ${t}`)),null)}async function sg(e){let t=dd();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 ud(r.url))}catch(n){return t.stop("Failed to fetch build"),Te.error(je.red(n.message)),null}}async function ud(e){let t=dd();t.start("Downloading APK...");try{let n=Cn.mkdtempSync(Li.join(ng.tmpdir(),`${m.nameLower}-audit-`)),i=Li.join(n,"app.apk"),r=await ig.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 dg=console.log;console.log=()=>{};lg();console.log=dg;X(W.bgCyan.black(m.cliTag("Production Build Orchestrator")));var Tn=(e,t=[])=>t.concat(e),M=new ag;M.name(m.nameLower).description(`${m.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 va(e)});M.command("host").description("Setup AWS S3 static hosting and CloudFront").action(async()=>{X(W.bgCyan.black(m.cliTag("Hosting"))),await xo()});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(W.bgCyan.black(m.cliTag("Sitemap Generator"))),await Fo(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 ke("--build-id <id>","Internal build ID").hideHelp()).addOption(new ke("--project-id <id>","Internal project ID").hideHelp()).addOption(new ke("--fail-only","Internal: mark an existing build failed").hideHelp()).addOption(new ke("--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||X(W.bgCyan.black(m.cliTag("Cloud Build"))),await ei(t)});var cg=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 ke("--local-runner","Internal: execute a managed Maestro run on this machine").hideHelp()).addOption(new ke("--test-run-id <id>","Internal test run ID").hideHelp()).addOption(new ke("--project-id <id>","Internal project ID").hideHelp()).addOption(new ke("--runner-token <token>","Internal runner token").hideHelp()).action(async e=>{X(W.bgCyan.black(m.cliTag("Maestro Testing"))),await os(e)});cg.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 ss(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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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 ke("--submit-id <id>","Internal submission ID").hideHelp()).addOption(new ke("--project-id <id>","Internal project ID").hideHelp()).addOption(new ke("--package-name <name>","Internal Android package name").hideHelp()).addOption(new ke("--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(W.bgCyan.black(m.cliTag("Store Submission"))),await qn(e)});M.command("login").description(`Login to ${m.name} Dashboard`).action(async()=>{X(W.bgCyan.black(m.cliTag("Login"))),await Da()});M.command("logout").description(`Logout from ${m.name} on this machine`).action(async()=>{X(W.bgCyan.black(m.cliTag("Logout"))),await Ca()});M.command("link").description(`Link local directory to a ${m.name} Project`).action(async()=>{X(W.bgCyan.black(m.cliTag("Link Project"))),await ka()});M.command("me").description("Display currently logged in user details").action(async()=>{await il()});M.command("init").description(`Create a new ${m.name} Project`).action(async()=>{X(W.bgCyan.black(m.cliTag("Init Project"))),await Na()});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(W.bgCyan.black(m.cliTag("Env Manager"))),await La(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(W.bgCyan.black(m.cliTag("Dev Server"))),await ol(e)});var kn=M.command("push").description("Configure and send provider-direct APNs/FCM notifications");kn.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(Po);kn.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(Oo);var fd=kn.command("credentials").description("Configure provider credentials");fd.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));fd.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));kn.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(Do);kn.command("status").description("Show aggregate push delivery counters").option("--days <number>","Statistics range, 1-90","30").action(Co);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 sl(e)});var md=M.command("version").description("Show or seed DB-owned native version counters"),gd=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");gd(md.command("show").description("Show the current native version counter")).action(async e=>{X(W.bgCyan.black(m.cliTag("Version Counter"))),await so("show",e)});gd(md.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(W.bgCyan.black(m.cliTag("Version Counter"))),await so("seed",{...t,value:t.value??e})});var hd=M.command("deeplink").description("Configure and verify app links, universal links, and URI schemes");hd.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,X(W.bgCyan.black(m.cliTag("Deep Links"))),await Ol(e)});hd.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(W.bgCyan.black(m.cliTag("Deep Link Verify"))),await Pl(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-AFUG7L3X.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=>{X(W.bgCyan.black(m.cliTag("Credentials Setup"))),await Jt(e),pd(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=>{X(W.bgCyan.black(m.cliTag("Service Credentials"))),await Ro(e),pd(W.green("Done!"))});var uo=M.command("device").description("Manage registered iOS test devices");uo.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)});uo.command("list").description("List all registered devices").option("--team-id <id>","Filter by Apple Developer Team ID").action(async e=>{await vi("list",e)});uo.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=>{X(W.bgCyan.black(m.cliTag(e.apk?"APK Audit":"Security Audit"))),await cd(e)});var ug=new Set(["login","logout","agent"]),pg=new Set(["build","credentials","credentials:service","credentials:setup","env","push","submit","version"]),fg=new Set(["publish","list","rollback","promote"]);function mg(e){let t=[],n=e;for(;n&&n!==M;)t.unshift(n.name()),n=n.parent;return t}function gg(e,t){let[n,i]=mg(e);return pg.has(n)?!0:n==="ota"?fg.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"||ug.has(n)||(_t(),!gg(t,i)))return;let r=To(i,re());if(!r)throw new We(`No linked ${m.name} project was found. Run \`${m.nameLower} link\` before using this command.`);await ko(r)});M.on("command:*",()=>{console.error(`Invalid command: %s
|
|
2062
|
+
`));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 = ${od})`))}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 eg(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(Qm))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(et.readSync(t,p,0,d,l+f*d),s(p,0)!==Zm)continue;let g;i?g=a(p,48):g=s(p,28),g>0&&(u===null||g<u)&&(u=g)}return u??0}catch{return null}finally{et.closeSync(t)}}function ad(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(...ad(r)):i.name.endsWith(".so")&&t.push(r)}return t}function tg(e){return e.includes("arm64-v8a")?"arm64-v8a":e.includes("x86_64")?"x86_64":"unknown"}var cd=async e=>{if(ye()||(Te.error(je.red(`You are not logged in. Run \`${m.nameLower} login\` first.`)),process.exit(1)),e.apk){await rg(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 nd(n,s);e.json?console.log(JSON.stringify(rd(a,r),null,2)):id(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)},ld=["16kb"];async function rg(e){let t=e.category?.toLowerCase();t&&!ld.includes(t)&&(Te.error(je.red(`Unknown APK check category: "${t}"`)),Te.info(je.dim(`Available APK checks: ${ld.join(", ")}`)),process.exit(1));let n=await og(e.apk);n||process.exit(1);let i=!t,r=!1;(i||t==="16kb")&&(await sd(n)||(r=!0)),r&&process.exit(1)}async function og(e){if(e.startsWith("build:")){let n=e.slice(6);return await sg(n)}if(e.startsWith("http://")||e.startsWith("https://"))return await ud(e);let t=Li.resolve(e);return Cn.existsSync(t)?t:(Te.error(je.red(`APK file not found: ${t}`)),null)}async function sg(e){let t=dd();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 ud(r.url))}catch(n){return t.stop("Failed to fetch build"),Te.error(je.red(n.message)),null}}async function ud(e){let t=dd();t.start("Downloading APK...");try{let n=Cn.mkdtempSync(Li.join(ng.tmpdir(),`${m.nameLower}-audit-`)),i=Li.join(n,"app.apk"),r=await ig.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 dg=console.log;console.log=()=>{};lg();console.log=dg;X(W.bgCyan.black(m.cliTag("Production Build Orchestrator")));var Tn=(e,t=[])=>t.concat(e),M=new ag;M.name(m.nameLower).description(`${m.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 va(e)});M.command("host").description("Setup AWS S3 static hosting and CloudFront").action(async()=>{X(W.bgCyan.black(m.cliTag("Hosting"))),await xo()});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(W.bgCyan.black(m.cliTag("Sitemap Generator"))),await Fo(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 ke("--build-id <id>","Internal build ID").hideHelp()).addOption(new ke("--project-id <id>","Internal project ID").hideHelp()).addOption(new ke("--fail-only","Internal: mark an existing build failed").hideHelp()).addOption(new ke("--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||X(W.bgCyan.black(m.cliTag("Cloud Build"))),await ei(t)});var cg=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 ke("--local-runner","Internal: execute a managed Maestro run on this machine").hideHelp()).addOption(new ke("--test-run-id <id>","Internal test run ID").hideHelp()).addOption(new ke("--project-id <id>","Internal project ID").hideHelp()).addOption(new ke("--runner-token <token>","Internal runner token").hideHelp()).action(async e=>{X(W.bgCyan.black(m.cliTag("Maestro Testing"))),await os(e)});cg.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 ss(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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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();X(W.bgCyan.black(m.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 ke("--submit-id <id>","Internal submission ID").hideHelp()).addOption(new ke("--project-id <id>","Internal project ID").hideHelp()).addOption(new ke("--package-name <name>","Internal Android package name").hideHelp()).addOption(new ke("--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(W.bgCyan.black(m.cliTag("Store Submission"))),await qn(e)});M.command("login").description(`Login to ${m.name} Dashboard`).action(async()=>{X(W.bgCyan.black(m.cliTag("Login"))),await Da()});M.command("logout").description(`Logout from ${m.name} on this machine`).action(async()=>{X(W.bgCyan.black(m.cliTag("Logout"))),await Ca()});M.command("link").description(`Link local directory to a ${m.name} Project`).action(async()=>{X(W.bgCyan.black(m.cliTag("Link Project"))),await ka()});M.command("me").description("Display currently logged in user details").action(async()=>{await il()});M.command("init").description(`Create a new ${m.name} Project`).action(async()=>{X(W.bgCyan.black(m.cliTag("Init Project"))),await Na()});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(W.bgCyan.black(m.cliTag("Env Manager"))),await La(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(W.bgCyan.black(m.cliTag("Dev Server"))),await ol(e)});var kn=M.command("push").description("Configure and send provider-direct APNs/FCM notifications");kn.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(Po);kn.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(Oo);var fd=kn.command("credentials").description("Configure provider credentials");fd.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));fd.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));kn.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(Do);kn.command("status").description("Show aggregate push delivery counters").option("--days <number>","Statistics range, 1-90","30").action(Co);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 sl(e)});var md=M.command("version").description("Show or seed DB-owned native version counters"),gd=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");gd(md.command("show").description("Show the current native version counter")).action(async e=>{X(W.bgCyan.black(m.cliTag("Version Counter"))),await so("show",e)});gd(md.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(W.bgCyan.black(m.cliTag("Version Counter"))),await so("seed",{...t,value:t.value??e})});var hd=M.command("deeplink").description("Configure and verify app links, universal links, and URI schemes");hd.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,X(W.bgCyan.black(m.cliTag("Deep Links"))),await Ol(e)});hd.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(W.bgCyan.black(m.cliTag("Deep Link Verify"))),await Pl(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-6OIUDAIQ.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=>{X(W.bgCyan.black(m.cliTag("Credentials Setup"))),await Jt(e),pd(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=>{X(W.bgCyan.black(m.cliTag("Service Credentials"))),await Ro(e),pd(W.green("Done!"))});var uo=M.command("device").description("Manage registered iOS test devices");uo.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)});uo.command("list").description("List all registered devices").option("--team-id <id>","Filter by Apple Developer Team ID").action(async e=>{await vi("list",e)});uo.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=>{X(W.bgCyan.black(m.cliTag(e.apk?"APK Audit":"Security Audit"))),await cd(e)});var ug=new Set(["login","logout","agent"]),pg=new Set(["build","credentials","credentials:service","credentials:setup","env","push","submit","version"]),fg=new Set(["publish","list","rollback","promote"]);function mg(e){let t=[],n=e;for(;n&&n!==M;)t.unshift(n.name()),n=n.parent;return t}function gg(e,t){let[n,i]=mg(e);return pg.has(n)?!0:n==="ota"?fg.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"||ug.has(n)||(_t(),!gg(t,i)))return;let r=To(i,re());if(!r)throw new We(`No linked ${m.name} project was found. Run \`${m.nameLower} link\` before using this command.`);await ko(r)});M.on("command:*",()=>{console.error(`Invalid command: %s
|
|
2063
2063
|
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});
|