[ https://issues.apache.org/jira/browse/CB-12774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16216315#comment-16216315 ]
ASF GitHub Bot commented on CB-12774: ------------------------------------- GitHub user akdor1154 opened a pull request: https://github.com/apache/cordova-lib/pull/602 CB-12774 : Don't munge scoped plugin IDs anymore. Comment requested. In order to get plugins that are under an npm scope (e.g. `@akdor1154/some-plugin`) to install, a previous change from took the approach to consider such a plugin to be called (have the id) `some-plugin` instead of `@akdor1154/some-plugin`. This allowed scoped plugins to install and preserved the assumption that plugins will always be installed in `plugins_dir/[plugin_id]`. However, it required special parsing logic around `npm` package IDs, and it broke the assumption that the `name` in an npm plugin's `package.json' would correspond to Cordova's idea of a plugin ID. IMO this approach is the source of further complexity which is not required, and is leading to weird bugs and special cases with scoped plugins. (see the linked issue, but there is stuff as basic as "`npm install` no longer works after installing a scoped plugin") This PR changes approach - such plugins are now considered to have the id `@akdor1154/some-plugin`, in agreement with how npm treats such packages. This allows almost all special cases for scoped packages to be removed (yay). The key difference in behaviour as a result of this, though, is that while plugins are still installed in `plugins_dir/[plugin_id]`, `[plugin_id]` may no longer be a single directory, leading to plugin directories that look like ``` plugins |- @akdor1154 | |- some-plugin |- cordova-some-other-plugin ``` Most of the logic changes in this PR are based around making this change work. It's largely done how I want it, but I guess maintainers probably have strong opinions over whether this is the right way to go or not. Because of this I've left some commits in marked as TEMP that are for my own workflow. Please keep in mind I'll remove these. The only one you should be mindful of is the monkey patch to `cordova-common`; this would need to be raised in a separate PR to cordova-common if this change was approved in principle. ### Platforms affected All ### What testing has been done on this change? New end-to-end integration tests including a proper scoped plugin fixture Unit tests on scoped plugins Unit tests for plugman metadata ### Checklist - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database - [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. - [x] Added automated test coverage as appropriate for this change. You can merge this pull request into a Git repository by running: $ git pull https://github.com/akdor1154/cordova-lib simple-scopes Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-lib/pull/602.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #602 ---- commit 9c1c320d72bf2860f95bd9330ffd7718cdabba82 Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-20T06:55:44Z change scope behaviour to consider scopes to be part of the package name commit 67dbb75fa96de8486418dd0a0bfbaa22300690d5 Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-20T07:07:56Z remove extraneous done callback from scope plugin tests commit c6f681cc4df5fd4a5bd246df00a627532111144c Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-20T08:40:08Z add scoped plugin testcase commit c2346e062518c639381ac167ba60a169500501eb Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-20T08:41:46Z allow scoped plugins to exist in a dir structure reflecting there name, c.f. npm commit 14c3f74a0d9033dfb250bc7b698e18eb226bf544 Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-20T08:42:07Z add an integration test to check scoped plugin add+remove commit 0e383f9b419c5aabbbb22bbacb456c0ff38649e1 Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-20T08:43:14Z TEMP lint with typescript commit 7018c13a635b46364b34cf4378c78c60a1012f8b Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-20T08:42:27Z TEMP override plugin discovery in cordova-common commit 7aad7297f7306b380761e01017c067b31beca4a7 Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-23T06:23:14Z fix get_fetch_metadata to not guess plugins_dir anymore commit 17a8cce029ede8060383f041bbc9735f841556bf Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-23T06:53:59Z remove top_plugins override commit c0b1f5caae2d75b1bec7052598bf0f5f03285827 Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-23T23:38:16Z unit test scopes commit 419485af86670606313abe097d7bbe220d80b756 Author: Jarrad Whitaker <jwhita...@officeworks.com.au> Date: 2017-10-24T04:36:53Z add metadata unit tests ---- > cordova plugin add doesn't support npm scope > -------------------------------------------- > > Key: CB-12774 > URL: https://issues.apache.org/jira/browse/CB-12774 > Project: Apache Cordova > Issue Type: Bug > Components: cordova-fetch > Affects Versions: 1.1.0 > Reporter: Enrico Mazzucchelli > Labels: cordova-8.0.0 > Fix For: 1.1.1 > > > STEP TO REPRODUCE: > 1) setup a private repo (for example sinopia with docker: > https://github.com/kfatehi/docker-sinopia) > 2) add scope in your npm config: npm config set @myco:registry > http://0.0.0.0:4873/ > 3) create you plugin. In package.json set name: @myco/my.co.plugin.demo; in > plugin.xml set plugin id: @myco/my.co.plugin.demo. > 3) publish plugin in your private repo: > - npm set registry http://0.0.0.0:4873 > - npm publish > - npm set registry https://registry.npmjs.org/ > 4) in your cordova project dir, exec: > cordova plugin add @myco/my.co.plugin.demo > EXPECTED BEHAVIOR: > cordova plugin are installed > ACTUAL BEHAVIOR: > cordova installation failed: > Error: Failed to fetch plugin my.co.plugin.demo via registry. > Probably this is either a connection problem, or plugin spec is incorrect. > Check your connection and plugin name/version/URL. > Error: npm: Command failed with exit code 1 Error output: > npm ERR! code E404 > npm ERR! 404 Registry returned 404 for GET on > https://registry.npmjs.org/my.co.plugin.demo > npm ERR! 404 > npm ERR! 404 'com.vipera.de.foundation.commons' 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. > However node module are correctly installed (verified with npm ls) and > fetch.json have a new entry with key > @my.co.plugin.demo. -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org