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

Integrate GitHub TukuToi Repos #4

Closed
smileBeda opened this issue Jun 27, 2022 · 16 comments
Closed

Integrate GitHub TukuToi Repos #4

smileBeda opened this issue Jun 27, 2022 · 16 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@smileBeda
Copy link
Member

smileBeda commented Jun 27, 2022

Currently this plugin allows only to get plugins from the CP Directory API.

Since the directory (or its owners) claim some sort of undocumented ownership over code, and requires too much manual work to maintain for a developer, and requires a forum account a developer might not want to partake in, at least TukuToi Plugins should be possible to be pulled directly from GitHub.

It should be relatively easy by listing to a new plugin header tag or similar.

@smileBeda smileBeda added this to the 1.2.0 milestone Jun 27, 2022
@smileBeda smileBeda self-assigned this Jun 27, 2022
@smileBeda smileBeda added the enhancement New feature or request label Jun 27, 2022
@smileBeda smileBeda changed the title Integrate GtiHub TukuToi Repos Integrate GitHub TukuToi Repos Jun 27, 2022
@smileBeda
Copy link
Member Author

Mentioned this to CP Plugin Review team.

For now, I am stalling this development in hope we can list plugins on the CP dire without all the fuss and getting clear ownership of our code (yes, it is OSS, but it is also ours and not the CP initiative or else to decide whether it gets deleted from the directory - up and until now clearly requests from developer to delete their plugins have not been respected, instead they have only been unlisted)

If we get:

  • possibility to list these plugins on the dir without any social fuss,
  • guarantee that the plugins will be deleted if we request (with proof)
    then we can consider listing it back.

@smileBeda smileBeda removed this from the 1.2.0 milestone Jun 27, 2022
@bahiirwa
Copy link

Consider using the GH API that provides the latest zip
https://api.github.com/repos/bahiirwa/latest-github-release/releases/latest in particular the html_url

This can used to get the latest release zip.

@smileBeda
Copy link
Member Author

Excellent hint, thank you.

I have tried that URL with my own org, but did not get results.
This is a service (REST) I need to enable for my org somewhere?

@smileBeda
Copy link
Member Author

Never-mind, I am too dumb
https://api.github.com/repos/tukutoi/tukutoi-cp-directory-integration/releases/latest works just fine

This is probably even better than the Dir API
I will try to include that whatever happens.

@bahiirwa
Copy link

bahiirwa commented Jun 27, 2022

This works just as well. 'https://github.com/' . $user . '/' . $repo . '/archive/' . $version . '.zip' or can be used in conjuction.

@smileBeda
Copy link
Member Author

Cool

I see their API doc includes a Authorization: token <TOKEN>, but in the URL I did not need that
Is that something required?
(I can google it - already on it - but perhaps you have insight on this?)

@bahiirwa
Copy link

No auth is needed. I am using this in the plugin https://GitHub.com/bahiirwa/latest-GitHub-release

@smileBeda smileBeda added this to the 1.2.0 milestone Jun 27, 2022
@smileBeda
Copy link
Member Author

This is implemented - currently only for TukuToi ORG plugins.

This needs more testing (been a long day) and I discovered I cannot delete (my own) plugins that have strict nonce control un uninstall when attempting to delete through the Integration plugin (because it uses different nonce keys)

I have to fix that in the integration, as other plugins (built on my own boilerplate) will run into the same issue.

The integration itself is done. It should also allow in future to provide a setting to pull basically any plugins from Github as long they are tagged with classicpress-plugin
The biggest issue is, Github does not provide a Name for things, but WP does only act on the name of the plugins array.
So had to workaround that a bit, and it is not as stable as I would like. The main problem is that plugins can have a different folder/slug than the name and even different folder name and slug of main file.

I have to stop fro today and go at it tomorrow fresh again.
Current (mostly working) changes are pushed to the 1.2 branch.

It should already allow to pull in TukuToi Github plugins even if not listed on the dir.

@smileBeda
Copy link
Member Author

OK, retested, fixed a bunch of things and made it all a bit more abstract.

@bahiirwa - this version will of course not show itself on the current installs that have the plugin at version 1.1.4 or lower.
It has to be manually updated, but from 1.2.0 on, the TukuToi Org plugins on GitHub also will push themselves to the screens.

The Code is relatively easy to adapt for any other repo too, but that is not yet supported. It will need a settings screen, which I plan in a version 1.3

I will ask Elisabetta as well if she can help me test this new 1.2 release (because I had to change a bunch of stuff I did wrong in the first place, there's risk I broke something)

@smileBeda
Copy link
Member Author

smileBeda commented Jun 28, 2022

Testing instructions:

If you have ClassicPress Plugin Directory version 1.1.4 or lower installed

  • Delete the current plugin in your install
  • Download the new version from https://github.com/TukuToi/tukutoi-cp-directory-integration/tree/1.2.0
  • Refresh the browser cache
  • Visit the "Manage CP Plugins" screen
  • Try to install, activate, deactivate, update and delete any plugins (to update, you can edit the installed plugin version you want to update to something lower than current version, to trigger the update notice)

If you do not have ClassicPress Plugin Directory installed yet

  • Download the new version from https://github.com/TukuToi/tukutoi-cp-directory-integration/tree/1.2.0
  • Install on your CP site
  • Visit the "Manage CP Plugins" screen
  • Try to install, activate, deactivate, update and delete any plugins (to update, you can edit the installed plugin version you want to update to something lower than current version, to trigger the update notice)

If reporting issues, it would be best to keep it short, precise so I can fix quickly.

@bahiirwa
Copy link

This works well. Great job.

Need to add a condition to redirect to the plugins.php page when one deactivates this very plugin.
It deactivates on AJAX button press but fails (not gracefully).

@smileBeda
Copy link
Member Author

Probably better to just disable all "Deactivate" and "Delete" buttons on that specific plugin. After all, one also cannot deactivate or deleted CP core while inside CP Core, and this is similar: the plugin acts like a core component.

Thanks for the heads up.

@smileBeda
Copy link
Member Author

This has been fixed as well in same 1.2 branch.

I am just doing a JS check if the plugin is the "core" one, if the user attempts to deactivate (or delete, however he'll never be able to reach he delete button actually) then a notice is presented and an error Thrown to console

@smileBeda
Copy link
Member Author

Pushed another fix to throw an appropriate notice when CP Dir API locks the IP due to too many requests.

@smileBeda
Copy link
Member Author

Pushed more improvements to handle errors in a nicer way.

@smileBeda
Copy link
Member Author

This is released in #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants