There's a behavioural mismatch between documentation (cordova-cli doc, Website) and what really happens when cordova plugin add is used when attempting to install a plugin from a git repo by specifying git_ref and subdir.
In order to install a plugin that is located in the provided github repo under the specified subdir.
What does actually happen?
Not what is documented. See:
23:36:55 ❯ cordova plugin add https://github.com/Chuckytuh/cordova-swift-plugins-test\#0.0.1:cordova-outsystems-swiftplugin42 --verbose
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "https://github.com/Chuckytuh/cordova-swift-plugins-test#0.0.1:cordova-outsystems-swiftplugin42"
fetch: Installing https://github.com/Chuckytuh/cordova-swift-plugins-test#0.0.1:cordova-outsystems-swiftplugin42 to /Users/calcifer/Development/OutSystems/outsystems-mobile-rd/tmp/test-plugin-swift/myapp
Running command: npm install https://github.com/Chuckytuh/cordova-swift-plugins-test#0.0.1:cordova-outsystems-swiftplugin42 --save-dev
Command finished with error code 1: npm install,https://github.com/Chuckytuh/cordova-swift-plugins-test#0.0.1:cordova-outsystems-swiftplugin42,--save-dev
Failed to fetch plugin https://github.com/Chuckytuh/cordova-swift-plugins-test#0.0.1:cordova-outsystems-swiftplugin42 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
CordovaError: Error: npm: Command failed with exit code 1 Error output:
npm ERR! code 128
npm ERR! Command failed: git checkout 0.0.1:cordova-outsystems-swiftplugin42
npm ERR! fatal: Cannot switch branch to a non-commit '0.0.1:cordova-outsystems-swiftplugin42'
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/calcifer/.npm/_logs/2020-11-24T00_57_08_549Z-debug.log
CordovaError: Failed to fetch plugin https://github.com/Chuckytuh/cordova-swift-plugins-test#0.0.1:cordova-outsystems-swiftplugin42 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
CordovaError: Error: npm: Command failed with exit code 1 Error output:
npm ERR! code 128
npm ERR! Command failed: git checkout 0.0.1:cordova-outsystems-swiftplugin42
npm ERR! fatal: Cannot switch branch to a non-commit '0.0.1:cordova-outsystems-swiftplugin42'
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/calcifer/.npm/_logs/2020-11-24T00_57_08_549Z-debug.log
at /Users/calcifer/.nodenv/versions/12.19.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:140:43
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Information
After debugging the install process, it is clear that cordova-lib is capable of parsing the required information from the URL (url, git_ref and subdir), sadly, when the times comes to fetch the plugin, cordova-fetch is executed which delegates to npm install, ending up failling because npm parses everything from # onwards as being the git_ref.
Bug Report
There's a behavioural mismatch between documentation (cordova-cli doc, Website) and what really happens when
cordova plugin add
is used when attempting to install a plugin from a git repo by specifyinggit_ref
andsubdir
.Problem
What is expected to happen?
According to the documentation, one could do:
In order to install a plugin that is located in the provided github repo under the specified subdir.
What does actually happen?
Not what is documented. See:
Information
After debugging the install process, it is clear that
cordova-lib
is capable of parsing the required information from the URL (url, git_ref and subdir), sadly, when the times comes to fetch the plugin,cordova-fetch
is executed which delegates tonpm install
, ending up failling because npm parses everything from#
onwards as being the git_ref.Command or Code
Environment, Platform, Device
Both Android and iOS
Version information
Checklist