[NPMCLI-119] Multiple prototypes for creating pages and components Created: 17/Mar/17  Updated: 14/Feb/18  Resolved: 29/Nov/17

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

Type: Story Priority: Neutral
Reporter: Christopher Zimmermann Assignee: Jaroslav Simak
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
dependency
is depended upon by NPMCLI-86 Add ability to generate additional fi... 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)
Documentation update required:
Yes
Date of First Response:
Epic Link: CLI v3
Sprint: Kromeriz 123, Kromeriz 124
Story Points: 5

 Description   

Option to define multiple 'prototypes' (currently there is one for page and one for component) and then be able to create new page or component from (optionally) given template. still use default one if there is no attribute.

Current default component template with 5-6 most used fields is super useful, but sometimes I am missing option to create empty component without dialog. simply just component definition and empty ftl...

maybe command like:

mgnl create-component something --prototype empty

To specify:
Exact syntax.

Note - eventually it would also be nice to have a prototype for light-modules, but that can come later.

Implemented as:
This is a breaking change, any prototypes that developers have implemented they will need to migrate to the new structure.

Structure becomes:

– mgnl-cli-prototypes
+--- components
+----- _default
+------- definition.yaml
+------- dialog.yaml
+------- template.ftl
+----- empty
+------- definition.yaml
+------- dialog.yaml
+------- template.ftl
+--- pages
...


 Comments   
Comment by Robert Kowalski [ 20/Mar/17 ]

i think `--prototype $path-to-folder-with-prototype` is a good modifier to specify a custom prototype

Comment by Christopher Zimmermann [ 21/Mar/17 ]

Prototypes live in the mgnl-cli-prototypes directory. I dont have to specify a path to there right? I am assuming that each prototype is just a directory in that mgnl-cli-prototypes directory. So i expect that I just give the name of the prototype.

Comment by Christopher Zimmermann [ 21/Mar/17 ]

Also would be nice to have an alias. "-pr"? "-pro"

Comment by Christopher Zimmermann [ 21/Mar/17 ]

By default (- or maybe configurabel in the cli config file?) the "page" and "component" prototypes are used.

Comment by Christopher Zimmermann [ 22/Mar/17 ]

What will the mgnl-cli-prototypes directory look like once there are a few of these? Also I can imagine that eventually we would have more types of them - maybe even a prototype for light-modules.
Should there be subdirectories for each type - to provide a bit of context? components pages?
tgregovsky any thoughts?

Comment by Tomáš Gregovský [ 23/Mar/17 ]

– mgnl-cli-prototypes
+--- component
+----- definition.yaml
+----- dialog.yaml
+----- template.ftl
+--- component-empty
+----- definition.yaml
+----- dialog.yaml
+----- template.ftl
+--- page
....

or

– mgnl-cli-prototypes
+--- component
+----- definition.yaml
+----- dialog.yaml
+----- template.ftl
+----- definition-empty.yaml
+----- dialog-empty.yaml
+----- template-empty.ftl
+--- page
....

in case of prototype for light module, I would go for 'light-module' folder as a sibling of component and page

Comment by Christopher Zimmermann [ 26/Jun/17 ]

Reopening because the prototypes directory could get cluttered if people dont name things correctly. And if they do name things correctly - then they have to enter a long name to specify their prototype. create-component myComp -P component-empty

To change:

  • Add level of directories to prototypes directory with "components" and "pages".
  • Put the current prototypes in "_default" directory.
  • Add new empty prototypes to demonstrate the feature (and because it would be helpful.)

This is a breaking change which will require a major version and a helpful warning message if people have modified the prototypes. (ie if they have the old prototype structure in their project)

Structure becomes:

– mgnl-cli-prototypes
+--- components
+----- _default
+------- definition.yaml
+------- dialog.yaml
+------- template.ftl
+----- empty
+------- definition.yaml
+------- dialog.yaml
+------- template.ftl
+--- pages
...

Comment by Christopher Zimmermann [ 21/Nov/17 ]

setting fix vesion to 3 because this will be a breaking change - any prototypes that users had created will no longer be valid - user will need to migrate them.

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