[NPMCLI-161] "_default" prototypes should not be available via "default" Created: 08/Feb/18  Updated: 16/Apr/20  Resolved: 15/Feb/18

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

Type: Bug Priority: Neutral
Reporter: Martin DrĂ¡pela Assignee: AntonĂ­n Juran
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relation
is related to DOCU-1334 DOC: changes in prototype name (_defa... 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
Documentation update required:
Yes
Date of First Response:
Epic Link: CLI v3
Sprint: Kromeriz 134
Story Points: 2

 Description   

The cli treats the "_default" prototypes in a special way, which could lead to confusion or errors.

It lists the "_default" prototype directory as "default":

Available prototypes are: [default, empty, with-js-model].

It allows the usage without the underscore:

> mgnl create-page a3 -P default

This is inconsistant to how the other prototuype directories are treated, for no real big benefit.
A dev could run into trouble if they made another prototuype directory called "default", they could run it, or might get confused.

TO change:
List the _default prototype directory just like the other ones:

Available prototypes are: [ _default, empty, with-js-model].

Do not support this usage (user must provide "_default":

> mgnl create-page a3 -P default

*Original description: *
In the stock installation of CLI v3 (3.0.0-SNAPSHOT of 7 February 2018) the

mgnl help create-page

(for example) says that:

Available prototypes are: [default, empty, with-js-model].

I would expect that the very last mgnl command of the five shown below (together with the output), will produce an error (as does the mgnl create-page a3 -P _empty command) and not build the structure from the _default prototype:

> mgnl create-page a1                                             
info Using configuration at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli.json
info Using prototypes at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli-prototypes
info No path option provided, page template will be created in the current folder.
info Created /home/martin/dev/all-light-modules/clitkt/dialogs/pages/a1.yaml
info Created /home/martin/dev/all-light-modules/clitkt/templates/pages/a1.ftl
info Created /home/martin/dev/all-light-modules/clitkt/templates/pages/a1.yaml
info Page template created


> mgnl create-page a2 -P empty
info Using configuration at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli.json
info Using prototypes at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli-prototypes
info No path option provided, page template will be created in the current folder.
info Created /home/martin/dev/all-light-modules/clitkt/templates/pages/a2.ftl
info Created /home/martin/dev/all-light-modules/clitkt/templates/pages/a2.yaml
info Page template created


> mgnl create-page a3 -P _empty
info Using configuration at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli.json
info Using prototypes at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli-prototypes
info No path option provided, page template will be created in the current folder.
ERR! /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli-prototypes/page/_empty doesn't exist. Please ensure that your mgnl-cli-prototypes folder contains prototype with name _empty.


> mgnl create-page a4 -P default
info Using configuration at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli.json
info Using prototypes at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli-prototypes
info No path option provided, page template will be created in the current folder.
info Created /home/martin/dev/all-light-modules/clitkt/templates/pages/a4.ftl
info Created /home/martin/dev/all-light-modules/clitkt/dialogs/pages/a4.yaml
info Created /home/martin/dev/all-light-modules/clitkt/templates/pages/a4.yaml
info Page template created

> mgnl create-page a5 -P _default
info Using configuration at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli.json
info Using prototypes at /home/martin/dev/cli3/npm-cli/lib/config/mgnl-cli-prototypes
info No path option provided, page template will be created in the current folder.
info Created /home/martin/dev/all-light-modules/clitkt/templates/pages/a5.ftl
info Created /home/martin/dev/all-light-modules/clitkt/templates/pages/a5.yaml
info Created /home/martin/dev/all-light-modules/clitkt/dialogs/pages/a5.yaml
info Page template created


 Comments   
Comment by Christopher Zimmermann [ 08/Feb/18 ]

I see what you mean.
But in my opinion I think its nice that it works as is.
Since the prototypes directory actually contains a directory named _default, I can totally see why a developer would expect that the _ would be accepted.
Of course the default is a bit of a special case. We decided to prepend the default directory with the _ so that it would always sort to the top and to indicate that it was special.

Do you see the current functionality causing problems for developers?

Comment by Christopher Zimmermann [ 08/Feb/18 ]

I see it as - the prototype system works based on the directory names. So _default should work since that is the directory name.
In addition we add "syntactic sugar" and accept "default" as well.
If we make any change to eliminate the inconsistancy - I would just take away the syntactic sugar and not accept "default" and just show "_default" in the help message.

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