e0ipso / plugnplay

šŸ¤– Plugin system for reusable code in node.js
GNU General Public License v2.0
67 stars 13 forks source link

Example plugins are discovered #75

Closed jmbeach closed 4 years ago

jmbeach commented 4 years ago

This may not be a real issue, but was curious if it was already known.

The example plugins "fruit, avocado, mango, pear, and ripeAvocado" are discovered simply by installing plugnplay.

I noticed this following the video tutorial on YouTube.

Code:

manager.discover()
    .then(discovered => {
        console.log('discovered plugins:', discovered);
        return manager.instantiate(pluginId, options);
    })

result:

{
  {
    id: 'disk',
    loader: 'FromDiskLoader.js',
    dependencies: [],
    _pluginPath: './fromDisk',
    name: 'Disk',
    description: 'Add messages from disk'
  },
  {
    id: 'sqs',
    loader: 'FromSqsLoader.js',
    dependencies: [],
    _pluginPath: './fromSQS',
    name: 'SQS',
    description: 'Add messages from SQS.'
  },
  {
    id: 'avocado',
    loader: 'customLoader.js',
    dependencies: [ 'mango', 'fruit' ],
    _pluginPath: './node_modules/plugnplay/test/test_plugins/avocado',
    name: 'Avocado',
    description: 'The main ingredient for guacamole.',
    type: 'fruit',
    sugarLevel: 'low'
  },
  {
    id: 'fruit',
    loader: 'loader.js',
    dependencies: [],
    _pluginPath: './node_modules/plugnplay/test/test_plugins/fruit',
    name: 'Fruit',
    description: 'A type of delicious food.'
  },
  {
    id: 'invalid_loader',
    loader: 'loader.js',
    dependencies: [],
    _pluginPath: './node_modules/plugnplay/test/test_plugins/invalid_loader',
    name: 'Invalid Loader'
  },
  {
    id: 'mango',
    loader: 'loader.js',
    dependencies: [],
    _pluginPath: './node_modules/plugnplay/test/test_plugins/mango',
    name: 'Mango',
    description: "It's an orange sweet oval."
  },
  {
    id: 'pear',
    loader: 'loader.js',
    dependencies: [ 'fruit' ],
    _pluginPath: './node_modules/plugnplay/test/test_plugins/pear',
    name: 'Pear',
    description: 'A kind of fruit',
    type: 'fruit'
  },
  {
    id: 'ripeAvocado',
    loader: '..\\avocado\\customLoader.js',
    dependencies: [ 'avocado', 'fruit' ],
    _pluginPath: './node_modules/plugnplay/test/test_plugins/ripeAvocado',
    name: 'Ripe Avocado',
    description: 'The main ingredient for *GOOD* guacamole.',
    type: 'fruit',
    sugarLevel: 'medium',
    decorates: 'avocado'
  }
}
e0ipso commented 4 years ago

This is indeed an intended feature. The goal of it is that plugin providers can provide optional enhancements that are available when plugnplay is installed.

ā€ā€ā€ā€ā€ā€ā€ Original Message ā€ā€ā€ā€ā€ā€ā€ On Sunday, January 26, 2020 9:53 PM, Jared Beach notifications@github.com wrote:

This may not be a real issue, but was curious if it was already known.

The example plugins "fruit, avocado, mango, pear, and ripeAvocado" are discovered simply by installing plugnplay.

I noticed this following the video tutorial on YouTube.

Code:

manager

.

discover

() .

then

(

discovered

=>

{

console

.

log

(

'

discovered plugins:

'

, discovered);

return

manager

.

instantiate

(pluginId, options); })

result:

{

{

id

:

'disk'

,

loader

:

'FromDiskLoader.js'

,

dependencies

: [],

_pluginPath

:

'./fromDisk'

,

name

:

'Disk'

,

description

:

'Add

messages

from

disk'

}, {

id

:

'sqs'

,

loader

:

'FromSqsLoader.js'

,

dependencies

: [],

_pluginPath

:

'./fromSQS'

,

name

:

'SQS'

,

description

:

'Add

messages

from

SQS.'

}, {

id

:

'avocado'

,

loader

:

'customLoader.js'

,

dependencies

: [

'mango'

,

'fruit'

],

_pluginPath

:

'./node_modules/plugnplay/test/test_plugins/avocado'

,

name

:

'Avocado'

,

description

:

'The

main

ingredient

for

guacamole.'

,

type

:

'fruit'

,

sugarLevel

:

'low'

}, {

id

:

'fruit'

,

loader

:

'loader.js'

,

dependencies

: [],

_pluginPath

:

'./node_modules/plugnplay/test/test_plugins/fruit'

,

name

:

'Fruit'

,

description

:

'A

type

of

delicious

food.'

}, {

id

:

'invalid_loader'

,

loader

:

'loader.js'

,

dependencies

: [],

_pluginPath

:

'./node_modules/plugnplay/test/test_plugins/invalid_loader'

,

name

:

'Invalid

Loader'

}, {

id

:

'mango'

,

loader

:

'loader.js'

,

dependencies

: [],

_pluginPath

:

'./node_modules/plugnplay/test/test_plugins/mango'

,

name

:

'Mango'

,

description

:

"

It's an orange sweet oval.

"

}, {

id

:

'pear'

,

loader

:

'loader.js'

,

dependencies

: [

'fruit'

],

_pluginPath

:

'./node_modules/plugnplay/test/test_plugins/pear'

,

name

:

'Pear'

,

description

:

'A

kind

of

fruit'

,

type

:

'fruit'

}, {

id

:

'ripeAvocado'

,

loader

:

'..\avocado\customLoader.js'

,

dependencies

: [

'avocado'

,

'fruit'

],

_pluginPath

:

'./node_modules/plugnplay/test/test_plugins/ripeAvocado'

,

name

:

'Ripe

Avocado'

,

description

:

'The

main

ingredient

for

GOOD

guacamole.'

,

type

:

'fruit'

,

sugarLevel

:

'medium'

,

decorates

:

'avocado'

} }

ā€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

jmbeach commented 4 years ago

Good deal. I'll close this then.