blipson89 / Leprechaun

A template code generation framework for Rainbow
MIT License
42 stars 22 forks source link

Leprechaun crashes when faced Sitecore cli items include with "scope": "descendants Only" #44

Closed Viktar-Semiarykou closed 3 years ago

Viktar-Semiarykou commented 3 years ago

https://github.com/blipson89/Leprechaun/blob/6930b8e2c8c0f1337baa3f2d849065a0cf4786f2/src/Leprechaun.InputProviders.Sitecore/TemplateReaders/SitecoreTemplateReader.cs#L37

module.DataStore.GetTreeNodeSync(fsTreeSpec.Path) returns null

That leads to null reference exception

blipson89 commented 3 years ago

Hi! Could you please attach your .module.json file, as well as your leprechaun.config file

you can replace any sensitive names/paths with placeholder values

Viktar-Semiarykou commented 3 years ago

ProjectName.Feature.Product.module.json.txt We used plugins to skip such includes but it is not a good fix

blipson89 commented 3 years ago

Hi @Viktar-Semiarykou - I wanted to give a quick update.

There are actually two issues here:

  1. Since the root of the tree isn't technically present because "descendants only" is set, Sitecore Serialization returns null rather than pass along the children. This is why you're getting the null reference error. 2 that config you sent me didn't have a templates node, so the expected behaviour is that it should be passed over, not parsed. It looks like the SitecoreTemplatePredicate isn't doing its job correctly.

What I'm planning on doing:

  1. Fix the SitecoreTemplatePredicate to ensure it's only attempting to build templates. This will coincidentally make your specific instance of the error go away, despite it not actually fixing the underlying problem.
  2. Account for scenarios where the root item isn't included.

I should be able to get a fix issued by next week, alongside the other 2 issues you logged and possibly a new feature now that Sitecore CLI 4.0 is out.

I'll keep you posted. Thank you again for reporting these issues.

blipson89 commented 3 years ago

Hi @Viktar-Semiarykou,

I've pushed up a beta version that should resolve this issue. Can you please do the following:

  1. run dotnet tool update --version 2.1.0-beta0012 leprechaun.cli
  2. Update your Leprechaun.config:
    1. The serializationFormatter type has been updated. Use the value from Leprechaun.config line 108
    2. Look at the latest Leprechaun.config lines 85-89. Please make sure the template predicate include(s) match the appropriate includes in your .module.json. The path no longer matters, but the name needs to match up.

Note: this version of Leprechaun now has /watch functionality too in case you're interested.

blipson89 commented 3 years ago

Fixed in 2.1.0