Create App plugin
A plugin to create an app in a light module.
Package name |
|
Repository link |
|
Latest version |
|
Changelog link |
Installing
The plugin doesn’t come pre-installed with Magnolia CLI.
You must add it to the mgnl.config.js
project file.
The plugin is installed automatically by the Jumpstart plugin if it is defined in a project template. |
Usage
Options
Form (short and long) | Description |
---|---|
|
Configures the content type by creating a new type or choosing an existing one. We recommended using singular form for the name. |
|
Sets the light module for the app.
By default, uses the directory specified in the |
|
The path to the custom prototype templates directory as the prototype source for app creation. |
|
Selects a prototype for app creation. |
|
Displays the version. |
|
Displays help information. |
Examples
In the following examples, assume that the mgnl.config.js
file looks like this:
import CreateAppPlugin from "@magnolia/cli-create-app-plugin";
export default {
plugins: [
new CreateAppPlugin()
]
};
For more information, see Configuring plugins.
Create a new app
npm run mgnl -- create-app "my-app"
This command creates a new app called my-app
based on the _default
prototype.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the new app will be created.
-
Choose an existing content type, or create a new one.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
Create a new app with a specific content type
npm run mgnl -- create-app "my-app" --content-type "my-ct"
This command creates a new app called my-app
based on the _default
prototype with the my-ct
content type.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the new app will be created.
If the my-ct
content type doesn’t exist in the light module directory, it is created automatically.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
Create a new app in a specific light module
npm run mgnl -- create-app "my-app" --light-module "my-lm"
This command creates a new app called my-app
based on the _default
prototype in the my-lm
light module.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose an existing content type, or create a new one.
If the my-lm
light module doesn’t exist in the light modules directory, the plugin prompts you to select another one.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
Create a new app based on a prototype from a custom prototypes directory
npm run mgnl -- create-app "my-app" --prototype-dir "/path/to/custom-prototypes-dir/app-content-type"
This command creates a new app called my-app
based on the _default
prototype from /path/to/custom-prototypes-dir/app-content-type
.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the new app will be created.
-
Choose an existing content type, or create a new one.
If the _default
prototype is not present in the custom prototypes directory, it prompts you to choose another prototype.
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
prototypeDir
-
prototype
-
The structure of the custom prototypes directory can be:
To use the custom
|
Create a new app based on a specific prototype
npm run mgnl -- create-app "my-app" --prototype "custom-prototype-name"
This command creates a new app called my-app
based on the custom-prototype-name
prototype.
The plugin will prompt you to:
-
Choose a directory containing all light modules.
-
Choose a light module directory where the new app will be created.
-
Choose an existing content type, or create a new one.
If the custom-prototype-name
prototype is not present, it prompts you to choose another prototype.
The Create App plugin only contains the To choose a custom prototype from a custom prototypes directory, use |
The plugin writes the following properties to the mgnl.config.js
file:
-
Global
-
lightModulesPath
-
-
Plugin
-
lightModule
-
prototype
-
Configuration
You can set the following properties in mgnl.config.js
to predefine the plugin’s behavior.
Global properties
Property name | Description |
---|---|
|
The path to a directory containing all light modules. |
|
The name of a light module where the app will be created. Alternative forms: |
Plugin properties
Property name | Description |
---|---|
|
The name of a light module where the app will be created. Alternative forms: |
|
The path to a custom prototypes directory. Alternative forms: |
|
The name of a prototype. Alternative forms: |
For more information, see Configuring plugins.