[NPMCLI-197] Add availability feature fails when an area is defined, but no components are included. Created: 07/Dec/18  Updated: 04/Apr/22

Status: Accepted
Project: Magnolia CLI
Component/s: None
Affects Version/s: 3.0.4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Nicolò Chieffo Assignee: Unassigned
Resolution: Unresolved Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 18.04.1 LTS
node: v10.14.1


Issue Links:
duplicate
is duplicated by NPMCLI-203 Create quotation error in hello-magno... Closed
relation
is related to DOCU-1844 CLI error when trying to do hello-mag... 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
Date of First Response:
Epic Link: Starting is easy

 Description   

Adding availability with the CLI fails if the page template definition has the area defined, but no components have been added to the availability yet. The feature can be used with the "add-availability" command or with the "create-component" command with the "-a" option.

Add availability feature fails when the defintion looks like this:

areas:
  main:

Or like this: 

areas:
  main:
    availableComponents:

 

However the add availability feature works properly when the defintion has no area defined, or when it already has one or more components.

Or like this: 

areas:
  main:
    availableComponents:
      jumbo2:
        id: test1:components/jumbo2

 

The purpose of this ticket is to ensure that the feature works in all of the scenarios listed above.

 

 

Notes from original poster:

I was following the tutorial while I got stuck at the "Create the quotation component" step

https://documentation.magnolia-cms.com/display/DOCS60/Hello+Magnolia#HelloMagnolia-Createthequotationcomponent

While executing this command "mgnl create-component quotation -a pages/hello@main"
I got this error:

 

tecla@tecla-vm:/opt/magnolia/light-modules/hello-magnolia$ mgnl create-component quotation -a pages/hello@main

info Using configuration at /opt/node-v10.14.1-linux-x64/lib/node_modules/@magnolia/cli/lib/config/mgnl-cli.json
info Using prototypes at /opt/node-v10.14.1-linux-x64/lib/node_modules/@magnolia/cli/lib/config/mgnl-cli-prototypes
info No path option provided, component will be created relative to the current folder.
ERR! hostNode.value.push is not a function
ERR! TypeError: hostNode.value.push is not a function
ERR!     at injectYamlData (/opt/node-v10.14.1-linux-x64/lib/node_modules/@magnolia/cli/lib/yamlHelper.js:119:20)
ERR!     at Object.injectSnippetAt (/opt/node-v10.14.1-linux-x64/lib/node_modules/@magnolia/cli/lib/yamlHelper.js:86:7)
ERR!     at injectComponentAvailability (/opt/node-v10.14.1-linux-x64/lib/node_modules/@magnolia/cli/lib/addAvailability.js:110:16)
ERR!     at modifyYamlConfiguration (/opt/node-v10.14.1-linux-x64/lib/node_modules/@magnolia/cli/lib/addAvailability.js:94:24)
ERR!     at fs.readFile (/opt/node-v10.14.1-linux-x64/lib/node_modules/@magnolia/cli/lib/addAvailability.js:78:5)
ERR!     at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
ERR! 
ERR! 
ERR! mgnl: 3.0.4 node: v10.14.1 os: linux
ERR! please open an issue including this log on https://jira.magnolia-cms.com/browse/NPMCLI

 



 Comments   
Comment by Srinivasa Rao Veeranki [ 12/Dec/18 ]

I too facing the same issue and the following is the log for the same.

 

E:\Sree\magnolia\light-modules\hello-magnolia>mgnl create-component quotation -a pages/hello@main
info Using configuration at C:\Users\srinivasarao.v\AppData\Roaming\npm\node_modules@magnolia\cli\lib\config\mgnl-cli.json
info Using prototypes at C:\Users\srinivasarao.v\AppData\Roaming\npm\node_modules@magnolia\cli\lib\config\mgnl-cli-prototypes
info No path option provided, component will be created relative to the current folder.
ERR! hostNode.value.push is not a function
ERR! TypeError: hostNode.value.push is not a function
ERR! at injectYamlData (C:\Users\srinivasarao.v\AppData\Roaming\npm\node_modules@magnolia\cli\lib\yamlHelper.js:119:20)
ERR! at Object.injectSnippetAt (C:\Users\srinivasarao.v\AppData\Roaming\npm\node_modules@magnolia\cli\lib\yamlHelper.js:86:7)
ERR! at injectComponentAvailability (C:\Users\srinivasarao.v\AppData\Roaming\npm\node_modules@magnolia\cli\lib\addAvailability.js:110:16)
ERR! at modifyYamlConfiguration (C:\Users\srinivasarao.v\AppData\Roaming\npm\node_modules@magnolia\cli\lib\addAvailability.js:94:24)
ERR! at fs.readFile (C:\Users\srinivasarao.v\AppData\Roaming\npm\node_modules@magnolia\cli\lib\addAvailability.js:78:5)
ERR! at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
ERR!
ERR!
ERR! mgnl: 3.0.4 node: v10.13.0 os: win32

Comment by Ferdinand Kasper [ 28/Dec/18 ]

The same error occurs under Linux (mgnl: 3.0.5 node: v10.15.0)

~/Projekte/magnolia/light-modules/hello-magnolia$ mgnl create-component quotation -a pages/hello@main
info Using configuration at /usr/lib/node_modules/@magnolia/cli/lib/config/mgnl-cli.json
info Using prototypes at /usr/lib/node_modules/@magnolia/cli/lib/config/mgnl-cli-prototypes
info No path option provided, component will be created relative to the current folder.
ERR! hostNode.value.push is not a function
ERR! TypeError: hostNode.value.push is not a function
ERR! at injectYamlData (/usr/lib/node_modules/@magnolia/cli/lib/yamlHelper.js:119:20)
ERR! at Object.injectSnippetAt (/usr/lib/node_modules/@magnolia/cli/lib/yamlHelper.js:86:7)
ERR! at injectComponentAvailability (/usr/lib/node_modules/@magnolia/cli/lib/addAvailability.js:110:16)
ERR! at modifyYamlConfiguration (/usr/lib/node_modules/@magnolia/cli/lib/addAvailability.js:94:24)
ERR! at fs.readFile (/usr/lib/node_modules/@magnolia/cli/lib/addAvailability.js:78:5)
ERR! at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
{{ERR! }}
{{ERR! }}
ERR! mgnl: 3.0.5 node: v10.15.0 os: linux

Comment by Maciej Dybek [ 29/Dec/18 ]

The workaround that I have found is to use:
mgnl create-component quotation
without
-a pages/hello@main

Comment by Ferdinand Kasper [ 31/Dec/18 ]

Thx @Maciej, your workaround worked for me.

Comment by Jorge Fernández García [ 04/Feb/19 ]

The WA works

Comment by Christopher Zimmermann [ 06/Feb/19 ]

We will fix this problem, but in the meantime we will update the tutorial to not add the 

areas:
  main:

As without adding these manually, then the feature does work.

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