@domain-first/project-structure 2.7.2 → 2.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +133 -73
- package/dist/index.js +133 -73
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -209,7 +209,7 @@ The project configuration is stored in `domain-first.project-structure.config.js
|
|
|
209
209
|
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
210
210
|
| `rootFolder` | Base path for generated source, relative to the project root. |
|
|
211
211
|
| `domainFirstPackages` | Explicit list of integrations used by templates. An empty array selects basic class templates where supported. |
|
|
212
|
-
| `defaultPersistenceLayerImplementation` | Suggested implementation label for execution commands and queries.
|
|
212
|
+
| `defaultPersistenceLayerImplementation` | Suggested implementation label for execution commands and queries. |
|
|
213
213
|
| `useReact` | Shows or hides the React module menu. |
|
|
214
214
|
| `testingLibrary` | Module imported by generated tests. Omit this field to disable test prompts. Templates expect helpers such as `describe`, `test`, `expect`, and `beforeEach`. |
|
|
215
215
|
|
package/dist/index.cjs
CHANGED
|
@@ -282,26 +282,9 @@ describe('${aggregateNaming.withSpaces}', () => {
|
|
|
282
282
|
if (withRepository) {
|
|
283
283
|
aggregatesFolder.createFile(`${aggregateNaming.fileName}-repository.ts`, `export abstract class ${aggregateNaming.ClassName}Repository { }`);
|
|
284
284
|
barrelFile.addLine(`export * from './${aggregateNaming.fileName}-repository'`);
|
|
285
|
-
if (scaffoldUnitTests) aggregatesFolder.createFile(`${aggregateNaming.fileName}-repository.spec.ts`, `
|
|
286
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
287
|
-
import { wire${aggregateNaming.ClassName}Repository } from '../../../wiring/repositories/wire-${aggregateNaming.fileName}-repository'
|
|
288
|
-
import type { ${aggregateNaming.ClassName}Repository } from './${aggregateNaming.fileName}-repository'
|
|
289
|
-
|
|
290
|
-
let ${aggregateNaming.variableName}Repository: ${aggregateNaming.ClassName}Repository
|
|
291
|
-
|
|
292
|
-
beforeEach(() => {
|
|
293
|
-
${aggregateNaming.variableName}Repository = wire${aggregateNaming.ClassName}Repository()
|
|
294
|
-
})
|
|
295
|
-
|
|
296
|
-
describe('${aggregateNaming.withSpaces} repository', () => {
|
|
297
|
-
test('can be wired', () => {
|
|
298
|
-
expect(${aggregateNaming.variableName}Repository).toBeDefined()
|
|
299
|
-
})
|
|
300
|
-
})
|
|
301
|
-
`.trim());
|
|
302
285
|
const infrastructureImplementationType = await (0, prompts_namespaceObject.input)({
|
|
303
286
|
message: 'Repository infrastructure implementation type:',
|
|
304
|
-
default:
|
|
287
|
+
default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
|
|
305
288
|
});
|
|
306
289
|
let addTestImplementation = false;
|
|
307
290
|
let testImplementationType = '';
|
|
@@ -333,6 +316,28 @@ export class ${naming.ClassName}${aggregateNaming.ClassName}Repository implement
|
|
|
333
316
|
|
|
334
317
|
`.trim());
|
|
335
318
|
}
|
|
319
|
+
if (scaffoldUnitTests) {
|
|
320
|
+
const implementationNaming = new UnknownFormatNaming(infrastructureImplementationType);
|
|
321
|
+
aggregatesFolder.createFile(`${aggregateNaming.fileName}-repository.spec.ts`, `
|
|
322
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
323
|
+
${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `import { wire${aggregateNaming.ClassName}Repository } from '../../../wiring/repositories/wire-${aggregateNaming.fileName}-repository'
|
|
324
|
+
import type { ${aggregateNaming.ClassName}Repository } from './${aggregateNaming.fileName}-repository'` : `import { ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository } from '../../../infrastructure/repositories/${implementationNaming.fileName}/${implementationNaming.fileName}-${aggregateNaming.fileName}-repository'
|
|
325
|
+
|
|
326
|
+
type ${aggregateNaming.ClassName}Repository = ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository`}
|
|
327
|
+
|
|
328
|
+
let ${aggregateNaming.variableName}Repository: ${aggregateNaming.ClassName}Repository
|
|
329
|
+
|
|
330
|
+
beforeEach(() => {
|
|
331
|
+
${aggregateNaming.variableName}Repository = ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `wire${aggregateNaming.ClassName}Repository()` : `new ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository()`}
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
describe('${aggregateNaming.withSpaces} repository', () => {
|
|
335
|
+
test('can be ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'wired' : 'created via constructor'}', () => {
|
|
336
|
+
expect(${aggregateNaming.variableName}Repository).toBeDefined()
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
`.trim());
|
|
340
|
+
}
|
|
336
341
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
337
342
|
const implementationNaming = new UnknownFormatNaming(infrastructureImplementationType);
|
|
338
343
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
@@ -377,23 +382,6 @@ export abstract class ${naming.ClassName} {
|
|
|
377
382
|
|
|
378
383
|
}
|
|
379
384
|
`.trim());
|
|
380
|
-
if (scaffoldUnitTests) applicationPortsFolder.createFile(`${naming.fileName}.spec.ts`, `
|
|
381
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
382
|
-
import { type ${naming.ClassName} } from './${naming.fileName}'
|
|
383
|
-
import { wire${naming.ClassName} } from '../../wiring/application-ports/wire-${naming.fileName}'
|
|
384
|
-
|
|
385
|
-
let ${naming.variableName}: ${naming.ClassName}
|
|
386
|
-
|
|
387
|
-
beforeEach(() => {
|
|
388
|
-
${naming.variableName} = wire${naming.ClassName}()
|
|
389
|
-
})
|
|
390
|
-
|
|
391
|
-
describe('${naming.withSpaces}', () => {
|
|
392
|
-
test('can be wired', () => {
|
|
393
|
-
expect(${naming.variableName}).toBeDefined()
|
|
394
|
-
})
|
|
395
|
-
})
|
|
396
|
-
`.trim());
|
|
397
385
|
const implementationType = await (0, prompts_namespaceObject.input)({
|
|
398
386
|
message: 'Adapter implementation type:',
|
|
399
387
|
default: 'api'
|
|
@@ -426,6 +414,28 @@ export class ${currentNaming.ClassName} extends ${naming.ClassName} {
|
|
|
426
414
|
}
|
|
427
415
|
`);
|
|
428
416
|
}
|
|
417
|
+
if (scaffoldUnitTests) {
|
|
418
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
419
|
+
applicationPortsFolder.createFile(`${naming.fileName}.spec.ts`, `
|
|
420
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
421
|
+
${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `import { type ${naming.ClassName} } from './${naming.fileName}'
|
|
422
|
+
import { wire${naming.ClassName} } from '../../wiring/application-ports/wire-${naming.fileName}'` : `import { ${implementationNaming.ClassName}${naming.ClassName} } from '../../infrastructure/application-adapters/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}'
|
|
423
|
+
|
|
424
|
+
type ${naming.ClassName} = ${implementationNaming.ClassName}${naming.ClassName}`}
|
|
425
|
+
|
|
426
|
+
let ${naming.variableName}: ${naming.ClassName}
|
|
427
|
+
|
|
428
|
+
beforeEach(() => {
|
|
429
|
+
${naming.variableName} = ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `wire${naming.ClassName}()` : `new ${implementationNaming.ClassName}${naming.ClassName}()`}
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
describe('${naming.withSpaces}', () => {
|
|
433
|
+
test('can be ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'wired' : 'created via constructor'}', () => {
|
|
434
|
+
expect(${naming.variableName}).toBeDefined()
|
|
435
|
+
})
|
|
436
|
+
})
|
|
437
|
+
`.trim());
|
|
438
|
+
}
|
|
429
439
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) wiringFolder.createFile(`wire-${naming.fileName}.ts`, `
|
|
430
440
|
import { wireClass } from '@domain-first/wire'
|
|
431
441
|
import { envBranchedWire } from '../../../${'shared' === boundedContextFolder.name ? '' : '../'}shared/wiring/env-branched-wire'
|
|
@@ -544,25 +554,7 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
544
554
|
message: 'Command type'
|
|
545
555
|
});
|
|
546
556
|
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === commandType;
|
|
547
|
-
|
|
548
|
-
isOrchestrator ? 'orchestration' : 'execution'
|
|
549
|
-
]).createFile(`${naming.fileName}-command.spec.ts`, `
|
|
550
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
551
|
-
import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
|
|
552
|
-
import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'
|
|
553
|
-
|
|
554
|
-
let ${naming.variableName}Command: ${naming.ClassName}Command
|
|
555
|
-
|
|
556
|
-
beforeEach(() => {
|
|
557
|
-
${naming.variableName}Command = wire${naming.ClassName}Command()
|
|
558
|
-
})
|
|
559
|
-
|
|
560
|
-
describe('${naming.withSpaces} command', () => {
|
|
561
|
-
test('can be wired', () => {
|
|
562
|
-
expect(${naming.variableName}Command).toBeDefined()
|
|
563
|
-
})
|
|
564
|
-
})
|
|
565
|
-
`.trim());
|
|
557
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
566
558
|
if (!isOrchestrator) {
|
|
567
559
|
const implementationType = await (0, prompts_namespaceObject.input)({
|
|
568
560
|
message: 'Command infrastructure implementation type:',
|
|
@@ -630,6 +622,30 @@ export abstract class ${naming.ClassName}Command {
|
|
|
630
622
|
export abstract class ${naming.ClassName}Command {
|
|
631
623
|
|
|
632
624
|
}`.trim());
|
|
625
|
+
if (scaffoldUnitTests) {
|
|
626
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
627
|
+
commandsFolder.subitem([
|
|
628
|
+
'execution'
|
|
629
|
+
]).createFile(`${naming.fileName}-command.spec.ts`, `
|
|
630
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
631
|
+
${withWiring ? `import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
|
|
632
|
+
import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Command } from '../../../infrastructure/commands/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-command'
|
|
633
|
+
|
|
634
|
+
type ${naming.ClassName}Command = ${implementationNaming.ClassName}${naming.ClassName}Command`}
|
|
635
|
+
|
|
636
|
+
let ${naming.variableName}Command: ${naming.ClassName}Command
|
|
637
|
+
|
|
638
|
+
beforeEach(() => {
|
|
639
|
+
${naming.variableName}Command = ${withWiring ? `wire${naming.ClassName}Command()` : `new ${implementationNaming.ClassName}${naming.ClassName}Command()`}
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
describe('${naming.withSpaces} command', () => {
|
|
643
|
+
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
644
|
+
expect(${naming.variableName}Command).toBeDefined()
|
|
645
|
+
})
|
|
646
|
+
})
|
|
647
|
+
`.trim());
|
|
648
|
+
}
|
|
633
649
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
634
650
|
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
635
651
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
@@ -685,6 +701,25 @@ import { ${naming.ClassName}Command } from '../../application/commands/orchestra
|
|
|
685
701
|
|
|
686
702
|
export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
|
|
687
703
|
`.trim());
|
|
704
|
+
if (scaffoldUnitTests) commandsFolder.subitem([
|
|
705
|
+
'orchestration'
|
|
706
|
+
]).createFile(`${naming.fileName}-command.spec.ts`, `
|
|
707
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
708
|
+
${withWiring ? `import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
|
|
709
|
+
import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${naming.ClassName}Command } from './${naming.fileName}-command'`}
|
|
710
|
+
|
|
711
|
+
let ${naming.variableName}Command: ${naming.ClassName}Command
|
|
712
|
+
|
|
713
|
+
beforeEach(() => {
|
|
714
|
+
${naming.variableName}Command = ${withWiring ? `wire${naming.ClassName}Command()` : `new ${naming.ClassName}Command()`}
|
|
715
|
+
})
|
|
716
|
+
|
|
717
|
+
describe('${naming.withSpaces} command', () => {
|
|
718
|
+
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
719
|
+
expect(${naming.variableName}Command).toBeDefined()
|
|
720
|
+
})
|
|
721
|
+
})
|
|
722
|
+
`.trim());
|
|
688
723
|
};
|
|
689
724
|
const scaffoldNewDomainService = async (boundedContextFolder)=>{
|
|
690
725
|
const portName = await (0, prompts_namespaceObject.input)({
|
|
@@ -1000,25 +1035,7 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
1000
1035
|
message: 'Query type'
|
|
1001
1036
|
});
|
|
1002
1037
|
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === queryType;
|
|
1003
|
-
|
|
1004
|
-
isOrchestrator ? 'orchestration' : 'execution'
|
|
1005
|
-
]).createFile(`${naming.fileName}-query.spec.ts`, `
|
|
1006
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
1007
|
-
import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
|
|
1008
|
-
import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'
|
|
1009
|
-
|
|
1010
|
-
let ${naming.variableName}Query: ${naming.ClassName}Query
|
|
1011
|
-
|
|
1012
|
-
beforeEach(() => {
|
|
1013
|
-
${naming.variableName}Query = wire${naming.ClassName}Query()
|
|
1014
|
-
})
|
|
1015
|
-
|
|
1016
|
-
describe('${naming.withSpaces} query', () => {
|
|
1017
|
-
test('can be wired', () => {
|
|
1018
|
-
expect(${naming.variableName}Query).toBeDefined()
|
|
1019
|
-
})
|
|
1020
|
-
})
|
|
1021
|
-
`.trim());
|
|
1038
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
1022
1039
|
if (!isOrchestrator) {
|
|
1023
1040
|
const implementationType = await (0, prompts_namespaceObject.input)({
|
|
1024
1041
|
message: 'Query infrastructure implementation type:',
|
|
@@ -1086,6 +1103,30 @@ export abstract class ${naming.ClassName}Query {
|
|
|
1086
1103
|
export abstract class ${naming.ClassName}Query {
|
|
1087
1104
|
|
|
1088
1105
|
}`.trim());
|
|
1106
|
+
if (scaffoldUnitTests) {
|
|
1107
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
1108
|
+
queriesFolder.subitem([
|
|
1109
|
+
'execution'
|
|
1110
|
+
]).createFile(`${naming.fileName}-query.spec.ts`, `
|
|
1111
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
1112
|
+
${withWiring ? `import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
|
|
1113
|
+
import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Query } from '../../../infrastructure/queries/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-query'
|
|
1114
|
+
|
|
1115
|
+
type ${naming.ClassName}Query = ${implementationNaming.ClassName}${naming.ClassName}Query`}
|
|
1116
|
+
|
|
1117
|
+
let ${naming.variableName}Query: ${naming.ClassName}Query
|
|
1118
|
+
|
|
1119
|
+
beforeEach(() => {
|
|
1120
|
+
${naming.variableName}Query = ${withWiring ? `wire${naming.ClassName}Query()` : `new ${implementationNaming.ClassName}${naming.ClassName}Query()`}
|
|
1121
|
+
})
|
|
1122
|
+
|
|
1123
|
+
describe('${naming.withSpaces} query', () => {
|
|
1124
|
+
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
1125
|
+
expect(${naming.variableName}Query).toBeDefined()
|
|
1126
|
+
})
|
|
1127
|
+
})
|
|
1128
|
+
`.trim());
|
|
1129
|
+
}
|
|
1089
1130
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
1090
1131
|
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
1091
1132
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
@@ -1141,6 +1182,25 @@ import { ${naming.ClassName}Query } from '../../application/queries/orchestratio
|
|
|
1141
1182
|
|
|
1142
1183
|
export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
|
|
1143
1184
|
`.trim());
|
|
1185
|
+
if (scaffoldUnitTests) queriesFolder.subitem([
|
|
1186
|
+
'orchestration'
|
|
1187
|
+
]).createFile(`${naming.fileName}-query.spec.ts`, `
|
|
1188
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
1189
|
+
${withWiring ? `import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
|
|
1190
|
+
import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${naming.ClassName}Query } from './${naming.fileName}-query'`}
|
|
1191
|
+
|
|
1192
|
+
let ${naming.variableName}Query: ${naming.ClassName}Query
|
|
1193
|
+
|
|
1194
|
+
beforeEach(() => {
|
|
1195
|
+
${naming.variableName}Query = ${withWiring ? `wire${naming.ClassName}Query()` : `new ${naming.ClassName}Query()`}
|
|
1196
|
+
})
|
|
1197
|
+
|
|
1198
|
+
describe('${naming.withSpaces} query', () => {
|
|
1199
|
+
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
1200
|
+
expect(${naming.variableName}Query).toBeDefined()
|
|
1201
|
+
})
|
|
1202
|
+
})
|
|
1203
|
+
`.trim());
|
|
1144
1204
|
};
|
|
1145
1205
|
const scaffoldNewUseCase = async (boundedContextFolder)=>{
|
|
1146
1206
|
const useCasesFolder = boundedContextFolder.subitem([
|
package/dist/index.js
CHANGED
|
@@ -252,26 +252,9 @@ describe('${aggregateNaming.withSpaces}', () => {
|
|
|
252
252
|
if (withRepository) {
|
|
253
253
|
aggregatesFolder.createFile(`${aggregateNaming.fileName}-repository.ts`, `export abstract class ${aggregateNaming.ClassName}Repository { }`);
|
|
254
254
|
barrelFile.addLine(`export * from './${aggregateNaming.fileName}-repository'`);
|
|
255
|
-
if (scaffoldUnitTests) aggregatesFolder.createFile(`${aggregateNaming.fileName}-repository.spec.ts`, `
|
|
256
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
257
|
-
import { wire${aggregateNaming.ClassName}Repository } from '../../../wiring/repositories/wire-${aggregateNaming.fileName}-repository'
|
|
258
|
-
import type { ${aggregateNaming.ClassName}Repository } from './${aggregateNaming.fileName}-repository'
|
|
259
|
-
|
|
260
|
-
let ${aggregateNaming.variableName}Repository: ${aggregateNaming.ClassName}Repository
|
|
261
|
-
|
|
262
|
-
beforeEach(() => {
|
|
263
|
-
${aggregateNaming.variableName}Repository = wire${aggregateNaming.ClassName}Repository()
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
describe('${aggregateNaming.withSpaces} repository', () => {
|
|
267
|
-
test('can be wired', () => {
|
|
268
|
-
expect(${aggregateNaming.variableName}Repository).toBeDefined()
|
|
269
|
-
})
|
|
270
|
-
})
|
|
271
|
-
`.trim());
|
|
272
255
|
const infrastructureImplementationType = await input({
|
|
273
256
|
message: 'Repository infrastructure implementation type:',
|
|
274
|
-
default:
|
|
257
|
+
default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
|
|
275
258
|
});
|
|
276
259
|
let addTestImplementation = false;
|
|
277
260
|
let testImplementationType = '';
|
|
@@ -303,6 +286,28 @@ export class ${naming.ClassName}${aggregateNaming.ClassName}Repository implement
|
|
|
303
286
|
|
|
304
287
|
`.trim());
|
|
305
288
|
}
|
|
289
|
+
if (scaffoldUnitTests) {
|
|
290
|
+
const implementationNaming = new UnknownFormatNaming(infrastructureImplementationType);
|
|
291
|
+
aggregatesFolder.createFile(`${aggregateNaming.fileName}-repository.spec.ts`, `
|
|
292
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
293
|
+
${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `import { wire${aggregateNaming.ClassName}Repository } from '../../../wiring/repositories/wire-${aggregateNaming.fileName}-repository'
|
|
294
|
+
import type { ${aggregateNaming.ClassName}Repository } from './${aggregateNaming.fileName}-repository'` : `import { ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository } from '../../../infrastructure/repositories/${implementationNaming.fileName}/${implementationNaming.fileName}-${aggregateNaming.fileName}-repository'
|
|
295
|
+
|
|
296
|
+
type ${aggregateNaming.ClassName}Repository = ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository`}
|
|
297
|
+
|
|
298
|
+
let ${aggregateNaming.variableName}Repository: ${aggregateNaming.ClassName}Repository
|
|
299
|
+
|
|
300
|
+
beforeEach(() => {
|
|
301
|
+
${aggregateNaming.variableName}Repository = ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `wire${aggregateNaming.ClassName}Repository()` : `new ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository()`}
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
describe('${aggregateNaming.withSpaces} repository', () => {
|
|
305
|
+
test('can be ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'wired' : 'created via constructor'}', () => {
|
|
306
|
+
expect(${aggregateNaming.variableName}Repository).toBeDefined()
|
|
307
|
+
})
|
|
308
|
+
})
|
|
309
|
+
`.trim());
|
|
310
|
+
}
|
|
306
311
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
307
312
|
const implementationNaming = new UnknownFormatNaming(infrastructureImplementationType);
|
|
308
313
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
@@ -347,23 +352,6 @@ export abstract class ${naming.ClassName} {
|
|
|
347
352
|
|
|
348
353
|
}
|
|
349
354
|
`.trim());
|
|
350
|
-
if (scaffoldUnitTests) applicationPortsFolder.createFile(`${naming.fileName}.spec.ts`, `
|
|
351
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
352
|
-
import { type ${naming.ClassName} } from './${naming.fileName}'
|
|
353
|
-
import { wire${naming.ClassName} } from '../../wiring/application-ports/wire-${naming.fileName}'
|
|
354
|
-
|
|
355
|
-
let ${naming.variableName}: ${naming.ClassName}
|
|
356
|
-
|
|
357
|
-
beforeEach(() => {
|
|
358
|
-
${naming.variableName} = wire${naming.ClassName}()
|
|
359
|
-
})
|
|
360
|
-
|
|
361
|
-
describe('${naming.withSpaces}', () => {
|
|
362
|
-
test('can be wired', () => {
|
|
363
|
-
expect(${naming.variableName}).toBeDefined()
|
|
364
|
-
})
|
|
365
|
-
})
|
|
366
|
-
`.trim());
|
|
367
355
|
const implementationType = await input({
|
|
368
356
|
message: 'Adapter implementation type:',
|
|
369
357
|
default: 'api'
|
|
@@ -396,6 +384,28 @@ export class ${currentNaming.ClassName} extends ${naming.ClassName} {
|
|
|
396
384
|
}
|
|
397
385
|
`);
|
|
398
386
|
}
|
|
387
|
+
if (scaffoldUnitTests) {
|
|
388
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
389
|
+
applicationPortsFolder.createFile(`${naming.fileName}.spec.ts`, `
|
|
390
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
391
|
+
${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `import { type ${naming.ClassName} } from './${naming.fileName}'
|
|
392
|
+
import { wire${naming.ClassName} } from '../../wiring/application-ports/wire-${naming.fileName}'` : `import { ${implementationNaming.ClassName}${naming.ClassName} } from '../../infrastructure/application-adapters/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}'
|
|
393
|
+
|
|
394
|
+
type ${naming.ClassName} = ${implementationNaming.ClassName}${naming.ClassName}`}
|
|
395
|
+
|
|
396
|
+
let ${naming.variableName}: ${naming.ClassName}
|
|
397
|
+
|
|
398
|
+
beforeEach(() => {
|
|
399
|
+
${naming.variableName} = ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `wire${naming.ClassName}()` : `new ${implementationNaming.ClassName}${naming.ClassName}()`}
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
describe('${naming.withSpaces}', () => {
|
|
403
|
+
test('can be ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'wired' : 'created via constructor'}', () => {
|
|
404
|
+
expect(${naming.variableName}).toBeDefined()
|
|
405
|
+
})
|
|
406
|
+
})
|
|
407
|
+
`.trim());
|
|
408
|
+
}
|
|
399
409
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) wiringFolder.createFile(`wire-${naming.fileName}.ts`, `
|
|
400
410
|
import { wireClass } from '@domain-first/wire'
|
|
401
411
|
import { envBranchedWire } from '../../../${'shared' === boundedContextFolder.name ? '' : '../'}shared/wiring/env-branched-wire'
|
|
@@ -514,25 +524,7 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
514
524
|
message: 'Command type'
|
|
515
525
|
});
|
|
516
526
|
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === commandType;
|
|
517
|
-
|
|
518
|
-
isOrchestrator ? 'orchestration' : 'execution'
|
|
519
|
-
]).createFile(`${naming.fileName}-command.spec.ts`, `
|
|
520
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
521
|
-
import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
|
|
522
|
-
import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'
|
|
523
|
-
|
|
524
|
-
let ${naming.variableName}Command: ${naming.ClassName}Command
|
|
525
|
-
|
|
526
|
-
beforeEach(() => {
|
|
527
|
-
${naming.variableName}Command = wire${naming.ClassName}Command()
|
|
528
|
-
})
|
|
529
|
-
|
|
530
|
-
describe('${naming.withSpaces} command', () => {
|
|
531
|
-
test('can be wired', () => {
|
|
532
|
-
expect(${naming.variableName}Command).toBeDefined()
|
|
533
|
-
})
|
|
534
|
-
})
|
|
535
|
-
`.trim());
|
|
527
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
536
528
|
if (!isOrchestrator) {
|
|
537
529
|
const implementationType = await input({
|
|
538
530
|
message: 'Command infrastructure implementation type:',
|
|
@@ -600,6 +592,30 @@ export abstract class ${naming.ClassName}Command {
|
|
|
600
592
|
export abstract class ${naming.ClassName}Command {
|
|
601
593
|
|
|
602
594
|
}`.trim());
|
|
595
|
+
if (scaffoldUnitTests) {
|
|
596
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
597
|
+
commandsFolder.subitem([
|
|
598
|
+
'execution'
|
|
599
|
+
]).createFile(`${naming.fileName}-command.spec.ts`, `
|
|
600
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
601
|
+
${withWiring ? `import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
|
|
602
|
+
import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Command } from '../../../infrastructure/commands/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-command'
|
|
603
|
+
|
|
604
|
+
type ${naming.ClassName}Command = ${implementationNaming.ClassName}${naming.ClassName}Command`}
|
|
605
|
+
|
|
606
|
+
let ${naming.variableName}Command: ${naming.ClassName}Command
|
|
607
|
+
|
|
608
|
+
beforeEach(() => {
|
|
609
|
+
${naming.variableName}Command = ${withWiring ? `wire${naming.ClassName}Command()` : `new ${implementationNaming.ClassName}${naming.ClassName}Command()`}
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
describe('${naming.withSpaces} command', () => {
|
|
613
|
+
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
614
|
+
expect(${naming.variableName}Command).toBeDefined()
|
|
615
|
+
})
|
|
616
|
+
})
|
|
617
|
+
`.trim());
|
|
618
|
+
}
|
|
603
619
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
604
620
|
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
605
621
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
@@ -655,6 +671,25 @@ import { ${naming.ClassName}Command } from '../../application/commands/orchestra
|
|
|
655
671
|
|
|
656
672
|
export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
|
|
657
673
|
`.trim());
|
|
674
|
+
if (scaffoldUnitTests) commandsFolder.subitem([
|
|
675
|
+
'orchestration'
|
|
676
|
+
]).createFile(`${naming.fileName}-command.spec.ts`, `
|
|
677
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
678
|
+
${withWiring ? `import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
|
|
679
|
+
import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${naming.ClassName}Command } from './${naming.fileName}-command'`}
|
|
680
|
+
|
|
681
|
+
let ${naming.variableName}Command: ${naming.ClassName}Command
|
|
682
|
+
|
|
683
|
+
beforeEach(() => {
|
|
684
|
+
${naming.variableName}Command = ${withWiring ? `wire${naming.ClassName}Command()` : `new ${naming.ClassName}Command()`}
|
|
685
|
+
})
|
|
686
|
+
|
|
687
|
+
describe('${naming.withSpaces} command', () => {
|
|
688
|
+
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
689
|
+
expect(${naming.variableName}Command).toBeDefined()
|
|
690
|
+
})
|
|
691
|
+
})
|
|
692
|
+
`.trim());
|
|
658
693
|
};
|
|
659
694
|
const scaffoldNewDomainService = async (boundedContextFolder)=>{
|
|
660
695
|
const portName = await input({
|
|
@@ -970,25 +1005,7 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
970
1005
|
message: 'Query type'
|
|
971
1006
|
});
|
|
972
1007
|
const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === queryType;
|
|
973
|
-
|
|
974
|
-
isOrchestrator ? 'orchestration' : 'execution'
|
|
975
|
-
]).createFile(`${naming.fileName}-query.spec.ts`, `
|
|
976
|
-
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
977
|
-
import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
|
|
978
|
-
import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'
|
|
979
|
-
|
|
980
|
-
let ${naming.variableName}Query: ${naming.ClassName}Query
|
|
981
|
-
|
|
982
|
-
beforeEach(() => {
|
|
983
|
-
${naming.variableName}Query = wire${naming.ClassName}Query()
|
|
984
|
-
})
|
|
985
|
-
|
|
986
|
-
describe('${naming.withSpaces} query', () => {
|
|
987
|
-
test('can be wired', () => {
|
|
988
|
-
expect(${naming.variableName}Query).toBeDefined()
|
|
989
|
-
})
|
|
990
|
-
})
|
|
991
|
-
`.trim());
|
|
1008
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
992
1009
|
if (!isOrchestrator) {
|
|
993
1010
|
const implementationType = await input({
|
|
994
1011
|
message: 'Query infrastructure implementation type:',
|
|
@@ -1056,6 +1073,30 @@ export abstract class ${naming.ClassName}Query {
|
|
|
1056
1073
|
export abstract class ${naming.ClassName}Query {
|
|
1057
1074
|
|
|
1058
1075
|
}`.trim());
|
|
1076
|
+
if (scaffoldUnitTests) {
|
|
1077
|
+
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
1078
|
+
queriesFolder.subitem([
|
|
1079
|
+
'execution'
|
|
1080
|
+
]).createFile(`${naming.fileName}-query.spec.ts`, `
|
|
1081
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
1082
|
+
${withWiring ? `import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
|
|
1083
|
+
import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Query } from '../../../infrastructure/queries/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-query'
|
|
1084
|
+
|
|
1085
|
+
type ${naming.ClassName}Query = ${implementationNaming.ClassName}${naming.ClassName}Query`}
|
|
1086
|
+
|
|
1087
|
+
let ${naming.variableName}Query: ${naming.ClassName}Query
|
|
1088
|
+
|
|
1089
|
+
beforeEach(() => {
|
|
1090
|
+
${naming.variableName}Query = ${withWiring ? `wire${naming.ClassName}Query()` : `new ${implementationNaming.ClassName}${naming.ClassName}Query()`}
|
|
1091
|
+
})
|
|
1092
|
+
|
|
1093
|
+
describe('${naming.withSpaces} query', () => {
|
|
1094
|
+
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
1095
|
+
expect(${naming.variableName}Query).toBeDefined()
|
|
1096
|
+
})
|
|
1097
|
+
})
|
|
1098
|
+
`.trim());
|
|
1099
|
+
}
|
|
1059
1100
|
if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
|
|
1060
1101
|
const implementationNaming = new UnknownFormatNaming(implementationType);
|
|
1061
1102
|
const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
|
|
@@ -1111,6 +1152,25 @@ import { ${naming.ClassName}Query } from '../../application/queries/orchestratio
|
|
|
1111
1152
|
|
|
1112
1153
|
export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
|
|
1113
1154
|
`.trim());
|
|
1155
|
+
if (scaffoldUnitTests) queriesFolder.subitem([
|
|
1156
|
+
'orchestration'
|
|
1157
|
+
]).createFile(`${naming.fileName}-query.spec.ts`, `
|
|
1158
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
1159
|
+
${withWiring ? `import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
|
|
1160
|
+
import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${naming.ClassName}Query } from './${naming.fileName}-query'`}
|
|
1161
|
+
|
|
1162
|
+
let ${naming.variableName}Query: ${naming.ClassName}Query
|
|
1163
|
+
|
|
1164
|
+
beforeEach(() => {
|
|
1165
|
+
${naming.variableName}Query = ${withWiring ? `wire${naming.ClassName}Query()` : `new ${naming.ClassName}Query()`}
|
|
1166
|
+
})
|
|
1167
|
+
|
|
1168
|
+
describe('${naming.withSpaces} query', () => {
|
|
1169
|
+
test('can be ${withWiring ? 'wired' : 'created via constructor'}', () => {
|
|
1170
|
+
expect(${naming.variableName}Query).toBeDefined()
|
|
1171
|
+
})
|
|
1172
|
+
})
|
|
1173
|
+
`.trim());
|
|
1114
1174
|
};
|
|
1115
1175
|
const scaffoldNewUseCase = async (boundedContextFolder)=>{
|
|
1116
1176
|
const useCasesFolder = boundedContextFolder.subitem([
|