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

lightDevCopyResources concept is broken by global install

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 0.0.1
    • None
    • Basel 55
    • 3

      TLDR
      lightDevCopyResources concept is broken now that mgnl is installed globally.
      For now to avoid confusion, remove the lightDevCopyResources configuration from the default configuration, and jquery from the package.json dependencies.

      Details
      The lightDevCopyResources configuration copies a file from the cli's node_modules directory to a light modules resource directory. This allows one to take advantage of npm to download an npm dependency declared in package.json "dependencies" (- ie jquery), and then copy that file into any new light module. Of course, for npm to download that declared dependency, one must run "npm install" on the cli project. So if a user wanted to use a new resource, they cannot just alter the cli configuration and run "mgnl create-light-module", they need to know that they must "npm install" again.

      However, now that the mgnl cli is typically (very conveniently) installed globally so that one can run "mgnl" from any location - this mechanism is broken and confusing.

      What is broken is that @magnolia/cli is only installed once, and so its declared npm dependencies are only installed that one time. If I now run "mgnl setup" to get the cli files to customize, I can only get different npm "dependencies" (for example angular, or to select different version of jquery), and therefore lightDevCopyResources, with confusing side-effects:

      • Changing the "dependencies" in the local package.json created by "mgnl setup", will have no effect. Even if I were to run "npm install" on this local package.json - the dependencies would not be available to lightDevCopyResources. (because it accesses the global directory.)
      • Changing the "dependencies" on the globally installed package.json, and trying to rerun "npm install" might be possible but I could not figure out how to do it. Even if it worked, then you would change the version of a module - and all projects would get that version - which might not be what you want.

        Acceptance criteria

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

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0d
                    0d
                    Logged:
                    Time Spent - 3h
                    3h