@webority/mobile-tools 0.138.0 → 0.139.1
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 +25 -0
- package/lib/cli.js +1 -1
- package/lib/keystore.js +1 -0
- package/lib/platform.js +1 -1
- package/lib/symbols.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -312,6 +312,31 @@ Renders every environment's launcher icons from one square source: an SVG, or a
|
|
|
312
312
|
- Production is clean. Staging carries an orange `STAGING` ribbon across the bottom-right corner, and Development a green `DEV` one. The ribbon is SVG text in a generic sans-serif, with no font file.
|
|
313
313
|
- The same source gives the same bytes on the same machine.
|
|
314
314
|
|
|
315
|
+
### `symbols`
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
npx mobile-tools symbols upload --env <Development|Staging|Production> --dsym <path>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Sends an iOS build's dSYM folder, or a zip of it, to Firebase Crashlytics so its crash stacks are symbolicated. The app id comes from `<firebasePlistDir>/GoogleService-Info.<Env>.plist`, and the upload runs `firebase crashlytics:symbols:upload --app <id> <path>`. It needs the Firebase CLI on PATH (`npm i -g firebase-tools`). Its credentials are the CLI's own, `GOOGLE_APPLICATION_CREDENTIALS` or `firebase login`; no token goes on the command line.
|
|
322
|
+
|
|
323
|
+
Exit codes: `0` when the upload finishes; `1` when the Firebase CLI is missing (`toolMissing`) or the upload fails (`toolFailed`); `2` for bad flags, a missing dSYM or a missing plist (`badInput`).
|
|
324
|
+
|
|
325
|
+
### `keystore`
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
npx mobile-tools keystore init --out <file.jks> [--alias upload] [--dname "CN=Android Upload Key"] [--validity-days 10000]
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Creates the Android upload keystore (PKCS12, RSA 2048) and prints its SHA-256 fingerprint. The password comes from the `MOBILE_TOOLS_KEYSTORE_PASSWORD` environment variable, at least 8 characters, and never goes on the command line or into the output. A file that already exists is refused: a keystore is never overwritten. It uses `keytool` from a JDK. Output:
|
|
332
|
+
|
|
333
|
+
```text
|
|
334
|
+
keystore <file.jks> created; upload key SHA-256 <hex>
|
|
335
|
+
set apps.<app>.mobile.android.uploadKeySha256 in .webority/infra/store.json to <hex>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Exit codes: `0` on success; `1` when `keytool` is missing (`toolMissing`) or fails (`toolFailed`); `2` for bad flags, a missing password or an existing file (`badInput`).
|
|
339
|
+
|
|
315
340
|
## Failures
|
|
316
341
|
|
|
317
342
|
A command that fails exits with one of these codes:
|
package/lib/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{parseArgs}from"node:util";import{build}from"./build.js";import{cache}from"./cache.js";import{parseEnvironment}from"./config.js";import{devices}from"./devices.js";import{doctor}from"./doctor.js";import{installHooks}from"./hooks.js";import{icons}from"./icons.js";import{restartMetro}from"./metro.js";import{CliError,fail,reportFailure,say,setJsonOutput,warn}from"./output.js";import{parseAndroidAbis}from"./platform.js";import{prebuild}from"./prebuild.js";import{run}from"./run.js";import{checkSync,sync,writeStamp}from"./sync.js";import{SIMULATOR_ARCHS}from"./xos.js";const COMMAND_USAGE={prebuild:" prebuild --env <Development|Staging|Production> [--platform android|ios]\n prebuild --same-env [--platform android|ios]\n Compile appsettings into appsettings.Compiled.json and stamp the native projects.",sync:" sync [--check | --stamp]\n --check: exit 1 with the fix command when node_modules (or ios/Pods) is stale.\n --stamp: record that node_modules matches the lockfile now (run it from postinstall).\n Without either: install from the lockfile, stamp, and reset native codegen when needed.",hooks:" hooks install\n Add git post-merge and post-checkout hooks that run sync --check.",run:" run --env <Environment> [--platform android|ios] [--device <serial|name>] [--rebuild] [--profiling] [--app <path.app>]\n Build for one device's ABI (or install the cached build with the same native fingerprint), install it there, reuse or start Metro, and launch. --rebuild skips the cache.\n iOS (macOS): installs the simulator app --app names on a booted simulator, starts Metro and launches it; it never builds.\n --profiling serves production JavaScript with React's profiling renderer; a Metro serving development JavaScript must be stopped first.",build:" build --env <Environment> --artifact apk|aab|ios-sim [--debug] [--debug-signed] [--ota-test] [--arch <value>] [--json] [-- <gradle args>]\n Prebuild, then build a release APK or App Bundle (Android, every ABI unless --arch) or an iOS simulator app through xOS Tools (xos on PATH).\n --arch for ios-sim: x86_64 (the default) or arm64. For apk and aab: arm64-v8a, armeabi-v7a, x86_64 or x86, as one value or a comma list; arm64 means arm64-v8a.\n --debug builds the debug variant (apk or ios-sim only).\n --debug-signed builds a staging test apk signed with the debug keystore, named *-debugsigned.apk (apk only; not with --debug or Production).\n --ota-test suffixes the OTA runtime version with -otatest, so only this build receives an update published for it.\n Arguments after -- go to Gradle unchanged (apk and aab only), for example -- --no-daemon --max-workers=3.",devices:" devices [--platform android|ios] [--json]\n Connect local MuMu emulators, then list every ready device once (simulators for iOS).",doctor:" doctor [--platform android|ios] [--fix] [--json]\n Check the toolchain and the app tree; exit 1 while a problem remains. --fix removes a stale autolinking cache.",cache:" cache list|clear [--json]\n List or remove this app's cached builds.",metro:" metro restart\n Stop the Metro mobile-tools started for this app and start it again on the same port.",icons:" icons [--source <png|svg>]\n Render per-environment launcher icons for Android flavors and iOS AppIcon-<Env> sets."},USAGE=`mobile-tools <command> [options] (run from the app's root folder)\n\n${Object.values(COMMAND_USAGE).join("\n\n")}`,knownCommand=e=>Object.hasOwn(COMMAND_USAGE,e),commandUsage=e=>`usage:\n${COMMAND_USAGE[e]}`,parse=(e,o,t,a=!1)=>{try{const{values:e,positionals:n}=parseArgs({args:o,options:t,allowPositionals:a,strict:!0});return{values:e,positionals:n}}catch(o){return fail("badInput",`${o.message}\n\n${commandUsage(e)}`)}},envOption=e=>"string"==typeof e?parseEnvironment(e):void 0,platformOption=e=>{if(void 0!==e)return"android"!==e&&"ios"!==e?fail("badInput",`--platform must be android or ios, not ${String(e)}`):e},JSON_COMMANDS=new Set(["build","cache","devices","doctor"]),artifactOption=e=>"apk"===e||"aab"===e||"ios-sim"===e?e:fail("badInput","build needs --artifact apk, aab or ios-sim"),main=async e=>{const[o,...t]=e,a=process.cwd(),n=t.indexOf("--"),s=n<0?t:t.slice(0,n);if(void 0!==o&&knownCommand(o)&&(s.includes("--help")||s.includes("-h")))say(commandUsage(o));else switch(setJsonOutput(JSON_COMMANDS.has(o??"")&&s.includes("--json")),o){case"prebuild":{const{values:e}=parse(o,t,{env:{type:"string"},"same-env":{type:"boolean"},platform:{type:"string"}});return void prebuild({appRoot:a,env:envOption(e.env),sameEnv:!0===e["same-env"],platform:platformOption(e.platform)})}case"sync":{const{values:e}=parse(o,t,{check:{type:"boolean"},stamp:{type:"boolean"}});if(e.check&&e.stamp&&fail("badInput","use --check or --stamp, not both"),e.stamp)return writeStamp(a),void say("sync --stamp: recorded node_modules as matching the lockfile");if(e.check){const e=checkSync(a,process.platform);return e.length>0&&fail("installStale",e.join("\n")),void say("sync --check: node_modules matches the lockfile")}return void sync(a,process.platform)}case"hooks":{const{positionals:e}=parse(o,t,{},!0);return"install"===e[0]&&1===e.length||fail("badInput",`usage: mobile-tools hooks install\n\n${USAGE}`),void installHooks(a)}case"run":{const{values:e}=parse(o,t,{env:{type:"string"},platform:{type:"string"},device:{type:"string"},rebuild:{type:"boolean"},profiling:{type:"boolean"},app:{type:"string"}}),n=envOption(e.env)??fail("badInput","run needs --env <Development|Staging|Production>");return void await run({appRoot:a,env:n,platform:platformOption(e.platform)??"android",device:"string"==typeof e.device?e.device:void 0,rebuild:!0===e.rebuild,profiling:!0===e.profiling,app:"string"==typeof e.app?e.app:void 0})}case"build":{const e=t.indexOf("--"),n=e<0?t:t.slice(0,e),s=e<0?[]:t.slice(e+1),{values:i}=parse(o,n,{env:{type:"string"},artifact:{type:"string"},debug:{type:"boolean"},"debug-signed":{type:"boolean"},"ota-test":{type:"boolean"},json:{type:"boolean"},arch:{type:"string"}}),r=envOption(i.env)??fail("badInput","build needs --env <Development|Staging|Production>"),p=artifactOption(i.artifact);!0===i.debug&&"aab"===p&&fail("badInput","--debug builds an apk or an ios-sim app; an App Bundle is release only"),"ios-sim"===p&&s.length>0&&fail("badInput","Gradle arguments after -- apply to apk and aab builds only");const l="string"==typeof i.arch?i.arch:void 0,d="ios-sim"===p?SIMULATOR_ARCHS.find(e=>e===(l??"x86_64"))??fail("badInput","--arch must be x86_64 or arm64"):void 0,c="ios-sim"===p||void 0===l?void 0:parseAndroidAbis(l);return void await build({appRoot:a,env:r,artifact:p,debug:!0===i.debug,debugSigned:!0===i["debug-signed"],otaTest:!0===i["ota-test"],gradleArgs:s,arch:d,abis:c})}case"devices":{const{values:e}=parse(o,t,{platform:{type:"string"},json:{type:"boolean"}});return void await devices({appRoot:a,platform:platformOption(e.platform)??"android"})}case"doctor":{const{values:e}=parse(o,t,{platform:{type:"string"},fix:{type:"boolean"},json:{type:"boolean"}});return void await doctor({appRoot:a,platform:platformOption(e.platform),fix:!0===e.fix})}case"cache":{const{positionals:e}=parse(o,t,{json:{type:"boolean"}},!0),n=e[0];return(1!==e.length||"list"!==n&&"clear"!==n)&&fail("badInput",`usage: mobile-tools cache list|clear\n\n${USAGE}`),void await cache({appRoot:a,action:n})}case"metro":{const{positionals:e}=parse(o,t,{},!0);return"restart"===e[0]&&1===e.length||fail("badInput",`usage: mobile-tools metro restart\n\n${USAGE}`),void await restartMetro(a)}case"icons":{const{values:e}=parse(o,t,{source:{type:"string"}});return void await icons({appRoot:a,source:"string"==typeof e.source?e.source:void 0})}case"help":{const e=t[0];return void 0===e?void say(USAGE):(knownCommand(e)||fail("badInput",`unknown command "${e}"\n\n${USAGE}`),void say(commandUsage(e)))}case void 0:case"--help":case"-h":return void say(USAGE);default:fail("badInput",`unknown command "${o}"\n\n${USAGE}`)}};main(process.argv.slice(2)).catch(e=>{e instanceof CliError&&(reportFailure(e),process.exit(e.exitCode)),warn(e instanceof Error?e.stack??e.message:String(e)),process.exit(1)});
|
|
2
|
+
import{parseArgs}from"node:util";import{build}from"./build.js";import{cache}from"./cache.js";import{parseEnvironment}from"./config.js";import{devices}from"./devices.js";import{doctor}from"./doctor.js";import{installHooks}from"./hooks.js";import{icons}from"./icons.js";import{initKeystore}from"./keystore.js";import{restartMetro}from"./metro.js";import{CliError,fail,reportFailure,say,setJsonOutput,warn}from"./output.js";import{parseAndroidAbis}from"./platform.js";import{prebuild}from"./prebuild.js";import{run}from"./run.js";import{uploadSymbols}from"./symbols.js";import{checkSync,sync,writeStamp}from"./sync.js";import{SIMULATOR_ARCHS}from"./xos.js";const COMMAND_USAGE={prebuild:" prebuild --env <Development|Staging|Production> [--platform android|ios]\n prebuild --same-env [--platform android|ios]\n Compile appsettings into appsettings.Compiled.json and stamp the native projects.",sync:" sync [--check | --stamp]\n --check: exit 1 with the fix command when node_modules (or ios/Pods) is stale.\n --stamp: record that node_modules matches the lockfile now (run it from postinstall).\n Without either: install from the lockfile, stamp, and reset native codegen when needed.",hooks:" hooks install\n Add git post-merge and post-checkout hooks that run sync --check.",run:" run --env <Environment> [--platform android|ios] [--device <serial|name>] [--rebuild] [--profiling] [--app <path.app>]\n Build for one device's ABI (or install the cached build with the same native fingerprint), install it there, reuse or start Metro, and launch. --rebuild skips the cache.\n iOS (macOS): installs the simulator app --app names on a booted simulator, starts Metro and launches it; it never builds.\n --profiling serves production JavaScript with React's profiling renderer; a Metro serving development JavaScript must be stopped first.",build:" build --env <Environment> --artifact apk|aab|ios-sim [--debug] [--debug-signed] [--ota-test] [--arch <value>] [--json] [-- <gradle args>]\n Prebuild, then build a release APK or App Bundle (Android, every ABI unless --arch) or an iOS simulator app through xOS Tools (xos on PATH).\n --arch for ios-sim: x86_64 (the default) or arm64. For apk and aab: arm64-v8a, armeabi-v7a, x86_64 or x86, as one value or a comma list; arm64 means arm64-v8a.\n --debug builds the debug variant (apk or ios-sim only).\n --debug-signed builds a staging test apk signed with the debug keystore, named *-debugsigned.apk (apk only; not with --debug or Production).\n --ota-test suffixes the OTA runtime version with -otatest, so only this build receives an update published for it.\n Arguments after -- go to Gradle unchanged (apk and aab only), for example -- --no-daemon --max-workers=3.",devices:" devices [--platform android|ios] [--json]\n Connect local MuMu emulators, then list every ready device once (simulators for iOS).",doctor:" doctor [--platform android|ios] [--fix] [--json]\n Check the toolchain and the app tree; exit 1 while a problem remains. --fix removes a stale autolinking cache.",cache:" cache list|clear [--json]\n List or remove this app's cached builds.",metro:" metro restart\n Stop the Metro mobile-tools started for this app and start it again on the same port.",icons:" icons [--source <png|svg>]\n Render per-environment launcher icons for Android flavors and iOS AppIcon-<Env> sets.",symbols:" symbols upload --env <Environment> --dsym <path>\n Upload an iOS build's dSYM folder or zip to Firebase Crashlytics, with the app id from that environment's GoogleService-Info plist; needs the Firebase CLI.",keystore:' keystore init --out <file.jks> [--alias upload] [--dname "CN=Android Upload Key"] [--validity-days 10000]\n Create the Android upload keystore with the password from MOBILE_TOOLS_KEYSTORE_PASSWORD and print its SHA-256 for store.json.'},USAGE=`mobile-tools <command> [options] (run from the app's root folder)\n\n${Object.values(COMMAND_USAGE).join("\n\n")}`,knownCommand=e=>Object.hasOwn(COMMAND_USAGE,e),commandUsage=e=>`usage:\n${COMMAND_USAGE[e]}`,parse=(e,o,t,a=!1)=>{try{const{values:e,positionals:n}=parseArgs({args:o,options:t,allowPositionals:a,strict:!0});return{values:e,positionals:n}}catch(o){return fail("badInput",`${o.message}\n\n${commandUsage(e)}`)}},envOption=e=>"string"==typeof e?parseEnvironment(e):void 0,platformOption=e=>{if(void 0!==e)return"android"!==e&&"ios"!==e?fail("badInput",`--platform must be android or ios, not ${String(e)}`):e},JSON_COMMANDS=new Set(["build","cache","devices","doctor"]),artifactOption=e=>"apk"===e||"aab"===e||"ios-sim"===e?e:fail("badInput","build needs --artifact apk, aab or ios-sim"),main=async e=>{const[o,...t]=e,a=process.cwd(),n=t.indexOf("--"),s=n<0?t:t.slice(0,n);if(void 0!==o&&knownCommand(o)&&(s.includes("--help")||s.includes("-h")))say(commandUsage(o));else switch(setJsonOutput(JSON_COMMANDS.has(o??"")&&s.includes("--json")),o){case"prebuild":{const{values:e}=parse(o,t,{env:{type:"string"},"same-env":{type:"boolean"},platform:{type:"string"}});return void prebuild({appRoot:a,env:envOption(e.env),sameEnv:!0===e["same-env"],platform:platformOption(e.platform)})}case"sync":{const{values:e}=parse(o,t,{check:{type:"boolean"},stamp:{type:"boolean"}});if(e.check&&e.stamp&&fail("badInput","use --check or --stamp, not both"),e.stamp)return writeStamp(a),void say("sync --stamp: recorded node_modules as matching the lockfile");if(e.check){const e=checkSync(a,process.platform);return e.length>0&&fail("installStale",e.join("\n")),void say("sync --check: node_modules matches the lockfile")}return void sync(a,process.platform)}case"hooks":{const{positionals:e}=parse(o,t,{},!0);return"install"===e[0]&&1===e.length||fail("badInput",`usage: mobile-tools hooks install\n\n${USAGE}`),void installHooks(a)}case"run":{const{values:e}=parse(o,t,{env:{type:"string"},platform:{type:"string"},device:{type:"string"},rebuild:{type:"boolean"},profiling:{type:"boolean"},app:{type:"string"}}),n=envOption(e.env)??fail("badInput","run needs --env <Development|Staging|Production>");return void await run({appRoot:a,env:n,platform:platformOption(e.platform)??"android",device:"string"==typeof e.device?e.device:void 0,rebuild:!0===e.rebuild,profiling:!0===e.profiling,app:"string"==typeof e.app?e.app:void 0})}case"build":{const e=t.indexOf("--"),n=e<0?t:t.slice(0,e),s=e<0?[]:t.slice(e+1),{values:i}=parse(o,n,{env:{type:"string"},artifact:{type:"string"},debug:{type:"boolean"},"debug-signed":{type:"boolean"},"ota-test":{type:"boolean"},json:{type:"boolean"},arch:{type:"string"}}),r=envOption(i.env)??fail("badInput","build needs --env <Development|Staging|Production>"),p=artifactOption(i.artifact);!0===i.debug&&"aab"===p&&fail("badInput","--debug builds an apk or an ios-sim app; an App Bundle is release only"),"ios-sim"===p&&s.length>0&&fail("badInput","Gradle arguments after -- apply to apk and aab builds only");const l="string"==typeof i.arch?i.arch:void 0,d="ios-sim"===p?SIMULATOR_ARCHS.find(e=>e===(l??"x86_64"))??fail("badInput","--arch must be x86_64 or arm64"):void 0,c="ios-sim"===p||void 0===l?void 0:parseAndroidAbis(l);return void await build({appRoot:a,env:r,artifact:p,debug:!0===i.debug,debugSigned:!0===i["debug-signed"],otaTest:!0===i["ota-test"],gradleArgs:s,arch:d,abis:c})}case"devices":{const{values:e}=parse(o,t,{platform:{type:"string"},json:{type:"boolean"}});return void await devices({appRoot:a,platform:platformOption(e.platform)??"android"})}case"doctor":{const{values:e}=parse(o,t,{platform:{type:"string"},fix:{type:"boolean"},json:{type:"boolean"}});return void await doctor({appRoot:a,platform:platformOption(e.platform),fix:!0===e.fix})}case"cache":{const{positionals:e}=parse(o,t,{json:{type:"boolean"}},!0),n=e[0];return(1!==e.length||"list"!==n&&"clear"!==n)&&fail("badInput",`usage: mobile-tools cache list|clear\n\n${USAGE}`),void await cache({appRoot:a,action:n})}case"metro":{const{positionals:e}=parse(o,t,{},!0);return"restart"===e[0]&&1===e.length||fail("badInput",`usage: mobile-tools metro restart\n\n${USAGE}`),void await restartMetro(a)}case"icons":{const{values:e}=parse(o,t,{source:{type:"string"}});return void await icons({appRoot:a,source:"string"==typeof e.source?e.source:void 0})}case"symbols":{const{values:e,positionals:n}=parse(o,t,{env:{type:"string"},dsym:{type:"string"}},!0);"upload"===n[0]&&1===n.length||fail("badInput",`usage: mobile-tools symbols upload --env <Environment> --dsym <path>\n\n${USAGE}`);const s=envOption(e.env)??fail("badInput","symbols upload needs --env <Development|Staging|Production>"),i="string"==typeof e.dsym?e.dsym:fail("badInput","symbols upload needs --dsym <path>");return void await uploadSymbols({appRoot:a,env:s,dsym:i})}case"keystore":{const{values:e,positionals:a}=parse(o,t,{out:{type:"string"},alias:{type:"string"},dname:{type:"string"},"validity-days":{type:"string"}},!0);"init"===a[0]&&1===a.length||fail("badInput",`usage: mobile-tools keystore init --out <file.jks>\n\n${USAGE}`);const n="string"==typeof e.out?e.out:fail("badInput","keystore init needs --out <file.jks>"),s="string"==typeof e["validity-days"]?e["validity-days"]:"10000";return/^[1-9][0-9]*$/.test(s)||fail("badInput",`--validity-days must be a positive whole number, not ${s}`),void await initKeystore({out:n,alias:"string"==typeof e.alias?e.alias:"upload",dname:"string"==typeof e.dname?e.dname:"CN=Android Upload Key",validityDays:Number(s)})}case"help":{const e=t[0];return void 0===e?void say(USAGE):(knownCommand(e)||fail("badInput",`unknown command "${e}"\n\n${USAGE}`),void say(commandUsage(e)))}case void 0:case"--help":case"-h":return void say(USAGE);default:fail("badInput",`unknown command "${o}"\n\n${USAGE}`)}};main(process.argv.slice(2)).catch(e=>{e instanceof CliError&&(reportFailure(e),process.exit(e.exitCode)),warn(e instanceof Error?e.stack??e.message:String(e)),process.exit(1)});
|
package/lib/keystore.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync}from"node:fs";import{capture}from"./exec.js";import{fail,say}from"./output.js";const PASSWORD_ENV="MOBILE_TOOLS_KEYSTORE_PASSWORD",MIN_PASSWORD_LENGTH=8,SHA256_LINE=/^[ \t]*SHA256:[ \t]*((?:[0-9A-F]{2}:){31}[0-9A-F]{2})\s*$/im;export const sha256Fingerprint=t=>SHA256_LINE.exec(t)?.[1].replace(/:/g,"").toLowerCase();export const initKeystore=async t=>{if(existsSync(t.out))return fail("badInput",`${t.out} exists; a keystore is never overwritten`);const e=process.env[PASSWORD_ENV];if(void 0===e||e.length<8)return fail("badInput",`${PASSWORD_ENV} must hold a keystore password of at least 8 characters`);const o=capture({file:"keytool",args:["-genkeypair","-noprompt","-keystore",t.out,"-storetype","PKCS12","-alias",t.alias,"-keyalg","RSA","-keysize","2048","-validity",String(t.validityDays),"-dname",t.dname,"-storepass:env",PASSWORD_ENV,"-keypass:env",PASSWORD_ENV]},process.cwd());if(-1===o.status)return fail("toolMissing","keytool not found on PATH; install a JDK, whose bin folder holds keytool");if(0!==o.status)return fail("toolFailed",`keytool could not create ${t.out} (exit ${o.status}): ${o.stderr.trim()}`);const s=capture({file:"keytool",args:["-list","-v","-keystore",t.out,"-alias",t.alias,"-storepass:env",PASSWORD_ENV]},process.cwd());if(0!==s.status)return fail("toolFailed",`keytool could not read ${t.out} back (exit ${s.status}): ${s.stderr.trim()}`);const a=sha256Fingerprint(s.stdout);if(void 0===a)return fail("toolFailed",`keytool printed no SHA-256 fingerprint for alias ${t.alias} in ${t.out}`);say(`keystore ${t.out} created; upload key SHA-256 ${a}`),say(`set apps.<app>.mobile.android.uploadKeySha256 in .webority/infra/store.json to ${a}`)};
|
package/lib/platform.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync}from"node:fs";import path from"node:path";import{fail,warn}from"./output.js";export const ANDROID_ABIS=["arm64-v8a","armeabi-v7a","x86_64","x86"];export const ABI_PATTERN=new RegExp(`^(${ANDROID_ABIS.join("|")})$`);export const parseAndroidAbis=n=>{const o=[];for(const t of n.split(",")){const n="arm64"===t?"arm64-v8a":t;ABI_PATTERN.test(n)||fail("badInput",`--arch must be a comma list of ${ANDROID_ABIS.join(", ")} (arm64 means arm64-v8a), not ${JSON.stringify(t)}`),o.includes(n)||o.push(n)}return o};const LONG_WINDOWS_APP_PATH=90;export const pathFor=n=>"win32"===n?path.win32:path.posix;const readEnv=(n,o)=>{const t=Object.keys(n).find(n=>n.toLowerCase()===o.toLowerCase());return void 0===t?void 0:n[t]};export const childEnv=n=>{const o={};for(const[t,e]of Object.entries(n))"nodefaultcurrentdirectoryinexepath"!==t.toLowerCase()&&(o[t]=e);return o};export const findOnPath=(n,o,t,e=existsSync)=>{const r=pathFor(t),
|
|
1
|
+
import{existsSync}from"node:fs";import path from"node:path";import{fail,warn}from"./output.js";export const ANDROID_ABIS=["arm64-v8a","armeabi-v7a","x86_64","x86"];export const ABI_PATTERN=new RegExp(`^(${ANDROID_ABIS.join("|")})$`);export const parseAndroidAbis=n=>{const o=[];for(const t of n.split(",")){const n="arm64"===t?"arm64-v8a":t;ABI_PATTERN.test(n)||fail("badInput",`--arch must be a comma list of ${ANDROID_ABIS.join(", ")} (arm64 means arm64-v8a), not ${JSON.stringify(t)}`),o.includes(n)||o.push(n)}return o};const LONG_WINDOWS_APP_PATH=90;export const pathFor=n=>"win32"===n?path.win32:path.posix;const readEnv=(n,o)=>{const t=Object.keys(n).find(n=>n.toLowerCase()===o.toLowerCase());return void 0===t?void 0:n[t]};export const childEnv=n=>{const o={};for(const[t,e]of Object.entries(n))"nodefaultcurrentdirectoryinexepath"!==t.toLowerCase()&&(o[t]=e);return o};export const findOnPath=(n,o,t,e=existsSync)=>{const r=pathFor(t),i=readEnv(o,"PATH")??"",a="win32"===t?`${n}.exe`:n;for(const n of i.split("win32"===t?";":":")){if(""===n)continue;const o=r.join(n,a);if(e(o))return o}};export const adbPath=(n,o,t=existsSync)=>{const e=pathFor(o),r=readEnv(n,"ANDROID_HOME");if(r){const n=e.join(r,"platform-tools","win32"===o?"adb.exe":"adb");if(t(n))return n}return findOnPath("adb",n,o,t)??fail("toolMissing","adb not found: set ANDROID_HOME to the Android SDK (adb lives in its platform-tools folder) or put adb on PATH.")};const SAFE_GRADLE_ARG=/^[A-Za-z0-9_:.,=-]+$/;export const gradleInvocation=(n,o,t,e)=>{for(const n of o)SAFE_GRADLE_ARG.test(n)||fail("badInput",`refusing Gradle argument ${JSON.stringify(n)}: only plain task names and -Pkey=value`);const r=pathFor(t);if("win32"!==t)return{file:r.join(n,"gradlew"),args:o};const i=r.join(n,"gradlew.bat");/["%]/.test(i)&&fail("appConfigInvalid",`the app path cannot hold " or %: ${i}`);const a=readEnv(e,"SystemRoot")??"C:\\Windows";return{file:readEnv(e,"ComSpec")??r.join(a,"System32","cmd.exe"),args:["/d","/s","/c",`""${i}" ${o.join(" ")}"`],windowsVerbatimArguments:!0}};export const requireDarwin=(n,o)=>{"darwin"!==n&&fail("platformUnavailable",`${o} needs macOS: the iOS Simulator and xcrun exist only there.`)};export const longWindowsPathWarning=(n,o)=>{const t=path.resolve(n).length;if(!("win32"!==o||t<=90))return`the app folder path is ${t} characters. A Windows tool in the Android native build cannot open a path over 260 characters, and the build adds about 170 under the app folder, so a path over 90 can fail with CreateProcess error=2. Move the app to a short folder such as C:\\w\\<app>, or map one with subst W: <path> and run from W:\\.`};export const warnLongWindowsPath=n=>{const o=longWindowsPathWarning(n,process.platform);void 0!==o&&warn(`Warning: ${o}`)};export const XCRUN="/usr/bin/xcrun";export const npmInvocation=(n,o,t,e,r=existsSync)=>{const i=pathFor(t),a=readEnv(o,"npm_execpath"),s=[a&&/npm-cli\.c?js$/.test(a)?a:void 0,"win32"===t?i.join(i.dirname(e),"node_modules","npm","bin","npm-cli.js"):i.join(i.dirname(e),"..","lib","node_modules","npm","bin","npm-cli.js")].find(n=>void 0!==n&&r(n));return s?{file:e,args:[s,...n]}:fail("toolMissing",`npm not found beside ${e}; install Node 24 with its bundled npm.`)};export const pnpmInvocation=(n,o,t,e,r=existsSync)=>{const i=readEnv(o,"npm_execpath");if(i&&/pnpm\.c?js$/.test(i)&&r(i))return{file:e,args:[i,...n]};const a=findOnPath("pnpm",o,t,r);return a?{file:a,args:n}:fail("toolMissing","pnpm not found on PATH (on Windows, pnpm.exe); install pnpm, or run through pnpm exec.")};export const firebaseInvocation=(n,o,t,e,r=existsSync)=>{if("win32"!==t){const e=findOnPath("firebase",o,t,r);return void 0===e?void 0:{file:e,args:n}}const i=pathFor(t),a=(readEnv(o,"PATH")??"").split(";").filter(n=>""!==n).map(n=>i.join(n,"firebase.cmd")).find(n=>r(n));if(void 0===a)return;const s=i.join(i.dirname(a),"node_modules","firebase-tools","lib","bin","firebase.js");return r(s)?{file:e,args:[s,...n]}:void 0};
|
package/lib/symbols.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import path from"node:path";import{loadToolsConfig}from"./config.js";import{capture}from"./exec.js";import{fail,say}from"./output.js";import{firebaseInvocation}from"./platform.js";const GOOGLE_APP_ID=/<key>GOOGLE_APP_ID<\/key>\s*<string>\s*([^<\s]+)\s*<\/string>/;export const googleAppId=o=>GOOGLE_APP_ID.exec(o)?.[1];export const uploadSymbols=async o=>{const s=path.resolve(o.appRoot,o.dsym);if(!existsSync(s))return fail("badInput",`dSYM not found: ${s}`);const t=path.join(o.appRoot,loadToolsConfig(o.appRoot).firebasePlistDir,`GoogleService-Info.${o.env}.plist`);if(!existsSync(t))return fail("badInput",`${t} is missing; upload needs it to name the ${o.env} Firebase app`);const i=googleAppId(readFileSync(t,"utf8"));if(void 0===i)return fail("badInput",`${t} has no GOOGLE_APP_ID`);const e=firebaseInvocation(["crashlytics:symbols:upload","--app",i,s],process.env,process.platform,process.execPath);if(void 0===e)return fail("toolMissing","the Firebase CLI is not on PATH; install it with npm i -g firebase-tools");const a=capture(e,o.appRoot);return-1===a.status?fail("toolMissing","the Firebase CLI is not on PATH; install it with npm i -g firebase-tools"):0!==a.status?fail("toolFailed",`firebase crashlytics:symbols:upload failed (exit ${a.status}): ${a.stderr.trim()}`):void say(`symbols upload: sent ${s} for ${i} to Firebase Crashlytics`)};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.139.1",
|
|
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",
|