@webority/mobile-tools 0.175.0 → 0.177.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.
package/README.md CHANGED
@@ -49,8 +49,7 @@ npx mobile-tools prebuild --same-env [--platform android|ios]
49
49
  - Writes `android/app/src/<flavor>/AndroidManifest.xml` for the environment's flavor, with the `expo.modules.updates.*` meta-data, and `ios/<name>/Supporting/Expo.plist` as a whole plist document. Both are git-ignored, so neither is tracked.
50
50
  - With OTA on, the manifest URL `<OTA_UPDATE_BASE_URL>/ota/manifest/<OTA_PROJECT_PUBLIC_ID>/<component public id>/<environment>`, the runtime version `VERSION_INTERNAL`, check on launch `ALWAYS`, launch wait 0, and the code-signing certificate with the key id read from it and `alg` `rsa-v1_5-sha256`.
51
51
  - With OTA off, the Android manifest holds only `expo.modules.updates.ENABLED` `false`, and Expo.plist holds only `EXUpdatesEnabled` `<false/>`.
52
- - `OTA_CODE_SIGNING_CERT` names the update server's PEM certificate, relative to the app folder. It is required, because the server signs every manifest and an app without the certificate cannot verify one. A missing or malformed `OTA_PROJECT_PUBLIC_ID` also fails; the public ids are GUIDs, written lowercase. A setting that still carries a removed key (`OTA_PROJECT_ID`, `OTA_ANDROID_COMPONENT_ID`, `OTA_IOS_COMPONENT_ID`) fails, naming its replacement.
53
- - An app without environment flavors is refused: the flavor manifest is the only place these settings go.
52
+ - `OTA_CODE_SIGNING_CERT` names the update server's PEM certificate, relative to the app folder. It is required, because the server signs every manifest and an app without the certificate cannot verify one. A missing or malformed `OTA_PROJECT_PUBLIC_ID` also fails; the public ids are GUIDs, written lowercase. - An app without environment flavors is refused: the flavor manifest is the only place these settings go.
54
53
  - Without `--platform`, it writes the files of every platform folder the app has.
55
54
  - `--same-env` recompiles the environment last compiled, which refreshes the build stamp.
56
55
  - Running it twice gives the same native files as running it once. A file whose content did not change is not rewritten.
@@ -92,7 +91,7 @@ npx mobile-tools run --env <Environment> [--platform android|ios] [--device <ser
92
91
  **Android** (the default):
93
92
 
94
93
  1. Runs `sync --check` and stops on a stale tree.
95
- 2. First runs `adb connect` for any open MuMu port (16384 + 32 n, and 7555) that `adb` does not list yet. Then lists `adb` devices. A device that answers on several serials (MuMu shows one instance as `127.0.0.1:16416`, `127.0.0.1:7555` and `emulator-5556`) is shown once.
94
+ 2. First runs `adb connect` for any open MuMu port (16384 + 32 n) that `adb` does not list yet. Then lists `adb` devices. A device that answers on several serials (MuMu shows one instance as `127.0.0.1:16416`, `127.0.0.1:7555` and `emulator-5556`) is shown once.
96
95
  3. Picks the device:
97
96
  - the one named by `--device` (any of its serials, or its model name);
98
97
  - otherwise the only device;
@@ -171,7 +170,7 @@ Exit codes: `0` when the artifacts exist; `1` when the build or the artifact che
171
170
  npx mobile-tools devices [--platform android|ios] [--json]
172
171
  ```
173
172
 
174
- 1. Android: connects the local MuMu emulators. For each open port in 16384 + 32 n (n from 0 to 15) and 7555 that `adb` does not list as `127.0.0.1:<port>`, it runs `adb connect`. A failed connect is a warning, never an error.
173
+ 1. Android: connects the local MuMu emulators. For each open port in 16384 + 32 n (n from 0 to 15) that `adb` does not list as `127.0.0.1:<port>`, it runs `adb connect`. A failed connect is a warning, never an error.
175
174
  2. Android: lists every ready device once, however many serials reach it.
176
175
  3. iOS (macOS only): lists the booted simulators from `xcrun simctl`. Physical iPhones are not listed, because `run` installs only simulator apps.
177
176
 
package/lib/build.js CHANGED
@@ -1 +1 @@
1
- import{copyFileSync,existsSync,readdirSync}from"node:fs";import path from"node:path";import{buildOrFail,logDir,logStamp}from"./buildLog.js";import{gradleOutputDir,gradleTask,loadToolsConfig,mappingFile,resolveIosProjectName}from"./config.js";import{fail,isJsonOutput,say,sayJson}from"./output.js";import{gradleInvocation,warnLongWindowsPath}from"./platform.js";import{prebuild}from"./prebuild.js";import{ensurePods,requireSynced}from"./sync.js";import{prependXosShims,xosPath,xosSimulatorBuild}from"./xos.js";const DEBUG_SIGNED_SUFFIX="-debugsigned.apk";export const debugSignedProblem=e=>e.debugSigned?"aab"===e.artifact?"--debug-signed builds an apk; an App Bundle is release only and would need the upload key":"ios-sim"===e.artifact?"--debug-signed signs an Android apk; ios-sim builds have no signing":e.debug?"--debug-signed signs the release build; --debug already builds the debug variant, so use one or the other":"Production"===e.env?"--debug-signed is for staging test builds; a Production build must be signed with the upload key":null:null;const debugSignedCopy=e=>{const o=`${e.slice(0,-4)}-debugsigned.apk`;return copyFileSync(e,o),o},buildAndroid=async(e,o,a)=>{const{appRoot:i,env:s}=e;requireSynced(i,{pods:!1});const t=loadToolsConfig(i),n=path.join(i,"android");existsSync(path.join(n,"app","build.gradle"))||fail("appConfigInvalid",`android/app/build.gradle not found in ${i}`),void 0!==e.abis&&e.gradleArgs.some(e=>e.startsWith("-PreactNativeArchitectures"))&&fail("badInput","--arch and a -PreactNativeArchitectures argument after -- both set the Android ABIs: pass only one"),prebuild({appRoot:i,env:s,platform:"android",otaTest:e.otaTest});const r=gradleTask(s,t.flavors,o,a),d=path.join(logDir(i),`gradle-${s}-${logStamp()}.log`),l=void 0===e.abis?[]:[`-PreactNativeArchitectures=${e.abis.join(",")}`],p=e.debugSigned?["-PweborityDebugSigned=true"]:[];warnLongWindowsPath(i),await buildOrFail(gradleInvocation(n,[`:app:${r}`,...l,...p,...e.gradleArgs],process.platform,process.env),n,d,`gradle ${r}`);const g=gradleOutputDir(i,s,t.flavors,o,a),u=existsSync(g)?readdirSync(g,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.${o}`)&&!e.name.endsWith("-debugsigned.apk")).map(e=>path.resolve(g,e.name)).sort():[];0===u.length&&fail("artifactMissing",`the build produced no ${o} in ${g}`);const c=mappingFile(i,s,t.flavors),b="release"===a&&existsSync(c)?c:null;return{artifacts:e.debugSigned?u.map(debugSignedCopy):u,mapping:b,log:d}},buildIos=async(e,o)=>{e.gradleArgs.length>0&&fail("badInput","Gradle arguments after -- apply to apk and aab builds only");const{appRoot:a,env:i}=e,s=xosPath(process.env,process.platform);requireSynced(a,{pods:!1});const t=loadToolsConfig(a),n=resolveIosProjectName(a,t)??fail("appConfigInvalid",`no ios/ folder in ${a}`);prebuild({appRoot:a,env:i,platform:"ios",otaTest:e.otaTest}),prependXosShims(s,a),ensurePods(a,process.platform);const r="release"===o?"Release":"Debug",d=path.join(logDir(a),`xos-${i}-${logStamp()}.log`);return{artifacts:[await xosSimulatorBuild(s,{appRoot:a,projectName:n,configuration:r,arch:e.arch??"x86_64"},d)],mapping:null,log:d}};export const build=async e=>{const o=debugSignedProblem(e);null!==o&&fail("badInput",o);const a=e.debug?"debug":"release",i="ios-sim"===e.artifact?await buildIos(e,a):await buildAndroid(e,e.artifact,a);if(isJsonOutput())sayJson({artifacts:i.artifacts,mapping:i.mapping,log:i.log});else{for(const e of i.artifacts)say(`build: ${e}`);null!==i.mapping&&say(`build: mapping ${i.mapping}`)}};
1
+ import{copyFileSync,existsSync,readdirSync}from"node:fs";import path from"node:path";import{buildOrFail,logDir,logStamp}from"./buildLog.js";import{gradleOutputDir,gradleTask,loadToolsConfig,mappingFile,resolveIosProjectName}from"./config.js";import{fail,isJsonOutput,say,sayJson}from"./output.js";import{gradleInvocation,warnLongWindowsPath}from"./platform.js";import{prebuild}from"./prebuild.js";import{ensurePods,requireSynced}from"./sync.js";import{prependXosToolPath,xosPath,xosSimulatorBuild}from"./xos.js";const DEBUG_SIGNED_SUFFIX="-debugsigned.apk";export const debugSignedProblem=e=>e.debugSigned?"aab"===e.artifact?"--debug-signed builds an apk; an App Bundle is release only and would need the upload key":"ios-sim"===e.artifact?"--debug-signed signs an Android apk; ios-sim builds have no signing":e.debug?"--debug-signed signs the release build; --debug already builds the debug variant, so use one or the other":"Production"===e.env?"--debug-signed is for staging test builds; a Production build must be signed with the upload key":null:null;const debugSignedCopy=e=>{const o=`${e.slice(0,-4)}-debugsigned.apk`;return copyFileSync(e,o),o},buildAndroid=async(e,o,a)=>{const{appRoot:i,env:s}=e;requireSynced(i,{pods:!1});const t=loadToolsConfig(i),n=path.join(i,"android");existsSync(path.join(n,"app","build.gradle"))||fail("appConfigInvalid",`android/app/build.gradle not found in ${i}`),void 0!==e.abis&&e.gradleArgs.some(e=>e.startsWith("-PreactNativeArchitectures"))&&fail("badInput","--arch and a -PreactNativeArchitectures argument after -- both set the Android ABIs: pass only one"),prebuild({appRoot:i,env:s,platform:"android",otaTest:e.otaTest});const r=gradleTask(s,t.flavors,o,a),d=path.join(logDir(i),`gradle-${s}-${logStamp()}.log`),l=void 0===e.abis?[]:[`-PreactNativeArchitectures=${e.abis.join(",")}`],p=e.debugSigned?["-PweborityDebugSigned=true"]:[];warnLongWindowsPath(i),await buildOrFail(gradleInvocation(n,[`:app:${r}`,...l,...p,...e.gradleArgs],process.platform,process.env),n,d,`gradle ${r}`);const g=gradleOutputDir(i,s,t.flavors,o,a),u=existsSync(g)?readdirSync(g,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.${o}`)&&!e.name.endsWith("-debugsigned.apk")).map(e=>path.resolve(g,e.name)).sort():[];0===u.length&&fail("artifactMissing",`the build produced no ${o} in ${g}`);const c=mappingFile(i,s,t.flavors),b="release"===a&&existsSync(c)?c:null;return{artifacts:e.debugSigned?u.map(debugSignedCopy):u,mapping:b,log:d}},buildIos=async(e,o)=>{e.gradleArgs.length>0&&fail("badInput","Gradle arguments after -- apply to apk and aab builds only");const{appRoot:a,env:i}=e,s=xosPath(process.env,process.platform);requireSynced(a,{pods:!1});const t=loadToolsConfig(a),n=resolveIosProjectName(a,t)??fail("appConfigInvalid",`no ios/ folder in ${a}`);prebuild({appRoot:a,env:i,platform:"ios",otaTest:e.otaTest}),prependXosToolPath(s,a),ensurePods(a,process.platform);const r="release"===o?"Release":"Debug",d=path.join(logDir(a),`xos-${i}-${logStamp()}.log`);return{artifacts:[await xosSimulatorBuild(s,{appRoot:a,projectName:n,configuration:r,arch:e.arch??"x86_64"},d)],mapping:null,log:d}};export const build=async e=>{const o=debugSignedProblem(e);null!==o&&fail("badInput",o);const a=e.debug?"debug":"release",i="ios-sim"===e.artifact?await buildIos(e,a):await buildAndroid(e,e.artifact,a);if(isJsonOutput())sayJson({artifacts:i.artifacts,mapping:i.mapping,log:i.log});else{for(const e of i.artifacts)say(`build: ${e}`);null!==i.mapping&&say(`build: mapping ${i.mapping}`)}};
package/lib/devices.d.ts CHANGED
@@ -38,7 +38,7 @@ export declare const pickDevice: <T extends {
38
38
  serials: string[];
39
39
  model: string;
40
40
  }>(devices: T[], requested: string | undefined, describe: (device: T) => string, interactive: boolean) => Promise<T>;
41
- /** adb ports of local emulators adb cannot find alone: MuMu Player 12 instances (16384 + 32 n) and the legacy MuMu port. */
41
+ /** adb ports of local emulators adb cannot find alone: MuMu Player 12 instances (16384 + 32 n). */
42
42
  export declare const LOCAL_EMULATOR_PORTS: readonly number[];
43
43
  /** One listed device, as the devices command prints it in JSON. */
44
44
  export type ListedDevice = ({
package/lib/devices.js CHANGED
@@ -1 +1 @@
1
- import{Socket}from"node:net";import{createInterface}from"node:readline/promises";import{capture}from"./exec.js";import{listAppleDevices}from"./ios.js";import{fail,isJsonOutput,say,sayJson,warn}from"./output.js";import{adbPath,requireDarwin}from"./platform.js";export const parseAdbDevices=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>""!==e&&!e.startsWith("List of devices")&&!e.startsWith("*")).map(e=>{const[t,o=""]=e.split(/\s+/);if(void 0===t)throw new Error("a non-empty adb line starts with its serial");return{serial:t,state:o}});const serialRank=e=>e.startsWith("emulator-")?1:e.includes(":")?2:0,deviceKey=e=>""!==e.serialNo?`${e.serialNo}|${e.androidId}`:/^[0-9a-f]{16}$/i.test(e.androidId)?`android:${e.androidId}`:`serial:${e.serial}`;export const dedupeDevices=e=>{const t=new Map;for(const o of e){const e=deviceKey(o);t.set(e,[...t.get(e)??[],o])}return[...t.values()].map(e=>{const t=[...e].sort((e,t)=>serialRank(e.serial)-serialRank(t.serial)||e.serial.localeCompare(t.serial)),[o]=t;if(void 0===o)throw new Error("a device group holds at least one probe");return{serial:o.serial,serials:t.map(e=>e.serial),model:o.model,abi:o.abi}}).sort((e,t)=>e.serial.localeCompare(t.serial))};const PROBE_SCRIPT="getprop ro.serialno; getprop ro.product.model; getprop ro.product.cpu.abi; settings get secure android_id";export const probeDevice=(e,t,o)=>{const s=capture({file:e,args:["-s",t,"shell",PROBE_SCRIPT]},o);if(0!==s.status)return fail("toolFailed",`adb could not read ${t}: ${s.stderr.trim()||s.stdout.trim()}`);const[r="",i="",a="",n=""]=s.stdout.split(/\r?\n/).map(e=>e.trim());return{serial:t,serialNo:r,model:i,abi:a,androidId:n}};export const listAndroidDevices=(e,t)=>{const o=capture({file:e,args:["devices"]},t);if(0!==o.status)return fail("toolFailed",`adb devices failed: ${o.stderr.trim()}`);const s=parseAdbDevices(o.stdout),r=s.filter(e=>"device"!==e.state),i=s.filter(e=>"device"===e.state);if(0===i.length){const e=r.map(e=>`${e.serial} is ${e.state}`).join("; ");return fail("deviceNotFound",`no Android device ready${e?` (${e})`:""}. Connect a phone with USB debugging, start an emulator, or adb connect host:port.`)}return dedupeDevices(i.map(o=>probeDevice(e,o.serial,t)))};export const describeDevice=e=>`${e.model||"unknown model"} (${e.serial}, ${e.abi})`;export const findDevice=(e,t)=>e.find(e=>e.serials.includes(t))??e.find(e=>e.model.toLowerCase()===t.toLowerCase());export const pickDevice=async(e,t,o,s)=>{const r=e.map((e,t)=>` ${t+1}. ${o(e)}`).join("\n");if(t)return findDevice(e,t)??fail("deviceNotFound",`no device matches --device ${t}. Connected:\n${r}`);const[i]=e;if(1===e.length&&void 0!==i)return i;if(!s)return fail("deviceAmbiguous",`several devices are connected; pass --device <serial|name>:\n${r}`);const a=createInterface({input:process.stdin,output:process.stdout});try{const t=await a.question(`Several devices are connected:\n${r}\nRun on which? [1-${e.length}] `);return e[Number(t.trim())-1]??fail("badInput",`no device numbered ${t.trim()}`)}finally{a.close()}};export const LOCAL_EMULATOR_PORTS=[...Array.from({length:16},(e,t)=>16384+32*t),7555];const isPortOpen=e=>new Promise(t=>{const o=new Socket;o.setTimeout(300),o.once("connect",()=>{o.destroy(),t(!0)}),o.once("timeout",()=>{o.destroy(),t(!1)}),o.once("error",()=>{o.destroy(),t(!1)}),o.connect(e,"127.0.0.1")});export const connectLocalEmulators=async(e,t)=>{const o=(await Promise.all(LOCAL_EMULATOR_PORTS.map(async e=>({port:e,open:await isPortOpen(e)})))).filter(e=>e.open).map(e=>e.port),s=capture({file:e,args:["devices"]},t),r=0===s.status?parseAdbDevices(s.stdout).map(e=>e.serial):[],i=[];for(const s of o){const o=`127.0.0.1:${s}`;if(r.includes(o))continue;const a=capture({file:e,args:["connect",o]},t),n=`${a.stdout}${a.stderr}`.trim();n.includes("connected to")?(say(`devices: connected ${o}`),i.push(o)):warn(`devices: ${o} is open but adb connect said: ${n}`)}return i};export const devices=async e=>{const{appRoot:t,platform:o}=e;let s;if("android"===o){const e=adbPath(process.env,process.platform);await connectLocalEmulators(e,t),s=listAndroidDevices(e,t).map(e=>({platform:"android",...e}))}else requireDarwin(process.platform,"devices --platform ios"),s=listAppleDevices(t).map(e=>({platform:"ios",...e}));if(isJsonOutput())sayJson({devices:s});else for(const e of s)if("android"===e.platform){const t=e.serials.length>1?` (also ${e.serials.slice(1).join(", ")})`:"";say(`${e.serial} ${e.model} ${e.abi}${t}`)}else say(`${e.udid} ${e.name} ${e.kind}`)};
1
+ import{Socket}from"node:net";import{createInterface}from"node:readline/promises";import{capture}from"./exec.js";import{listAppleDevices}from"./ios.js";import{fail,isJsonOutput,say,sayJson,warn}from"./output.js";import{adbPath,requireDarwin}from"./platform.js";export const parseAdbDevices=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>""!==e&&!e.startsWith("List of devices")&&!e.startsWith("*")).map(e=>{const[t,o=""]=e.split(/\s+/);if(void 0===t)throw new Error("a non-empty adb line starts with its serial");return{serial:t,state:o}});const serialRank=e=>e.startsWith("emulator-")?1:e.includes(":")?2:0,deviceKey=e=>""!==e.serialNo?`${e.serialNo}|${e.androidId}`:/^[0-9a-f]{16}$/i.test(e.androidId)?`android:${e.androidId}`:`serial:${e.serial}`;export const dedupeDevices=e=>{const t=new Map;for(const o of e){const e=deviceKey(o);t.set(e,[...t.get(e)??[],o])}return[...t.values()].map(e=>{const t=[...e].sort((e,t)=>serialRank(e.serial)-serialRank(t.serial)||e.serial.localeCompare(t.serial)),[o]=t;if(void 0===o)throw new Error("a device group holds at least one probe");return{serial:o.serial,serials:t.map(e=>e.serial),model:o.model,abi:o.abi}}).sort((e,t)=>e.serial.localeCompare(t.serial))};const PROBE_SCRIPT="getprop ro.serialno; getprop ro.product.model; getprop ro.product.cpu.abi; settings get secure android_id";export const probeDevice=(e,t,o)=>{const s=capture({file:e,args:["-s",t,"shell",PROBE_SCRIPT]},o);if(0!==s.status)return fail("toolFailed",`adb could not read ${t}: ${s.stderr.trim()||s.stdout.trim()}`);const[r="",i="",a="",n=""]=s.stdout.split(/\r?\n/).map(e=>e.trim());return{serial:t,serialNo:r,model:i,abi:a,androidId:n}};export const listAndroidDevices=(e,t)=>{const o=capture({file:e,args:["devices"]},t);if(0!==o.status)return fail("toolFailed",`adb devices failed: ${o.stderr.trim()}`);const s=parseAdbDevices(o.stdout),r=s.filter(e=>"device"!==e.state),i=s.filter(e=>"device"===e.state);if(0===i.length){const e=r.map(e=>`${e.serial} is ${e.state}`).join("; ");return fail("deviceNotFound",`no Android device ready${e?` (${e})`:""}. Connect a phone with USB debugging, start an emulator, or adb connect host:port.`)}return dedupeDevices(i.map(o=>probeDevice(e,o.serial,t)))};export const describeDevice=e=>`${e.model||"unknown model"} (${e.serial}, ${e.abi})`;export const findDevice=(e,t)=>e.find(e=>e.serials.includes(t))??e.find(e=>e.model.toLowerCase()===t.toLowerCase());export const pickDevice=async(e,t,o,s)=>{const r=e.map((e,t)=>` ${t+1}. ${o(e)}`).join("\n");if(t)return findDevice(e,t)??fail("deviceNotFound",`no device matches --device ${t}. Connected:\n${r}`);const[i]=e;if(1===e.length&&void 0!==i)return i;if(!s)return fail("deviceAmbiguous",`several devices are connected; pass --device <serial|name>:\n${r}`);const a=createInterface({input:process.stdin,output:process.stdout});try{const t=await a.question(`Several devices are connected:\n${r}\nRun on which? [1-${e.length}] `);return e[Number(t.trim())-1]??fail("badInput",`no device numbered ${t.trim()}`)}finally{a.close()}};export const LOCAL_EMULATOR_PORTS=Array.from({length:16},(e,t)=>16384+32*t);const isPortOpen=e=>new Promise(t=>{const o=new Socket;o.setTimeout(300),o.once("connect",()=>{o.destroy(),t(!0)}),o.once("timeout",()=>{o.destroy(),t(!1)}),o.once("error",()=>{o.destroy(),t(!1)}),o.connect(e,"127.0.0.1")});export const connectLocalEmulators=async(e,t)=>{const o=(await Promise.all(LOCAL_EMULATOR_PORTS.map(async e=>({port:e,open:await isPortOpen(e)})))).filter(e=>e.open).map(e=>e.port),s=capture({file:e,args:["devices"]},t),r=0===s.status?parseAdbDevices(s.stdout).map(e=>e.serial):[],i=[];for(const s of o){const o=`127.0.0.1:${s}`;if(r.includes(o))continue;const a=capture({file:e,args:["connect",o]},t),n=`${a.stdout}${a.stderr}`.trim();n.includes("connected to")?(say(`devices: connected ${o}`),i.push(o)):warn(`devices: ${o} is open but adb connect said: ${n}`)}return i};export const devices=async e=>{const{appRoot:t,platform:o}=e;let s;if("android"===o){const e=adbPath(process.env,process.platform);await connectLocalEmulators(e,t),s=listAndroidDevices(e,t).map(e=>({platform:"android",...e}))}else requireDarwin(process.platform,"devices --platform ios"),s=listAppleDevices(t).map(e=>({platform:"ios",...e}));if(isJsonOutput())sayJson({devices:s});else for(const e of s)if("android"===e.platform){const t=e.serials.length>1?` (also ${e.serials.slice(1).join(", ")})`:"";say(`${e.serial} ${e.model} ${e.abi}${t}`)}else say(`${e.udid} ${e.name} ${e.kind}`)};
package/lib/sync.d.ts CHANGED
@@ -6,7 +6,7 @@ export type PackageManager = "npm" | "pnpm";
6
6
  export interface InstallStamp {
7
7
  hash: string;
8
8
  manager: PackageManager;
9
- nativePackages?: Record<string, string>;
9
+ nativePackages: Record<string, string>;
10
10
  }
11
11
  export declare const lockfileOf: (appRoot: string) => {
12
12
  manager: PackageManager;
package/lib/sync.js CHANGED
@@ -1 +1 @@
1
- import{createHash}from"node:crypto";import{existsSync,readdirSync,readFileSync,rmSync,statSync,writeFileSync}from"node:fs";import path from"node:path";import{isRecord}from"./config.js";import{capture,runInherit}from"./exec.js";import{CliError,fail,say}from"./output.js";import{findOnPath,gradleInvocation,npmInvocation,pnpmInvocation}from"./platform.js";import{prependXosShims,xosPath}from"./xos.js";export const STAMP_FILE=path.join("node_modules",".webority-install.json");export const PODS_RECORD=path.join("ios","Pods",".webority-native.json");const INSTALL_FIELDS=["dependencies","devDependencies","optionalDependencies","peerDependencies","bundleDependencies","overrides","resolutions","pnpm","workspaces"];export const lockfileOf=e=>{const s=path.join(e,"pnpm-lock.yaml"),o=path.join(e,"package-lock.json");return existsSync(s)&&existsSync(o)?fail("appConfigInvalid","both pnpm-lock.yaml and package-lock.json exist: delete the one not in use"):existsSync(s)?{manager:"pnpm",file:s}:existsSync(o)?{manager:"npm",file:o}:fail("appConfigInvalid",`no package-lock.json or pnpm-lock.yaml in ${e}`)};const filesUnder=(e,s="")=>readdirSync(e,{withFileTypes:!0}).flatMap(o=>{const n=""===s?o.name:`${s}/${o.name}`;return o.isDirectory()?filesUnder(path.join(e,o.name),n):[n]}).sort();export const installHash=e=>{const{file:s}=lockfileOf(e),o=JSON.parse(readFileSync(path.join(e,"package.json"),"utf8"));if(!isRecord(o))return fail("appConfigInvalid",`${path.join(e,"package.json")} must hold a JSON object`);const n=createHash("sha256");n.update(`lockfile:${path.basename(s)}\0`),n.update(readFileSync(s)),n.update("\0package.json\0"),n.update(JSON.stringify(INSTALL_FIELDS.map(e=>[e,o[e]??null])));const t=path.join(e,"patches");if(existsSync(t))for(const e of filesUnder(t))n.update(`\0patches/${e}\0`),n.update(readFileSync(path.join(t,...e.split("/"))));return n.digest("hex")};const isInstallStamp=e=>isRecord(e)&&"string"==typeof e.hash&&("npm"===e.manager||"pnpm"===e.manager)&&(void 0===e.nativePackages||isRecord(e.nativePackages)&&Object.values(e.nativePackages).every(e=>"string"==typeof e));export const readStamp=e=>{const s=path.join(e,STAMP_FILE);if(existsSync(s))try{const e=JSON.parse(readFileSync(s,"utf8"));return isInstallStamp(e)?e:void 0}catch{return}};const POD_FIX="cd ios && pod install",hasXos=e=>void 0!==findOnPath("xos",process.env,e),installsPods=e=>"darwin"===e||hasXos(e);export const podsStale=e=>{const s=path.join(e,"ios","Podfile.lock"),o=path.join(e,"ios","Pods","Manifest.lock");return!(!existsSync(s)||!existsSync(o))&&!readFileSync(s).equals(readFileSync(o))};const nodeModulesNewerThanPods=e=>{const s=[path.join(e,"node_modules",".modules.yaml"),path.join(e,"node_modules",".pnpm","lock.yaml")].find(e=>existsSync(e)),o=path.join(e,"ios","Pods","Manifest.lock");return!(!s||!existsSync(o))&&statSync(s).mtimeMs>statSync(o).mtimeMs};export const checkSync=(e,s,o=!0)=>{const n=[],t=readStamp(e),{file:a}=lockfileOf(e);if(t?t.hash!==installHash(e)&&n.push(`node_modules is stale: ${path.basename(a)}, package.json or patches/ changed since the last install. Fix: npx mobile-tools sync`):n.push("node_modules has no install stamp (never installed through mobile-tools). Fix: npx mobile-tools sync"),t){const s=changedNativePackages(t.nativePackages??{},nativePackages(e));s.length>0&&n.push(`node_modules native packages changed since the last install: ${s.join(", ")}. Fix: npx mobile-tools sync`)}const i=o&&installsPods(s);return i&&podsStale(e)&&n.push(`ios/Pods is stale: ios/Podfile.lock differs from ios/Pods/Manifest.lock. Fix: ${POD_FIX}`),i&&existsSync(path.join(e,"ios","Podfile.lock"))&&nodeModulesNewerThanPods(e)&&n.push("node_modules changed after the last pod install; run pod install in ios/ (or mobile-tools sync)"),n};export const requireSynced=(e,{pods:s})=>{const o=checkSync(e,process.platform,s);o.length>0&&fail("installStale",o.join("\n"))};export const nativePackages=e=>{const s=path.join(e,"node_modules");if(!existsSync(s))return{};const o=[];for(const e of readdirSync(s,{withFileTypes:!0}))if(!e.name.startsWith(".")&&e.isDirectory())if(e.name.startsWith("@"))for(const n of readdirSync(path.join(s,e.name),{withFileTypes:!0}))n.isDirectory()&&o.push(path.join(s,e.name,n.name));else o.push(path.join(s,e.name));const n={};for(const e of o){const s=path.join(e,"android"),o=path.join(e,"package.json");if(existsSync(s)&&statSync(s).isDirectory()&&existsSync(o))try{const e=JSON.parse(readFileSync(o,"utf8"));isRecord(e)&&"string"==typeof e.name&&"string"==typeof e.version&&""!==e.name&&""!==e.version&&(n[e.name]=e.version)}catch(e){fail("toolFailed",`${o} is not valid package.json, so its native package cannot be read: ${e instanceof Error?e.message:String(e)}`)}}return n};export const changedNativePackages=(e,s)=>[...new Set([...Object.keys(e),...Object.keys(s)])].filter(o=>e[o]!==s[o]).sort();const POD_INPUT_FILES=["ios/Podfile","ios/Podfile.properties.json"],podInputsHash=e=>{const s=createHash("sha256");for(const o of POD_INPUT_FILES){const n=path.join(e,...o.split("/"));s.update(`${o}\0`),existsSync(n)&&s.update(readFileSync(n))}return s.digest("hex")};export const podsRecord=e=>JSON.stringify({nativePackages:nativePackages(e),podInputs:podInputsHash(e)});export const writeStamp=e=>{const{manager:s}=lockfileOf(e),o={hash:installHash(e),manager:s,nativePackages:nativePackages(e)};return writeFileSync(path.join(e,STAMP_FILE),`${JSON.stringify(o,null,2)}\n`,"utf8"),o};export const installInvocation=(e,s)=>"pnpm"===e?pnpmInvocation(["install","--frozen-lockfile"],process.env,s,process.execPath):npmInvocation(["ci"],process.env,s,process.execPath);export const localPathPods=e=>{const s=[];let o,n=!1;for(const t of e.split(/\r?\n/)){if(/^\S/.test(t)){n="EXTERNAL SOURCES:"===t,o=void 0;continue}if(!n)continue;const e=/^ {2}"?([^"\s:]+)"?:$/.exec(t);e?o=e[1]:void 0!==o&&/^ {4}:path:/.test(t)&&(s.push(o),o=void 0)}return s};const recordChange=(e,s)=>{let o;try{o=JSON.parse(e)}catch{return"the pod install record is from an older mobile-tools"}return isRecord(o)&&"string"==typeof o.podInputs&&isRecord(o.nativePackages)?o.podInputs!==podInputsHash(s)?"ios/Podfile or ios/Podfile.properties.json changed since the last pod install":JSON.stringify(o.nativePackages)!==JSON.stringify(nativePackages(s))?"native packages changed since the last pod install":void 0:"the pod install record is from an older mobile-tools"},POD_VERSION_MOVED=/changed the version of the dependency|pod update/,runPod=(e,s,o)=>{const n=capture({file:e,args:s},o);return-1===n.status&&fail("toolFailed",`pod ${s[0]} could not start: ${n.stderr}`),process.stdout.write(n.stdout),process.stderr.write(n.stderr),n};export const ensurePods=(e,s)=>{if(!existsSync(path.join(e,"ios","Podfile")))return;const o=path.join(e,"ios","Pods"),n=path.join(e,PODS_RECORD);let t;if(t=existsSync(o)?existsSync(path.join(e,"ios","Podfile.lock"))?existsSync(path.join(o,"Manifest.lock"))?podsStale(e)?"ios/Podfile.lock differs from ios/Pods/Manifest.lock":nodeModulesNewerThanPods(e)?"node_modules changed after the last pod install":existsSync(n)?recordChange(readFileSync(n,"utf8"),e):"no pod install record":"ios/Pods/Manifest.lock is missing":"ios/Podfile.lock is missing":"ios/Pods is missing",void 0===t)return void say("pods: up to date with ios/Podfile.lock and the Podfile settings");say(`pods: ${t}; running pod install`);const a=findOnPath("pod",process.env,s);if(!a){const e=hasXos(s)?"check xos doctor --json names its shims folder":"install CocoaPods (brew install cocoapods)";throw new CliError("toolMissing",`pod not found on PATH; ${e}, then ${POD_FIX}`)}const i=path.join(e,"ios");let c=runPod(a,["install"],i);if(0!==c.status&&POD_VERSION_MOVED.test(`${c.stdout}${c.stderr}`)){const e=path.join(i,"Podfile.lock"),s=existsSync(e)?localPathPods(readFileSync(e,"utf8")):[];s.length>0&&(say(`pods: updating ${s.length} local pods moved by a package upgrade`),c=runPod(a,["update",...s,"--no-repo-update"],i),0!==c.status&&fail("toolFailed",`pod update failed (exit ${c.status})`))}0!==c.status&&fail("toolFailed",`pod install failed (exit ${c.status})`);const r=path.join(e,"ios","build","ModuleCache.noindex");existsSync(r)&&(rmSync(r,{recursive:!0,force:!0}),say(`sync: removed ${path.relative(e,r)}`)),writeFileSync(n,podsRecord(e),"utf8")};export const sync=(e,s)=>{const{manager:o}=lockfileOf(e),n=readStamp(e)?.nativePackages??nativePackages(e);say("sync: "+("pnpm"===o?"pnpm install --frozen-lockfile":"npm ci")),runInherit(installInvocation(o,s),e,`${o} install`);const t=writeStamp(e).nativePackages,a=changedNativePackages(n,t),i=path.join(e,"android"),c=existsSync(path.join(i,"app",".cxx"))||existsSync(path.join(i,"app","build"));if(a.length>0&&c){say(`sync: native packages changed (${a.join(", ")}): regenerating codegen`),runInherit(gradleInvocation(i,["generateCodegenArtifactsFromSchema"],s,process.env),i,"gradlew generateCodegenArtifactsFromSchema");for(const s of[path.join(i,"app",".cxx"),path.join(i,"app","build","generated","autolinking")])rmSync(s,{recursive:!0,force:!0}),say(`sync: removed ${path.relative(e,s)}`)}installsPods(s)&&existsSync(path.join(e,"ios","Podfile"))&&(hasXos(s)&&prependXosShims(xosPath(process.env,s),e),ensurePods(e,s)),say("sync: done")};
1
+ import{createHash}from"node:crypto";import{existsSync,readdirSync,readFileSync,rmSync,statSync,writeFileSync}from"node:fs";import path from"node:path";import{isRecord}from"./config.js";import{capture,runInherit}from"./exec.js";import{CliError,fail,say}from"./output.js";import{findOnPath,gradleInvocation,npmInvocation,pnpmInvocation}from"./platform.js";import{prependXosToolPath,xosPath}from"./xos.js";export const STAMP_FILE=path.join("node_modules",".webority-install.json");export const PODS_RECORD=path.join("ios","Pods",".webority-native.json");const INSTALL_FIELDS=["dependencies","devDependencies","optionalDependencies","peerDependencies","bundleDependencies","overrides","resolutions","pnpm","workspaces"];export const lockfileOf=e=>{const s=path.join(e,"pnpm-lock.yaml"),o=path.join(e,"package-lock.json");return existsSync(s)&&existsSync(o)?fail("appConfigInvalid","both pnpm-lock.yaml and package-lock.json exist: delete the one not in use"):existsSync(s)?{manager:"pnpm",file:s}:existsSync(o)?{manager:"npm",file:o}:fail("appConfigInvalid",`no package-lock.json or pnpm-lock.yaml in ${e}`)};const filesUnder=(e,s="")=>readdirSync(e,{withFileTypes:!0}).flatMap(o=>{const n=""===s?o.name:`${s}/${o.name}`;return o.isDirectory()?filesUnder(path.join(e,o.name),n):[n]}).sort();export const installHash=e=>{const{file:s}=lockfileOf(e),o=JSON.parse(readFileSync(path.join(e,"package.json"),"utf8"));if(!isRecord(o))return fail("appConfigInvalid",`${path.join(e,"package.json")} must hold a JSON object`);const n=createHash("sha256");n.update(`lockfile:${path.basename(s)}\0`),n.update(readFileSync(s)),n.update("\0package.json\0"),n.update(JSON.stringify(INSTALL_FIELDS.map(e=>[e,o[e]??null])));const t=path.join(e,"patches");if(existsSync(t))for(const e of filesUnder(t))n.update(`\0patches/${e}\0`),n.update(readFileSync(path.join(t,...e.split("/"))));return n.digest("hex")};const isInstallStamp=e=>isRecord(e)&&"string"==typeof e.hash&&("npm"===e.manager||"pnpm"===e.manager)&&isRecord(e.nativePackages)&&Object.values(e.nativePackages).every(e=>"string"==typeof e);export const readStamp=e=>{const s=path.join(e,STAMP_FILE);if(existsSync(s))try{const e=JSON.parse(readFileSync(s,"utf8"));return isInstallStamp(e)?e:void 0}catch{return}};const POD_FIX="cd ios && pod install",hasXos=e=>void 0!==findOnPath("xos",process.env,e),installsPods=e=>"darwin"===e||hasXos(e);export const podsStale=e=>{const s=path.join(e,"ios","Podfile.lock"),o=path.join(e,"ios","Pods","Manifest.lock");return!(!existsSync(s)||!existsSync(o))&&!readFileSync(s).equals(readFileSync(o))};const nodeModulesNewerThanPods=e=>{const s=[path.join(e,"node_modules",".modules.yaml"),path.join(e,"node_modules",".pnpm","lock.yaml")].find(e=>existsSync(e)),o=path.join(e,"ios","Pods","Manifest.lock");return!(!s||!existsSync(o))&&statSync(s).mtimeMs>statSync(o).mtimeMs};export const checkSync=(e,s,o=!0)=>{const n=[],t=readStamp(e),{file:a}=lockfileOf(e);if(t?t.hash!==installHash(e)&&n.push(`node_modules is stale: ${path.basename(a)}, package.json or patches/ changed since the last install. Fix: npx mobile-tools sync`):n.push("node_modules has no install stamp (never installed through mobile-tools). Fix: npx mobile-tools sync"),t){const s=changedNativePackages(t.nativePackages,nativePackages(e));s.length>0&&n.push(`node_modules native packages changed since the last install: ${s.join(", ")}. Fix: npx mobile-tools sync`)}const i=o&&installsPods(s);return i&&podsStale(e)&&n.push(`ios/Pods is stale: ios/Podfile.lock differs from ios/Pods/Manifest.lock. Fix: ${POD_FIX}`),i&&existsSync(path.join(e,"ios","Podfile.lock"))&&nodeModulesNewerThanPods(e)&&n.push("node_modules changed after the last pod install; run pod install in ios/ (or mobile-tools sync)"),n};export const requireSynced=(e,{pods:s})=>{const o=checkSync(e,process.platform,s);o.length>0&&fail("installStale",o.join("\n"))};export const nativePackages=e=>{const s=path.join(e,"node_modules");if(!existsSync(s))return{};const o=[];for(const e of readdirSync(s,{withFileTypes:!0}))if(!e.name.startsWith(".")&&e.isDirectory())if(e.name.startsWith("@"))for(const n of readdirSync(path.join(s,e.name),{withFileTypes:!0}))n.isDirectory()&&o.push(path.join(s,e.name,n.name));else o.push(path.join(s,e.name));const n={};for(const e of o){const s=path.join(e,"android"),o=path.join(e,"package.json");if(existsSync(s)&&statSync(s).isDirectory()&&existsSync(o))try{const e=JSON.parse(readFileSync(o,"utf8"));isRecord(e)&&"string"==typeof e.name&&"string"==typeof e.version&&""!==e.name&&""!==e.version&&(n[e.name]=e.version)}catch(e){fail("toolFailed",`${o} is not valid package.json, so its native package cannot be read: ${e instanceof Error?e.message:String(e)}`)}}return n};export const changedNativePackages=(e,s)=>[...new Set([...Object.keys(e),...Object.keys(s)])].filter(o=>e[o]!==s[o]).sort();const POD_INPUT_FILES=["ios/Podfile","ios/Podfile.properties.json"],podInputsHash=e=>{const s=createHash("sha256");for(const o of POD_INPUT_FILES){const n=path.join(e,...o.split("/"));s.update(`${o}\0`),existsSync(n)&&s.update(readFileSync(n))}return s.digest("hex")};export const podsRecord=e=>JSON.stringify({nativePackages:nativePackages(e),podInputs:podInputsHash(e)});export const writeStamp=e=>{const{manager:s}=lockfileOf(e),o={hash:installHash(e),manager:s,nativePackages:nativePackages(e)};return writeFileSync(path.join(e,STAMP_FILE),`${JSON.stringify(o,null,2)}\n`,"utf8"),o};export const installInvocation=(e,s)=>"pnpm"===e?pnpmInvocation(["install","--frozen-lockfile"],process.env,s,process.execPath):npmInvocation(["ci"],process.env,s,process.execPath);export const localPathPods=e=>{const s=[];let o,n=!1;for(const t of e.split(/\r?\n/)){if(/^\S/.test(t)){n="EXTERNAL SOURCES:"===t,o=void 0;continue}if(!n)continue;const e=/^ {2}"?([^"\s:]+)"?:$/.exec(t);e?o=e[1]:void 0!==o&&/^ {4}:path:/.test(t)&&(s.push(o),o=void 0)}return s};const recordChange=(e,s)=>{let o;try{o=JSON.parse(e)}catch{return"the pod install record is unreadable"}return isRecord(o)&&"string"==typeof o.podInputs&&isRecord(o.nativePackages)?o.podInputs!==podInputsHash(s)?"ios/Podfile or ios/Podfile.properties.json changed since the last pod install":JSON.stringify(o.nativePackages)!==JSON.stringify(nativePackages(s))?"native packages changed since the last pod install":void 0:"the pod install record is incomplete"},POD_VERSION_MOVED=/changed the version of the dependency|pod update/,runPod=(e,s,o)=>{const n=capture({file:e,args:s},o);return-1===n.status&&fail("toolFailed",`pod ${s[0]} could not start: ${n.stderr}`),process.stdout.write(n.stdout),process.stderr.write(n.stderr),n};export const ensurePods=(e,s)=>{if(!existsSync(path.join(e,"ios","Podfile")))return;const o=path.join(e,"ios","Pods"),n=path.join(e,PODS_RECORD);let t;if(t=existsSync(o)?existsSync(path.join(e,"ios","Podfile.lock"))?existsSync(path.join(o,"Manifest.lock"))?podsStale(e)?"ios/Podfile.lock differs from ios/Pods/Manifest.lock":nodeModulesNewerThanPods(e)?"node_modules changed after the last pod install":existsSync(n)?recordChange(readFileSync(n,"utf8"),e):"no pod install record":"ios/Pods/Manifest.lock is missing":"ios/Podfile.lock is missing":"ios/Pods is missing",void 0===t)return void say("pods: up to date with ios/Podfile.lock and the Podfile settings");say(`pods: ${t}; running pod install`);const a=findOnPath("pod",process.env,s);if(!a){const e=hasXos(s)?"check xos doctor --json names its shims folder":"install CocoaPods (brew install cocoapods)";throw new CliError("toolMissing",`pod not found on PATH; ${e}, then ${POD_FIX}`)}const i=path.join(e,"ios");let c=runPod(a,["install"],i);if(0!==c.status&&POD_VERSION_MOVED.test(`${c.stdout}${c.stderr}`)){const e=path.join(i,"Podfile.lock"),s=existsSync(e)?localPathPods(readFileSync(e,"utf8")):[];s.length>0&&(say(`pods: updating ${s.length} local pods moved by a package upgrade`),c=runPod(a,["update",...s,"--no-repo-update"],i),0!==c.status&&fail("toolFailed",`pod update failed (exit ${c.status})`))}0!==c.status&&fail("toolFailed",`pod install failed (exit ${c.status})`);const r=path.join(e,"ios","build","ModuleCache.noindex");existsSync(r)&&(rmSync(r,{recursive:!0,force:!0}),say(`sync: removed ${path.relative(e,r)}`)),writeFileSync(n,podsRecord(e),"utf8")};export const sync=(e,s)=>{const{manager:o}=lockfileOf(e),n=readStamp(e)?.nativePackages??nativePackages(e);say("sync: "+("pnpm"===o?"pnpm install --frozen-lockfile":"npm ci")),runInherit(installInvocation(o,s),e,`${o} install`);const t=writeStamp(e).nativePackages,a=changedNativePackages(n,t),i=path.join(e,"android"),c=existsSync(path.join(i,"app",".cxx"))||existsSync(path.join(i,"app","build"));if(a.length>0&&c){say(`sync: native packages changed (${a.join(", ")}): regenerating codegen`),runInherit(gradleInvocation(i,["generateCodegenArtifactsFromSchema"],s,process.env),i,"gradlew generateCodegenArtifactsFromSchema");for(const s of[path.join(i,"app",".cxx"),path.join(i,"app","build","generated","autolinking")])rmSync(s,{recursive:!0,force:!0}),say(`sync: removed ${path.relative(e,s)}`)}installsPods(s)&&existsSync(path.join(e,"ios","Podfile"))&&(hasXos(s)&&prependXosToolPath(xosPath(process.env,s),e),ensurePods(e,s)),say("sync: done")};
package/lib/xos.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare const XOS_MISSING_MESSAGE = "xos not found on PATH. iOS simulator
13
13
  /** xos on PATH, else toolMissing with the recipe for building on a host that has xos. */
14
14
  export declare const xosPath: (env: Env, platform: HostPlatform) => string;
15
15
  /** Puts the shim folder `xos doctor --json` names (field `shims`) first on this process's PATH, as ios-release.sh does before pod install. */
16
- export declare const prependXosShims: (xos: string, cwd: string) => void;
16
+ export declare const prependXosToolPath: (xos: string, cwd: string) => void;
17
17
  /** Where an ios-sim build writes its pods, intermediates and app. */
18
18
  export declare const simulatorBuildDir: (appRoot: string, configuration: IosConfiguration) => string;
19
19
  /** `xos build --pods` then `xos app` for the simulator, both into `log`; returns the absolute path of <projectName>.app. */
package/lib/xos.js CHANGED
@@ -1 +1 @@
1
- import{existsSync,readdirSync}from"node:fs";import path from"node:path";import{buildOrFail}from"./buildLog.js";import{capture}from"./exec.js";import{fail}from"./output.js";import{findOnPath}from"./platform.js";export const SIMULATOR_ARCHS=["x86_64","arm64"];export const XOS_MISSING_MESSAGE="xos not found on PATH. iOS simulator apps build with xOS Tools on a build host, not on this machine. Run npx mobile-tools build --env <Env> --artifact ios-sim --debug --arch arm64 on a host that has xos, copy the resulting .app here, then npx mobile-tools run --env <Env> --platform ios --app <path.app>.";export const xosPath=(o,t)=>findOnPath("xos",o,t)??fail("toolMissing",XOS_MISSING_MESSAGE);export const prependXosShims=(o,t)=>{const i=capture({file:o,args:["doctor","--json"]},t);let s;0!==i.status&&fail("toolMissing",`xos doctor failed: ${i.stderr.trim()}`);try{s=JSON.parse(i.stdout).shims}catch{s=void 0}"string"!=typeof s&&fail("toolFailed","xos doctor --json printed no string field shims: reinstall xOS Tools, then run xos doctor --json and check it prints shims"),process.env.PATH=s+path.delimiter+(process.env.PATH??"")};export const simulatorBuildDir=(o,t)=>path.join(o,"ios","build","xos",`${t}-iphonesimulator`);export const xosSimulatorBuild=async(o,t,i)=>{const{appRoot:s,projectName:a,configuration:r,arch:n}=t,e=simulatorBuildDir(s,r);await buildOrFail({file:o,args:["build","--pods",path.join("ios","Pods"),"--build-dir",e,"--configuration",r,"--platform","iossimulator","--arch",n,"--jobs","0"]},s,i,"xos build --pods"),await buildOrFail({file:o,args:["app","--project",path.join("ios",`${a}.xcodeproj`),"--target",a,"--configuration",r,"--platform","iossimulator","--arch",n,"--build-dir",e,"--assets",path.join("ios",a,"Images.xcassets"),"--jobs","0"]},s,i,"xos app");const subfolders=o=>existsSync(o)?readdirSync(o,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(t=>path.join(o,t.name)):[],p=`${a}.app`,l=subfolders(e),d=[...l,...l.flatMap(subfolders)].find(o=>path.basename(o)===p)??fail("artifactMissing",`the build produced no ${p} in ${e}: read the xos log at ${i}`);return path.resolve(d)};
1
+ import{existsSync,readdirSync}from"node:fs";import path from"node:path";import{buildOrFail}from"./buildLog.js";import{capture}from"./exec.js";import{fail}from"./output.js";import{findOnPath}from"./platform.js";export const SIMULATOR_ARCHS=["x86_64","arm64"];export const XOS_MISSING_MESSAGE="xos not found on PATH. iOS simulator apps build with xOS Tools on a build host, not on this machine. Run npx mobile-tools build --env <Env> --artifact ios-sim --debug --arch arm64 on a host that has xos, copy the resulting .app here, then npx mobile-tools run --env <Env> --platform ios --app <path.app>.";export const xosPath=(o,t)=>findOnPath("xos",o,t)??fail("toolMissing",XOS_MISSING_MESSAGE);export const prependXosToolPath=(o,t)=>{const i=capture({file:o,args:["doctor","--json"]},t);let s;0!==i.status&&fail("toolMissing",`xos doctor failed: ${i.stderr.trim()}`);try{s=JSON.parse(i.stdout).shims}catch{s=void 0}"string"!=typeof s&&fail("toolFailed","xos doctor --json printed no string field shims: reinstall xOS Tools, then run xos doctor --json and check it prints shims"),process.env.PATH=s+path.delimiter+(process.env.PATH??"")};export const simulatorBuildDir=(o,t)=>path.join(o,"ios","build","xos",`${t}-iphonesimulator`);export const xosSimulatorBuild=async(o,t,i)=>{const{appRoot:s,projectName:a,configuration:r,arch:n}=t,e=simulatorBuildDir(s,r);await buildOrFail({file:o,args:["build","--pods",path.join("ios","Pods"),"--build-dir",e,"--configuration",r,"--platform","iossimulator","--arch",n,"--jobs","0"]},s,i,"xos build --pods"),await buildOrFail({file:o,args:["app","--project",path.join("ios",`${a}.xcodeproj`),"--target",a,"--configuration",r,"--platform","iossimulator","--arch",n,"--build-dir",e,"--assets",path.join("ios",a,"Images.xcassets"),"--jobs","0"]},s,i,"xos app");const subfolders=o=>existsSync(o)?readdirSync(o,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(t=>path.join(o,t.name)):[],p=`${a}.app`,l=subfolders(e),d=[...l,...l.flatMap(subfolders)].find(o=>path.basename(o)===p)??fail("artifactMissing",`the build produced no ${p} in ${e}: read the xos log at ${i}`);return path.resolve(d)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-tools",
3
- "version": "0.175.0",
3
+ "version": "0.177.0",
4
4
  "description": "Dev-time CLI for Webority React Native apps: one prebuild, a dependency guard, a device-aware run and per-environment launcher icons, the same on Windows and macOS.",
5
5
  "keywords": [
6
6
  "react-native",