dpa99c / cordova-check-plugins

A CLI tool to check for / manage plugin updates in Cordova/Phonegap projects.
217 stars 25 forks source link

errors #23

Closed kodeine closed 6 years ago

kodeine commented 6 years ago

this is how package.json looks like

...
        "cordova-plugin-geolocation": "git+https://github.com/apache/cordova-plugin-geolocation.git",
        "cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps",
        "cordova-plugin-inappbrowser": "^1.7.1",
        "cordova-plugin-network-information": "^1.3.3",
        "cordova-plugin-sim": "^1.3.3",

plugins/fetch.json

....
    "cordova-plugin-geolocation": {
        "source": {
            "type": "registry",
            "id": "cordova-plugin-geolocation@git+https://github.com/apache/cordova-plugin-geolocation.git"
        },
        "is_top_level": true,
        "variables": {}
    },
    "cordova-clipboard": {
        "source": {
            "type": "registry",
            "id": "cordova-clipboard@^1.0.0"
        },
        "is_top_level": true,
        "variables": {}
    },
    "cordova-plugin-googlemaps": {
        "source": {
            "type": "registry",
            "id": "https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps"
        },
        "is_top_level": true,
        "variables": {
            "API_KEY_FOR_ANDROID": "--trimmed--",
            "API_KEY_FOR_IOS": "--trimmed--"
        }
    },
plugin: cordova-plugin-googlemaps
source: npm://https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps
installed version: 2.0.0-beta3-20170804-1618
remote version: UNKNOWN - check remote source is valid
error: Failed to check npm registry for plugin 'cordova-plugin-googlemaps': Error: Command failed: npm view "https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps" version
npm ERR! code E404
npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/--trimmed--
npm ERR! 404 
npm ERR! 404  '--trimmed--' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
dpa99c commented 6 years ago

It appears this is due to a change in the format of fetch.json when using cordova@7. By default, cordova@7 uses npm install to install plugins whereas cordova@6 and earlier used git clone. Therefore, when adding a plugin from a git repo, the entry in fetch.json is different between the cordova versions.

For example:

cordova plugin add https://github.com/apache/cordova-plugin-geolocation

Entry in fetch.json using cordova@6.5.0:

"cordova-plugin-geolocation": {
    "source": {
        "type": "git",
        "url": "https://github.com/apache/cordova-plugin-geolocation",
        "subdir": "."
    },
"is_top_level": true,
        "variables": {}
}

Entry in fetch.json using cordova@7.0.1:

"cordova-plugin-geolocation": {
    "source": {
        "type": "registry",
        "id": "https://github.com/apache/cordova-plugin-geolocation"
    },
    "is_top_level": true,
    "variables": {}
}

As you can see, cordova@7 now sets type: registry even though it was installed from a Git repo.

This tool currently expects type: git hence the error.

I'll have to do some regex checking on the source.id to determine the source type, rather than relying on source.type.

Will publish a patch release to fix this soon.

dpa99c commented 6 years ago

Fixed in cordova-check-plugins@3.1.0 which now fully supports cordova@7.