@webority/mobile-tools 0.147.0 → 0.149.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/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:!0});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{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}`)}};
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{capture,runInherit}from"./exec.js";import{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"),n=path.join(e,"package-lock.json");return existsSync(s)&&existsSync(n)?fail("appConfigInvalid","both pnpm-lock.yaml and package-lock.json exist: delete the one not in use"):existsSync(s)?{manager:"pnpm",file:s}:existsSync(n)?{manager:"npm",file:n}:fail("appConfigInvalid",`no package-lock.json or pnpm-lock.yaml in ${e}`)};const filesUnder=(e,s="")=>readdirSync(e,{withFileTypes:!0}).flatMap(n=>{const o=""===s?n.name:`${s}/${n.name}`;return n.isDirectory()?filesUnder(path.join(e,n.name),o):[o]}).sort();export const installHash=e=>{const{file:s}=lockfileOf(e),n=JSON.parse(readFileSync(path.join(e,"package.json"),"utf8")),o=createHash("sha256");o.update(`lockfile:${path.basename(s)}\0`),o.update(readFileSync(s)),o.update("\0package.json\0"),o.update(JSON.stringify(INSTALL_FIELDS.map(e=>[e,n[e]??null])));const t=path.join(e,"patches");if(existsSync(t))for(const e of filesUnder(t))o.update(`\0patches/${e}\0`),o.update(readFileSync(path.join(t,...e.split("/"))));return o.digest("hex")};export const readStamp=e=>{const s=path.join(e,STAMP_FILE);if(existsSync(s))try{return JSON.parse(readFileSync(s,"utf8"))}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"),n=path.join(e,"ios","Pods","Manifest.lock");return!(!existsSync(s)||!existsSync(n))&&!readFileSync(s).equals(readFileSync(n))};const nodeModulesNewerThanPods=e=>{const s=[path.join(e,"node_modules",".modules.yaml"),path.join(e,"node_modules",".pnpm","lock.yaml")].find(e=>existsSync(e)),n=path.join(e,"ios","Pods","Manifest.lock");return!(!s||!existsSync(n))&&statSync(s).mtimeMs>statSync(n).mtimeMs};export const checkSync=(e,s,n=!0)=>{const o=[],t=readStamp(e),{file:a}=lockfileOf(e);if(t?t.hash!==installHash(e)&&o.push(`node_modules is stale: ${path.basename(a)}, package.json or patches/ changed since the last install. Fix: npx mobile-tools sync`):o.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&&o.push(`node_modules native packages changed since the last install: ${s.join(", ")}. Fix: npx mobile-tools sync`)}const i=n&&installsPods(s);return i&&podsStale(e)&&o.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)&&o.push("node_modules changed after the last pod install; run pod install in ios/ (or mobile-tools sync)"),o};export const requireSynced=(e,{pods:s})=>{const n=checkSync(e,process.platform,s);n.length>0&&fail("installStale",n.join("\n"))};export const nativePackages=e=>{const s=path.join(e,"node_modules");if(!existsSync(s))return{};const n=[];for(const e of readdirSync(s,{withFileTypes:!0}))if(!e.name.startsWith(".")&&e.isDirectory())if(e.name.startsWith("@"))for(const o of readdirSync(path.join(s,e.name),{withFileTypes:!0}))o.isDirectory()&&n.push(path.join(s,e.name,o.name));else n.push(path.join(s,e.name));const o={};for(const e of n){const s=path.join(e,"android"),n=path.join(e,"package.json");if(existsSync(s)&&statSync(s).isDirectory()&&existsSync(n))try{const e=JSON.parse(readFileSync(n,"utf8"));e.name&&e.version&&(o[e.name]=e.version)}catch(e){fail("toolFailed",`${n} is not valid package.json, so its native package cannot be read: ${e.message}`)}}return o};export const changedNativePackages=(e,s)=>[...new Set([...Object.keys(e),...Object.keys(s)])].filter(n=>e[n]!==s[n]).sort();export const writeStamp=e=>{const{manager:s}=lockfileOf(e),n={hash:installHash(e),manager:s,nativePackages:nativePackages(e)};return writeFileSync(path.join(e,STAMP_FILE),`${JSON.stringify(n,null,2)}\n`,"utf8"),n};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 n,o=!1;for(const t of e.split(/\r?\n/)){if(/^\S/.test(t)){o="EXTERNAL SOURCES:"===t,n=void 0;continue}if(!o)continue;const e=/^ {2}"?([^"\s:]+)"?:$/.exec(t);e?n=e[1]:void 0!==n&&/^ {4}:path:/.test(t)&&(s.push(n),n=void 0)}return s};const POD_VERSION_MOVED=/changed the version of the dependency|pod update/,runPod=(e,s,n)=>{const o=capture({file:e,args:s},n);return-1===o.status&&fail("toolFailed",`pod ${s[0]} could not start: ${o.stderr}`),process.stdout.write(o.stdout),process.stderr.write(o.stderr),o};export const ensurePods=(e,s)=>{if(!existsSync(path.join(e,"ios","Podfile")))return;const n=path.join(e,"ios","Pods"),o=path.join(e,PODS_RECORD);let t;if(existsSync(n)?existsSync(path.join(e,"ios","Podfile.lock"))?existsSync(path.join(n,"Manifest.lock"))?podsStale(e)?t="ios/Podfile.lock differs from ios/Pods/Manifest.lock":nodeModulesNewerThanPods(e)?t="node_modules changed after the last pod install":existsSync(o)?readFileSync(o,"utf8")!==JSON.stringify(nativePackages(e))&&(t="native packages changed since the last pod install"):t="no pod install record":t="ios/Pods/Manifest.lock is missing":t="ios/Podfile.lock is missing":t="ios/Pods is missing",void 0===t)return;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)";fail("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(o,JSON.stringify(nativePackages(e)),"utf8")};export const sync=(e,s)=>{const{manager:n}=lockfileOf(e),o=readStamp(e)?.nativePackages??nativePackages(e);say("sync: "+("pnpm"===n?"pnpm install --frozen-lockfile":"npm ci")),runInherit(installInvocation(n,s),e,`${n} install`);const t=writeStamp(e).nativePackages,a=changedNativePackages(o,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{capture,runInherit}from"./exec.js";import{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")),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")};export const readStamp=e=>{const s=path.join(e,STAMP_FILE);if(existsSync(s))try{return JSON.parse(readFileSync(s,"utf8"))}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"));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.message}`)}}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 void 0===o.podInputs||void 0===o.nativePackages?"the pod install record is from an older mobile-tools":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},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)";fail("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")};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-tools",
3
- "version": "0.147.0",
3
+ "version": "0.149.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",