blipson89 / leprechaun Goto Github PK
View Code? Open in Web Editor NEWA template code generation framework for Rainbow
License: MIT License
A template code generation framework for Rainbow
License: MIT License
I'm in a situation right now where an item is located at /sitecore/templates/Feature/Navigation/Menu Item
. In the roslyn code gen file, {template.CodeName}
is returning Menu Item
rather than MenuItem
. I was able to determine that if I put a folder inbetween Navigation
and Menu Item
(i.e. /sitecore/templates/Feature/Navigation/Metadata/Menu Item
, {template.CodeName}
appropriately becomes MenuItem
I tracked it down to this if statement:
https://github.com/kamsar/Leprechaun/blob/e0a23cb499d11656d2ef1729ed0e8c6da4a31da4/src/Leprechaun/MetadataGeneration/StandardTypeNameGenerator.cs#L48
name
= Menu Item
. Since there's no .
, it doesn't go through ConvertToIdentifier()
, which would remove the spaces.
Is there a reason it's like this, or should I open a PR in which this situation is handled?
public const string {field.CodeName}FieldName = ""{field.Name}"";");
I'm trying to run Leprechaun in a Helix project. When it runs I'm getting the exception
Leprechaun.Validation.ArchitectureValidationException: At least one error occurred validating your template architecture.
I don't see any information in this error that can help me troubleshoot what the problem is. Can you provide assistance in how to troubleshoot this error?
This is a example how we fixed this problem via GlassMapper.csx changes. Hope it will be helpful
GlassMapper.csx.txt
Adding some debug logging would be quite handy when troubleshooting configuration issues
At the moment, if I use default config which has the template exclusion rules on <templateReader>
node:
<excludedBaseTemplate id="{8CA06D6A-B353-44E8-BC31-B528C7306971}" name="Rendering Parameters Template" />
I will have no possibility to know if the template is inherited from rendering parameters template or not.
What I would expect from this type of exclusion is that if we ignore that base template, it is obviously not included into de-serialized base templates property, as well as no fields from that base are template included into AllFields
propery. However, I would still like to see base template ID in the template.TemplateInfo.BaseTemplateIds
property.
That would mean that Leprechaun did read the .yaml properly, however did not de-serialize ignored base template.
Would that make sense?
Running dotnet leprechaun /c Leprechaun.config in a directory with a config fails to find the config file. It displays, "The import path \Users\username\Developer\Project\src\ did not exist, and will be skipped!"
exe's may not always be available. I want to investigate the possibility of using powershell instead.
Is there any public example of project that using Leprechaun with Sitecore content serialization?
I spend a few hours to make it working but only what I can achive is:
1>Loaded metadata for 0 configurations (0 total templates) in 12ms.
1>Code generator has loaded in 199ms.
Good morning,
I am currently in an upgrade from Sitecore 8.2 to 10.2, with leprechaun in use. We used it for model generation but also to generate builders to supplement unit tests, coming from a Unicorn background in 8.2. We basically just did this with a CodeGen file in the test project as well.
We are moving to SCS over Unicorn and now that the Serialization and Generation configs are tied together, is it possible to provide multiple generation configurations per serialization configuration?
Thanks,
Ryan
I have installed leprechaun 2.2.2 but when i build my project it always comes up with an error “exited with code 1”
same configurations work in other project, its been long i am trying to figure but not sure what is the issue
Configuration name in leprechaun config and module.json are same
same steps giving issues in other developer repo too and they are also facing same issue
what could be wrong?
There may be times when I would like to override the return type of a field. Say for instance I have a droplink that will return IStandardTemplateItem
. Maybe I know it'll always be IFooItem
. I want to be able to have a way of overriding that.
If multiple base templates inherit the same base template, the field code gets generated multiple times.
Example:
The Page Description Base
template has a property Introduction
on it.
Page Base
has Page Description Base
as a base template.
Article Page
has Page Base
and Page Description Base
as a base template.
The resulting code generation has Introduction
twice.
Is there also a way to generate code from rendering definitions? In TDS we had a structure like this for every project. So the rendering ID is available in code
namespace MySite.Feature.Accordion
{
public static partial class Renderings {
public static readonly ID TimelineAccordionContainer = new ID("{80cb32f0-caa0-467a-bbdb-cd82f8f1b9c7}") ;
}
}
just change to value.Split(Environment.NewLine) for SitecoreTemplateReader
Need to elaborate on how to fix the issue, not just where to look
Currently, model generation is happening for all the projects, if the change is only for one project, there should be some feasibility to generate only for that specific project instead of all the projects.
Shout out to @rolek for opening up this enhancement on Synthesis
The improvement here would be to consider Standard Rendering Parameters similarly to StandardTemplate and provide base in Synthesis namespace
Essentially, Rendering Parameters templates should be treated in a similar fashion as Standard Template
Presence of Multi-Line
Hint: __Long description
Value: |
Line 1
Line 2
Line 3
__Long description
in serialization file
....
ID: "049c2604-7311-45a2-b05d-590dce623b89"
Parent: "049c2604-7311-45a2-b05d-590dce623b88"
Template: "049c2604-7311-45a2-b05d-590dce623b87"
Path: /sitecore/templates/Feature/MyFeature/MyTemplate
Languages:
- Language: en
Fields:
- ID: "049c2604-7311-45a2-b05d-590dce623b86"
Hint: Title
Value: Field that require long desciption
- ID: "049c2604-7311-45a2-b05d-590dce623b85"
Hint: __Long description
Value: |
Line 1
Line 2
Line 3
...
causes the generation of the .cs
file that could not be compiled due to syntax errors.
/// <summary>Line 1
Line 2
Line 3</summary>
[SitecoreField(FieldName = ...)]
I want to add the ability to generate template constants as part of the templates, such as FieldID and FieldName
See title :)
.net core 3.1 is reaching of support this year. Are there any plans for upgrading this repository to .net 6?
TODO:
includeTemplatesForSelection
module.DataStore.GetTreeNodeSync(fsTreeSpec.Path) returns null
That leads to null reference exception
I'm trying to use the NuGet package version and specify the path to the scripts which I want in source control (but not the binaries), but Leprechaun seems to always append whatever path I specify to the path where the executable is (/packages/Leprechaun + /...) which is not to be in source control.
I've tried tokenized paths like $(ConfigDirectory), ./../../../Foundation/... and others, but it's always appended.
Here is the error output I'm getting since it can't find the scripts below the exe in the NuGet packages folder:
[16:21:36] Using gulpfile ~\Source\Repos\Website\Gulpfile.js
[16:21:36] Starting '07-Code-Generate-Models'...
_ _
| | ___ _ __ _ __ ___ ___| |__ __ _ _ _ _ __
| | / _ \ '_ \| '__/ _ \/ __| '_ \ / _` | | | | '_ \
| |__| __/ |_) | | | __/ (__| | | | (_| | |_| | | | |
|_____\___| .__/|_| \___|\___|_| |_|\__,_|\__,_|_| |_|
|_| Version 1.0.1-pre01
@@ .###@@::;%%&&00'
@><@ .###@@::;%%&&00'
________) .###@@::;%%&&00'
| | .###@@::;%%&&00'
_ _|===LI===|_ .###@@::;%%&&00'
/ \_(____________) .###@@::;%%&&00'
\ / (88 o o 88) .###@@::;%%&&00'
\/\ 88: 7 :88` .###@@::;%%&&00'
\/\ '88'=='88' .###@@::;%%&&00'
\ \__'8888'__________.###@@::;%%&&00'
\___<\""/>_____/_/_.###@@::;%%&&00'
/ >< \ .###@@::;%%&&00'
/ __/--\__\ (oO@OoO@@o@oO@@o)
'-.______.-' /`"""""""""""""`\
_|_||_|_ | |
___LI)||(LI___ | |
( ~~ || ~~ ) \ /
`-----''-----` '.___________.'
Loaded metadata for 17 configurations (0 total templates) in 156ms.
Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Code generation script 'C:\Users\david\Source\Repos\Website\packages\Leprechaun.Console.1.0.1-pre01\lib\net46\.\src\Foundation\CodeGen\code\Scripts\Diagnostics.csx' was not found on disk.
at Leprechaun.CodeGen.Roslyn.CSharpScriptCodeGenerator.<ProcessScripts>b__7_0(String script)
at System.Linq.Parallel.SelectQueryOperator`2.SelectQueryOperatorResults.GetElement(Int32 index)
at System.Linq.Parallel.QueryResults`1.get_Item(Int32 index)
at System.Linq.Parallel.PartitionedDataSource`1.ListContiguousIndexRangeEnumerator.MoveNext(T& currentElement, Int32& currentKey)
at System.Linq.Parallel.StopAndGoSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
at System.Linq.Parallel.SpoolingTask.SpoolStopAndGo[TInputOutput,TIgnoreKey](QueryTaskGroupState groupState, PartitionedStream`2 partitions, SynchronousChannel`1[] channels, TaskScheduler taskScheduler)
at System.Linq.Parallel.DefaultMergeHelper`2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute()
at System.Linq.Parallel.MergeExecutor`1.Execute()
at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2 partitionedStream)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
at System.Linq.Parallel.QueryOperator`1.ExecuteAndGetResultsAsArray()
at System.Linq.ParallelEnumerable.ToArray[TSource](ParallelQuery`1 source)
at Leprechaun.CodeGen.Roslyn.CSharpScriptCodeGenerator.ProcessScripts(String scripts)
at lambda_method(Closure , Object[] )
at Configy.Containers.MicroContainer.Activate(Type type, KeyValuePair`2[] unmappedConstructorParameters)
at Configy.XmlContainerBuilder.<>c__DisplayClass5_0.<RegisterConfigTypeInterface>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at Configy.Containers.MicroContainer.Resolve(Type type)
at Configy.Containers.MicroContainer.Resolve[T]()
at Leprechaun.Console.Program.<>c__DisplayClass0_0.<Main>b__0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Leprechaun.Console.Program.Main(String[] args)
[16:21:37] '07-Code-Generate-Models' errored after 529 ms
[16:21:37] Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c ".\packages\Leprechaun.Console.1.0.1-pre01\lib\net46\Leprechaun.console.exe /c .\src\Foundation\CodeGen\code\Leprechaun.config"
Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Code generation script 'C:\Users\david\Source\Repos\Website\packages\Leprechaun.Console.1.0.1-pre01\lib\net46\.\src\Foundation\CodeGen\code\Scripts\Diagnostics.csx' was not found on disk.
at Leprechaun.CodeGen.Roslyn.CSharpScriptCodeGenerator.<ProcessScripts>b__7_0(String script)
at System.Linq.Parallel.SelectQueryOperator`2.SelectQueryOperatorResults.GetElement(Int32 index)
at System.Linq.Parallel.QueryResults`1.get_Item(Int32 index)
at System.Linq.Parallel.PartitionedDataSource`1.ListContiguousIndexRangeEnumerator.MoveNext(T& currentElement, Int32& currentKey)
at System.Linq.Parallel.StopAndGoSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
at System.Linq.Parallel.SpoolingTask.SpoolStopAndGo[TInputOutput,TIgnoreKey](QueryTaskGroupState groupState, PartitionedStream`2 partitions, SynchronousChannel`1[] channels, TaskScheduler taskScheduler)
at System.Linq.Parallel.DefaultMergeHelper`2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute()
at System.Linq.Parallel.MergeExecutor`1.Execute()
at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2 partitionedStream)
at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
at System.Linq.Parallel.QueryOperator`1.ExecuteAndGetResultsAsArray()
at System.Linq.ParallelEnumerable.ToArray[TSource](ParallelQuery`1 source)
at Leprechaun.CodeGen.Roslyn.CSharpScriptCodeGenerator.ProcessScripts(String scripts)
at lambda_method(Closure , Object[] )
at Configy.Containers.MicroContainer.Activate(Type type, KeyValuePair`2[] unmappedConstructorParameters)
at Configy.XmlContainerBuilder.<>c__DisplayClass5_0.<RegisterConfigTypeInterface>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at Configy.Containers.MicroContainer.Resolve(Type type)
at Configy.Containers.MicroContainer.Resolve[T]()
at Leprechaun.Console.Program.<>c__DisplayClass0_0.<Main>b__0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Leprechaun.Console.Program.Main(String[] args)
at ChildProcess.exithandler (child_process.js:213:12)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:821:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Process terminated with code 1.```
Add the ability to output code to multiple files.
Opened on behalf of Khushboo Sorthiya on Slack
Hello, I would like to use the NuGet version of this to keep binaries out of source control, but it seems that the only version available there is over a year old and missing many of the great features that you've added. I see that you have some scripts for packaging and pushing to NuGet - is it possibly an issue with these?
Thanks!
How to make it work if Sitecore is running in a Docker container?
Does Leprechaun have any support for Docker environment? Thanks!
The unique field validation considers all base templates' fields, but not the current template's fields being processed. The current template should be concatenated into the template list for validation.
In our solution, we sometimes use the standard rendering parameters item of sitecore as base templates. As this item comes from sitecore and defines some sitecore-internals, we don't want to serialize them.
Due to the missing serialization, we get the following message for all the items with the standard rendering parameters as base template:
Unable to resolve base template 8ca06d6a-b353-44e8-bc31-b528c7306971. No fields from this template will exist.
This is somehow annoying, as a real missing item wouldn't stand out of all these messages. Therefore, it would be really cool to get a possibility to whitelist some missing base templates, so that only "real" missing templates will generate a warning.
I'm running Leprechaun from a Gulp script (although I tried from command line with the same result) and receive the following error. If I copy all of the DLLs from the zip on GitHub it works fine, but that shouldn't be necessary for a NuGet package.
Here is the error text:
C:\Users\david\Source\Repos\Website> cmd.exe /c gulp -b "C:\Users\david\Source\Repos\Website" --color --gulpfile "C:\Users\david\Source\Repos\Website\Gulpfile.js" 07-Code-Generate-Models [15:52:55] Using gulpfile ~\Source\Repos\Website\Gulpfile.js [15:52:55] Starting '07-Code-Generate-Models'... Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'CommandLineArgumentsParser, Version=3.0.9.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. at Leprechaun.Console.Program.Main(String[] args) [15:52:55] '07-Code-Generate-Models' errored after 164 ms [15:52:55] Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c ".\packages\Leprechaun.Console.1.0.1-pre01\lib\net46\Leprechaun.console.exe /c .\src\Foundation\CodeGen\code\Leprechaun.config" Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'CommandLineArgumentsParser, Version=3.0.9.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. at Leprechaun.Console.Program.Main(String[] args) at ChildProcess.exithandler (child_process.js:213:12) at emitTwo (events.js:87:13) at ChildProcess.emit (events.js:172:7) at maybeClose (internal/child_process.js:821:16) at Socket.<anonymous> (internal/child_process.js:319:11) at emitOne (events.js:77:13) at Socket.emit (events.js:169:7) at Pipe._onclose (net.js:469:12) Process terminated with code 1.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.