@gluestack-framework-v3/framework
v0.0.95
Published
This Plugin provides a Plugin Manager and a BasePlugin class for managing and installing plugins in a project. The Plugin consists of two main files:
Downloads
115
Readme
Framework Plugin
This Plugin provides a Plugin Manager and a BasePlugin class for managing and installing plugins in a project. The Plugin consists of two main files:
BasePlugin.ts
The
BasePlugin
class is an abstract class that serves as the base for both client and server plugins. It defines various methods for copying directories, merging dependencies, updating configuration files, and more. Subclasses must implement abstract methods such asinstall
,update
, anduninstall
.PluginManager.ts
The
PluginManager
class is responsible for managing the installation of plugins. It provides methods for loading plugin classes, installing dependencies, and copying plugin Plugins based on the generation type (template or example).
BasePlugin Class
Properties
pluginName
: Name of the plugin.sourcePath
: Path to the source directory.projectName
: Name of the project.generateFrom
: Generation type, either 'template' or 'example'.
Methods
Common Methods (Used by both client and server plugins)
copyDirectories()
: Copy multiple directories from source to destination.copyDirectory()
: Copy a single directory from source to destination.mergeDependencies()
: Merge dependencies, devDependencies, scripts, etc. from the plugin to the project's package.json.mergeTSconfigPaths()
: Merge tsconfig paths from the plugin to the project's tsconfig.json.updatePluginJson()
: Merge plugin-specific JSON to the project JSON.updateProjectNameInPackageJson()
: Update the project name in package.json.
client Plugin Methods
deleteDirectories()
: Delete multiple directories from the destination.mergeAppJson()
: Merge app.json from the plugin to the project, with specific keys for iOS, Android, and web.replaceMainLayout()
: Replace the main layout from the plugin to the project.
server Plugin Methods
mergeAppModule()
: Merge app Plugin from the plugin to the project.copyDockerComposeForDB()
: Copy docker-compose.yml from the plugin to the project.
Abstract Methods
install()
: Abstract method to install the plugin.update()
: Abstract method to update the plugin.uninstall()
: Abstract method to uninstall the plugin.
PluginManager Class
Properties
baseDir
: Base directory for the project.projectName
: Name of the project.generateFrom
: Generation type, either 'template' or 'example'.generationType
: Type of generation, either 'project' or 'example'.
Methods
updateGenerationFrom(generationFrom: 'template' | 'example'): PluginManager
: Update the generation type of the PluginManager instance.installPlugin(pluginName: string, pluginType: 'server' | 'client'): Promise<void>
: Install a plugin by copying its Plugin, installing dependencies, and initializing the plugin class.
Usage
To use the Plugin Manager, create an instance of the PluginManager
class, configure it, and then call the installPlugin
method to install individual plugins.
// Example usage
const pluginManager = new PluginManager('/path/to/project', 'myProject', 'template', 'project');
await pluginManager.installPlugin('myPlugin', 'client');
Note: You can use these methods in various plugins and call in the install function of any plugin.
Logs
Please use logger instead of console.logging. Logs from logger doesn't show in production. If you want to manage logs in development env, you can set ENABLE_LOGGING=false/true
in .env
.