[NPMCLI-33] lightDevCopyResources concept is broken by global install Created: 19/Jul/16  Updated: 22/Aug/16  Resolved: 02/Aug/16

Status: Closed
Project: Magnolia CLI
Component/s: None
Affects Version/s: None
Fix Version/s: 0.0.1

Type: Bug Priority: Neutral
Reporter: Christopher Zimmermann Assignee: Federico Grilli
Resolution: Fixed Votes: 0
Labels: quickwin
Remaining Estimate: 0d
Time Spent: 3h
Original Estimate: Not Specified

Issue Links:
relation
is related to NPMCLI-39 Remove jquery from default configuration Closed
is related to NPMCLI-38 Use resources from other npm packages... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Sprint: Basel 55
Story Points: 3

 Description   

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.

Generated at Mon Feb 12 04:45:52 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.