Skip to content

Commit ded5eb8

Browse files
feat(core): added pathScheme for project generators (#464)
Co-authored-by: Richard Compton <rich.compton@curvedental.com>
1 parent 5d69a5e commit ded5eb8

File tree

16 files changed

+190
-32
lines changed

16 files changed

+190
-32
lines changed

docs/core/generators/application.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ Generate a dotnet project under the application directory.
4747
### skipSwaggerLib
4848

4949
- (): By default, if using webapi template, an additional library is scaffolded for swagger files. This skips that setup.
50+
51+
### pathScheme
52+
53+
- (string): Determines if the project should follow NX or dotnet path naming conventions

docs/core/generators/library.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ Generate a dotnet project under the library directory.
4343
### skipSwaggerLib
4444

4545
- (): By default, if using webapi template, an additional library is scaffolded for swagger files. This skips that setup.
46+
47+
### pathScheme
48+
49+
- (string): Determines if the project should follow NX or dotnet path naming conventions

docs/core/generators/test.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ Generate a .NET test project for an existing application or library
3535
- (string): The name of the solution file to add the project to
3636

3737
- (boolean): Should the project be added to the default solution file?
38+
39+
### pathScheme
40+
41+
- (string): Determines if the project should follow NX or dotnet path naming conventions

e2e/core-e2e/tests/nx-dotnet.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,28 @@ describe('nx-dotnet e2e', () => {
241241
});
242242
});
243243

244+
describe('nx g using dotnet pathSchema', () => {
245+
it('no directory', async () => {
246+
const libName = uniq('CurveDental.Foobar.SomeLib');
247+
await runNxCommandAsync(
248+
`generate @nx-dotnet/core:lib ${libName} --language="C#" --template="classlib" --pathScheme=dotnet`,
249+
);
250+
251+
expect(() => checkFilesExist(`libs/${libName}`)).not.toThrow();
252+
expect(() => checkFilesExist(`libs/${libName}.Test`)).not.toThrow();
253+
});
254+
255+
it('with directory', async () => {
256+
const libName = uniq('CurveDental.Foobar.SomeLib');
257+
await runNxCommandAsync(
258+
`generate @nx-dotnet/core:lib ${libName} --language="C#" --template="classlib" --pathScheme=dotnet --directory foo`,
259+
);
260+
261+
expect(() => checkFilesExist(`libs/foo/${libName}`)).not.toThrow();
262+
expect(() => checkFilesExist(`libs/foo/${libName}.Test`)).not.toThrow();
263+
});
264+
});
265+
244266
describe('nx g import-projects', () => {
245267
it('should import apps, libs, and test', async () => {
246268
const testApp = uniq('app');

packages/core/src/generators/app/generator.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe('nx-dotnet app generator', () => {
2222
projectType: 'application',
2323
standalone: false,
2424
skipSwaggerLib: true,
25+
pathScheme: 'nx',
2526
};
2627

2728
beforeEach(() => {

packages/core/src/generators/app/schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@
8181
"skipSwaggerLib": {
8282
"description": "By default, if using webapi template, an additional library is scaffolded for swagger files. This skips that setup.",
8383
"default": true
84+
},
85+
"pathScheme": {
86+
"description": "Determines if the project should follow NX or dotnet path naming conventions",
87+
"type": "string",
88+
"default": "nx",
89+
"enum": ["nx", "dotnet"],
90+
"x-prompt": {
91+
"message": "Which path naming conventions should the project use?",
92+
"type": "list",
93+
"items": [
94+
{ "value": "nx", "label": "NX naming conventions" },
95+
{ "value": "dotnet", "label": "Dotnet naming conventions" }
96+
]
97+
}
8498
}
8599
},
86100
"required": ["name", "language"]

packages/core/src/generators/lib/generator.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe('nx-dotnet library generator', () => {
2222
standalone: false,
2323
projectType: 'library',
2424
skipSwaggerLib: true,
25+
pathScheme: 'nx',
2526
};
2627

2728
beforeEach(() => {

packages/core/src/generators/lib/schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@
7575
"skipSwaggerLib": {
7676
"description": "By default, if using webapi template, an additional library is scaffolded for swagger files. This skips that setup.",
7777
"default": false
78+
},
79+
"pathScheme": {
80+
"description": "Determines if the project should follow NX or dotnet path naming conventions",
81+
"type": "string",
82+
"default": "nx",
83+
"enum": ["nx", "dotnet"],
84+
"x-prompt": {
85+
"message": "Which path naming conventions should the project use?",
86+
"type": "list",
87+
"items": [
88+
{ "value": "nx", "label": "NX naming conventions" },
89+
{ "value": "dotnet", "label": "Dotnet naming conventions" }
90+
]
91+
}
7892
}
7993
},
8094
"required": ["name", "language", "testTemplate"]

packages/core/src/generators/test/generator.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('nx-dotnet test generator', () => {
1919
language: 'C#',
2020
skipOutputPathManipulation: true,
2121
standalone: false,
22+
pathScheme: 'nx',
2223
};
2324

2425
beforeEach(() => {

packages/core/src/generators/test/schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@
7272
}
7373
],
7474
"alias": ["solution", "s"]
75+
},
76+
"pathScheme": {
77+
"description": "Determines if the project should follow NX or dotnet path naming conventions",
78+
"type": "string",
79+
"default": "nx",
80+
"enum": ["nx", "dotnet"],
81+
"x-prompt": {
82+
"message": "Which path naming conventions should the project use?",
83+
"type": "list",
84+
"items": [
85+
{ "value": "nx", "label": "NX naming conventions" },
86+
{ "value": "dotnet", "label": "Dotnet naming conventions" }
87+
]
88+
}
7589
}
7690
},
7791
"required": ["name", "testTemplate"]

0 commit comments

Comments
 (0)