JBARiskManagement / MapPIG

Probably Isn't GIS; A desktop mapping interactivity platform
MIT License
3 stars 0 forks source link

How to deploy plugins #28

Closed JamesRamm closed 7 years ago

JamesRamm commented 8 years ago

MapThing will accept any folder as its' 'plugins' folder and scan the subdirs for package.json files. Any it finds, it will try to import as a plugin.

This brings up the question of how a developer should deploy plugins? Three possible methods and their problems are:

  1. Put relevant files in a folder and drop it in the 'plugins' directory This will only work if the plugin has no other dependencies than MapThings' own dependencies, so is a fairly poor solution. Upside is it is very simple
  2. Use NPM install You can install a local package by doing just npm install /path/to/local/package when in the MapThing folder. However, this will install the plugin alongside all MapThings' other dependencies in node_modules - if mapthing were to scan that directory it would try to import many non-plugins. The way around this is to run npm install /path/to/local/package -g --prefix /path/to/plugins and it will install in path/to/plugins/node_modules. You can then set this path as the plugin path. The downside is it will duplicate dependencies between mapthing and its' plugins. This could bloat the distribution somewhat.
  3. Use npm link? NPM link appears to make a symlink from some package to another folder: https://docs.npmjs.com/cli/link So, we could potentially npm install the plugin as a normal node package in the mapthing node_modules folder, then use npm link to symlink plugin packages to the plugins folder.

NPM link seems to be the best solution, although introduces a bit of work for a user to install a plugin.

It would be good if MapThing could do this behind the scenes - add the ability to npm install then npm link in a single step either from NPM repo or a local directory.

JamesRamm commented 7 years ago

There is now an option to install plugins in the plugin panel. This uses NPM under the hood, so plugins can be installed from the npm repository, github or a local tarball or a local directory with a package.json