-
Notifications
You must be signed in to change notification settings - Fork 23
/
Leprechaun.config
131 lines (114 loc) · 7.64 KB
/
Leprechaun.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0" encoding="utf-8" ?>
<!--
GETTING STARTED WITH LEPRECHAUN
1. Make a COPY of this file to store your base Leprechaun configuration.
- This file should go in source control.
- It can go anywhere under your project, in some global location (like say /src)
2. Alter the Sample.Base configuration below, in your copy, to define the model conventions of your project.
- Where to find serialized item files
- Where generated code is stored
- Which code generator(s) you want to use (e.g. Constants, Synthesis, etc)
- Ignored field names
- Use of variables ($(layer) and $(module)) allow you to define conventions once and reuse them on module configs,
assuming module configs are named as 'Layer.Module'
3. Define config files for each Helix module in your project.
- Normally these should be placed alongside the module's source code
- These do not need to be deployed to the website at all
- These are not Sitecore config patches. See the sample below in the 'import' comments.
4. Alter the 'import' attribute on your base config file to find all your module configuration files
5. Run `Leprechaun.Console.exe -c "path\to\Leprechaun.MyCopy.config"` to generate your code
AVAILABLE VARIABLES IN CONFIG:
$(layer) - the Helix-style layer of the configuration (assumes config is named Layer.Module)
$(module) the Helix-style module of the configuration
$(configurationName) - the full name of the configuration
$(configDirectory) - the full path to the directory containing the root Leprechaun config file being used
NOTE: variables cannot be used on the 'import' declaration. Paths there are always relative to $(configDirectory).
-->
<leprechaun>
<!--
Use the 'import' attribute to load module configurations from other files.
This enables you to store modules' codegen configurations alongside their source for improved discoverability.
Wildcards are allowed (* and **). Relative paths are allowed, and are relative to the base config file path.
Multiple path globs are also allowed, semicolon delimited (e.g. c:\*\foo.config;d:\foo.config)
A module configuration would normally 'extend' a base config defined here that embeds the project's conventions.
For example, a module config file might contain:
<configuration name="Feature.ModuleName" extends="Sample.Base">
</configuration>
Each configuration can override anything that is in defaults or the 'extends' configuration. For more info, see
https://kamsar.net/index.php/2017/02/Unicorn-4-Part-III-Configuration-Enhancements/ (the technique is the same as Unicorn)
-->
<configurations import="**\*.module.json">
<!--
Base code generation configuration.
Use this abstract configuration to override the <defaults> where needed.
(leave defaults alone to make config upgrades simpler)
-->
<configuration name="Sample.Base" abstract="true">
<codeGenerator scripts="Scripts/Synthesis.csx, Scripts/Habitat.csx, Scripts/Diagnostics.csx" outputFile="$(configDirectory)\models\$(layer).$(module).Model.cs" />
<templatePredicate rootNamespace="Sample.$(layer).$(module)" />
</configuration>
</configurations>
<!-- Config shared across all configurations -->
<shared name="Shared">
<orchestrator type="Leprechaun.InputProviders.Sitecore.SitecoreOrchestrator, Leprechaun.InputProviders.Sitecore" singleInstance="true" />
<inputProvider type="Leprechaun.InputProviders.Sitecore.SitecoreInputProvider, Leprechaun.InputProviders.Sitecore" singleInstance="true" />
<watcher type="Leprechaun.InputProviders.Sitecore.SitecoreWatcher, Leprechaun.InputProviders.Sitecore" singleInstance="true" />
<!--
If you need to override a field type, you can add a <fieldType> child node in metadataGenerator.
Example:
<metadataGenerator type="Leprechaun.MetadataGeneration.StandardTemplateMetadataGenerator, Leprechaun" singleInstance="true">
<fieldType id="{00000000-0000-0000-0000-000000000000}" type="datetime" />
<fieldType id="{11111111-1111-1111-1111-111111111111}" type="droptree" />
</metadataGenerator>
Be sure that your .CSX file is setup to handle this in the GetFieldType(...) method.
-->
<metadataGenerator type="Leprechaun.MetadataGeneration.StandardTemplateMetadataGenerator, Leprechaun" singleInstance="true" />
<!--
You can disable the validators (not recommended) by adding the following attributes to the architectureValidator:
- allowFieldNamesIdenticalToTemplateName="true"
- allowNovelFieldNames="true"
-->
<architectureValidator type="Leprechaun.Validation.StandardArchitectureValidator, Leprechaun" singleInstance="true" />
<architectureValidatorLogger type="Leprechaun.Validation.StandardArchitectureValidatorLogger, Leprechaun" singleInstance="true" />
<logger type="Leprechaun.Execution.ConsoleLogger, Leprechaun" singleInstance="true" />
<loggerFactory type="Leprechaun.InputProviders.Sitecore.ConsoleLoggerFactory, Leprechaun.InputProviders.Sitecore" singleInstance="true" />
</shared>
<!-- Defaults all configurations inherit unless overridden -->
<defaults>
<!--
The code generator does what it sounds like.
Note the Roslyn codegen requires 'scripts' and 'outputFile' parameters which are not provided by default.
-->
<codeGenerator type="Leprechaun.CodeGen.Roslyn.CSharpScriptCodeGenerator, Leprechaun.CodeGen.Roslyn" singleInstance="true" />
<!--
The template filter defines what items are included as templates from the data store.
The name MUST match up with the include name found in the .module.json
case-insensitive
-->
<templatePredicate type="Leprechaun.InputProviders.Sitecore.Filters.SitecoreTemplatePredicate, Leprechaun.InputProviders.Sitecore" rootNamespace="$(layer).$(module)" singleInstance="true">
<include name="Templates" />
</templatePredicate>
<fieldFilter type="Leprechaun.Filters.StandardFieldFilter, Leprechaun" singleInstance="true">
<!--
Excludes can either be field names (wildcards supported) or field IDs (e.g. <exclude fieldId="guid" />)
Note that these are TEMPLATE FIELD excludes (ignore on code generation), not excluding reading serialized item fields.
-->
<exclude name="__*" />
</fieldFilter>
<typeNameGenerator type="Leprechaun.MetadataGeneration.StandardTypeNameGenerator, Leprechaun" singleInstance="true" namespaceRootPath="/sitecore/templates/$(layer)/$(module)" keepLeadingUnderscores="false" />
<templateReader type="Leprechaun.InputProviders.Sitecore.TemplateReaders.SitecoreTemplateReader, Leprechaun.InputProviders.Sitecore" singleInstance="true">
<excludedBaseTemplate id="{8CA06D6A-B353-44E8-BC31-B528C7306971}" name="Rendering Parameters Template" />
</templateReader>
<serializationFormatter
type="Leprechaun.InputProviders.Sitecore.YamlSerializationFormatterWrapper, Leprechaun.InputProviders.Sitecore"
singleInstance="true" />
<logger type="Leprechaun.Execution.ConsoleLogger, Leprechaun" singleInstance="true" />
<!-- configRootDirectory should be the path to your sitecore.json file -->
<moduleConfigReader type="Leprechaun.InputProviders.Sitecore.ModuleConfigurationReader, Leprechaun.InputProviders.Sitecore" configRootDirectory="$(configDirectory)" singleInstance="true" />
<loggerFactory type="Leprechaun.InputProviders.Sitecore.ConsoleLoggerFactory, Leprechaun.InputProviders.Sitecore" singleInstance="true" />
<rootConfigurationManager type="Sitecore.DevEx.Configuration.FilesystemConfigurationManager, Sitecore.DevEx.Configuration" singleInstance="true" />
<serializationModuleConfigurationManager
type="Sitecore.DevEx.Serialization.Client.Datasources.Filesystem.Configuration.FilesystemSerializationModuleConfigurationManager, Sitecore.DevEx.Serialization.Client"
singleInstance="true" />
</defaults>
</leprechaun>