Coder Social home page Coder Social logo

cordova-fetch's Issues

[email protected] -> [email protected] breaks plugin installs using git repos or local directories

Bug Report

Problem

What is expected to happen?

$ npx cordova plugin add https://github.com/phonegap/phonegap-plugin-contentsync.git 

should succeed since "url to a git repository containing a plugin.xml" is a valid plugin-spec.

What does actually happen?

Information

on [email protected], plugins can be added using either the registry or a git URL

$ npx cordova --version
8.0.0
$ npx cordova plugin add https://github.com/phonegap/phonegap-plugin-contentsync.git
Installing "phonegap-plugin-contentsync" for android
Installing "phonegap-plugin-contentsync" for ios
Adding phonegap-plugin-contentsync to package.json
Saved plugin info for "phonegap-plugin-contentsync" to config.xml
$ npx cordova plugin rm phonegap-plugin-contentsync
Uninstalling phonegap-plugin-contentsync from android
Uninstalling phonegap-plugin-contentsync from ios
Removing "phonegap-plugin-contentsync"
Removing plugin phonegap-plugin-contentsync from config.xml file...
Removing phonegap-plugin-contentsync from package.json
$ npx cordova plugin add phonegap-plugin-contentsync
Installing "phonegap-plugin-contentsync" for android
Installing "phonegap-plugin-contentsync" for ios
Adding phonegap-plugin-contentsync to package.json
Saved plugin info for "phonegap-plugin-contentsync" to config.xml
$ npx cordova plugin rm phonegap-plugin-contentsync
Uninstalling phonegap-plugin-contentsync from android
Uninstalling phonegap-plugin-contentsync from ios
Removing "phonegap-plugin-contentsync"
Removing plugin phonegap-plugin-contentsync from config.xml file...
Removing phonegap-plugin-contentsync from package.json

In the same directory, with [email protected], plugins can only be added using the registry, and only intermittently

$ npm install [email protected]

+ [email protected]
added 161 packages from 112 contributors, removed 73 packages, updated 53 packages and audited 1707 packages in 19.859s

Note that, in the case of the registry add, the first run of the command fails, and the second run of the identical command succeeds

$ npx cordova plugin add phonegap-plugin-contentsync
Failed to fetch plugin phonegap-plugin-contentsync via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Could not determine package name from output:
[email protected] node_modules/phonegap-plugin-contentsync

$ npx cordova plugin add phonegap-plugin-contentsync
Installing "phonegap-plugin-contentsync" for android
Installing "phonegap-plugin-contentsync" for ios
Adding phonegap-plugin-contentsync to package.json

However, the git add always fails.

$ npx cordova plugin add https://github.com/phonegap/phonegap-plugin-contentsync.git
Failed to fetch plugin https://github.com/phonegap/phonegap-plugin-contentsync.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Could not determine package name from output:
[email protected] node_modules/phonegap-plugin-contentsync

$ npx cordova plugin add https://github.com/phonegap/phonegap-plugin-contentsync.git
Failed to fetch plugin https://github.com/phonegap/phonegap-plugin-contentsync.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Could not determine package name from output:
[email protected] node_modules/phonegap-plugin-contentsync

$ npx cordova plugin add https://github.com/phonegap/phonegap-plugin-contentsync.git
Failed to fetch plugin https://github.com/phonegap/phonegap-plugin-contentsync.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Could not determine package name from output:
[email protected] node_modules/phonegap-plugin-contentsync

Command or Code

$ cordova plugin add <git URL>

OR

$ cordova plugin add <local URL>

Environment, Platform, Device

Mac OSX Catalina 10.15.5

Version information

For cordova and ionic:

$ npx cordova --version
9.0.0 ([email protected])
$ npx ionic --version
6.10.1

For other cordova dependencies, I have attached my package.json
package.json.gz

For the rest of the environment:

  • OSX 10.15.5
  • Android Studio 4.0
  • Xcode 11.5
export NVM_VERSION=0.35.3
export NODE_VERSION=14.5.0
export NPM_VERSION=6.14.5

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Detect which package manager to invoke

https://github.com/pnpm/pnpm is almost a drop-in replacement for npm, and I am successfully using it with cordova-fetch by creating a symlink from npm to pnpm.

The flags used by cordova-fetch are also compatible with yarn, afaics, but I havent tested that. npm is also planning a new package manager on the horizon, https://github.com/npm/tink , which looks likely to support the same args.

@zkochan, creator of pnpm, has created https://github.com/zkochan/which-pm to do the detection, so it should be fairly easy to invoke the correct package manager, using the same flags.

Cannot determine package name from spec git+https://github.com...

Bug Report

Problem

fetch repeat the plugin whose repo like git+https://xxx when exec
npm install && cordova prepare

What is expected to happen?

the plugin has been download when npm install
no need to download it when cordova prepare

What does actually happen?

Discovered saved plugin "org.wbt11a.Canvas2ImagePlugin". Adding it to the project
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "git+https://github.com/wbt11a/Canvas2ImagePlugin.git#6195584c2b"
fetch: Installing git+https://github.com/wbt11a/Canvas2ImagePlugin.git#6195584c2b to /Users/me/app

Information

git clone a cordova app project
npm install && cordova prepare

cordova-fetch.js

return pathToInstalledPackage(target, dest)
                .catch(_ => installPackage(target, dest, opts));
function pathToInstalledPackage (spec, dest) {
    return Promise.resolve().then(_ => {
        const { name, rawSpec } = npa(spec, dest);
        if (!name) {
            throw new CordovaError(`Cannot determine package name from spec ${spec}`);
        }
        return resolvePathToPackage(name, dest)
            .then(([pkgPath, { version }]) => {
                if (!semver.satisfies(version, rawSpec)) {
                    throw new CordovaError(`Installed package ${name}@${version} does not satisfy ${name}@${rawSpec}`);
                }
                return pkgPath;
            });
    });
}

npa could't resolve the plugin name
Cannot determine package name from spec git+https://github.com...

Command or Code

Environment, Platform, Device

Version information

[email protected]
[email protected]

Checklist

  • [ x] I searched for existing GitHub issues
  • [ x] I updated all Cordova tooling to most recent version
  • [ x] I included all the necessary information above

How to handle `save: true` when requested package is already installed

After merging #24, we do not invoke npm install if the requested package is already installed. Thus, cordova-fetch will not add the requested package to dependencies of package.json.

However, some tests in cordova-lib expect that calling cordova-fetch with {save: true} will add the requested package to dependencies of package.json. This does not cause the tests to fail with the current version of cordova-fetch since there are no "dependency cache-hits" right now. But when I experimented with #44 to speed up cordova-lib E2E tests, some of the tests started to fail.

So how should we handle save: true when the requested package is already installed?

I think the current behavior is fine. When we find a package already installed, either a user manually installed it, or it had been previously installed by Cordova. In any case, it would have been added to dependencies unless that behavior was explicitly suppressed. So I don't really expect this behavor to break anything.

Frankly, it would be better if cordova-fetch would only fetch dependencies and was not expected to manage package.json in the first place, but that is a different story I guess.

coho audit-license-headers issues in cordova-fetch

Migrated from https://issues.apache.org/jira/browse/CB-14256:

coho audit-license-headers -r fetch uncovered the following text files without a valid license header:

  • spec/support/dummy-local-plugin/plugin.xml
  • spec/support/repo-name-neq-plugin-id.git/HEAD
  • spec/support/repo-name-neq-plugin-id.git/config
  • spec/support/repo-name-neq-plugin-id.git/refs/heads/master

On the 1.3.x branch this issue only shows up in spec/support/dummy-local-plugin/plugin.xml at this time.

Recommended solution is to add standard header to spec/support/dummy-local-plugin/plugin.xml and add the other files to .ratignore.

Save platforms and plugins to devDependencies

Feature Request

Motivation Behind Feature

Currently, Cordova platforms and plugins are saved as dependencies in the package.json file. Hence, during the Cordova prepare step, necessary files for plugins are moved for bundling with the app. These dependencies are not used directly with the app, so I believe, they should be treated as devDependencies.

I want to clear out Cordova platforms and plugins from dependencies because it could affect platforms that leverage the npm modules. This issues can be seen with the newest platform - Electron. With Electron it is expected that you use npm packages within the application and should be installed as dependencies.

For instance, if we want to use lodash with Electron app, we would npm install lodash and then import it using require. When we run the application everything works as expected because it uses the module from {project}/node_modules. But with build we need to take all the dependencies from the project and install them within the app.

As a result:

  • With Cordova platforms and plugins defined in the dependencies, for example, cordova-electron the packaged app size will increase greatly.

  • With Cordova platforms and plugins defined in the devDependencies, they would not be installed with the app and reduce the package size.

Again, Cordova platforms and plugins should be treated as development building blocks and shouldn't be in the app

Feature Description

The current implementation of the npm arguments handling is the following:

function npmArgs (target, userOptions) {
    const opts = Object.assign({ production: true }, userOptions);

    const args = ['install', target];

    if (opts.production) {
        args.push('--production');
    }
    if (opts.save_exact) {
        args.push('--save-exact');
    } else if (opts.save) {
        args.push('--save');
    } else {
        args.push('--no-save');
    }
    return args;
}

My suggestion would be instead of using --save flag, change it to --save-dev. While the --save option still appears to work, it is no longer required. The npm install saves any specified packages into dependencies by default.

Besides that, we also append --production flag. With the --production flag npm will not install modules listed in devDependencies. However, the --production flag has no particular meaning when we are adding a dependency to a project. I think that should be removed. Plus, if you use --production and --save-dev flags together, it causes npm install to break.

Later we could also remove options, like production, that get passed from cordova-lib to the cordova-fetch and do a general clean up.

Alternatives or Workarounds

Manually move Cordova platforms and plugins, that don't need to be bundled with an app, from dependencies to the devDependecies.

cordova-fetch cannot install plugins from git repos with npm 3 if project has unmet peer dependencies

Bug Report

As the subject line says, the cordova-fetch module cannot install plugins from git repositories when used with npm 3 (and perhaps 4 - I haven't tested that).

Problem

When I run cordova plugin add --save git+https://github.com/apache/cordova-plugin-inappbrowser.git, I get an error message instead of the plugin installing correctly (this happens with every git repository I've tested).

What is expected to happen?

I expect the plugin to install correctly.

What does actually happen?

I see the following error output:

Failed to fetch plugin git+https://github.com/apache/cordova-plugin-inappbrowser.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: Cannot find module 'UNMET/package.json' from '/Users/neagleson/cordova-fetch-bug-demo/test'

Information

The problematic code is here. It assumes that the last line of output will have the installed plugin's spec on it, but that is not true when there is an unmet peer dependency - hence the 'UNMET' string in the error message.

Command or Code

Here is a script that reliably reproduces the problem on my machine (Mac OS X 10.14.6). It assumes a working node and npm version of some sort are already installed.

#! /bin/bash

mkdir -p "$HOME/cordova-fetch-bug-demo"

cd "$HOME/cordova-fetch-bug-demo"

# Accept all default options when prompted
npm init

npm install --save [email protected]
npm install --save [email protected]

export PATH="$HOME/cordova-fetch-bug-demo/node_modules/.bin:$PATH"

cordova create test com.example.cordovafetchbug CordovaFetchBug

cd test

cordova platform add ios

# Adding a dependency that has an unmet peer dependency to trigger the issue
npm install --save [email protected]

cordova plugin add --save git+https://github.com/apache/cordova-plugin-inappbrowser.git

Environment, Platform, Device

Version information

As documented above, Cordova CLI 9, default version of the iOS platform, installing the cordova-inapp-browser plugin from Git, XCode 10.1, on Mac OS X 10.14.6.

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Support node recursive module resolution algorithm

Currently, cordova-fetch only checks the project's node_module directory, without checking parent directories. For example, in:

myproject/
  node_modules/
    dependency/ -> ../packages/dependency
  packages/
    dependency/
    subproject/
      index.js
      config.xml
      package.json
  package.json

If we require('dependency') from index.js, node will search through all ancestor directories for node_modules/dependency.

However, cordova-fetch doesn't support this. Instead, it will install dependency again (from the npm repository) inside myproject/packages/subproject/node_modules

This is a problem for use cases like yarn workspaces, where the standard node module resolution algorithm is used to help "dependency" be developed alongside "subproject".

Solving this problem could be a good way to improve support for yarn workspaces without needing to add explicit support for yarn.

References:

cordova-fetch patch release August 2018

Migrated from https://issues.apache.org/jira/browse/CB-14251, with minor updates:

1.3.x patch release wanted with the following updates:

  • repo URL fix from GH-20
  • explicit requirement for [email protected] (or cordova-common@^2.2.5) in dependencies, which would be an in-range update (not wanted in master branch, see note below)
  • resolve coho audit-license-headers issue in 1.3.x patch release branch (cherry-pick of some commits from GH-36) ref: GH-35

Following steps at https://github.com/apache/cordova-coho/blob/master/docs/tools-release-process.md (with some minor adjustments)

Note: cordova-common@^2.2.5 dependency update is not wanted in master branch. The master branch of this and other Cordova repos should now target the next major release as discussed in this [email protected] thread.

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

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 #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

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Private repository and UNMET DEPENDENCY

I ran into an issue which was hard to figured it out so I want to share it for others. Maybe something should be written somewhere in the documentation of cordova-fetch or cordova-cli or even better this should be consolidated.

My use case:

I develop a cordova plugin for my app in a bitbucket private repository and obviously I want to cordova plugin add it in my project.

The issue:

First time I add my plugin on working project with the command:

$ cordova plugin add git+ssh://[email protected]/myteam/cordova-plugin-my-plugin.git

All goes fine (nb: did not investigate why it goes fine on the first time). Problems happen when I was trying to start a fresh clone of my project.

$ cordova prepare --verbose
...
Discovered plugin "cordova-plugin-my-plugin" in config.xml. Adding it to the project
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "git+ssh://[email protected]/myteam/cordova-plugin-my-plugin.git"
Running command: npm install git+ssh://[email protected]/myteam/cordova-plugin-my-plugin.git --production --no-save
Command finished with error code 0: npm install,git+ssh://[email protected]/myteam/cordova-plugin-my-plugin.git,--production,--no-save
Failed to restore plugin "cordova-plugin-my-plugin" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin git+ssh://[email protected]/myteam/cordova-plugin-my-plugin.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Failed to get absolute path to installed module
...

As you can see Command finished with error code 0: npm install (OK) and then Failed to restore plugin "cordova-plugin-my-plugin" from config.xml.... Failed to get absolute path to installed module 🤔

When I realized that, I started looking for code root issue: cordova-cli > cordova-lib > cordova-fetch
And investigating in dependency-ls, I understood how cordova-fetch is checking npm install execution success and how custom repository (out of registry) are handle as 'UNMET DEPENDENCY'.

  1. snapshot npm dependency root tree (npm ls --depth=0 parsed by dependency-ls under the hood)
  2. invoke npm install
  3. snapshot npm dependency root tree again
  4. diff trees and expecting 1 line diff as the new installed package
  5. search for the new installed package directory in node_modules
    5.1. try in node_modules/${package_id_issued_from_dependency_ls}
    5.2. if failed try loading all node_modules/*/package.json and try to find givenPackageUrl === pkg.repository.url

At start I thought my case matches 5.1. case... Wrong! dependency-ls in the particular case of out of registry packages output my package id has: UNMET DEPENDENCY cordova-plugin-my-plugin... Then trying to find node_modules/UNMET DEPENDENCY cordova-plugin-my-plugin/... 🤪
So, go to 5.2.! And here I have made the most insidious mistake... In Bitbucket you can clone your repository with two different

git+ssh://[email protected]:myteam/cordova-plugin-my-plugin.git
                           ^

and

git+ssh://[email protected]/myteam/cordova-plugin-my-plugin.git
                           ^

And unfortunately I've added my plugin with one form while the other was in my package.json.

Conclusion

While all is going well on the install, cordova-fetch wasn't able to realize it. And I really didn't expect cordova relying on the package.json repository url... I don't know why by design cordova-fetch does not rely on npm exit code? And at least may be you should remove UNMET DEPENDENCY from the package name in 5.1. so that directory exist test succeed.

HTH, cheers!

cordova cannot add plugins from git (CordovaError: Error: An unknown git error occurred)

Bug Report

Problem

CordovaError: Error: An unknown git error occurred

What is expected to happen?

What does actually happen?

When you try to build the app from the scratch in macOS Terminal using: sudo cordova platform add ios
the following error appear for each plugin listed on config.xml

Error :

Discovered plugin "cordova-plugin-vibration". Adding it to the project
Failed to fetch plugin https://github.com/apache/cordova-plugin-vibration.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
CordovaError: Error: An unknown git error occurred

Information

cordova cannot fetch plugin from git
(plugin listed on config.xml file)

for e.g.:
<plugin name="cordova-plugin-battery-status" spec="https://github.com/apache/cordova-plugin-battery-status.git" />

Command or Code

sudo cordova platform add ios

Environment, Platform, Device

MacOS Terminal

Version information

CLI 11.1.0
Cordova-ios v6.3.0
Node v18.16.0
git v2.40.1
Xocde 14.3

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

cordova-fetch is much slower at prepare

It would appear that when I run a cordova prepare using cordova-fetch, it takes drastically longer than when I run it without cordova-fetch.

I have tested this on a repo with no platforms or plugins present in the directory structure, and about 20 plugins and 2 platforms defined in the package.json.

Using cordova 6.5, cordova prepare runs in about 30 seconds to add the platforms and plugins.
Using cordova 7, cordova prepare --nofetch takes about the same amount of time.
Using cordova 7, cordova prepare takes about somewhere around 5 minutes.
Using cordova 8, cordova prepare takes about the same amount of time as cordova 7 with the fetch.

Is this a known issue? This is a pretty painful amount of time to have to wait for a clean build. It causes builds on our build server to bloat quite significantly.

Any help would be appreciated.
Thanks!

CordovaError: Could not determine package name from output

Bug Report

Problem

When I attempt to install a plugin I get an error.

These are all steps I have done successfully in the past.

What is expected to happen?

Successful installation of the plugin

What does actually happen?

$ cordova plugin add ../cordova-background-geolocation
{ CordovaError: Could not determine package name from output:
up to date in 10.929s
at getTargetPackageSpecFromNpmInstallOutput (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/index.js:104:11)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
name: 'CordovaError',
message:
'Could not determine package name from output:\nup to date in 10.929s',
code: 0,
context: undefined }

Information

Command or Code

Environment, Platform, Device

Mac 10.14.4

Version information

Device manufacturer / model:
Cordova version (cordova -v):
9.0.0 ([email protected])
Cordova platform version (cordova platform ls):
android ^8.0.0
browser ^6.0.0
electron ^1.0.0
osx ^5.0.0
windows ^7.0.0

Checklist

  • [ x] I searched for existing GitHub issues
  • [ x] I updated all Cordova tooling to most recent version
  • [ x] I included all the necessary information above

Incorrect module ID in case of certain URL patterns

From review of PR #38 (1.3.1 patch release updates on 1.3.x branch) and unit testing in WIP PR #39 we discovered that the code will use incorrect module ID in case of certain URL patterns on 1.3.1. It is not yet certain whether or not this would be an issue on master.

Sample URLs where the incorrect module ID is observed in the unit tests in WIP PR #39:

  • https://scm.git.service.io/user/my-repo.git
  • git://scm.git.service.io/user/my-repo.git
  • https://scm.service.io/user/my-repo-other-url where npm indicates that it installed [email protected]
  • https://scm.service.io/user/my-repo#old-tag
  • git://scm.service.io/user/my-repo#old-tag

Unfortunately the unit tests in WIP PR #39 will not work on master due to changes in the code.

TODO:

  • add unit testing to cover this behavior in master
  • resolve on master if needed
  • determine whether or not there is any need to resolve this issue on 1.3.x, before next major release is published from the changes in master

Too slow donwloading/installing plugins

Using cordova 6.5, cordova prepare my proyect runs in about 5~6 minutes to add the platforms and plugins.
Using cordova 8, around 44 minutes.....

Any release to fix that?

Fails to get the installed target package name

In the getTargetPackageSpecFromNpmInstallOutput method, if the dependency or sub-dependency have a postinstall, for example electron package, it will print out extra lines:

> [email protected] postinstall /cordova-project/node_modules/electron
> node install.js 

Because of this additional print, the getTargetPackageSpecFromNpmInstallOutput method fails to parse properly the printout for the package name.

Appending the --silent flag would hide the addition printout and maintain the proper parsing. However, the --silent flag would prevent showing npm ERR! output on error. and they would be printed just in the .log file.

As a recommendation it would be better to loop through the printout and look for a particular format.


The steps for reproduce:


$ npx cordova@nightly create cordova-project
$ cd cordova-project
$ npx cordova@nightly platform add github:apache/cordova-electron

The steps above uses Nightly to test the Electron for Cordova 9 release.


Error:


Using cordova-fetch for github:apache/cordova-electron
Failed to fetch platform github:apache/cordova-electron
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Could not determine package name from output:
> [email protected] postinstall /cordova-procject/node_modules/electron
> node install.js

+ [email protected]

Adding Cordova plugins is much slower

I've been looking at why our builds for an Ionic based application are much slower with Cordova 8.1.2 vs 6.5, and I believe it's related to this project. For example, adding a plugin via link where it doesn't actually need to download anything, in our project, Cordova 6.5 takes 3.6s, and 8.1 takes 9.5s. As I dug into the code further, I found that dependency-ls takes ~3.5s, and it runs before and after npm install in cordova-fetch. With our 29 plugins, this adds a solid 3 minutes. It's unfortunately even slower with our jenkins VM, adding ~6 minutes to builds. I realize this is called out as a quirk in this proposal: https://github.com/apache/cordova-discuss/blob/master/proposals/fetching.md . I wonder if this quirk could be addressed to get the package.name in less than 7 seconds.

cordova prepare : failed to fetch plugins with github spec with npm@7

Bug Report

Problem

On my CI builds (clean every run), I run :

  • npm install
  • cordova prepare
    During the cordova prepare step, plugins are already installed, so it should no fetch them

What is expected to happen?

With [email protected] :

Extract of the logs pertaining to plugin cordova.plugins.diagnostic :

Discovered saved plugin "cordova-plugin-file-transfer". Adding it to the project
Installing "cordova-plugin-file-transfer" for android
Plugin dependency "[email protected]" already fetched, using that version.
Dependent plugin "cordova-plugin-file" already installed on android.
Installing "cordova-plugin-file-transfer" for ios

What does actually happen?

With [email protected] :

Extract of the logs pertaining to plugin cordova.plugins.diagnostic :

Discovered saved plugin "cordova-plugin-file-transfer". Adding it to the project
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "git+https://github.com/dpa99c/cordova-plugin-file-transfer.git"
fetch: Installing git+https://github.com/dpa99c/cordova-plugin-file-transfer.git to /Users/vagrant/git
Running command: npm install git+https://github.com/dpa99c/cordova-plugin-file-transfer.git --no-save
Command finished with error code 0: npm install,git+https://github.com/dpa99c/cordova-plugin-file-transfer.git,--no-save
Failed to restore plugin "cordova-plugin-file-transfer" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin git+https://github.com/dpa99c/cordova-plugin-file-transfer.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Could not determine package name from output:

Information

package.json :

  "dependencies": {
    "cordova-plugin-file-transfer": "git+https://github.com/dpa99c/cordova-plugin-file-transfer.git",
    ...
  }

I have the same issue with github dependencies with syntax :
github:dpa99c/cordova-plugin-file-transfer

Command or Code

ionic cordova prepare --no-build --prod --release

Environment, Platform, Device

Version information

Stack used: Xcode 12.1.x, on macOS 10.15.6 (Catalina)
ionic : 5.4.16
cordova : 9.0.0
cordova-common: 3.2.0
cordova-fetch : 2.0.1

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Install a cordova plugin by tagged version from a custom git repo fails

We're having trouble installing plugins from a private git repository by url.

cordova plugin --verbose add git+https://gitlab.internal/cordova-plugin-our-custom-plugin.git

Adding an existing tag to the url to make cordova-fetch fail:
cordova plugin --verbose add git+https://gitlab.internal/cordova-plugin-our-custom-plugin.git#1.11.0

The error implies, that the destination path could not be found:

Failed to get absolute path to installed module
    at C:\Users\xyz\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\fetch.js:173:37

Since --nofetch is deprecated in recent versions of cordova, is there a way to make this work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.