Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/plugin package id sync #10

Merged
merged 4 commits into from
Jul 15, 2017

Conversation

emcniece
Copy link

@emcniece emcniece commented Jul 15, 2017

It turns out that while the publish to NPM solved our Ionic/Cordova resolution errors, Cordova has some behaviour where it updates package.json with each plugin as a Dependency, along with updating config.xml with the usual plugin details.

Because this repo is published at https://www.npmjs.com/package/cordova-open-native-settings, npm install cordova-open-native-settings causes this repo to be added to package.json as this:

"dependencies": {
...
  "cordova-open-native-settings": "~1.3.0",
...
}

However when Cordova reconciles the plugin repo on npmjs.com (cordova-open-native-settings) it adds the plugin ID to package.json instead of the NPM repo name, which creates this:

"dependencies": {
...
  "cordova-open-native-settings": "~1.3.0",
  "com.phonegap.plugins.nativesettingsopener": "^1.3.0",
...
}

This new package.json now fails to npm install because the plugin ID as a dependency isn't an actual NPM package.

I think the plugin needs to be published to NPM as its plugin ID, not as the package.json name. To confirm this behaviour, I published the plugin to a private registry:

plugin in private registry

After adjusting my project to pull from this private registry, the install process worked mostly as expected:

# ionic cordova plugin add com.phonegap.plugins.nativesettingsopener
✔ Creating ./www directory for you - done!
> cordova plugin add com.phonegap.plugins.nativesettingsopener --save
✔ Running command - done!
Adding net.gsrweb.cordova.plugins.cordovaopennativesettings to package.json
Saved plugin info for "net.gsrweb.cordova.plugins.cordovaopennativesettings" to config.xml

... but as you can see, Cordova parses the NPM repo and adds the plugin ID to package.json, and in this case net.gsrweb.cordova.plugins.cordovaopennativesettings is not a valid repository so if this change gets committed, any build after this point will result in a failure to obtain the plugin.

This PR is a 2-step fix for these problems. Contained here are some changes:

  • Unified package.json name with plugin ID
  • Breaking/Minor version bump due to package renaming
  • Adjusted the README to reference the new install steps

... and to make this fully functional, this plugin will need to be published to NPM as its plugin ID (net.gsrweb.cordova.plugins.cordovaopennativesettings). Now that the package.json name is the same as the plugin ID, the procedure is simply npm publish after merging this PR.

@guyromb as maintainer of this project, I think it makes sense for you to perform the merge and publish! Please let me know if it's a hassle and perhaps we can publish in a different way.

emcniece added a commit to emcniece/Cordova-open-native-settings that referenced this pull request Jul 15, 2017
@emcniece emcniece mentioned this pull request Jul 15, 2017
@guyromb guyromb merged commit b87dfb5 into guyromb:master Jul 15, 2017
@emcniece
Copy link
Author

@guyromb thanks for merging this! Sorry to bother you - final needed step is executing npm publish to ensure that this exists at https://www.npmjs.com/package/net.gsrweb.cordova.plugins.cordovaopennativesettings

This means that you could unpublish https://www.npmjs.com/package/cordova-open-native-settings as well.

@guyromb
Copy link
Owner

guyromb commented Jul 16, 2017

@emcniece I changed everything to cordova-open-native-settings, so it will be consistent.
Can you confirm if you still have issues?

Thanks

@emcniece
Copy link
Author

@guyromb Confirmed working!

✗ ionic cordova plugin add cordova-open-native-settings
> cordova plugin add cordova-open-native-settings --save
✔ Running command - done!
Installing "cordova-open-native-settings" for android
Installing "cordova-open-native-settings" for browser
Installing "cordova-open-native-settings" for ios
Adding cordova-open-native-settings to package.json
Saved plugin info for "cordova-open-native-settings" to config.xml

Thanks so much for your help.

@guyromb
Copy link
Owner

guyromb commented Jul 17, 2017

Thank you @emcniece

@emcniece emcniece deleted the fix/plugin-package-id-sync branch July 17, 2017 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants