lirichard commented on pull request #874:
URL: https://github.com/apache/cordova-lib/pull/874#issuecomment-917177913


   Just following the code visually, I believe this is the order of events:
   1. 
[restore-util.js#L137](https://github.com/apache/cordova-lib/blob/ef1868884164a0838da66bd97503a0a1903e0bcd/src/cordova/restore-util.js#L137)
 ends up invoking `cordovaPlatform('add', ...)`
   2. Which takes us into 
[`platform/index.js`](https://github.com/apache/cordova-lib/blob/dd872f044211592b11c17d23d56cd17192e4b51f/src/cordova/platform/index.js#L48)
   3. Which invokes a local function `add` 
([platform/index.js#L70](https://github.com/apache/cordova-lib/blob/dd872f044211592b11c17d23d56cd17192e4b51f/src/cordova/platform/index.js#L70))
   4. Which calls `addHelper` 
([platform/index.js#L27](https://github.com/apache/cordova-lib/blob/dd872f044211592b11c17d23d56cd17192e4b51f/src/cordova/platform/index.js#L27))
   
   I confirmed that, if I make aidanas's code change within a live Cordova 
project in the local 
`node_modules/cordova-lib/src/cordova/platform/addHelper.js`, then `cordova 
prepare` pulls the correct version `^10.1.0`.
   
   For example using my `testProject` reproduction from before, modified to use 
`npx` so it uses the local `cordova` and `cordova-lib` instead of global:
   
   ```
   npx cordova create testProject
   cd testProject
   npm i [email protected]
   npx cordova platform add [email protected]
   rm -r platforms
   
   npm i -D cordova
   
   # At this point, before continuing, change "else if" to "if" in 
./node_modules/cordova-lib/src/cordova/platform/addHelper.js#L102
   # You could do it manually in a text editor - I'm using PowerShell for the 
sake of reproducing
   $addHelperJs = Get-Content 
".\node_modules\cordova-lib\src\cordova\platform\addHelper.js" -Raw;
   $addHelperJs = $addHelperJs.Replace("else if (spec === undefined && pkgJson 
&& pkgJson.devDependencies && cmd === 'add')", "if (spec === undefined && 
pkgJson && pkgJson.devDependencies && cmd === 'add')");
   $addHelperJs | Set-Content 
".\node_modules\cordova-lib\src\cordova\platform\addHelper.js"
   
   npx cordova prepare android
   ```
   
   ```
   Discovered platform "android". Adding it to the project
   Using cordova-fetch for cordova-android@^10.1.0
   Adding android project...
   Creating Cordova project for the Android platform:
           Path: platforms\android
           Package: io.cordova.hellocordova
           Name: HelloCordova
           Activity: MainActivity
           Android target: android-30
   Subproject Path: CordovaLib
   Subproject Path: app
   Android project created with [email protected]
   Installing "cordova-plugin-whitelist" for android
   Plugin doesn't support this project's cordova-android version. 
cordova-android: 10.1.0, failed version requirement: >=4.0.0 <10.0.0
   Skipping 'cordova-plugin-whitelist' for android
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to