@radhya/mach 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as a,M as b,N as c}from"./chunk-
|
|
1
|
+
import{L as a,M as b,N as c}from"./chunk-EOCEKS22.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 we,B as Un,C as Fn,D as It,E as vo,F as Qe,G as Ro,H as Oo,I as Vi,J as Po,K as Do,M as jt,a as pt,b as Ao,c as yo,d as Fi,e as So,f as bo,g as Tn,h as kn,i as Nn,j as Bi,k as Hi,l as xn,m as Ln,n as Eo,o as Io,p as _o,q as ji,r as Ht,s as wo,t as Gi,u as Et,v as Mn,w as Re,x as $o,y as ft,z as de}from"./chunk-
|
|
2
|
+
import{A as we,B as Un,C as Fn,D as It,E as vo,F as Qe,G as Ro,H as Oo,I as Vi,J as Po,K as Do,M as jt,a as pt,b as Ao,c as yo,d as Fi,e as So,f as bo,g as Tn,h as kn,i as Nn,j as Bi,k as Hi,l as xn,m as Ln,n as Eo,o as Io,p as _o,q as ji,r as Ht,s as wo,t as Gi,u as Et,v as Mn,w as Re,x as $o,y as ft,z as de}from"./chunk-EOCEKS22.js";import{a as m,b as go,c as Ae,d as ho,e as bt,f as Ze,g as je,h as v}from"./chunk-S64YFTRR.js";import{Command as cg,Option as Ne}from"commander";import{configDotenv as ug}from"dotenv";import{intro as X,outro as pd}from"@clack/prompts";import q from"chalk";import{text as Co,confirm as Ad,spinner as yd,isCancel as zi,cancel as Gt,note as Sd,outro as bd}from"@clack/prompts";import Vt from"chalk";async function To(){try{let e=await Co({message:"Enter Bucket Name:",placeholder:"e.g. my-app-dev",validate(r){if(r.length===0)return"Bucket name is required"}});zi(e)&&(Gt("Operation cancelled."),process.exit(0));let t=await Co({message:"Enter Region:",initialValue:"ap-south-1"});zi(t)&&(Gt("Operation cancelled."),process.exit(0));let n=await Ad({message:"Do you want to create a CloudFront Distribution for this bucket?",initialValue:!0});zi(n)&&(Gt("Operation cancelled."),process.exit(0));let i=yd();i.start("Setting up hosting infrastructure...");try{let r=await v.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: ${Vt.cyan(o.bucketName)}
|
|
3
3
|
`;s+=`Region: ${Vt.cyan(o.region)}
|
|
4
4
|
`,s+=`S3 Website URL: ${Vt.blue(o.s3WebsiteUrl)}`,o.cloudFrontId&&(s+=`
|
|
5
5
|
|
|
@@ -1822,5 +1822,5 @@ module.exports = function withMachDeepLinks(config) {
|
|
|
1822
1822
|
Running expo prebuild for deeper analysis...`));try{qm("npx expo prebuild --no-install",{cwd:e,stdio:"pipe"})}catch{return Rn.warn(ve.yellow("Prebuild failed \u2014 skipping manifest/plist checks.")),o}}else if(!l)return t.json||Rn.info(ve.dim(`
|
|
1823
1823
|
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(ve.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?ve.yellow(`${d.label} \u2014 ${p} finding(s)`):ve.green(`${d.label} \u2014 clean`))}catch(u){c.stop(ve.red(`${d.label} \u2014 error`)),o.push({category:d.category,label:d.label,findings:[],durationMs:0,error:u.message})}}}return o}import pe from"chalk";import{log as se}from"@clack/prompts";var Mt={critical:pe.bgRed.white.bold,high:pe.red.bold,medium:pe.yellow.bold,low:pe.blue,info:pe.dim},ki={critical:0,high:1,medium:2,low:3,info:4};function Xm(e,t){if(!t)return!0;let n=ki[t];return n===void 0?!0:ki[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=>Xm(d.severity,t));if(a.length===0&&!s.error)continue;if(se.info(""),se.info(pe.bold(` ${s.label}`)+pe.dim(` ${a.length} finding(s)`)),se.info(pe.dim(" "+"\u2500".repeat(60))),s.error){se.error(pe.red(` Error: ${s.error}`));continue}let l=[...a].sort((d,c)=>ki[d.severity]-ki[c.severity]);for(let d of l){let c=Mt[d.severity](` ${d.severity.toUpperCase()} `);se.info(` ${c} ${pe.bold(d.id)} ${d.title}`),se.info(pe.dim(` ${d.description}`)),d.file&&se.info(pe.dim(` File: ${d.file}${d.line?`:${d.line}`:""}`)),se.info(pe.cyan(` Fix: ${d.recommendation}`)),se.info(""),i[d.severity]++,n++}}se.info(""),se.info(pe.bold(" Summary")),se.info(pe.dim(" "+"\u2500".repeat(60))),se.info(` Total: ${pe.bold(String(n))} finding(s)`),se.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?(se.info(""),se.error(pe.red.bold(` FAIL \u2014 ${i.critical} critical, ${i.high} high issue(s) found`))):n>0?(se.info(""),se.warn(pe.yellow(" PASS (with warnings) \u2014 no critical or high issues"))):(se.info(""),se.success(pe.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(Te))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 ae,spinner as Zm}from"@clack/prompts";import ne from"chalk";import Xe from"fs";import Qm from"os";import Ut from"path";import{execSync as eg}from"child_process";var od=16384,tg=1,ng=Buffer.from([127,69,76,70]);async function sd(e){ae.info(ne.bold.underline("16KB Page Alignment Check")),console.log("");let t=Ut.resolve(e);if(!Xe.existsSync(t))return ae.error(ne.red(`APK file not found: ${t}`)),!1;if(!t.endsWith(".apk"))return ae.error(ne.red("The provided file is not an APK file.")),!1;let n=Zm();n.start("Extracting and analyzing native libraries...");let i=Xe.mkdtempSync(Ut.join(Qm.tmpdir(),"mach-16kb-"));try{try{eg(`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(Ut.join(i,"lib"));if(r.length===0)return n.stop("Analysis complete."),ae.info(ne.yellow("No arm64-v8a or x86_64 native libraries found in the APK.")),ae.info(ne.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=rg(d),u=Ut.basename(l),f=ig(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 ae.info(ne.yellow("No valid ELF shared libraries found.")),!0;let s=o.filter(l=>!l.compatible),a=o.filter(l=>l.compatible);if(ae.info(ne.dim(`Checked ${o.length} native librar${o.length===1?"y":"ies"}
|
|
1824
1824
|
`)),s.length>0){ae.info(ne.red.bold(`Incompatible libraries:
|
|
1825
|
-
`));for(let l of s)ae.error(ne.red(`${ne.bold(l.name)} ${ne.dim(`(${l.arch})`)}`)),ae.info(ne.dim(` PT_LOAD alignment: 2**${Math.log2(l.align)} (${l.align} bytes, needs 2**14 = ${od})`))}return a.length>0&&(console.log(""),ae.success(ne.green(`${a.length} librar${a.length===1?"y":"ies"} correctly aligned (2**14 or higher).`))),console.log(""),s.length===0?(ae.success(ne.green.bold("ELF Verification Successful. APK is 16KB compatible.")),!0):(ae.error(ne.red.bold(`Found ${s.length} unaligned lib${s.length===1?"":"s"} (arm64-v8a/x86_64 libs need to be aligned).`)),console.log(""),ae.info(ne.yellow("To fix this:")),ae.info(ne.dim(" 1. Rebuild with NDK r28+ which defaults to 16KB page alignment")),ae.info(ne.dim(" 2. Or set -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON in CMake")),ae.info(ne.dim(" 3. Update third-party libraries that ship prebuilt .so files")),ae.info(ne.dim(" 4. After rebuilding: zipalign -p -f -v 16 input.apk output.apk")),console.log(""),ae.info(ne.dim("Reference: https://developer.android.com/guide/practices/page-sizes")),!1)}catch(r){return n.stop("Analysis failed."),ae.error(ne.red(`Failed to analyze APK: ${r.message}`)),!1}finally{try{Xe.rmSync(i,{recursive:!0,force:!0})}catch{}}}function ig(e){let t=Xe.openSync(e,"r");try{let n=Buffer.alloc(64);if(Xe.readSync(t,n,0,64,0),!n.subarray(0,4).equals(ng))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(Xe.readSync(t,p,0,d,l+f*d),s(p,0)!==tg)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{Xe.closeSync(t)}}function ad(e){let t=[];if(!Xe.existsSync(e))return t;let n=Xe.readdirSync(e,{withFileTypes:!0});for(let i of n){let r=Ut.join(e,i.name);i.isDirectory()?t.push(...ad(r)):i.name.endsWith(".so")&&t.push(r)}return t}function rg(e){return e.includes("arm64-v8a")?"arm64-v8a":e.includes("x86_64")?"x86_64":"unknown"}var cd=async e=>{if(Ae()||(ke.error(He.red(`You are not logged in. Run \`${m.nameLower} login\` first.`)),process.exit(1)),e.apk){await ag(e);return}let n=process.cwd(),i=Ni.join(n,"package.json");On.existsSync(i)||(ke.error(He.red("No package.json found. Run this command from a project root.")),process.exit(1));let r=JSON.parse(On.readFileSync(i,"utf-8")),o=!!(r.dependencies?.expo||r.devDependencies?.expo);e.json||(ke.info(He.dim(`Project: ${r.name||"unknown"} v${r.version||"0.0.0"}`)),ke.info(He.dim(`Type: ${o?"Expo":"Bare React Native"}`)),ke.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 ag(e){let t=e.category?.toLowerCase();t&&!ld.includes(t)&&(ke.error(He.red(`Unknown APK check category: "${t}"`)),ke.info(He.dim(`Available APK checks: ${ld.join(", ")}`)),process.exit(1));let n=await lg(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 lg(e){if(e.startsWith("build:")){let n=e.slice(6);return await dg(n)}if(e.startsWith("http://")||e.startsWith("https://"))return await ud(e);let t=Ni.resolve(e);return On.existsSync(t)?t:(ke.error(He.red(`APK file not found: ${t}`)),null)}async function dg(e){let t=dd();t.start(`Fetching APK from build ${e}...`);try{let n=await v.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"),ke.error(He.red("This build does not have an APK artifact.")),ke.info(He.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"),ke.error(He.red(n.message)),null}}async function ud(e){let t=dd();t.start("Downloading APK...");try{let n=On.mkdtempSync(Ni.join(og.tmpdir(),`${m.nameLower}-audit-`)),i=Ni.join(n,"app.apk"),r=await sg.get(e,{responseType:"arraybuffer"});On.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"),ke.error(He.red(`Failed to download APK: ${n.message}`)),null}}var pg=console.log;console.log=()=>{};ug();console.log=pg;X(q.bgCyan.black(m.cliTag("Production Build Orchestrator")));var Pn=(e,t=[])=>t.concat(e),M=new cg;M.name(m.nameLower).description(`${m.name} CLI: Powerful Cloud Infrastructure Tools`).version(Qe).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(q.bgCyan.black(m.cliTag("Hosting"))),await To()});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(q.bgCyan.black(m.cliTag("Sitemap Generator"))),await Lo(e)});M.command("build").description("Run a build on a cloud provider (AWS Spot Instances)").argument("[platform]","Target platform (android, ios)").option("--platform <os>","Target platform alias (android, ios) [Optional]").option("--repo <url>","Git Repository URL").option("--branch <name>","Git Branch").option("--ami <id>","AMI ID").option("--bucket <name>","S3 Bucket for artifacts").option("--region <region>","AWS Region").option("--aws-profile <name>","AWS Credentials Profile").option("-p, --build-profile <name>","Build Profile (e.g. production, staging)").option("--profile <name>","Build Profile (alias for --build-profile)").option("--dry-run","Generate User Data script without launching").option("--keep-instance","Do not terminate the instance after build").option("--subnet <id>","VPC Subnet ID to launch the instance in").option("--security-group <id>","VPC Security Group ID to use").option("--ssh-host <host>","Remote host for iOS build (SSH)").option("--ssh-user <user>","SSH username for remote host").option("--ssh-key <path>","Path to private SSH key for remote host").option("--ios-scheme <scheme>","iOS Scheme to build").option("--ios-team-id <id>","Apple Development Team ID").option("--ios-configuration <config>","Xcode configuration (Release/Debug)").option("--ios-export-method <method>","Export method (ad-hoc, app-store, development, enterprise)").option("--ios-api-key-id <id>","App Store Connect API Key ID").option("--ios-api-key-issuer <id>","App Store Connect API Key Issuer ID").option("--ios-api-key-path <path>","Path to App Store Connect API Key (.p8) file").option("--simulator","Build for iOS Simulator (no signing required)").addOption(new Ne("--build-id <id>","Internal build ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--fail-only","Internal: mark an existing build failed").hideHelp()).addOption(new Ne("--error <message>","Internal failure message").hideHelp()).option("--local","Run build on local machine").option("--auto-version","Assign the next Android versionCode or iOS buildNumber from Mach").option("--auto-submit","Submit this build after it completes successfully").option("--submit-track <track>","Google Play track to use with --auto-submit").option("--submit-release-status <status>","Google Play release status to use with --auto-submit").option("--submit-rollout <fraction>","Google Play staged rollout fraction to use with --auto-submit").option("--submit-changes-not-sent-for-review","Commit Google Play changes without automatically sending them for review when using --auto-submit").option("--submit-credential-id <id>","Service credential ID to use with --auto-submit").option("--submit-json-output <path>","Write auto-submit metadata JSON to a file for CI/CD").option("--verbose","Enable verbose logging").option("--json-output <path>","Write build metadata JSON to a file for CI/CD").option("--maestro","Queue a managed Maestro test run after a successful build").option("--maestro-flows <path>","Maestro flow file or directory (default: .maestro)").option("--maestro-device <device>","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",Pn,[]).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(q.bgCyan.black(m.cliTag("Cloud Build"))),await Zn(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",Pn,[]).option("--wait","Wait for managed Maestro completion and exit non-zero on failure").option("--wait-timeout <minutes>","Maximum minutes to wait for managed Maestro completion","60").option("--wait-interval <seconds>","Polling interval while waiting for managed Maestro completion","15").option("--json-output <path>","Write test run metadata JSON to a file for CI/CD").addOption(new Ne("--local-runner","Internal: execute a managed Maestro run on this machine").hideHelp()).addOption(new Ne("--test-run-id <id>","Internal test run ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--runner-token <token>","Internal runner token").hideHelp()).action(async e=>{X(q.bgCyan.black(m.cliTag("Maestro Testing"))),await ss(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(q.bgCyan.black(m.cliTag("OTA Setup"))),await st("setup",{...e,yes:e.yes||t.yes})});Ft(Bt.command("publish").description("Publish an OTA update")).action(async e=>{let t=M.opts();X(q.bgCyan.black(m.cliTag("OTA Publish"))),await st("publish",{...e,yes:e.yes||t.yes})});Ft(Bt.command("verify").description("Verify OTA configuration")).action(async e=>{let t=M.opts();X(q.bgCyan.black(m.cliTag("OTA Verify"))),await st("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(q.bgCyan.black(m.cliTag("OTA Updates"))),await st("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(q.bgCyan.black(m.cliTag("OTA Rollback"))),await st("rollback",{...e,yes:e.yes||t.yes})});Ft(Bt.command("promote").description("Promote an OTA update")).action(async e=>{let t=M.opts();X(q.bgCyan.black(m.cliTag("OTA Promote"))),await st("promote",{...e,yes:e.yes||t.yes})});M.command("submit").description("Automated Store Submission (App Store / Google Play)").option("--platform <os>","Target platform (ios/android)").option("-p, --profile <name>","Build/submission profile to submit from (e.g. production, preprod)").option("--track <track>","Google Play Track (internal, alpha, beta, production)").option("--release-status <status>","Google Play release status (completed, draft, halted, inProgress)").option("--rollout <fraction>","Google Play staged rollout fraction for inProgress releases (example: 0.1)").option("--changes-not-sent-for-review","Commit Google Play changes without automatically sending them for review").option("--ssh-host <host>","Remote macOS host for iOS submission").option("--ssh-user <user>","SSH username for remote iOS submission").option("--ssh-key <path>","Path to private SSH key for remote iOS submission").option("--credential-id <id>","Service credential ID to use when multiple submission credentials exist").option("--local","Run submission on this machine (internal runner mode for iOS)").addOption(new Ne("--submit-id <id>","Internal submission ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--package-name <name>","Internal Android package name").hideHelp()).addOption(new Ne("--bundle-id <id>","Internal iOS bundle identifier").hideHelp()).option("--json-output <path>","Write submission metadata JSON to a file for CI/CD").option("--latest","Use the latest successful build for submission").option("--build-id <id>","Use a specific build ID for submission").action(async e=>{let t=M.opts();e.quiet=e.quiet||t.quiet,e.yes=e.yes||t.yes,X(q.bgCyan.black(m.cliTag("Store Submission"))),await Wn(e)});M.command("login").description(`Login to ${m.name} Dashboard`).action(async()=>{X(q.bgCyan.black(m.cliTag("Login"))),await Da()});M.command("logout").description(`Logout from ${m.name} on this machine`).action(async()=>{X(q.bgCyan.black(m.cliTag("Logout"))),await Ca()});M.command("link").description(`Link local directory to a ${m.name} Project`).action(async()=>{X(q.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(q.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(q.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(q.bgCyan.black(m.cliTag("Dev Server"))),await ol(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(Oo);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(Ro);var fd=Dn.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=>Vi("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=>Vi("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",Pn,[]).option("--user <id>","Application user ID; repeatable",Pn,[]).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(Po);Dn.command("status").description("Show aggregate push delivery counters").option("--days <number>","Statistics range, 1-90","30").action(Do);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(q.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(q.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",Pn,[]).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(q.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(q.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("--force","Force recreate certificates (nuke existing on Apple Portal)",!1).action(async e=>{let{credentialsMainCommand:t}=await import("./credentials-P2SLBNWN.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(q.bgCyan.black(m.cliTag("Credentials Setup"))),await jt(e),pd(q.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(q.bgCyan.black(m.cliTag("Service Credentials"))),await vo(e),pd(q.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 wi("register",e)});uo.command("list").description("List all registered devices").option("--team-id <id>","Filter by Apple Developer Team ID").action(async e=>{await wi("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 wi("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(q.bgCyan.black(m.cliTag(e.apk?"APK Audit":"Security Audit"))),await cd(e)});var fg=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"&&(fg.has(n)||bt())});M.on("command:*",()=>{console.error(`Invalid command: %s
|
|
1825
|
+
`));for(let l of s)ae.error(ne.red(`${ne.bold(l.name)} ${ne.dim(`(${l.arch})`)}`)),ae.info(ne.dim(` PT_LOAD alignment: 2**${Math.log2(l.align)} (${l.align} bytes, needs 2**14 = ${od})`))}return a.length>0&&(console.log(""),ae.success(ne.green(`${a.length} librar${a.length===1?"y":"ies"} correctly aligned (2**14 or higher).`))),console.log(""),s.length===0?(ae.success(ne.green.bold("ELF Verification Successful. APK is 16KB compatible.")),!0):(ae.error(ne.red.bold(`Found ${s.length} unaligned lib${s.length===1?"":"s"} (arm64-v8a/x86_64 libs need to be aligned).`)),console.log(""),ae.info(ne.yellow("To fix this:")),ae.info(ne.dim(" 1. Rebuild with NDK r28+ which defaults to 16KB page alignment")),ae.info(ne.dim(" 2. Or set -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON in CMake")),ae.info(ne.dim(" 3. Update third-party libraries that ship prebuilt .so files")),ae.info(ne.dim(" 4. After rebuilding: zipalign -p -f -v 16 input.apk output.apk")),console.log(""),ae.info(ne.dim("Reference: https://developer.android.com/guide/practices/page-sizes")),!1)}catch(r){return n.stop("Analysis failed."),ae.error(ne.red(`Failed to analyze APK: ${r.message}`)),!1}finally{try{Xe.rmSync(i,{recursive:!0,force:!0})}catch{}}}function ig(e){let t=Xe.openSync(e,"r");try{let n=Buffer.alloc(64);if(Xe.readSync(t,n,0,64,0),!n.subarray(0,4).equals(ng))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(Xe.readSync(t,p,0,d,l+f*d),s(p,0)!==tg)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{Xe.closeSync(t)}}function ad(e){let t=[];if(!Xe.existsSync(e))return t;let n=Xe.readdirSync(e,{withFileTypes:!0});for(let i of n){let r=Ut.join(e,i.name);i.isDirectory()?t.push(...ad(r)):i.name.endsWith(".so")&&t.push(r)}return t}function rg(e){return e.includes("arm64-v8a")?"arm64-v8a":e.includes("x86_64")?"x86_64":"unknown"}var cd=async e=>{if(Ae()||(ke.error(He.red(`You are not logged in. Run \`${m.nameLower} login\` first.`)),process.exit(1)),e.apk){await ag(e);return}let n=process.cwd(),i=Ni.join(n,"package.json");On.existsSync(i)||(ke.error(He.red("No package.json found. Run this command from a project root.")),process.exit(1));let r=JSON.parse(On.readFileSync(i,"utf-8")),o=!!(r.dependencies?.expo||r.devDependencies?.expo);e.json||(ke.info(He.dim(`Project: ${r.name||"unknown"} v${r.version||"0.0.0"}`)),ke.info(He.dim(`Type: ${o?"Expo":"Bare React Native"}`)),ke.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 ag(e){let t=e.category?.toLowerCase();t&&!ld.includes(t)&&(ke.error(He.red(`Unknown APK check category: "${t}"`)),ke.info(He.dim(`Available APK checks: ${ld.join(", ")}`)),process.exit(1));let n=await lg(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 lg(e){if(e.startsWith("build:")){let n=e.slice(6);return await dg(n)}if(e.startsWith("http://")||e.startsWith("https://"))return await ud(e);let t=Ni.resolve(e);return On.existsSync(t)?t:(ke.error(He.red(`APK file not found: ${t}`)),null)}async function dg(e){let t=dd();t.start(`Fetching APK from build ${e}...`);try{let n=await v.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"),ke.error(He.red("This build does not have an APK artifact.")),ke.info(He.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"),ke.error(He.red(n.message)),null}}async function ud(e){let t=dd();t.start("Downloading APK...");try{let n=On.mkdtempSync(Ni.join(og.tmpdir(),`${m.nameLower}-audit-`)),i=Ni.join(n,"app.apk"),r=await sg.get(e,{responseType:"arraybuffer"});On.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"),ke.error(He.red(`Failed to download APK: ${n.message}`)),null}}var pg=console.log;console.log=()=>{};ug();console.log=pg;X(q.bgCyan.black(m.cliTag("Production Build Orchestrator")));var Pn=(e,t=[])=>t.concat(e),M=new cg;M.name(m.nameLower).description(`${m.name} CLI: Powerful Cloud Infrastructure Tools`).version(Qe).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(q.bgCyan.black(m.cliTag("Hosting"))),await To()});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(q.bgCyan.black(m.cliTag("Sitemap Generator"))),await Lo(e)});M.command("build").description("Run a build on a cloud provider (AWS Spot Instances)").argument("[platform]","Target platform (android, ios)").option("--platform <os>","Target platform alias (android, ios) [Optional]").option("--repo <url>","Git Repository URL").option("--branch <name>","Git Branch").option("--ami <id>","AMI ID").option("--bucket <name>","S3 Bucket for artifacts").option("--region <region>","AWS Region").option("--aws-profile <name>","AWS Credentials Profile").option("-p, --build-profile <name>","Build Profile (e.g. production, staging)").option("--profile <name>","Build Profile (alias for --build-profile)").option("--dry-run","Generate User Data script without launching").option("--keep-instance","Do not terminate the instance after build").option("--subnet <id>","VPC Subnet ID to launch the instance in").option("--security-group <id>","VPC Security Group ID to use").option("--ssh-host <host>","Remote host for iOS build (SSH)").option("--ssh-user <user>","SSH username for remote host").option("--ssh-key <path>","Path to private SSH key for remote host").option("--ios-scheme <scheme>","iOS Scheme to build").option("--ios-team-id <id>","Apple Development Team ID").option("--ios-configuration <config>","Xcode configuration (Release/Debug)").option("--ios-export-method <method>","Export method (ad-hoc, app-store, development, enterprise)").option("--ios-api-key-id <id>","App Store Connect API Key ID").option("--ios-api-key-issuer <id>","App Store Connect API Key Issuer ID").option("--ios-api-key-path <path>","Path to App Store Connect API Key (.p8) file").option("--simulator","Build for iOS Simulator (no signing required)").addOption(new Ne("--build-id <id>","Internal build ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--fail-only","Internal: mark an existing build failed").hideHelp()).addOption(new Ne("--error <message>","Internal failure message").hideHelp()).option("--local","Run build on local machine").option("--auto-version","Assign the next Android versionCode or iOS buildNumber from Mach").option("--auto-submit","Submit this build after it completes successfully").option("--submit-track <track>","Google Play track to use with --auto-submit").option("--submit-release-status <status>","Google Play release status to use with --auto-submit").option("--submit-rollout <fraction>","Google Play staged rollout fraction to use with --auto-submit").option("--submit-changes-not-sent-for-review","Commit Google Play changes without automatically sending them for review when using --auto-submit").option("--submit-credential-id <id>","Service credential ID to use with --auto-submit").option("--submit-json-output <path>","Write auto-submit metadata JSON to a file for CI/CD").option("--verbose","Enable verbose logging").option("--json-output <path>","Write build metadata JSON to a file for CI/CD").option("--maestro","Queue a managed Maestro test run after a successful build").option("--maestro-flows <path>","Maestro flow file or directory (default: .maestro)").option("--maestro-device <device>","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",Pn,[]).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(q.bgCyan.black(m.cliTag("Cloud Build"))),await Zn(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",Pn,[]).option("--wait","Wait for managed Maestro completion and exit non-zero on failure").option("--wait-timeout <minutes>","Maximum minutes to wait for managed Maestro completion","60").option("--wait-interval <seconds>","Polling interval while waiting for managed Maestro completion","15").option("--json-output <path>","Write test run metadata JSON to a file for CI/CD").addOption(new Ne("--local-runner","Internal: execute a managed Maestro run on this machine").hideHelp()).addOption(new Ne("--test-run-id <id>","Internal test run ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--runner-token <token>","Internal runner token").hideHelp()).action(async e=>{X(q.bgCyan.black(m.cliTag("Maestro Testing"))),await ss(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(q.bgCyan.black(m.cliTag("OTA Setup"))),await st("setup",{...e,yes:e.yes||t.yes})});Ft(Bt.command("publish").description("Publish an OTA update")).action(async e=>{let t=M.opts();X(q.bgCyan.black(m.cliTag("OTA Publish"))),await st("publish",{...e,yes:e.yes||t.yes})});Ft(Bt.command("verify").description("Verify OTA configuration")).action(async e=>{let t=M.opts();X(q.bgCyan.black(m.cliTag("OTA Verify"))),await st("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(q.bgCyan.black(m.cliTag("OTA Updates"))),await st("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(q.bgCyan.black(m.cliTag("OTA Rollback"))),await st("rollback",{...e,yes:e.yes||t.yes})});Ft(Bt.command("promote").description("Promote an OTA update")).action(async e=>{let t=M.opts();X(q.bgCyan.black(m.cliTag("OTA Promote"))),await st("promote",{...e,yes:e.yes||t.yes})});M.command("submit").description("Automated Store Submission (App Store / Google Play)").option("--platform <os>","Target platform (ios/android)").option("-p, --profile <name>","Build/submission profile to submit from (e.g. production, preprod)").option("--track <track>","Google Play Track (internal, alpha, beta, production)").option("--release-status <status>","Google Play release status (completed, draft, halted, inProgress)").option("--rollout <fraction>","Google Play staged rollout fraction for inProgress releases (example: 0.1)").option("--changes-not-sent-for-review","Commit Google Play changes without automatically sending them for review").option("--ssh-host <host>","Remote macOS host for iOS submission").option("--ssh-user <user>","SSH username for remote iOS submission").option("--ssh-key <path>","Path to private SSH key for remote iOS submission").option("--credential-id <id>","Service credential ID to use when multiple submission credentials exist").option("--local","Run submission on this machine (internal runner mode for iOS)").addOption(new Ne("--submit-id <id>","Internal submission ID").hideHelp()).addOption(new Ne("--project-id <id>","Internal project ID").hideHelp()).addOption(new Ne("--package-name <name>","Internal Android package name").hideHelp()).addOption(new Ne("--bundle-id <id>","Internal iOS bundle identifier").hideHelp()).option("--json-output <path>","Write submission metadata JSON to a file for CI/CD").option("--latest","Use the latest successful build for submission").option("--build-id <id>","Use a specific build ID for submission").action(async e=>{let t=M.opts();e.quiet=e.quiet||t.quiet,e.yes=e.yes||t.yes,X(q.bgCyan.black(m.cliTag("Store Submission"))),await Wn(e)});M.command("login").description(`Login to ${m.name} Dashboard`).action(async()=>{X(q.bgCyan.black(m.cliTag("Login"))),await Da()});M.command("logout").description(`Logout from ${m.name} on this machine`).action(async()=>{X(q.bgCyan.black(m.cliTag("Logout"))),await Ca()});M.command("link").description(`Link local directory to a ${m.name} Project`).action(async()=>{X(q.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(q.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(q.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(q.bgCyan.black(m.cliTag("Dev Server"))),await ol(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(Oo);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(Ro);var fd=Dn.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=>Vi("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=>Vi("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",Pn,[]).option("--user <id>","Application user ID; repeatable",Pn,[]).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(Po);Dn.command("status").description("Show aggregate push delivery counters").option("--days <number>","Statistics range, 1-90","30").action(Do);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(q.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(q.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",Pn,[]).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(q.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(q.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("--force","Force recreate certificates (nuke existing on Apple Portal)",!1).action(async e=>{let{credentialsMainCommand:t}=await import("./credentials-EFMCWAD4.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(q.bgCyan.black(m.cliTag("Credentials Setup"))),await jt(e),pd(q.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(q.bgCyan.black(m.cliTag("Service Credentials"))),await vo(e),pd(q.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 wi("register",e)});uo.command("list").description("List all registered devices").option("--team-id <id>","Filter by Apple Developer Team ID").action(async e=>{await wi("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 wi("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(q.bgCyan.black(m.cliTag(e.apk?"APK Audit":"Security Audit"))),await cd(e)});var fg=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"&&(fg.has(n)||bt())});M.on("command:*",()=>{console.error(`Invalid command: %s
|
|
1826
1826
|
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);
|