extiverse / bazaar

The extension marketplace for your Flarum forum.
https://discuss.flarum.org/d/5151
MIT License
59 stars 14 forks source link

WIP Premium packages; Bazaar #66

Closed clarkwinkelmann closed 6 years ago

clarkwinkelmann commented 7 years ago

Work in progress

Private packages implementation

flagrow.io counterpart in https://github.com/gravure/flagrow.io/pull/7

codecov-io commented 7 years ago

Codecov Report

Merging #66 into master will decrease coverage by 1%. The diff coverage is 21.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #66      +/-   ##
==========================================
- Coverage   28.87%   27.87%   -1.01%     
==========================================
  Files          43       49       +6     
  Lines        1070     1001      -69     
==========================================
- Hits          309      279      -30     
+ Misses        761      722      -39
Impacted Files Coverage Δ
...ntrollers/ConnectedExtensionResourceController.php 0% <0%> (ø)
...lers/SubscriptionRedirectUnsubscribeController.php 0% <0%> (ø)
...Api/Controllers/SubscriptionRedirectController.php 0% <0%> (ø)
src/Listeners/AddSatisConfiguration.php 0% <0%> (ø)
...rollers/SubscriptionRedirectCallbackController.php 0% <0%> (ø)
src/Search/FlagrowApi.php 0% <0%> (ø) :arrow_up:
src/Listeners/AddApiControllers.php 0% <0%> (ø) :arrow_up:
src/Repositories/ExtensionRepository.php 0% <0%> (ø) :arrow_up:
src/Extensions/Extension.php 0% <0%> (ø) :arrow_up:
...rc/Api/Controllers/FavoriteExtensionController.php 0% <0%> (ø) :arrow_up:
... and 47 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 38c6b15...e03f506. Read the comment docs.

clarkwinkelmann commented 7 years ago

If we mark a normal package premium in flagrow.io it looks like Bazaar uses our Satis endpoint to download it, which works fine.

However when trying to install premium packages which are not in Packagist, Bazaar fails with the message Package "flagrow/dummy-premium-one" listed for update is not installed. Ignoring.

Using composer require flagrow/dummy-premium-one by hand in the same install works without issue.

Ping @luceos if you want to test. You need both this branch of bazaar and the linked branch of flagrow.io

Additional note: When the case above happens, Composer does not fail. because that's just a warning. Instead the controller fails when trying to return the data about the installed package. Because it happens in an ApiController, beta6 only returns an "Internal Server Error" string. core dev-master displays the full error message (which is just null returned instead of the Extension)

clarkwinkelmann commented 7 years ago

Finally fixed the two issue preventing installation of satis packages.

First, the code looking for package versions wasn't using the repos from the composer.json file but only the default one (In other words, only from Packagist)

I fixed the first issue by re-using the Composer client, but we need to refresh it after we changed composer.json.

We could do some fancy Composer stuff to tell it which packages we added, but it's maybe safer to re-create a new one. That's what happened before already, except it wasn't created by Bazaar and didn't load the composer.json correctly.

I added unit tests for Satis install by the way. I had to find a way to simulate HTTP requests for Composer. I went with a solution I found on SO using the PHP dev server. It probably has no change to work on Windows.

Maybe it's possible to mock HTTP requests for Composer, but I'm not sure how. This would require more research.

luceos commented 7 years ago

Is this ready for the final review @clarkwinkelmann ?

clarkwinkelmann commented 7 years ago

Not quite yet @luceos

I still need to make it user-friendly if you're not connected to flagrow.io or are not a premium user (aka user with a credit card)

Also I might make some changes as I finish work on flagrow.io

clarkwinkelmann commented 7 years ago

Note to self: I probably misunderstood how badges work :joy:

I'll fix it soon.

image

clarkwinkelmann commented 7 years ago

Note to self: package state is not (yet) updated after an extension is bought via the new popup

clarkwinkelmann commented 6 years ago

@flagrow/gravure did somebody try this PR ? Are we still missing something ?

As I said somewhere else it could do with some relooking but it's ready feature-wise (unless the team feature breaks it ? But I don't think so)

Maybe I should just make sure it doesn't break if flagrow.io doesn't offer any premium extension and merge it so we can move forward ? I think it currently assumes a few new feature from flagrow.io

luceos commented 6 years ago

@clarkwinkelmann let's do that, just try it with your current dev flagrow then merge. We need to do a test drive with premium teams before releasing bazaar and flagrow anyway.