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

enableReleaseAssets() no longer the supported method #533

Open
Narimm opened this issue Jun 1, 2023 · 5 comments
Open

enableReleaseAssets() no longer the supported method #533

Narimm opened this issue Jun 1, 2023 · 5 comments

Comments

@Narimm
Copy link

Narimm commented Jun 1, 2023

In the README.md the above code is still the recommended way to enable github release. However as you pointed out it no longer exists in the VCS Api and while I know if the plugin coder is sure he is using github he can still call it. IDE's hate it and its poor coding practice as it requires a virtually unchecked cast

Should the readme say

use YahnisElsts\PluginUpdateChecker\v5\PucFactory;
use YahnisElsts\PluginUpdateChecker\v5p1\Vcs\Api;
$myUpdateChecker->getVcsApi()->setStrategyFilterName(Api::STRATEGY_LATEST_RELEASE);
@YahnisElsts
Copy link
Owner

There is no enableReleaseStrategy() method and the readme doesn't mention it. Did you mean enableReleaseAssets()? Also, setStrategyFilterName() is mainly intended for internal use, it accepts a filter name not one of the STRATEGY_... constants, and you normally don't need to call it unless you want to use a custom filter name (not the same as a custom filter) for some reason.

If you want to be explicit about calling enableReleaseAssets(), you could directly construct a GitHubApi or a GitLabApi instance and then pass it to the Vcs\PluginUpdateChecker constructor. It's more complex than just calling buildUpdateChecker(), but it provides more control and should satisfy the IDE.

@Narimm
Copy link
Author

Narimm commented Jun 4, 2023

My aplogies I did mean

$myUpdateChecker = PucFactory::buildUpdateChecker('@plugin.github_repo@/releases/latest/download/info.json', __FILE__, '/@plugin.slug@');
    $myUpdateChecker->getVcsApi()->enableReleaseAssets();

Above is how we used to enable a release strategy prior to v5 using Github.
Its no longer possible because the function was removed from the API. As you mentioned its available in some API's but not all.

@Narimm
Copy link
Author

Narimm commented Jun 4, 2023

Also please review
https://github.com/YahnisElsts/plugin-update-checker
image

@Narimm Narimm changed the title enableReleaseStrategy() no longer the supported method enableReleaseAssets() no longer the supported method Jun 5, 2023
@YahnisElsts
Copy link
Owner

As I mentioned, if you want to be explicit about it, you could construct an API instance directly. For example:

$githubApiInstance = new \YahnisElsts\PluginUpdateChecker\v5p1\Vcs\GitHubApi(
	'https://github.com/username/repository',
	'access-token-here'
);
$githubApiInstance->enableReleaseAssets();

$updateChecker = new \YahnisElsts\PluginUpdateChecker\v5p1\Vcs\PluginUpdateChecker(
	$githubApiInstance,
	__FILE__,
	'plugin-slug-here'
);

What should I review about that screenshot? That code will still work as long as you're using a GitHub repository.

@liedekef
Copy link
Contributor

liedekef commented Aug 9, 2023

It works fine, the way I use it (for my plugin):

// include our custom update checker code
require_once 'plugin-update-checker/plugin-update-checker.php';
use YahnisElsts\PluginUpdateChecker\v5\PucFactory;
$myUpdateChecker = PucFactory::buildUpdateChecker(
        'https://github.com/liedekef/events-made-easy/',
        __FILE__,
        'events-made-easy'
);
// we'll use a release asset
$myUpdateChecker->getVcsApi()->enableReleaseAssets('/events-made-easy\.zip/');

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

No branches or pull requests

3 participants