Code Monkey home page Code Monkey logo

Comments (7)

mcaskill avatar mcaskill commented on May 20, 2024 2

I was thinking about this a couple of weeks ago. Specifically, I was wondering how one would also support non-EDD APIs. The following is what I came up with, it's clunky but a practical solution:

GRAVITY_FORMS_KEY='MyLicenseKey'
POLYLANG_PRO_KEY='MyEddLicenseKey'
POLYLANG_PRO_URL='MyEddRegisteredUrl'
POLYLANG_PRO_USERNAME='MyPolylangUsername'
POLYLANG_PRO_PASSWORD='MyPolylangPassword'
[
  {
    "type": "package",
    "package": {
      "name": "wpsyntex/polylang-pro",
      "version": "2.8.2",
      "type": "wordpress-plugin",
      "dist": {
        "type": "zip",
        "url": "https://www.polylang.pro/?edd_action=get_version&item_name=Polylang+Pro&license={%POLYLANG_PRO_KEY}&url={%POLYLANG_PRO_URL}&version={%VERSION}"
      },
      "extra": {
        "private-composer-installer": {
          "http": {
            "method": "POST",
            "username": "{%POLYLANG_PRO_USERNAME}",
            "password": "{%POLYLANG_PRO_PASSWORD}",
            "response-type": "json",
            "download-url-key": "download_link"
          }
        }
      },
      "require": {
        "composer/installers": "^1.4",
        "ffraenz/private-composer-installer": "^5.0"
      }
    }
  },
  {
    "type": "package",
    "package": {
      "name": "gravityforms/gravityforms",
      "version": "2.4.20",
      "type": "wordpress-plugin",
      "dist": {
        "type": "zip",
        "url": "https://www.gravityhelp.com/wp-content/plugins/gravitymanager/api.php?op=get_plugin&slug=gravityforms&key={%GRAVITY_FORMS_KEY}&version={%VERSION}"
      },
      "extra": {
        "private-composer-installer": {
          "http": {
            "method": "POST",
            "response-type": "json",
            "download-url-key": "download_url_latest"
          }
        }
      },
      "require": {
        "composer/installers": "^1.4",
        "ffraenz/private-composer-installer": "^5.0"
      }
    }
  }
]

Inspired by Composer's custom header authentication

from private-composer-installer.

szepeviktor avatar szepeviktor commented on May 20, 2024

@ffraenz What do you think about supporting plugins distributed with EDD?

from private-composer-installer.

szepeviktor avatar szepeviktor commented on May 20, 2024

These are the steps.

  1. Get plugin data from {%EDD_SELLER_WEBSITE_URL}?edd_action=get_version&item_id={%EDD_ITEM_ID}&license={%EDD_LICENSE_KEY}&url={%EDD_REGISTERED_WEBSITE_URL} as JSON
  2. Take 'package' element from the JSON
  3. Download plugin ZIP from that URL

Seems possible to me.

from private-composer-installer.

szepeviktor avatar szepeviktor commented on May 20, 2024

@ffraenz It would be nice to make private-composer-installer extendable and develop these features in a separate plugin.

from private-composer-installer.

ffraenz avatar ffraenz commented on May 20, 2024

I think both approaches are very interesting.

The configuration array I introduced in #25 may be exploited to offer a location for custom environment loaders that can be described in a modular way similar to what you suggested above. Tough, we'd need to design it in a way that makes this feature easily accessible. An alternative would be build in support for certain vendors.

from private-composer-installer.

szepeviktor avatar szepeviktor commented on May 20, 2024

build in support for certain vendors.

Instead we can provide a mechanism to get the download URL by code e.g. from an API: gravityforms, polylang, envato
Some kind of hook maybe ...

from private-composer-installer.

drzraf avatar drzraf commented on May 20, 2024

I don't think it's should be make extensible because many users won't accept pulling many levels of dependencies with all the gotchas there is wrt of composer install/update sequence (see, eg, merge-plugin).
But it should be rather support most known-cases and optionally be generic enough (URL + payload + placeholder?) to manage custom cases.

About the generic handler proposed by @mcaskill it's probably the way to go:

  • URL
  • method
  • content
  • payload's key

But to be truly generic you may miss:

  • authentication (for Basic auth)
  • content type (json, form-urlencoded, ...)
  • headers (for arbitrary headers)
  • user-agent (in case this is needed)
  • and possibly whether redirects are followed or not.
  • and the fact that the payload may be in XML, YAML, ... or have decode a given key (gzip, base64, ...) or the object key be nested.

That's why implementing known providers (one provider being < 10 LoC in a PHP method) is probably quicker, simpler, easier to configure and would serve the vast majority of users turning into this composer plugin.

Eg: Instead of type: package, is it possible to register another repository type (like gravityforms, edd, ffraenz/private:gravityforms, name it) so that the overall user's configuration is made even simpler?

from private-composer-installer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.