apache / cordova-fetch

Apache Cordova Fetch Library
https://cordova.apache.org/
Apache License 2.0
27 stars 27 forks source link

cordova-android referencing git repo is changed to npm package version when performing a release build #92

Open ebhsgit opened 4 years ago

ebhsgit commented 4 years ago

Bug Report

cordova-android referencing git repo is not respected, and is being changed to npm package version when performing a release build

Problem

When cordova-android is in devDependencies, and is referencing a git branch (rather than a npm package version). As part of the release build (with clean environment - no platform and plugin folder), cordova-android reference is changed to latest stable npm package.

example package.json "devDependencies": { .... "cordova-android": "git+https://github.com/8bhsolutions/cordova-android.git#9.0.x-mod", ..... }

What is expected to happen?

The reference should remains unchanged.

What does actually happen?

The reference gets changed to 9.0.0, and the build process

"devDependencies": { .... "cordova-android": "9.0.0", ..... }

Information

After upgrading cordova-android to 9.0 and cordova to 10.0.0, when I build I notice that some of my cordova plugins where moved to devDependencies.

It seems that only the cordova plugins which reference git repos were moved. The plugins that reference a npm package release were still kept in dependencies node.

Then googling for why this happened, I stumbled across the apache/cordova-fetch#64, which is released in cordova-fetch 3.0.0

So I decided to manually move all the other cordova plugins and cordova-android platform to devDependencies.

If I leave cordova-android in dependencies node, the build does not touch it.

Command or Code

When I checkout a clean copy of my source code. So the node_module, platform and plugins folder will be fetched as part of the build process.

I run then following command

  1. npm install
  2. ionic cordova build android --release

Environment, Platform, Device

Windows 10 VS Code: 1.50.1 Node: 12.19.0

Release build for Android

Debug build seems ok

Version information

cordova info

Cordova Packages:

cli: 10.0.0
    common: 4.0.2
    create: 3.0.0
    lib: 10.0.0
        common: 4.0.2
        fetch: 3.0.0
        serve: 4.0.0

Project Installed Platforms:

android: 9.0.0

Environment:

OS: Microsoft Windows 10 Pro 10.0.19041 (19041) (win32 10.0.19041) x64
Node: v12.19.0
npm: 6.14.8

ionic info

Ionic:

Ionic CLI : 5.2.3 Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.2.4

Cordova:

Cordova CLI : 10.0.0 Cordova Platforms : android 9.0.0 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 3.1.2, (and 42 other plugins)

Utility:

cordova-res : not installed native-run : 0.2.8

System:

Android SDK Tools : 26.1.1 NodeJS : v12.19.0 npm : 6.14.8 OS : Windows 10

Checklist

HarelM commented 3 years ago

@ebhsgit were you able to find a work around for this? I have the same issue with cordova-ios git version...

HarelM commented 3 years ago

I think I was able to overcome this by placing the cordova-ios git link in dependencies and not devDependencies. I'm failing to understand the logic here if it's not a bug...

QuentinFarizon commented 3 years ago

Same here, don't put cordova-android and cordova-ios in devDependencies, or they will not be taken into account.µ When running cordova build, cordova fetches another version from npm, silently.

Definintely a bug according to https://github.com/apache/cordova-fetch/pull/65 mentioning "platforms and plugins"

HarelM commented 3 years ago

@erisu this is the bug we talked about in slack...

erisu commented 3 years ago

Yeah, I remember, except I can not reproduce this at all.

I showed you all the steps I took to try to reproduce it and its output but everything checked out correctly.

HarelM commented 3 years ago

@erisu I'm having this issue again (this time with a regular version and not git repo version). See if you can reproduce it on your end: Clone https://github.com/IsraelHikingMap/Site

cd IsraelHiking.Web
npm install
rm -rf platforms/ && rm -rf plugins/ (just in case...)
npx cordova platform remove android
npx cordova platform add android@10.1.1
npx cordova prepare android

this will output the following: Using cordova-fetch for cordova-android@^9.0.0.

If I move the "cordova-android": "^10.1.1" in my package.json from devDependencies to dependencies prepare command will work with the right version.

breautek commented 3 years ago

I think this will be resolved by https://github.com/apache/cordova-lib/pull/880 which was just merged in. In a day or two, you can test it by installing cordova@nightly.