Skip to content

Commit 7ab5645

Browse files
authored
Merge pull request #1 from ivanbicalho/features/v2
Features/v2
2 parents 4a622dd + f9cf5b5 commit 7ab5645

40 files changed

Lines changed: 335 additions & 408 deletions

File tree

README.md

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ In this example we'll use txt and c# files, but you can define any kind of files
1010

1111
To create a new template, you just have to add a new folder inside the folder **flash-templates**, which has to be located together with flash executable.
1212

13-
Inside your folder, just put your template files and a **config.json**.
13+
Inside your folder, just put your template files and folders and a **config.json** (optional).
1414

1515
The folder structure is like this:
1616

@@ -19,44 +19,35 @@ flash-templates
1919
use-case
2020
config.json
2121
Readme.txt
22-
UseCaseName.cs
23-
UseCaseNameInput.cs
22+
EmptyFolderToCreate
23+
UseCaseName
24+
UseCaseName.cs
25+
UseCaseNameInput.cs
2426
```
2527

2628
With the structure above, you can use the "use-case" template.
2729

2830
## The config.json file
2931

30-
The config.json file contains all of the template configuration, the name of the files you want to create, the location of them and your variables, which are optionals.
32+
The config.json file is optional and contains all of the template configuration, which are the template description and variables.
3133

34+
The template description will be shown to the user when they interact with the flash CLI, to help them understand what that template does.
35+
36+
The variables are used to replace the occurrences on the template files and folders.
37+
3238
The config.json structure example:
3339

3440
```json
3541
{
36-
"creations": [
37-
{
38-
"templateFile": "Readme.txt"
39-
},
40-
{
41-
"location" : "Features/UseCaseName",
42-
"templateFile": "UseCaseName.cs"
43-
},
44-
{
45-
"location" : "Features/UseCaseName",
46-
"templateFile": "UseCaseNameInput.cs"
47-
},
48-
{
49-
"location": "EmptyFolderToCreate"
50-
}
51-
],
52-
"variables": [
42+
"description" : "Create a use case based on clean architecture",
43+
"variables" : [
5344
{
54-
"replace": "UseCaseName",
55-
"question": "Enter the use case name:"
45+
"replace" : "UseCaseName",
46+
"question" : "Enter the use case name:"
5647
},
5748
{
58-
"replace": "Repository",
59-
"question": "Enter the repository name:"
49+
"replace" : "Repository",
50+
"question" : "Enter the repository name:"
6051
}
6152
]
6253
}
@@ -87,10 +78,9 @@ In the terminal's current directory, we'll have:
8778
```
8879
Readme.txt
8980
EmptyFolderToCreate
90-
Features
91-
MyFirstUseCase
92-
MyFirstUseCase.cs
93-
MyFirstUseCaseInput.cs
81+
MyFirstUseCase
82+
MyFirstUseCase.cs
83+
MyFirstUseCaseInput.cs
9484
```
9585
9686
Let's suppose that inside the **Readme.txt** file the initial value was:
@@ -144,6 +134,6 @@ public class SaveCustomer
144134
145135
## How to use
146136
147-
Download the latest version of the flash executable from [Releases Page](https://github.com/ivanbicalho/flash-cli/releases) and place it in a folder that is in [PATH environment variable](https://en.wikipedia.org/wiki/PATH_(variable)) (it's necessary in order to use flash at all locations on the terminal).
137+
Download the latest version of the flash executable from [Releases Page](https://github.com/ivanbicalho/flash-cli/releases) and place it in a folder that is in [PATH environment variable](https://en.wikipedia.org/wiki/PATH_(variable)) (in order to use flash at all locations on the terminal).
148138
149139
After that, create a folder named **flash-templates** in the same directory as the flash executable and configure your templates. To verify that your templates are configured correctly, use the **flash validate** command.

src/flash.Tests/CreateTemplatesTests.cs

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/flash.Tests/CreateTemplateFixture.cs renamed to src/flash.Tests/Fixtures/CreateTemplateFixture.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22
using System.IO;
33
using System.Linq;
44
using System.Reflection;
5-
using System.Threading.Tasks;
6-
using flash.Commands;
75
using flash.Domain;
8-
using flash.Domain.Exceptions;
9-
using Xunit;
106

11-
namespace flash.Tests
7+
namespace flash.Tests.Fixtures
128
{
139
public class CreateTemplateFixture : IDisposable
1410
{
@@ -17,7 +13,7 @@ public CreateTemplateFixture()
1713
var templateFolder = Path.Combine(
1814
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
1915
"ValidTemplates",
20-
"validVariables");
16+
"validTemplateVariables");
2117

2218
var templates = new FlashTemplates(templateFolder);
2319
templates.Load().Wait();
@@ -29,12 +25,13 @@ public CreateTemplateFixture()
2925

3026
public void Dispose()
3127
{
32-
File.Delete("NewTest.txt");
3328
File.Delete("MyFile.txt");
29+
File.Delete("NewTest2.txt");
3430
File.Delete("Variables.txt");
35-
Directory.Delete("MyFolder", true);
36-
Directory.Delete("test", true);
37-
Directory.Delete("FolderToCreate", true);
31+
32+
Directory.Delete("AnotherFolder", true);
33+
Directory.Delete("Folder", true);
34+
Directory.Delete("NEWTEST", true);
3835
}
3936
}
4037
}

src/flash.Tests/InvalidCreateTemplatesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class InvalidCreateTemplatesTests
1414
[Fact]
1515
public async Task InvalidAssignVariableTest()
1616
{
17-
var templates = await GetValidFlashTemplates("validVariables");
17+
var templates = await GetValidFlashTemplates("validTemplateVariables");
1818
var template = templates.Get("use-case");
1919

2020
var ex = await Assert.ThrowsAsync<FlashException>(async () =>

src/flash.Tests/InvalidTemplates/emptyArrayCreations/use-case/config.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/flash.Tests/InvalidTemplates/missingTemplates/Test.txt renamed to src/flash.Tests/InvalidTemplates/invalidConfigFile/use-case/Test.txt

File renamed without changes.

src/flash.Tests/InvalidTemplates/invalidCreationFields/use-case/config.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/flash.Tests/InvalidTemplates/invalidQuestionVariable/use-case/config.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"creations": [
3-
{
4-
"templateFile": "Test.txt"
5-
}
6-
],
72
"variables" : [
83
{
94
"replace" : "teste"

src/flash.Tests/InvalidTemplates/invalidReplaceVariable/use-case/config.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"creations": [
3-
{
4-
"templateFile": "Test.txt"
5-
}
6-
],
72
"variables" : [
83
{
94
"question" : "Enter the name:"

src/flash.Tests/InvalidTemplates/invalidTemplateFile/use-case/config.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)