Mantra official documentation

22-installing-and-uninstalling-components.md

A  A  A 

Installing and Uninstalling Components

Each component of a Mantra project should be installed specifically with the command install-component:

$ mantrad install-component mycomponent

When running this, Mantra will look for folder components, indicated in the property "ComponentsLocations" in mantraconfig.json file with the name "mycomponent".

The component optionally can define a mantra.json file, a Node.js module with the file mycomponent.js name as indicated in Component Definition section, if need, to register all hooks it implements (we've seen in this documentation that all of them can be defined implicity by definitions).

If the component defines Install property, then the optional method onInstall will be invoked.

Remember: if the component will be part of the project and this on should be installed later one in other environments, then the component is considered a default component, and, in this case, you should include its name in "DefaultComponents" property of mantraconfig.json file.

Uninstalling a component

To uninstall a Mantra component for the current project, you should use uninstall-component command:

$ mantrad uninstall-component mycomponent

As indicated in Component Definition section, if the component defines Install property, then the optional method onUninstall will be invoked.

Reinstalling a component

You can perform the uninstalling and installing actions at once when needed, for example, when you need to install changes in a component model during development when no update needed:

To do that, you can use reinstall-command:

$ mantrad reinstall-component mycomponent

To learn by example, go to Mantra demos and components sections of Mantra site.