-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall_docs.txt
More file actions
1470 lines (969 loc) · 46.5 KB
/
Copy pathall_docs.txt
File metadata and controls
1470 lines (969 loc) · 46.5 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ForgeFoundary Installation Guide
This document explains how to install ForgeFoundary on your system, including the requirements and the provided installation scripts.
---
## Requirements
Before installing ForgeFoundary, make sure you have the following installed:
- **PHP** (version 8.2 or higher)
[Download PHP](https://www.php.net/downloads)
- **Composer** (PHP dependency manager)
[Download Composer](https://getcomposer.org/download/)
> ForgeFoundary depends on PHP and Composer to run and manage dependencies.
---
## Installation Scripts
ForgeFoundary provides two scripts to install the tool, depending on your operating system.
### 1. Unix / Linux / macOS
Script: `install.sh`
**How to run:**
```bash
chmod +x install.sh
./install.sh
```
The script will:
1. Ask for the installation directory (default: `~/ForgeFoundary`).
2. Clone the ForgeFoundary repository to the specified folder.
3. Install PHP dependencies using Composer.
4. Attempt to make the `ForgeFoundary` command available globally (requires write access to `/usr/local/bin`).
If the script cannot link globally, you can manually add the install directory to your `PATH`.
---
### 2. Windows
Script: `install.ps1`
**How to run:**
Open PowerShell with administrative rights and execute:
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force
.\install.ps1
```
The script will:
1. Ask for the installation directory (default: `$HOME\ForgeFoundary`).
2. Clone the ForgeFoundary repository to the specified folder.
3. Install PHP dependencies using Composer.
4. Optionally, guide you to make `ForgeFoundary` accessible globally.
---
## Next Steps
After installation, you can run the tool using:
```bash
ForgeFoundary dry-run
```# Documentation Map
This file serves as a central map for all documentation in the `Docs/` folder.
## Getting Started
- [Installation Instructions](Installation.md) – Describes requirements (PHP & Composer) and provides installation scripts for Unix and Windows.
- [Getting Started](Getting_Started.md) – Overview of ForgeFoundary, first steps, and initial setup.
- [Creating Modes](Modes/Creating_Modes.md) – Guide for creating custom scaffolding modes.
- [Commands Reference](Commands/Commands.md) – Overview of available commands and their purposes.
---
## Commands Documentation
- [Scaffold Command](Commands/Scaffold.md) – Main scaffolding command to generate project structure.
- [Create Mode Command](Commands/Create_Mode.md) – Command to create a new mode scaffold.
- [Dry Run Command](Commands/Dry_Run.md) – Simulate scaffolding without changing real files.
- [Dumb Mode Command](Commands/Dumb_Mode.md) – Dump configuration values for a single mode.
- [Dumb Modes Command](Commands/Dumb_Modes.md) – List all available modes and their metadata.
---
## Mode Sections
Each mode in ForgeFoundary can include optional and required sections to define its behavior. These sections are documented individually:
- [Mode Metadata](Modes/ModeSections/Mode_Metadata.md) – Basic metadata for a mode (name, version, author, description, language).
- [Mutators](Modes/ModeSections/Mutators.md) – Define reusable anchors for values and link them to CLI flags.
- [CLI Flags](Modes/ModeSections/CLI_Flags.md) – Optional feature to modify values via terminal using mutators.
- [Component](Modes/ModeSections/Component.md) – Core section defining the component path and name. **Required**.
- [Directories](Modes/ModeSections/Directories.md) – Optional folder structure definitions.
- [Commands](Modes/ModeSections/Commands.md) – Optional pre/post scaffolding commands.
- [Templates](Modes/ModeSections/Templates.md) – Optional templates section with defaults, overrides, and supported engines.
- [Units](Modes/ModeSections/Units.md) – Optional units system for advanced scaffolding logic.
- [Naming Conventions](Modes/ModeSections/Naming_Conventions.md) – Optional section to enforce naming styles and apply exceptions.
- [Enabling or Disabling Sections](Modes/ModeSections/Enabling_or_Disabling_Sections.md) – Control which sections are processed during scaffolding.
---
> This map will continue to grow as more documentation is added, providing a single reference point for all ForgeFoundary features.
# Getting Started with ForgeFoundary
## What is ForgeFoundary?
ForgeFoundary is a general-purpose programming scaffolder designed to help developers quickly set up project structures, templates, and reusable components. Unlike framework-specific tools, ForgeFoundary is **mode-based**, meaning you can create custom scaffolding "modes" for any programming language, framework, or project type.
It’s for developers who want **flexible, repeatable project scaffolding** without being tied to a specific ecosystem.
---
## Who is this for?
* Developers interested in **defining their own project structures** and automating repetitive setups.
* Anyone curious about creating **custom modes** for any programming workflow.
> ⚠️ You will need **PHP 8.2+** and **Composer** installed before using ForgeFoundary.
---
## After Installation
Once you’ve followed the instructions in [Installation Instructions](Installation.md) and successfully installed ForgeFoundary:
1. Verify the installation:
```bash
ForgeFoundary list
```
This will display available commands and options.
2. Test a scaffold run using the dry-run command:
```bash
ForgeFoundary dry-run
```
This simulates scaffolding without creating files, letting you preview your setup.
---
## Creating Custom Modes
### How to create a mode:
1. Generate a new mode skeleton:
```bash
ForgeFoundary create-mode MyCustomMode
```
This creates a folder in `Modes/` with all necessary files ready for configuration.
2. Edit your mode configuration YAML:
* Define directories, templates, units, and naming conventions.
* Optionally add CLI flags or pre/post commands.
3. Run your mode:
```bash
ForgeFoundary scaffold --mode=MyCustomMode
```
This will scaffold the structure based on your configuration.# Dry Run Command
## Overview
The `dry-run` command allows you to **simulate a full ForgeFoundary scaffolding** without creating or modifying any real files. It’s perfect for **previewing your mode configuration** and seeing the generated project structure safely.
Think of it as a “practice run” before committing your scaffolding to disk.
---
## Usage
```bash
ForgeFoundary dry-run --mode=ModeName [options]
```
### Options
* `--mode=` – Specify which mode to simulate.
* `--modes-path=` – Optionally set a custom path to your modes folder.
* `--config-name=` – Select a specific main configuration file name.
* `--config-path=` – Set a custom path to the main configuration YAML.
* `--custom=*` – Pass additional custom CLI flags declared in the mode.
* `--cli-log` – Enable logging output directly in the terminal.
* `--file-log` – Save logs to a file.
---
## How it works
When executed, `dry-run`:
1. Loads your **tool and mode configuration**.
2. Creates a **temporary folder** to simulate all scaffolding operations.
3. Overrides paths (like components) to ensure nothing is written to your actual project.
4. Runs all systems in order:
* Components
* Directories
* Units
* Templates
* Commands
5. Renders a **tree view** of the generated structure.
6. Cleans up by **deleting the temporary folder** after the run.
> The command gives a safe, real-time preview of your project scaffolding without affecting your actual files.
---
## Example
```bash
# Simulate scaffolding for the default mode
ForgeFoundary dry-run
# Simulate a custom mode with CLI logging
ForgeFoundary dry-run --mode=MyCustomMode --cli-log
# Simulate using additional custom flags
ForgeFoundary dry-run --mode=WebApp --custom=component_path=/tmp/temp_components
```
---
## Next Steps
After reviewing a dry run:
1. Update your mode’s YAML configuration or templates as needed.
2. Once satisfied, run the **real scaffolding** with:
```bash
ForgeFoundary scaffold --mode=MyCustomMode
```# Scaffold Command
## Overview
The `scaffold` command is the **main command** in ForgeFoundary. It generates the project structure according to a selected **mode**, creating directories, templates, units, and components automatically. This is the command you will use most often to apply the scaffolding defined in your modes.
## Usage
```bash
ForgeFoundary scaffold --mode=ModeName [options]
```
### Options
* `--mode=` – Specify which mode to run.
* `--modes-path=` – Optionally set a custom path to your modes folder.
* `--tree-view` – Render a visual tree of the generated project structure.
* `--config-name=` – Select a specific configuration file name for the mode(Main config not mode).
* `--config-path=` – Set a custom path to the mode’s configuration YAML(Main config not mode).
* `--custom=*` – Pass additional custom cli flags declared in the mode.
* `--cli-log` – Enable logging output directly in the terminal.
* `--file-log` – Save logs to a file.
---
## How it works
When executed, `scaffold`:
1. Loads your **tool and mode configuration**.
2. Boots all necessary systems for scaffolding.
3. Runs the following **in order**:
* Pre-Scaffold Commands
* Components
* Directories
* Units
* Templates
* Post-Scaffold Commands
4. Outputs logs and reports.
5. Optionally, displays a **tree view** of the generated structure if `--tree-view` is enabled.
> Think of this command as the central engine that applies all the rules and templates you’ve defined in your mode.
---
## Example
```bash
# Run the default mode defined in the main config file
ForgeFoundary scaffold
# Run a custom mode and render tree view
ForgeFoundary scaffold --mode=MyCustomMode --tree-view
```# Commands in ForgeFoundary
ForgeFoundary exposes a set of **commands** that allow you to interact with the tool, run scaffolding tasks, and manage modes. Commands are modular and extensible, and each has its own dedicated documentation in `Docs/Commands/`.
---
## Available Commands
* **ScaffoldCommand** – Executes the scaffolding process for a specified mode, generating directories, templates, and units.
**Docs:** [ScaffoldCommand](Scaffold.md)
* **Create Mode Command** – Generates a new mode skeleton for you to configure.
**Docs:** [Create Mode Command](Create_Mode.md)
* **Dry Run Command** – Simulates scaffolding without creating files, so you can preview your setup.
**Docs:** [Dry Run Command](Dry_Run.md)
* **Dumb Modes Command** – Lists all available modes in a simple, readable format.
**Docs:** [Dumb Modes Command](Dumb_Modes.md)
* **Dumb Mode Command** – Shows details for a single mode, including directories, templates, and units.
**Docs:** [Dumb Mode Command](Dumb_Mode.md)
---
For detailed usage and examples, see the individual command docs inside `Docs/Commands/`.
# Create Mode Command
## Overview
The `create-mode` command allows you to **quickly generate a new mode skeleton** in ForgeFoundary. A mode defines how your project should be scaffolded, including directories, templates, units, components, commands, CLI flags, and naming conventions.
With the latest update, you can now **choose from four mode types** that provide different levels of detail for your new mode:
* **Minimal** – Only mode metadata, component path & name, empty directories array, and basic template paths.
* **Moderate** – Metadata, component, templates, units sections included, but without nested keys.
* **Extended** – Includes metadata, component, templates, units, commands, CLI flags, and naming conventions with mutators.
* **Full** – All keys, including nested keys and mutators; the most complete starting template.
This command is the **starting point** for building custom scaffolding logic that suits your workflow.
---
## Usage
```bash
ForgeFoundary create-mode --mode-name=MyCustomMode --mode-type=[minimal|moderate|extended|full] [options]
```
### Options
* `--mode-name=` – **Required.** The name of the new mode you want to create.
* `--mode-type=` – **Optional.** The type of mode template to use (`minimal`, `moderate`, `extended`, `full`). Defaults to `full` if not specified.
* `--cli-log` – Enable logging output directly in the terminal while generating the mode.
* `--file-log` – Save logs to a file while generating the mode.
---
## How it works
When executed, `create-mode`:
1. Loads your **tool configuration** and CLI context.
2. Resolves paths for the new mode folder and its YAML configuration.
3. Determines which **mode template** to use (`minimal`, `moderate`, `extended`, or `full`).
4. Creates the **mode directory** and a **Templates folder** inside it.
5. Copies the selected **YAML template** into the new mode folder, ready to be edited.
6. Logs messages confirming the creation of the mode.
> Think of this command as the scaffolding for your scaffolding—everything else you define in the mode will be based on this initial setup.
---
## Examples
```bash
# Create a new minimal mode
ForgeFoundary create-mode --mode-name=SimpleMode --mode-type=minimal
# Create a full-featured mode with CLI logging enabled
ForgeFoundary create-mode --mode-name=AdvancedMode --mode-type=full --cli-log
# Create a moderate mode
ForgeFoundary create-mode --mode-name=ModerateMode
```
---
## Next Steps
After creating a mode:
1. Navigate to your new mode folder:
```bash
cd Modes/MyCustomMode
```
2. Edit the YAML file to define your **directories, templates, units, components, commands, CLI flags, and naming conventions** according to your workflow.
3. Add or customize templates in the `Templates/` folder.
4. Run the mode using:
```bash
ForgeFoundary scaffold --mode=MyCustomMode
```# Dumb Modes Command
## Overview
The `dumb-modes` command lists all **modes available** in ForgeFoundary. It scans your configured modes folder, retrieves metadata from each mode, and displays a structured view in the terminal. This is useful for quickly checking which modes you have installed and their basic configuration info.
Think of it as a **mode inventory command**.
---
## Usage
```bash
ForgeFoundary dumb-modes [options]
```
### Options
* `--config-name=` – Specify a main configuration file name.
* `--config-path=` – Set a custom path to the main configuration YAML.
* `--custom=*` – Pass additional custom CLI flags.
* `--cli-log` – Enable logging output in the terminal.
* `--file-log` – Save logs to a file.
---
## How it works
When executed, `dumb-modes`:
1. Loads your **main configuration** to locate the modes folder.
2. Scans each subdirectory in the modes folder for YAML mode files.
3. Parses each mode’s metadata (like name, description, or author) from the YAML file.
4. Displays all modes in a **tree-like structure**, including metadata if available.
> The command only reads and displays metadata — it **does not modify** any files or run scaffolding.
---
## Example
```bash
# List all available modes
ForgeFoundary dumb-modes
```
---
## Next Steps
After reviewing your modes:
1. Run the **dry-run** command to preview scaffolding for a specific mode:
```bash
ForgeFoundary dry-run --mode=MyCustomMode
```
2. Run the **scaffold** command to apply a mode and generate project files:
```bash
ForgeFoundary scaffold --mode=MyCustomMode
```# Dumb Mode Command
## Overview
The `dumb-mode` command allows you to **inspect the configuration values** of a single ForgeFoundary mode. It outputs the mode’s settings in a clear, structured format so you can understand its directories, templates, units, naming conventions, commands, and CLI flags without editing the files directly.
You can view the mode either as a **tree view** or as **raw YAML**.
---
## Usage
```bash
ForgeFoundary dumb-mode --mode=ModeName [options]
```
### Options
* `--mode=` – Specify which mode to inspect.
* `--modes-path=` – Optionally set a custom path to your modes folder.
* `--raw-yaml` – Output the configuration as raw YAML instead of a tree view.
* `--config-name=` – Specify a main configuration file name.
* `--config-path=` – Set a custom path to the main configuration YAML.
* `--custom=*` – Pass additional CLI flags.
* `--cli-log` – Enable logging output in the terminal.
* `--file-log` – Save logs to a file.
---
## How it works
When executed, `dumb-mode`:
1. Loads your **tool configuration** and **CLI input context**.
2. Locates the specified mode’s YAML configuration file.
3. Reads the mode’s configuration into memory.
4. Outputs the configuration either as:
* **Tree view** – nested directories, templates, and units displayed hierarchically.
* **Raw YAML** – full YAML content, useful for copying or editing.
5. Adds headers and footers for readability in the terminal.
> This command does **not modify any files** or run scaffolding — it only displays the mode’s configuration.
---
## Example
```bash
# Display a mode in tree view
ForgeFoundary dumb-mode --mode=MyCustomMode
# Display a mode as raw YAML
ForgeFoundary dumb-mode --mode=MyCustomMode --raw-yaml
# Using a custom modes folder
ForgeFoundary dumb-mode --mode=MyCustomMode --modes-path=/path/to/modes
```
---
## Next Steps
After reviewing a mode with `dumb-mode`:
* Use `dry-run` to simulate scaffolding with this mode.
* Use `scaffold` to apply the mode and generate project files.## Enabling or Disabling Sections
Each optional section in a mode can be **enabled or disabled** using the `*_enabled` boolean key. By default, most sections are enabled (`true`), but you can turn off any section if you don’t want it processed during scaffolding.
### Example
```yaml
cli_flags_enabled: true # Set to false to disable CLI flags entirely
commands_enabled: true # Set to false to skip running pre/post commands
directories_enabled: true # Set to false to skip creating directories
units_enabled: true # Set to false to skip creating units
templates_enabled: true # Set to false to skip creating templates
naming_conventions_enabled: true # Set to false to skip applying naming conventions
```
### Notes
* Setting a section to `false` completely **skips that system** during the scaffolding process.
* Even if the section is defined, ForgeFoundary will ignore it if the corresponding `*_enabled` flag is `false`.
* Disabling **directories** has a cascading effect:
* `units` and `templates` will **not run** if `directories_enabled` is `false`, since they rely on the folder structure to exist.
* This gives you control to **reuse modes without running certain systems**, or to **temporarily disable parts** of a mode for testing.
> For example, if `cli_flags_enabled` is `false`, the CLI flags section will be ignored, even if you have mutators and flags defined.# Mode Metadata
## Overview
The **Mode Metadata** section defines basic information about your mode. It helps you organize your modes and is used by the `dumb-mode` and `dumb-modes` commands to display mode details in the terminal.
This section is optional but highly recommended for clarity and maintainability.
---
## Metadata Keys
```yaml
mode_metadata:
name:
version:
description: >
language:
author:
```
### Key Details
* **name** – The human-readable name of the mode.
* **version** – The current version of your mode (e.g., `1.0.0`).
* **description** – A short description of what the mode does. Use the `>` YAML syntax to allow multi-line descriptions.
* **language** – The primary programming language or framework this mode targets.
* **author** – Your name or the person who created the mode.
---
## Usage
* The metadata is **automatically displayed** when running:
```bash
ForgeFoundary dumb-modes
ForgeFoundary dumb-mode --mode=YourModeName
```
* It helps **organize multiple modes** in large projects, making it easier to understand what each mode does at a glance.
---
## Notes
* Keep metadata concise but informative.
* You can omit keys if they are not relevant, but `name` is recommended.
* You can even add more metadata keys if you want to.# CLI Flags
## Overview
CLI flags let you **modify configuration values without touching the YAML** by linking them to **mutators** (YAML anchors). This is an optional feature that gives you more flexibility during scaffolding runs.
---
## Example
```yaml
component_name: *component_name_mutator YourComponentName # assign a mutator
cli_flags:
component_name: *component_name_mutator # assign a CLI flag linked to the mutator
component_name: *component_name_mutator # reference the mutator as the key value
```
### Usage in the terminal
```bash
# Set a single value using the custom CLI flag
ForgeFoundary scaffold --custom=component_name=CustomComponentName
# Multiple flags in one command
ForgeFoundary scaffold --custom=flag1=value1 --custom=flag2=value2
# Or using comma-separated format
ForgeFoundary scaffold --custom=flag1=value1,flag2=value2
```
---
## Notes
* You **don’t need to stick with the key name** in the YAML when declaring CLI flags; you can name flags anything:
```yaml
CustomCLIFlag: *customMutator
```
* Currently, **normal CLI flag syntax** (e.g., `--component_name=value`) is **not supported** due to technical limitations. You must use `--custom=`.
* For more on mutators and how they work, see [Mutators](Mutators.md).# Units
## Overview
The **Units** section is an optional but powerful part of your mode. Think of **units as modular boxes** that organize your project structure in ways that simple directories cannot. Units can represent common scaffolding patterns like `Crud`, `Auth`, or custom logic blocks.
Units are often used in combination with the **Units Map** section, which links units to specific directories, allowing you to control exactly where each unit is applied.
> ⚠️ Units rely on directories being created. If `directories_enabled` is `false`, units will be skipped during scaffolding.
---
## Keys
```yaml
units_enabled: true
units:
- Crud
- Auth
- Logic
```
### Explanation
* `units_enabled` – Boolean flag to enable or disable unit processing.
* `units` – A list of unit names available in this mode. These are the scaffolding building blocks you can assign to directories using `units_map`.
---
## Units Map
The **Units Map** section defines **how units are linked to directories**. There are two modes:
* `mode: directories` – Map each directory to the units it should receive.
* `mode: units` – Map each unit to the directories it should affect.
```yaml
units_map:
mode: directories # or 'units'
```
---
### Directories Mode
```yaml
units_map:
mode: directories
directories:
units_created_by_default: true
overrides: {}
```
**Keys:**
* `units_created_by_default` – Determines if every directory should automatically receive all units listed in `units`.
* `overrides` – Specify unit assignments per directory. Use an array of unit names or `"*"` to assign all units.
**Examples:**
```yaml
units:
- Crud
- Auth
- Logic
units_map:
mode: directories
directories:
units_created_by_default: true
overrides:
Models: []
Policies:
- Crud
- Logic
```
* Every directory gets all units by default.
* `Models` receives no units.
* `Policies` receives only `Crud` and `Logic`.
```yaml
units:
- Crud
- Auth
- Logic
units_map:
mode: directories
directories:
units_created_by_default: false
overrides:
Models: [Crud]
Policies: ["*"]
```
* No directory receives units by default.
* `Models` gets only `Crud`.
* `Policies` gets all units.
---
### Units Mode
```yaml
units_map:
mode: units
units:
units_created_by_default: true
overrides:
Crud: [Controllers]
Logic: []
```
**Keys:**
* `units_created_by_default` – Determines if all directories receive this unit automatically.
* `overrides` – Assigns specific directories to individual units. Use `"*"` to assign the unit to every directory.
**Examples:**
```yaml
units:
- Crud
- Auth
- Logic
units_map:
mode: units
units:
units_created_by_default: false
overrides:
Crud: [Controllers]
Logic: ["*"]
```
* Every directory receives `Logic`.
* `Controllers` additionally gets `Crud`.
* No directory receives `Auth`.
---
### Notes
* Units can be reused across multiple directories or customized per directory using the **overrides**.
* Units help maintain modularity and reduce repetitive configuration, especially in large projects.# Directories Section
## Overview
The **Directories** section allows you to define all the folders you want ForgeFoundary to create during scaffolding. This section is **optional**, but useful for ensuring your project has the exact folder structure you need.
---
## Keys
```yaml
directories: []
```
## Explanation
* `directories` – An array of folder paths relative to your scaffolding root. ForgeFoundary will create each directory listed here automatically.
## Example:
```yaml
directories:
- src/Controllers
- src/Models
- tests
- public/assets
```
> The names of directories can also follow a **naming convention** defined in the [Naming Convention section](Naming_Conventions.md) to keep your project structure consistent.
# Templates
## Overview
The **Templates** section defines how your mode handles **file templates**. Templates are the building blocks that generate actual files in your projects. This section is optional, but it is a core part of flexible scaffolding.
Templates allow you to define:
* **Default template behavior** (file names, paths, extensions, placeholders)
* **Per-template overrides**
* **Template engine usage** (e.g., Mustache, Twig, Blade)
* **Placeholders**, including metadata placeholders
* **Multiple file paths for a single template**, enabling one template to generate multiple files
> ⚠️ Supported template engines: **Mustache**, **Twig**, **Blade**
> ⚠️ Templates rely on directories being created. If `directories_enabled` is `false`, templates may be skipped.
---
## Templates Environment Keys
```yaml
templates_path: # Relative path to the Templates folder in your mode
templates_enabled: # true/false to enable template processing
templates_require_existing_dirs: # If true, only generate templates for directories that exist
template_engine_extensions: [] # Array of file extensions to treat as templates
```
### `templates_path`
* Path to your templates folder, relative to the scaffolder’s App/Src folder.
* Example: `Modes/MyMode/Templates/`
### `templates_enabled`
* Boolean flag to enable template processing.
* Example: `true`
### `templates_require_existing_dirs`
* Boolean flag; if `true`, templates will only generate files for directories that already exist.
### `template_engine_extensions`
* List the file extensions to be processed as templates.
* Example:
```yaml
template_engine_extensions:
- mustache
- twig
- blade.php
```
---
## Templates Configuration
Templates can be defined with **defaults** and **overrides**:
```yaml
templates:
defaults: {}
overrides: {}
```
### `defaults`
* Applies default metadata and placeholders to all templates in the mode.
* Can include:
```yaml
templates:
defaults:
file_name: defaultFileName
file_extension: php
file_paths: ["Models"]
placeholders:
component_name: *component_name_mutator
```
### `overrides`
* Allows specific templates to deviate from defaults.
* Each override must reference the full template filename.
* Example:
```yaml
templates:
overrides:
model.mustache:
file_name: CustomModel
file_extension: php
file_paths:
- "Models"
- "Repositories"
placeholders:
domain_name: ExampleDomain
```
*Overrides replace the defaults for the specified fields. If a field is not overridden, the defaults are used.*
---
## Template YAML Metadata
Each template file can include a **YAML front matter section** at the top. This serves as the template's **file metadata** and allows defining **additional placeholders**.
Example:
```yaml
---
file_name: "MyFile_{{placeholder}}.php"
file_paths: ["Services", "Repositories"]
file_extension: php
---
```
### Key fields
* **`file_name`** – The name of the file to generate. Can reference placeholders.
* **`file_paths`** – Array of paths where this template will be generated. Paths are relative to the component or mode. You can define multiple paths to generate the same template in different locations.
* **`file_extension`** – The file extension to use.
> A file **must have a file name, a file extension and at least one file path** for ForgeFoundary to generate it. This can be defined either in the template file itself or in the mode configuration.
### Hierarchy of value resolution:
When ForgeFoundary generates a template, it determines values in this order:
Mode configuration overrides (templates.overrides.template_name) → highest priority
Template YAML section → overrides defaults from the mode configuration
Mode configuration defaults (templates.defaults) → lowest priority
⚠️ This hierarchy applies to both placeholders and metadata (like file_name, file_extension). For example, if file_name exists in the mode override, it will replace any file_name defined in the template YAML.
---
## Placeholders
**Placeholders** are variables that you reference inside templates. Their format depends on the template engine (e.g., `{{placeholder}}` for Mustache).
*Placeholders exist in three places:*
1. **Template metadata YAML**
You can both define placeholders or use them in your template's YAML section Example:
```yaml
---
file_name: "{{MyFileNamePlaceholder}}"
custom_placeholder: "Hello"
---
```
2. **Template body**
You can reference placeholders in the template content. Example (Mustache):