[NPMCLI-10] Refactor initial code Created: 14/Apr/16  Updated: 22/Aug/16  Resolved: 13/May/16

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

Type: Improvement Priority: Neutral
Reporter: Jan Haderka Assignee: Federico Grilli
Resolution: Fixed Votes: 0
Labels: mh5371, npm
Remaining Estimate: 0d
Time Spent: 6d 3h
Original Estimate: Not Specified

Issue Links:
dependency
is depended upon by NPMCLI-5 Investigate, improvement of npm link Closed
relation
is related to NPMCLI-16 Streamline tests Closed
is related to NPMCLI-11 Decide whether to keep bootstrap and ... Closed
is related to NPMCLI-12 Polish and streamline commands doc an... 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)
Date of First Response:
Sprint: Basel 43
Story Points: 13

 Description   

Refactor code originally contributed by Tomáš Gregovský.

Based on the comments below and in attached concept page:

  • convert scripts to single one named mgnl (syntax will then be mgnl create-page xxx, {{mgnl create-component xxx}, etc )
  • upon install, make scripts global ( install only with -g)
  • during install, prototypes used by cli to produce template and dialog definitions are expanded in global node_modules location
  • as optional step, add mgnl setup that will copy prototypes and package.json to either current location or to one provided as parameter to the command
  • modify script to read prototypes from the location specified in MGNLCLI_HOME system property or from default (global) location if not set.

This way internals of the cli will stay hidden by default, but can be still exposed via setup for those who need to have multiple different types of prototypes and other configuration for multiple different projects.

If in doubt, check the concept page or consult w/ reporter.



 Comments   
Comment by Tomáš Gregovský [ 18/Apr/16 ]

After discussion with Jan, we suggest to try to do global installation of cli and then have a command like setup-project etc.. which will always in selected <workingDirectory> create files needed for CLItoolign (package.json, _prototype, readme.md ,...).

Comment by Tomáš Gregovský [ 20/Apr/16 ]

Do we know what happens when we push new version of cli with updated prototypes? (I hope answer is they simply get updated

In case of global installation of cli, they will be updated (if user run update / new installation of cli).

to rest of had's comment/question I completely agree having prototypes and (part) of package json removed from "global" one and placed into project folder, to be able to have modifications specific for each project. so, using some kind of setup. I believe it is doable form current status, and will be really nice to have it working this way. Thanks!

Comment by Tomáš Gregovský [ 20/Apr/16 ]

... but if you're fine with the defaults...

but then you don't even see what's are defaults... (mostly for configuration in package.json)

Comment by Jan Haderka [ 20/Apr/16 ]

I finally start to get the reason why you want prototypes and possibly package.json also outside ... I'd make their copying to somewhere else as an option to the setup subcommand

Yes, that's the idea. If you don't want to customize them in any way and are happy w/ everything working automagically, then you just install cli and don't care how it works. OTOH if you want to understand where the templates are coming from or potentially tweak some settings or add something on top of it, you would use setup ... and by using setup you would also ensure that you can commit your config somewhere and even merge it with any changes we do in future versions of the scripts/prototypes/config/whatever.

Comment by Federico Grilli [ 20/Apr/16 ]

tgregovsky Well, that would be self-documented by the subcommand itself (besides possibly being in our doc website). For instance, you run mgnl setup -h and you get something like

 Usage: mgnl setup [options]

  This command does this and that...

  Options:

    -h, --help                          output usage information
    -V, --version                     output the version number
    -f, --fancy--option ...
Comment by Christopher Zimmermann [ 10/May/16 ]

The self-documentation is great. Just details, but I would change:

jumpstart to "Download and prepare Magnolia for light development"
setup to "Extract prototypes and package.json of CLI tools so that they can be customized"
create-light-module to "Create a light module"
create-page to "Create a page template"
create-component to "Create a component template"
add-availability to "Make a component available"
help to "Display help for [cmd]"

Usage instructions should not include "mgnl-jumpstart", but "mgnl".

Comment by Christopher Zimmermann [ 10/May/16 ]

When i run "setup" command, I dont get the original package.json, I get the npm processed one, which is hard to read. Is that intended? I would have expected the original one.

Comment by Federico Grilli [ 11/May/16 ]

help to "Display help for [cmd]"

Unfortunately that is provided by commander package and cannot be changed easily. What I can do is making the descriptions of our commands consistent with this one by making first letter lowercase, e.g. "download and prepare Magnolia for light development"

Usage instructions should not include "mgnl-jumpstart", but "mgnl".

Again that comes from the commander package and cannot be changed.

When i run "setup" command, I dont get the original package.json, I get the npm processed one...

Weird, I get a non processed one. Maybe depends on how you installed the cli tools? I created the tgz file with npm pack and then did sudo npm install magnolia-cli-0.0.1-snapshot.tgz -g

Comment by Christopher Zimmermann [ 11/May/16 ]

I think that the package.json is getting processed like that in another step. Maybe it's not avoidable.

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