Git Product home page Git Product logo

Comments (8)

LayZeeDK avatar LayZeeDK commented on August 24, 2024 1

Self-registering plugins would make them easy to consume.

Manually registered plugins might allow for some flexibility such as the type name in your example or configuration options, for example to preregister some common option like API path and credentials.

from scully.

LayZeeDK avatar LayZeeDK commented on August 24, 2024 1

Thank you, Sander. I'm thinking of creating some content about plugins.

from scully.

aaronfrost avatar aaronfrost commented on August 24, 2024

To add clarity: you would consume both of these the same way.

For a plugin that queries a CMS or an API somewhere, your sample plugin config looks the same for both of these examples:

// In your scully.config.js
exports.config = {
    ...,
    routes: {
        "/sample/:sampleId": {
            type: "samplePlugin",   // or the name you gave it when you manually register it
            sampleId: {
                cmsCredentials: {
                    publicKey: "1234",
                    privateKey: "abcd",
                },
                query(db){
                    return db.collection('sampleIds'); // in the database was firebase... example
                },
                property: 'item.id'
            }
        }
    },
}

from scully.

aaronfrost avatar aaronfrost commented on August 24, 2024

@SanderElias @beeman @LayZeeDK @SanderElias @jorgeucano @Splaktar what do you all think?

from scully.

SanderElias avatar SanderElias commented on August 24, 2024

The problem with "self-registration" is that somehow Scully needs to be able to pull those in.
That requires a list of available plugins somewhere. Such a list also needs maintenance.
First of all, plugins themselves need to put their main in this list.
Also, if a plugin is removed it needs to be taken off this list.
The list itself needs to be in a common-place, like angular.json, package.json or scully.config.js

I would like to propose a middle ground, that doesn't need a list, and makes it easy to pull them in:
in scully config.js:

require('./extraPlugin/extra-plugin.js')(registerPlugin);

in ./extraPlugin/extra-plugin.js'

/** plugin code here **/
module.exports = registerPlugin => registerPlugin('router', 'extra', extraRoutesPlugin);

Works with #107
This would keep the flexibility and would put in the "list" inside the scully.config.js
Also, if we go this route, I can provide something like this:

npm run scully addPluginToConfig "myNpmProvidedPlugin"

which will add the line:

require("myNpmProvidedPlugin")(registerPlugin);

to the scully.config.js if is not yet there.
Plugin authors can add this to their package.json install script.

from scully.

aaronfrost avatar aaronfrost commented on August 24, 2024

After talking to you this evening, I feel like simplifying the codebase by removing the dependency on vm will make this problem largely go away. If all contexts point to the same version of registerPlugin, then we will eliminate our errors here.

Sander and I spoke about the advantages of using vm and running the community/plugin code inside of the vm. It protects us from cowboy code that can break us. But it doesn't solve the bigger, harder to fix issues that will eventually arrive. So for now, it seems like we may punt and remove vm and use a simple require for now.

from scully.

LayZeeDK avatar LayZeeDK commented on August 24, 2024

Are the docs still representative of how you want plugins to be registered? https://github.com/scullyio/scully/blob/master/docs/plugins.md

from scully.

SanderElias avatar SanderElias commented on August 24, 2024

@LayZeeDK, yes no change there. However you need to import/require registerPlugin now.
(have a look at this)

from scully.

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.