Uploaded image for project: 'Magnolia CLI'
  1. Magnolia CLI
  2. NPMCLI-25

Local mgnl cli configuration should be used automatically

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Outdated
    • Icon: Major Major
    • 0.0.1
    • None
    • None
    • 8

      When running the mgnl command, use the mgnl cli config file (i.e., mgnl-config.json) in the current directory or any of its parents. If none exists, then fall back to the global one defined by the MGNLCLI_HOME, or eventually to the global one delivered during the global npm install.

      Reason:
      Currently it is not that easy to set a project to use a local mgnl cli configuration, and people could easily make mistakes and use the wrong cli configuration if they forget to change the configuration.
      This is because the config to be used is set globally via an environment variable. Ideally running mgnl in a directory should use the local config if present. This is how the npm cli works.

      A few possible problematic scenarios:

      • I am working on two (or more) projects with custom configs. After a break I come back to a project, but when I start using the cli it's creating files based on the config from another project.
      • I am working on a project in a team. A teammate checked in the mgnl cli configuration, I get the project and start working but did not know that I had to set the ENV variable to use this config and therefore I'm using the wrong one.
      • I set an ENV variable via the 'export' command, but come back to the project later or in another tab and local configuration is no longer used.

      Some of these are partially mitigated by the helpful INFO message that the CLI gives

      INFO: MGNLCLI_HOME env variable is set. Using prototypes at /Users/czimmermann/Documents/a-projects/lightdev-lab/mgnl-cli/test4

      A description based on this ticket and linked NPMCLI-27 of how it would work

      The mgnl CLI is installed globally which means you can now access it in the terminal from any location simply by typing "mgnl".

      While the CLI is ready to go with sensible defaults, you have the option to customize it to match your needs more closely. For example you can configure what a new component or page contains, which directories are in a new light module, or even which magnolia.properties are set on a new magnolia install. You can easily create the cli configuration files in the current directory with the "mgnl setup" command. This creates the mgnl-config.json file and a directory mgnl-config-prototypes which contains prototypes for the component and page files. Just edit these files to customize how the mgnl cli works.

      Whenever you run the mgnl cli, it will use the configuration found in the current directory, or any of its parents. For example, you can run "mgnl setup" in the directory that contains your main "light-modules" directory to create the configuration files there - and then whenever you run the cli in any of your modules, your configuration will be used. This also gives you the flexibility to configure the CLI differently for different projects if you need to.

        Acceptance criteria

              fgrilli Federico Grilli
              czimmermann Christopher Zimmermann
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD