@webority/mobile-tools 0.150.0 → 0.152.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/config.d.ts +3 -3
- package/lib/doctor.d.ts +1 -1
- package/lib/doctor.js +1 -1
- package/lib/icons.d.ts +1 -1
- package/lib/prebuild.d.ts +2 -2
- package/lib/profilingHook.js +1 -1
- package/lib/run.d.ts +2 -2
- package/package.json +1 -1
package/lib/config.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ export type Environment = (typeof ENVIRONMENTS)[number];
|
|
|
3
3
|
export declare const CONFIG_FILE = "mobile-tools.config.json";
|
|
4
4
|
export declare const COMPILED_FILE = "appsettings.Compiled.json";
|
|
5
5
|
export interface ToolsConfig {
|
|
6
|
-
iosProjectName?: string;
|
|
6
|
+
iosProjectName?: string | undefined;
|
|
7
7
|
flavors: boolean;
|
|
8
|
-
localApiPort?: number;
|
|
9
|
-
iconSource?: string;
|
|
8
|
+
localApiPort?: number | undefined;
|
|
9
|
+
iconSource?: string | undefined;
|
|
10
10
|
firebasePlistDir: string;
|
|
11
11
|
/** Setting keys the app reads beyond REQUIRED_SETTINGS; each must be present and not null in the merged settings. */
|
|
12
12
|
requiredSettings: readonly string[];
|
package/lib/doctor.d.ts
CHANGED
package/lib/doctor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync,readFileSync,rmSync}from"node:fs";import path from"node:path";import{capture}from"./exec.js";import{fail,isJsonOutput,say,sayJson}from"./output.js";import{adbPath,findOnPath,longWindowsPathWarning}from"./platform.js";import{checkNdkHook,usesFirebase}from"./prebuild.js";import{checkSync}from"./sync.js";import{xosPath}from"./xos.js";export const JDK_MAJOR=17;const JDK_FIX="install JDK 17 and set JAVA_HOME",ADB_FIX="set ANDROID_HOME to the Android SDK (adb lives in its platform-tools folder) or put adb on PATH",NINJA_FIX="install ninja 1.11 or newer (scoop install ninja) and put it first on PATH",XCODE_FIX="install Xcode, then xcode-select -s /Applications/Xcode.app",XOS_FIX="install xOS Tools (xos) and put it on PATH",APP_PATH_FIX="move the app to a short folder such as C:\\w\\<app>, or map one with subst W: <path>",AUTOLINKING_FILE=path.join("android","build","generated","autolinking","autolinking.json"),AUTOLINKING_DIRS=[path.join("android","build","generated","autolinking"),path.join("android","app","build","generated","autolinking")];export const javaMajor=o=>{const e=/version\b[^"]*"([^"]+)"/.exec(o)?.[1];if(void 0===e)return;const s=e.split(/[._+-]/),t=Number(s[0]),n=1===t?Number(s[1]):t;return Number.isInteger(n)?n:void 0};export const gradleSdkVersions=o=>{const e={},s=/ndkVersion\s*=\s*["']([^"']+)["']/.exec(o),t=/buildToolsVersion\s*=\s*["']([^"']+)["']/.exec(o),n=/compileSdkVersion\s*=\s*(\d+)/.exec(o);return s&&(e.ndk=s
|
|
1
|
+
import{existsSync,readFileSync,rmSync}from"node:fs";import path from"node:path";import{capture}from"./exec.js";import{fail,isJsonOutput,say,sayJson}from"./output.js";import{adbPath,findOnPath,longWindowsPathWarning}from"./platform.js";import{checkNdkHook,usesFirebase}from"./prebuild.js";import{checkSync}from"./sync.js";import{xosPath}from"./xos.js";export const JDK_MAJOR=17;const JDK_FIX="install JDK 17 and set JAVA_HOME",ADB_FIX="set ANDROID_HOME to the Android SDK (adb lives in its platform-tools folder) or put adb on PATH",NINJA_FIX="install ninja 1.11 or newer (scoop install ninja) and put it first on PATH",XCODE_FIX="install Xcode, then xcode-select -s /Applications/Xcode.app",XOS_FIX="install xOS Tools (xos) and put it on PATH",APP_PATH_FIX="move the app to a short folder such as C:\\w\\<app>, or map one with subst W: <path>",AUTOLINKING_FILE=path.join("android","build","generated","autolinking","autolinking.json"),AUTOLINKING_DIRS=[path.join("android","build","generated","autolinking"),path.join("android","app","build","generated","autolinking")];export const javaMajor=o=>{const e=/version\b[^"]*"([^"]+)"/.exec(o)?.[1];if(void 0===e)return;const s=e.split(/[._+-]/),t=Number(s[0]),n=1===t?Number(s[1]):t;return Number.isInteger(n)?n:void 0};export const gradleSdkVersions=o=>{const e={},s=/ndkVersion\s*=\s*["']([^"']+)["']/.exec(o)?.[1],t=/buildToolsVersion\s*=\s*["']([^"']+)["']/.exec(o)?.[1],n=/compileSdkVersion\s*=\s*(\d+)/.exec(o)?.[1];return void 0!==s&&(e.ndk=s),void 0!==t&&(e.buildTools=t),void 0!==n&&(e.compileSdk=n),e};const samePath=(o,e)=>{const norm=o=>{const e=path.resolve(o).replace(/[\\/]+$/,"");return"win32"===process.platform?e.toLowerCase():e};return norm(o)===norm(e)};export const autolinkingProblem=(o,e,s)=>{let t;try{t=JSON.parse(o)}catch{return"android/build/generated/autolinking/autolinking.json does not parse"}if("string"==typeof t?.root&&!samePath(t.root,e))return`the autolinking cache was made for ${t.root}, not ${e}`;for(const[o,e]of Object.entries(t?.dependencies??{}))if("string"==typeof e?.root&&!s(e.root))return`the autolinking cache names ${o} at ${e.root}, which no longer exists`};const ok=(o,e)=>({code:o,status:"ok",message:e}),skipped=(o,e)=>({code:o,status:"skipped",message:e}),problem=(o,e,s)=>({code:o,status:"problem",message:e,fix:s}),probe=(o,e,s)=>{try{return s()}catch(s){return problem(o,s instanceof Error?s.message:String(s),e)}},outputOf=o=>[o.stdout,o.stderr].join("\n").trim()||`exited with status ${o.status}`,SDK_SPECS=[{code:"ndk",key:"ndkVersion",field:"ndk",folder:(o,e)=>path.join(o,"ndk",e),install:o=>`sdkmanager "ndk;${o}"`},{code:"buildTools",key:"buildToolsVersion",field:"buildTools",folder:(o,e)=>path.join(o,"build-tools",e),install:o=>`sdkmanager "build-tools;${o}"`},{code:"androidPlatform",key:"compileSdkVersion",field:"compileSdk",folder:(o,e)=>path.join(o,"platforms",`android-${e}`),install:o=>`sdkmanager "platforms;android-${o}"`}],sdkCheck=(o,e)=>probe(e.code,"fix the Android SDK under ANDROID_HOME",()=>{const s=path.join(o,"android","build.gradle");if(!existsSync(s))return skipped(e.code,"no android/build.gradle");const t=process.env.ANDROID_HOME;if(!t)return skipped(e.code,"ANDROID_HOME is not set");const n=gradleSdkVersions(readFileSync(s,"utf8"))[e.field];if(void 0===n)return skipped(e.code,`${e.key} is not declared in android/build.gradle`);const r=e.folder(t,n);return existsSync(r)?ok(e.code,r):problem(e.code,`${r} is missing`,e.install(n))}),androidChecks=o=>{const{appRoot:e}=o,s=[];s.push(probe("nodeVersion","install Node 24",()=>{const o=process.versions.node;return 24===Number(o.split(".")[0])?ok("nodeVersion",`Node ${o}`):problem("nodeVersion",`Node ${o} is not Node 24`,"install Node 24")})),s.push(probe("androidHome","set ANDROID_HOME to the Android SDK folder",()=>{const o=process.env.ANDROID_HOME;return o?existsSync(o)?ok("androidHome",o):problem("androidHome",`ANDROID_HOME ${o} does not exist`,"set ANDROID_HOME to the Android SDK folder"):problem("androidHome","ANDROID_HOME is not set","set ANDROID_HOME to the Android SDK folder")}));const t={};s.push(probe("adb",ADB_FIX,()=>{const o=adbPath(process.env,process.platform),s=capture({file:o,args:["version"]},e);if(0!==s.status)return problem("adb",outputOf(s),ADB_FIX);t.path=o;const n=s.stdout.split(/\r?\n/).find(o=>o.startsWith("Version"));return ok("adb",n?`${o}, ${n.trim()}`:o)}));const n=t.path;s.push(void 0===n?skipped("adbServer","adb is not available"):probe("adbServer","use one adb, the SDK platform-tools one: MuMu ships its own adb",()=>{const o=capture({file:n,args:["devices"]},e),s=`${o.stdout}\n${o.stderr}`.split(/\r?\n/).find(o=>o.includes("doesn't match this client"));return void 0===s?ok("adbServer","one adb server version"):problem("adbServer",`another adb restarted the adb server at a different version: ${s.trim()}`,"use one adb, the SDK platform-tools one: MuMu ships its own adb")})),s.push(probe("jdk",JDK_FIX,()=>{const o=process.env.JAVA_HOME,s="win32"===process.platform?"java.exe":"java",t=o?path.join(o,"bin",s):void 0,n=void 0!==t&&existsSync(t)?t:findOnPath("java",process.env,process.platform);if(void 0===n)return problem("jdk","java not found",JDK_FIX);const r=capture({file:n,args:["-version"]},e),i=javaMajor(`${r.stderr}${r.stdout}`);return 17===i?ok("jdk",`Java ${i} at ${n}`):problem("jdk",`Java ${i??"unknown"} at ${n}; React Native builds need Java 17`,JDK_FIX)}));for(const o of SDK_SPECS)s.push(sdkCheck(e,o));s.push("win32"!==process.platform?skipped("ninja","only Windows builds need ninja on PATH"):probe("ninja",NINJA_FIX,()=>{const o=findOnPath("ninja",process.env,process.platform);if(void 0===o)return problem("ninja","ninja not found on PATH",NINJA_FIX);const s=capture({file:o,args:["--version"]},e).stdout.trim(),t=/^(\d+)\.(\d+)/.exec(s);if(!t)return problem("ninja",`ninja --version printed no version at ${o}`,NINJA_FIX);return Number(t[1])>1||1===Number(t[1])&&Number(t[2])>=11?ok("ninja",`ninja ${s} at ${o}`):problem("ninja",`ninja ${s} at ${o} is older than 1.11`,NINJA_FIX)})),s.push(probe("install","npx mobile-tools sync",()=>{const o=checkSync(e,process.platform);return 0===o.length?ok("install","node_modules matches the lockfile"):problem("install",o.join("; "),"npx mobile-tools sync")})),s.push("win32"!==process.platform?skipped("appPath","only Windows has the long-path limit"):probe("appPath",APP_PATH_FIX,()=>{const o=longWindowsPathWarning(e,process.platform);return void 0===o?ok("appPath","the app folder path is short enough for the Android native build"):{code:"appPath",status:"warning",message:o}}));const r="npx mobile-tools doctor --fix";return s.push(probe("autolinkingCache",r,()=>{const s=path.join(e,AUTOLINKING_FILE);if(!existsSync(s))return ok("autolinkingCache","no autolinking cache yet");const t=autolinkingProblem(readFileSync(s,"utf8"),e,existsSync);if(void 0===t)return ok("autolinkingCache","matches this tree");if(!o.fix)return problem("autolinkingCache",t,r);for(const o of AUTOLINKING_DIRS)rmSync(path.join(e,o),{recursive:!0,force:!0});return{code:"autolinkingCache",status:"fixed",message:"removed both autolinking caches; the next build regenerates them"}})),s.push(probe("ndkHook","add the subprojects block the message names to android/build.gradle",()=>(checkNdkHook(e),ok("ndkHook","library modules get the app NDK")))),s.push(probe("firebaseConfig","add the Firebase Android config for this app",()=>{if(!usesFirebase(e))return skipped("firebaseConfig","the app does not use @react-native-firebase");const o=path.join(e,"android","app","google-services.json");return existsSync(o)?ok("firebaseConfig","android/app/google-services.json"):problem("firebaseConfig","android/app/google-services.json is missing","add the Firebase Android config for this app")})),s},xcodeCheck=o=>probe("xcode",XCODE_FIX,()=>{const e=capture({file:"/usr/bin/xcode-select",args:["-p"]},o);return 0===e.status?ok("xcode",e.stdout.trim()):problem("xcode","no Xcode developer directory is selected",XCODE_FIX)}),xosCheck=o=>probe("xos",XOS_FIX,()=>{const e=xosPath(process.env,process.platform),s=capture({file:e,args:["doctor","--json"]},o);return 0===s.status?ok("xos",e):problem("xos",s.stderr.trim().split(/\r?\n/)[0]||`xos doctor exited with status ${s.status}`,"run xos doctor and install what it names")});export const iosChecks=(o,e)=>["darwin"===e?xcodeCheck(o):xosCheck(o),probe("cocoapods","install CocoaPods",()=>{const o=findOnPath("pod",process.env,e);return void 0===o?problem("cocoapods","pod not found on PATH","install CocoaPods"):ok("cocoapods",o)})];export const doctor=async o=>{const e=path.join(o.appRoot,"android"),s=path.join(o.appRoot,"ios");"android"!==o.platform||existsSync(e)||fail("appConfigInvalid",`no android/ folder in ${o.appRoot}`);const t=[];("android"===o.platform||void 0===o.platform&&existsSync(e))&&t.push(...androidChecks(o));const n="darwin"===process.platform||void 0!==findOnPath("xos",process.env,process.platform);("ios"===o.platform||void 0===o.platform&&n&&existsSync(s))&&t.push(...iosChecks(o.appRoot,process.platform));const r=t.filter(o=>"problem"===o.status).length;if(isJsonOutput())sayJson({checks:t,problems:r});else{for(const o of t){const e="problem"===o.status&&o.fix?` Fix: ${o.fix}`:"";say(`doctor: ${o.status} ${o.code}: ${o.message}${e}`)}say(0===r?"doctor: ready":`doctor: ${r} problem(s)`)}r>0&&(process.exitCode=1)};
|
package/lib/icons.d.ts
CHANGED
package/lib/prebuild.d.ts
CHANGED
|
@@ -63,9 +63,9 @@ export declare const stampAndroid: (appRoot: string, settings: AppSettings, env:
|
|
|
63
63
|
export declare const stampIos: (appRoot: string, settings: AppSettings, env: Environment, config: ToolsConfig, projectName: string, otaTest: boolean) => void;
|
|
64
64
|
export interface PrebuildOptions {
|
|
65
65
|
appRoot: string;
|
|
66
|
-
env?: Environment;
|
|
66
|
+
env?: Environment | undefined;
|
|
67
67
|
sameEnv?: boolean;
|
|
68
|
-
platform?: MobilePlatform;
|
|
68
|
+
platform?: MobilePlatform | undefined;
|
|
69
69
|
/** Only `build --ota-test` sets it: the OTA runtime version gets the `-otatest` suffix. */
|
|
70
70
|
otaTest?: boolean;
|
|
71
71
|
}
|
package/lib/profilingHook.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
if(void 0===globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__){const e=new Map,o=new Map;let t=1;globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__={supportsFiber:!0,renderers:e,inject(_){const i=t++;return e.set(i,_),o.set(i,new Set),i},onCommitFiberRoot(e,t){o.get(e)?.add(t)},onCommitFiberUnmount(){},onPostCommitFiberRoot(){},getFiberRoots:e=>o.get(e)??new Set,checkDCE(){}}}globalThis.__WEBORITY_PROFILING__=!0;
|
|
1
|
+
export{};if(void 0===globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__){const e=new Map,o=new Map;let t=1;globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__={supportsFiber:!0,renderers:e,inject(_){const i=t++;return e.set(i,_),o.set(i,new Set),i},onCommitFiberRoot(e,t){o.get(e)?.add(t)},onCommitFiberUnmount(){},onPostCommitFiberRoot(){},getFiberRoots:e=>o.get(e)??new Set,checkDCE(){}}}globalThis.__WEBORITY_PROFILING__=!0;
|
package/lib/run.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ export interface RunOptions {
|
|
|
4
4
|
appRoot: string;
|
|
5
5
|
env: Environment;
|
|
6
6
|
platform: MobilePlatform;
|
|
7
|
-
device?: string;
|
|
7
|
+
device?: string | undefined;
|
|
8
8
|
rebuild: boolean;
|
|
9
9
|
/** Serve production JavaScript with the profiling renderer; the native build is the same debug build. */
|
|
10
10
|
profiling: boolean;
|
|
11
11
|
/** iOS only and required there: the simulator .app built by `build --artifact ios-sim`; run never builds for iOS. */
|
|
12
|
-
app?: string;
|
|
12
|
+
app?: string | undefined;
|
|
13
13
|
}
|
|
14
14
|
/** The Android namespace from build.gradle (`namespace "x"` or `namespace = 'x'`); MainActivity lives in it. */
|
|
15
15
|
export declare const readNamespace: (buildGradle: string) => string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.152.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",
|