@domain-first/project-structure 2.6.0 → 2.7.0
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/dist/index.cjs +230 -19
- package/dist/index.js +230 -19
- package/dist/use-cases/index.d.ts +3 -0
- package/dist/use-cases/scaffold-new-application-service.d.ts +2 -0
- package/dist/use-cases/scaffold-new-infrastructure-service.d.ts +2 -0
- package/dist/use-cases/scaffold-new-presentation-service.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -447,6 +447,56 @@ export const wire${naming.ClassName} = envBranchedWire({
|
|
|
447
447
|
|
|
448
448
|
`.trim());
|
|
449
449
|
};
|
|
450
|
+
const scaffoldNewApplicationService = async (boundedContextFolder)=>{
|
|
451
|
+
const name = await (0, prompts_namespaceObject.input)({
|
|
452
|
+
message: 'Name: '
|
|
453
|
+
});
|
|
454
|
+
const naming = new UnknownFormatNaming(name);
|
|
455
|
+
let scaffoldUnitTests;
|
|
456
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
457
|
+
message: 'Scaffold unit-tests'
|
|
458
|
+
});
|
|
459
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
460
|
+
const wiringFolder = boundedContextFolder.subitem([
|
|
461
|
+
'wiring',
|
|
462
|
+
'application-services'
|
|
463
|
+
]);
|
|
464
|
+
const applicationServicesFolder = boundedContextFolder.subitem([
|
|
465
|
+
'application',
|
|
466
|
+
'services'
|
|
467
|
+
]);
|
|
468
|
+
applicationServicesFolder.createFile(`${naming.fileName}-application-service.ts`, `
|
|
469
|
+
export class ${naming.ClassName}ApplicationService {
|
|
470
|
+
|
|
471
|
+
}
|
|
472
|
+
`.trim());
|
|
473
|
+
if (scaffoldUnitTests) applicationServicesFolder.createFile(`${naming.fileName}-application-service.spec.ts`, `
|
|
474
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
475
|
+
${withWiring ? `import { type ${naming.ClassName}ApplicationService } from './${naming.fileName}-application-service'
|
|
476
|
+
import { wire${naming.ClassName}ApplicationService } from '../../wiring/application-services/wire-${naming.fileName}-application-service'` : `import { ${naming.ClassName}ApplicationService } from './${naming.fileName}-application-service'`}
|
|
477
|
+
|
|
478
|
+
let ${naming.variableName}ApplicationService: ${naming.ClassName}ApplicationService
|
|
479
|
+
|
|
480
|
+
beforeEach(() => {
|
|
481
|
+
${naming.variableName}ApplicationService = ${withWiring ? `wire${naming.ClassName}ApplicationService()` : `new ${naming.ClassName}ApplicationService()`}
|
|
482
|
+
})
|
|
483
|
+
|
|
484
|
+
describe('${naming.withSpaces}', () => {
|
|
485
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
486
|
+
expect(${naming.variableName}ApplicationService).toBeDefined()
|
|
487
|
+
})
|
|
488
|
+
})
|
|
489
|
+
`.trim());
|
|
490
|
+
if (withWiring) wiringFolder.createFile(`wire-${naming.fileName}-application-service.ts`, `
|
|
491
|
+
import { wireClass } from '@domain-first/wire'
|
|
492
|
+
import { ${naming.ClassName}ApplicationService } from '../../application/services/${naming.fileName}-application-service'
|
|
493
|
+
|
|
494
|
+
export const wire${naming.ClassName}ApplicationService = wireClass(
|
|
495
|
+
${naming.ClassName}ApplicationService,
|
|
496
|
+
[]
|
|
497
|
+
)
|
|
498
|
+
`.trim());
|
|
499
|
+
};
|
|
450
500
|
const scaffoldNewBoundedContextUseCase = async ()=>{
|
|
451
501
|
const name = await (0, prompts_namespaceObject.input)({
|
|
452
502
|
message: 'Name:',
|
|
@@ -639,24 +689,46 @@ const scaffoldNewDomainService = async (boundedContextFolder)=>{
|
|
|
639
689
|
message: 'Name:'
|
|
640
690
|
});
|
|
641
691
|
const naming = new UnknownFormatNaming(portName);
|
|
642
|
-
|
|
692
|
+
let scaffoldUnitTests;
|
|
693
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
694
|
+
message: 'Scaffold unit-tests'
|
|
695
|
+
});
|
|
696
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
697
|
+
const domainServicesFolder = boundedContextFolder.subitem([
|
|
643
698
|
'domain',
|
|
644
699
|
'services'
|
|
645
|
-
])
|
|
646
|
-
|
|
700
|
+
]);
|
|
701
|
+
domainServicesFolder.createFile(`${naming.fileName}-domain-service.ts`, `
|
|
702
|
+
export class ${naming.ClassName}DomainService {
|
|
647
703
|
|
|
648
704
|
}
|
|
649
705
|
`.trim());
|
|
650
|
-
if (
|
|
706
|
+
if (scaffoldUnitTests) domainServicesFolder.createFile(`${naming.fileName}-domain-service.spec.ts`, `
|
|
707
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
708
|
+
${withWiring ? `import { type ${naming.ClassName}DomainService } from './${naming.fileName}-domain-service'
|
|
709
|
+
import { wire${naming.ClassName}DomainService } from '../../wiring/domain-services/wire-${naming.fileName}-domain-service'` : `import { ${naming.ClassName}DomainService } from './${naming.fileName}-domain-service'`}
|
|
710
|
+
|
|
711
|
+
let ${naming.variableName}DomainService: ${naming.ClassName}DomainService
|
|
712
|
+
|
|
713
|
+
beforeEach(() => {
|
|
714
|
+
${naming.variableName}DomainService = ${withWiring ? `wire${naming.ClassName}DomainService()` : `new ${naming.ClassName}DomainService()`}
|
|
715
|
+
})
|
|
716
|
+
|
|
717
|
+
describe('${naming.withSpaces}', () => {
|
|
718
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
719
|
+
expect(${naming.variableName}DomainService).toBeDefined()
|
|
720
|
+
})
|
|
721
|
+
})
|
|
722
|
+
`.trim());
|
|
723
|
+
if (withWiring) boundedContextFolder.subitem([
|
|
651
724
|
'wiring',
|
|
652
|
-
'domain'
|
|
653
|
-
|
|
654
|
-
]).createFile(`wire-${naming.fileName}-service.ts`, `
|
|
725
|
+
'domain-services'
|
|
726
|
+
]).createFile(`wire-${naming.fileName}-domain-service.ts`, `
|
|
655
727
|
import { wireClass } from '@domain-first/wire'
|
|
656
|
-
import { ${naming.ClassName}
|
|
728
|
+
import { ${naming.ClassName}DomainService } from '../../domain/services/${naming.fileName}-domain-service'
|
|
657
729
|
|
|
658
|
-
export const wire${naming.ClassName}
|
|
659
|
-
${naming.ClassName}
|
|
730
|
+
export const wire${naming.ClassName}DomainService = wireClass(
|
|
731
|
+
${naming.ClassName}DomainService,
|
|
660
732
|
[]
|
|
661
733
|
)
|
|
662
734
|
`.trim());
|
|
@@ -801,6 +873,106 @@ export const wire${endpointNaming.ClassName} = wireClass(
|
|
|
801
873
|
wiringFolder.file('index.ts').addLine(`export * from './${wireNaming.fileName}'`);
|
|
802
874
|
}
|
|
803
875
|
};
|
|
876
|
+
const scaffoldNewInfrastructureService = async (boundedContextFolder)=>{
|
|
877
|
+
const name = await (0, prompts_namespaceObject.input)({
|
|
878
|
+
message: 'Name: '
|
|
879
|
+
});
|
|
880
|
+
const naming = new UnknownFormatNaming(name);
|
|
881
|
+
let scaffoldUnitTests;
|
|
882
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
883
|
+
message: 'Scaffold unit-tests'
|
|
884
|
+
});
|
|
885
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
886
|
+
const wiringFolder = boundedContextFolder.subitem([
|
|
887
|
+
'wiring',
|
|
888
|
+
'infrastructure-services'
|
|
889
|
+
]);
|
|
890
|
+
const infrastructureServicesFolder = boundedContextFolder.subitem([
|
|
891
|
+
'infrastructure',
|
|
892
|
+
'services'
|
|
893
|
+
]);
|
|
894
|
+
infrastructureServicesFolder.createFile(`${naming.fileName}-infrastructure-service.ts`, `
|
|
895
|
+
export class ${naming.ClassName}InfrastructureService {
|
|
896
|
+
|
|
897
|
+
}
|
|
898
|
+
`.trim());
|
|
899
|
+
if (scaffoldUnitTests) infrastructureServicesFolder.createFile(`${naming.fileName}-infrastructure-service.spec.ts`, `
|
|
900
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
901
|
+
${withWiring ? `import { type ${naming.ClassName}InfrastructureService } from './${naming.fileName}-infrastructure-service'
|
|
902
|
+
import { wire${naming.ClassName}InfrastructureService } from '../../wiring/infrastructure-services/wire-${naming.fileName}-infrastructure-service'` : `import { ${naming.ClassName}InfrastructureService } from './${naming.fileName}-infrastructure-service'`}
|
|
903
|
+
|
|
904
|
+
let ${naming.variableName}InfrastructureService: ${naming.ClassName}InfrastructureService
|
|
905
|
+
|
|
906
|
+
beforeEach(() => {
|
|
907
|
+
${naming.variableName}InfrastructureService = ${withWiring ? `wire${naming.ClassName}InfrastructureService()` : `new ${naming.ClassName}InfrastructureService()`}
|
|
908
|
+
})
|
|
909
|
+
|
|
910
|
+
describe('${naming.withSpaces}', () => {
|
|
911
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
912
|
+
expect(${naming.variableName}InfrastructureService).toBeDefined()
|
|
913
|
+
})
|
|
914
|
+
})
|
|
915
|
+
`.trim());
|
|
916
|
+
if (withWiring) wiringFolder.createFile(`wire-${naming.fileName}-infrastructure-service.ts`, `
|
|
917
|
+
import { wireClass } from '@domain-first/wire'
|
|
918
|
+
import { ${naming.ClassName}InfrastructureService } from '../../infrastructure/services/${naming.fileName}-infrastructure-service'
|
|
919
|
+
|
|
920
|
+
export const wire${naming.ClassName}InfrastructureService = wireClass(
|
|
921
|
+
${naming.ClassName}InfrastructureService,
|
|
922
|
+
[]
|
|
923
|
+
)
|
|
924
|
+
`.trim());
|
|
925
|
+
};
|
|
926
|
+
const scaffoldNewPresentationService = async (boundedContextFolder)=>{
|
|
927
|
+
const name = await (0, prompts_namespaceObject.input)({
|
|
928
|
+
message: 'Name: '
|
|
929
|
+
});
|
|
930
|
+
const naming = new UnknownFormatNaming(name);
|
|
931
|
+
let scaffoldUnitTests;
|
|
932
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
933
|
+
message: 'Scaffold unit-tests'
|
|
934
|
+
});
|
|
935
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
936
|
+
const wiringFolder = boundedContextFolder.subitem([
|
|
937
|
+
'wiring',
|
|
938
|
+
'presentation-services'
|
|
939
|
+
]);
|
|
940
|
+
const presentationServicesFolder = boundedContextFolder.subitem([
|
|
941
|
+
'presentation',
|
|
942
|
+
'services'
|
|
943
|
+
]);
|
|
944
|
+
presentationServicesFolder.createFile(`${naming.fileName}-presentation-service.ts`, `
|
|
945
|
+
export class ${naming.ClassName}PresentationService {
|
|
946
|
+
|
|
947
|
+
}
|
|
948
|
+
`.trim());
|
|
949
|
+
if (scaffoldUnitTests) presentationServicesFolder.createFile(`${naming.fileName}-presentation-service.spec.ts`, `
|
|
950
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
951
|
+
${withWiring ? `import { type ${naming.ClassName}PresentationService } from './${naming.fileName}-presentation-service'
|
|
952
|
+
import { wire${naming.ClassName}PresentationService } from '../../wiring/presentation-services/wire-${naming.fileName}-presentation-service'` : `import { ${naming.ClassName}PresentationService } from './${naming.fileName}-presentation-service'`}
|
|
953
|
+
|
|
954
|
+
let ${naming.variableName}PresentationService: ${naming.ClassName}PresentationService
|
|
955
|
+
|
|
956
|
+
beforeEach(() => {
|
|
957
|
+
${naming.variableName}PresentationService = ${withWiring ? `wire${naming.ClassName}PresentationService()` : `new ${naming.ClassName}PresentationService()`}
|
|
958
|
+
})
|
|
959
|
+
|
|
960
|
+
describe('${naming.withSpaces}', () => {
|
|
961
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
962
|
+
expect(${naming.variableName}PresentationService).toBeDefined()
|
|
963
|
+
})
|
|
964
|
+
})
|
|
965
|
+
`.trim());
|
|
966
|
+
if (withWiring) wiringFolder.createFile(`wire-${naming.fileName}-presentation-service.ts`, `
|
|
967
|
+
import { wireClass } from '@domain-first/wire'
|
|
968
|
+
import { ${naming.ClassName}PresentationService } from '../../presentation/services/${naming.fileName}-presentation-service'
|
|
969
|
+
|
|
970
|
+
export const wire${naming.ClassName}PresentationService = wireClass(
|
|
971
|
+
${naming.ClassName}PresentationService,
|
|
972
|
+
[]
|
|
973
|
+
)
|
|
974
|
+
`.trim());
|
|
975
|
+
};
|
|
804
976
|
const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
805
977
|
const queriesFolder = boundedContextFolder.subitem([
|
|
806
978
|
'application',
|
|
@@ -975,6 +1147,11 @@ const scaffoldNewUseCase = async (boundedContextFolder)=>{
|
|
|
975
1147
|
message: 'Name: '
|
|
976
1148
|
});
|
|
977
1149
|
const naming = new UnknownFormatNaming(useCaseName);
|
|
1150
|
+
let scaffoldUnitTests;
|
|
1151
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
1152
|
+
message: 'Scaffold unit-tests'
|
|
1153
|
+
});
|
|
1154
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
978
1155
|
useCasesFolder.createFile(`${naming.fileName}-use-case.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
979
1156
|
import { defineHandler } from '@domain-first/handlers'
|
|
980
1157
|
|
|
@@ -997,7 +1174,24 @@ export class ${naming.ClassName}UseCase {
|
|
|
997
1174
|
|
|
998
1175
|
}
|
|
999
1176
|
`.trim());
|
|
1000
|
-
if (
|
|
1177
|
+
if (scaffoldUnitTests) useCasesFolder.createFile(`${naming.fileName}-use-case.spec.ts`, `
|
|
1178
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
1179
|
+
${withWiring ? `import { type ${naming.ClassName}UseCase } from './${naming.fileName}-use-case'
|
|
1180
|
+
import { wire${naming.ClassName}UseCase } from '../../wiring/use-cases/wire-${naming.fileName}-use-case'` : `import { ${naming.ClassName}UseCase } from './${naming.fileName}-use-case'`}
|
|
1181
|
+
|
|
1182
|
+
let ${naming.variableName}UseCase: ${naming.ClassName}UseCase
|
|
1183
|
+
|
|
1184
|
+
beforeEach(() => {
|
|
1185
|
+
${naming.variableName}UseCase = ${withWiring ? `wire${naming.ClassName}UseCase()` : `new ${naming.ClassName}UseCase()`}
|
|
1186
|
+
})
|
|
1187
|
+
|
|
1188
|
+
describe('${naming.withSpaces} use case', () => {
|
|
1189
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
1190
|
+
expect(${naming.variableName}UseCase).toBeDefined()
|
|
1191
|
+
})
|
|
1192
|
+
})
|
|
1193
|
+
`.trim());
|
|
1194
|
+
if (withWiring) boundedContextFolder.subitem([
|
|
1001
1195
|
'wiring',
|
|
1002
1196
|
'use-cases'
|
|
1003
1197
|
]).createFile(`wire-${naming.fileName}-use-case.ts`, `
|
|
@@ -1201,13 +1395,11 @@ const main = async ()=>{
|
|
|
1201
1395
|
]);
|
|
1202
1396
|
const layer = await (0, prompts_namespaceObject.select)({
|
|
1203
1397
|
message: 'Layer:',
|
|
1204
|
-
choices:
|
|
1398
|
+
choices: [
|
|
1205
1399
|
'Domain',
|
|
1206
1400
|
'Application',
|
|
1401
|
+
'Infrastructure',
|
|
1207
1402
|
'Presentation'
|
|
1208
|
-
] : [
|
|
1209
|
-
'Domain',
|
|
1210
|
-
'Application'
|
|
1211
1403
|
]
|
|
1212
1404
|
});
|
|
1213
1405
|
if ('Domain' === layer) {
|
|
@@ -1237,9 +1429,11 @@ const main = async ()=>{
|
|
|
1237
1429
|
'New Query',
|
|
1238
1430
|
'New Command',
|
|
1239
1431
|
'New Use Case',
|
|
1240
|
-
'New Port'
|
|
1432
|
+
'New Port',
|
|
1433
|
+
'New Service'
|
|
1241
1434
|
] : [
|
|
1242
|
-
'New Port'
|
|
1435
|
+
'New Port',
|
|
1436
|
+
'New Service'
|
|
1243
1437
|
]
|
|
1244
1438
|
});
|
|
1245
1439
|
switch(operation){
|
|
@@ -1251,20 +1445,37 @@ const main = async ()=>{
|
|
|
1251
1445
|
return void await scaffoldNewUseCase(boundedContextFolder);
|
|
1252
1446
|
case 'New Port':
|
|
1253
1447
|
return void await scaffoldNewApplicationPort(boundedContextFolder);
|
|
1448
|
+
case 'New Service':
|
|
1449
|
+
return void await scaffoldNewApplicationService(boundedContextFolder);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
if ('Infrastructure' === layer) {
|
|
1453
|
+
const operation = await (0, prompts_namespaceObject.select)({
|
|
1454
|
+
message: 'Infrastructure layer operation:',
|
|
1455
|
+
choices: [
|
|
1456
|
+
'New Service'
|
|
1457
|
+
]
|
|
1458
|
+
});
|
|
1459
|
+
switch(operation){
|
|
1460
|
+
case 'New Service':
|
|
1461
|
+
return void await scaffoldNewInfrastructureService(boundedContextFolder);
|
|
1254
1462
|
}
|
|
1255
1463
|
}
|
|
1256
1464
|
if ('Presentation' === layer) {
|
|
1257
1465
|
const action = await (0, prompts_namespaceObject.select)({
|
|
1258
1466
|
message: 'Presentation layer operation:',
|
|
1259
1467
|
choices: specificContext ? [
|
|
1260
|
-
ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers-rest') ? 'New Handlers-REST Endpoint' : void 0
|
|
1468
|
+
ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers-rest') ? 'New Handlers-REST Endpoint' : void 0,
|
|
1469
|
+
'New Service'
|
|
1261
1470
|
].filter((x)=>x) : [
|
|
1262
|
-
''
|
|
1471
|
+
'New Service'
|
|
1263
1472
|
]
|
|
1264
1473
|
});
|
|
1265
1474
|
switch(action){
|
|
1266
1475
|
case 'New Handlers-REST Endpoint':
|
|
1267
1476
|
return void await scaffoldNewHandlersRestEndpoint(boundedContextFolder);
|
|
1477
|
+
case 'New Service':
|
|
1478
|
+
return void await scaffoldNewPresentationService(boundedContextFolder);
|
|
1268
1479
|
}
|
|
1269
1480
|
}
|
|
1270
1481
|
return;
|
package/dist/index.js
CHANGED
|
@@ -417,6 +417,56 @@ export const wire${naming.ClassName} = envBranchedWire({
|
|
|
417
417
|
|
|
418
418
|
`.trim());
|
|
419
419
|
};
|
|
420
|
+
const scaffoldNewApplicationService = async (boundedContextFolder)=>{
|
|
421
|
+
const name = await input({
|
|
422
|
+
message: 'Name: '
|
|
423
|
+
});
|
|
424
|
+
const naming = new UnknownFormatNaming(name);
|
|
425
|
+
let scaffoldUnitTests;
|
|
426
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
427
|
+
message: 'Scaffold unit-tests'
|
|
428
|
+
});
|
|
429
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
430
|
+
const wiringFolder = boundedContextFolder.subitem([
|
|
431
|
+
'wiring',
|
|
432
|
+
'application-services'
|
|
433
|
+
]);
|
|
434
|
+
const applicationServicesFolder = boundedContextFolder.subitem([
|
|
435
|
+
'application',
|
|
436
|
+
'services'
|
|
437
|
+
]);
|
|
438
|
+
applicationServicesFolder.createFile(`${naming.fileName}-application-service.ts`, `
|
|
439
|
+
export class ${naming.ClassName}ApplicationService {
|
|
440
|
+
|
|
441
|
+
}
|
|
442
|
+
`.trim());
|
|
443
|
+
if (scaffoldUnitTests) applicationServicesFolder.createFile(`${naming.fileName}-application-service.spec.ts`, `
|
|
444
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
445
|
+
${withWiring ? `import { type ${naming.ClassName}ApplicationService } from './${naming.fileName}-application-service'
|
|
446
|
+
import { wire${naming.ClassName}ApplicationService } from '../../wiring/application-services/wire-${naming.fileName}-application-service'` : `import { ${naming.ClassName}ApplicationService } from './${naming.fileName}-application-service'`}
|
|
447
|
+
|
|
448
|
+
let ${naming.variableName}ApplicationService: ${naming.ClassName}ApplicationService
|
|
449
|
+
|
|
450
|
+
beforeEach(() => {
|
|
451
|
+
${naming.variableName}ApplicationService = ${withWiring ? `wire${naming.ClassName}ApplicationService()` : `new ${naming.ClassName}ApplicationService()`}
|
|
452
|
+
})
|
|
453
|
+
|
|
454
|
+
describe('${naming.withSpaces}', () => {
|
|
455
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
456
|
+
expect(${naming.variableName}ApplicationService).toBeDefined()
|
|
457
|
+
})
|
|
458
|
+
})
|
|
459
|
+
`.trim());
|
|
460
|
+
if (withWiring) wiringFolder.createFile(`wire-${naming.fileName}-application-service.ts`, `
|
|
461
|
+
import { wireClass } from '@domain-first/wire'
|
|
462
|
+
import { ${naming.ClassName}ApplicationService } from '../../application/services/${naming.fileName}-application-service'
|
|
463
|
+
|
|
464
|
+
export const wire${naming.ClassName}ApplicationService = wireClass(
|
|
465
|
+
${naming.ClassName}ApplicationService,
|
|
466
|
+
[]
|
|
467
|
+
)
|
|
468
|
+
`.trim());
|
|
469
|
+
};
|
|
420
470
|
const scaffoldNewBoundedContextUseCase = async ()=>{
|
|
421
471
|
const name = await input({
|
|
422
472
|
message: 'Name:',
|
|
@@ -609,24 +659,46 @@ const scaffoldNewDomainService = async (boundedContextFolder)=>{
|
|
|
609
659
|
message: 'Name:'
|
|
610
660
|
});
|
|
611
661
|
const naming = new UnknownFormatNaming(portName);
|
|
612
|
-
|
|
662
|
+
let scaffoldUnitTests;
|
|
663
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
664
|
+
message: 'Scaffold unit-tests'
|
|
665
|
+
});
|
|
666
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
667
|
+
const domainServicesFolder = boundedContextFolder.subitem([
|
|
613
668
|
'domain',
|
|
614
669
|
'services'
|
|
615
|
-
])
|
|
616
|
-
|
|
670
|
+
]);
|
|
671
|
+
domainServicesFolder.createFile(`${naming.fileName}-domain-service.ts`, `
|
|
672
|
+
export class ${naming.ClassName}DomainService {
|
|
617
673
|
|
|
618
674
|
}
|
|
619
675
|
`.trim());
|
|
620
|
-
if (
|
|
676
|
+
if (scaffoldUnitTests) domainServicesFolder.createFile(`${naming.fileName}-domain-service.spec.ts`, `
|
|
677
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
678
|
+
${withWiring ? `import { type ${naming.ClassName}DomainService } from './${naming.fileName}-domain-service'
|
|
679
|
+
import { wire${naming.ClassName}DomainService } from '../../wiring/domain-services/wire-${naming.fileName}-domain-service'` : `import { ${naming.ClassName}DomainService } from './${naming.fileName}-domain-service'`}
|
|
680
|
+
|
|
681
|
+
let ${naming.variableName}DomainService: ${naming.ClassName}DomainService
|
|
682
|
+
|
|
683
|
+
beforeEach(() => {
|
|
684
|
+
${naming.variableName}DomainService = ${withWiring ? `wire${naming.ClassName}DomainService()` : `new ${naming.ClassName}DomainService()`}
|
|
685
|
+
})
|
|
686
|
+
|
|
687
|
+
describe('${naming.withSpaces}', () => {
|
|
688
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
689
|
+
expect(${naming.variableName}DomainService).toBeDefined()
|
|
690
|
+
})
|
|
691
|
+
})
|
|
692
|
+
`.trim());
|
|
693
|
+
if (withWiring) boundedContextFolder.subitem([
|
|
621
694
|
'wiring',
|
|
622
|
-
'domain'
|
|
623
|
-
|
|
624
|
-
]).createFile(`wire-${naming.fileName}-service.ts`, `
|
|
695
|
+
'domain-services'
|
|
696
|
+
]).createFile(`wire-${naming.fileName}-domain-service.ts`, `
|
|
625
697
|
import { wireClass } from '@domain-first/wire'
|
|
626
|
-
import { ${naming.ClassName}
|
|
698
|
+
import { ${naming.ClassName}DomainService } from '../../domain/services/${naming.fileName}-domain-service'
|
|
627
699
|
|
|
628
|
-
export const wire${naming.ClassName}
|
|
629
|
-
${naming.ClassName}
|
|
700
|
+
export const wire${naming.ClassName}DomainService = wireClass(
|
|
701
|
+
${naming.ClassName}DomainService,
|
|
630
702
|
[]
|
|
631
703
|
)
|
|
632
704
|
`.trim());
|
|
@@ -771,6 +843,106 @@ export const wire${endpointNaming.ClassName} = wireClass(
|
|
|
771
843
|
wiringFolder.file('index.ts').addLine(`export * from './${wireNaming.fileName}'`);
|
|
772
844
|
}
|
|
773
845
|
};
|
|
846
|
+
const scaffoldNewInfrastructureService = async (boundedContextFolder)=>{
|
|
847
|
+
const name = await input({
|
|
848
|
+
message: 'Name: '
|
|
849
|
+
});
|
|
850
|
+
const naming = new UnknownFormatNaming(name);
|
|
851
|
+
let scaffoldUnitTests;
|
|
852
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
853
|
+
message: 'Scaffold unit-tests'
|
|
854
|
+
});
|
|
855
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
856
|
+
const wiringFolder = boundedContextFolder.subitem([
|
|
857
|
+
'wiring',
|
|
858
|
+
'infrastructure-services'
|
|
859
|
+
]);
|
|
860
|
+
const infrastructureServicesFolder = boundedContextFolder.subitem([
|
|
861
|
+
'infrastructure',
|
|
862
|
+
'services'
|
|
863
|
+
]);
|
|
864
|
+
infrastructureServicesFolder.createFile(`${naming.fileName}-infrastructure-service.ts`, `
|
|
865
|
+
export class ${naming.ClassName}InfrastructureService {
|
|
866
|
+
|
|
867
|
+
}
|
|
868
|
+
`.trim());
|
|
869
|
+
if (scaffoldUnitTests) infrastructureServicesFolder.createFile(`${naming.fileName}-infrastructure-service.spec.ts`, `
|
|
870
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
871
|
+
${withWiring ? `import { type ${naming.ClassName}InfrastructureService } from './${naming.fileName}-infrastructure-service'
|
|
872
|
+
import { wire${naming.ClassName}InfrastructureService } from '../../wiring/infrastructure-services/wire-${naming.fileName}-infrastructure-service'` : `import { ${naming.ClassName}InfrastructureService } from './${naming.fileName}-infrastructure-service'`}
|
|
873
|
+
|
|
874
|
+
let ${naming.variableName}InfrastructureService: ${naming.ClassName}InfrastructureService
|
|
875
|
+
|
|
876
|
+
beforeEach(() => {
|
|
877
|
+
${naming.variableName}InfrastructureService = ${withWiring ? `wire${naming.ClassName}InfrastructureService()` : `new ${naming.ClassName}InfrastructureService()`}
|
|
878
|
+
})
|
|
879
|
+
|
|
880
|
+
describe('${naming.withSpaces}', () => {
|
|
881
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
882
|
+
expect(${naming.variableName}InfrastructureService).toBeDefined()
|
|
883
|
+
})
|
|
884
|
+
})
|
|
885
|
+
`.trim());
|
|
886
|
+
if (withWiring) wiringFolder.createFile(`wire-${naming.fileName}-infrastructure-service.ts`, `
|
|
887
|
+
import { wireClass } from '@domain-first/wire'
|
|
888
|
+
import { ${naming.ClassName}InfrastructureService } from '../../infrastructure/services/${naming.fileName}-infrastructure-service'
|
|
889
|
+
|
|
890
|
+
export const wire${naming.ClassName}InfrastructureService = wireClass(
|
|
891
|
+
${naming.ClassName}InfrastructureService,
|
|
892
|
+
[]
|
|
893
|
+
)
|
|
894
|
+
`.trim());
|
|
895
|
+
};
|
|
896
|
+
const scaffoldNewPresentationService = async (boundedContextFolder)=>{
|
|
897
|
+
const name = await input({
|
|
898
|
+
message: 'Name: '
|
|
899
|
+
});
|
|
900
|
+
const naming = new UnknownFormatNaming(name);
|
|
901
|
+
let scaffoldUnitTests;
|
|
902
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
903
|
+
message: 'Scaffold unit-tests'
|
|
904
|
+
});
|
|
905
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
906
|
+
const wiringFolder = boundedContextFolder.subitem([
|
|
907
|
+
'wiring',
|
|
908
|
+
'presentation-services'
|
|
909
|
+
]);
|
|
910
|
+
const presentationServicesFolder = boundedContextFolder.subitem([
|
|
911
|
+
'presentation',
|
|
912
|
+
'services'
|
|
913
|
+
]);
|
|
914
|
+
presentationServicesFolder.createFile(`${naming.fileName}-presentation-service.ts`, `
|
|
915
|
+
export class ${naming.ClassName}PresentationService {
|
|
916
|
+
|
|
917
|
+
}
|
|
918
|
+
`.trim());
|
|
919
|
+
if (scaffoldUnitTests) presentationServicesFolder.createFile(`${naming.fileName}-presentation-service.spec.ts`, `
|
|
920
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
921
|
+
${withWiring ? `import { type ${naming.ClassName}PresentationService } from './${naming.fileName}-presentation-service'
|
|
922
|
+
import { wire${naming.ClassName}PresentationService } from '../../wiring/presentation-services/wire-${naming.fileName}-presentation-service'` : `import { ${naming.ClassName}PresentationService } from './${naming.fileName}-presentation-service'`}
|
|
923
|
+
|
|
924
|
+
let ${naming.variableName}PresentationService: ${naming.ClassName}PresentationService
|
|
925
|
+
|
|
926
|
+
beforeEach(() => {
|
|
927
|
+
${naming.variableName}PresentationService = ${withWiring ? `wire${naming.ClassName}PresentationService()` : `new ${naming.ClassName}PresentationService()`}
|
|
928
|
+
})
|
|
929
|
+
|
|
930
|
+
describe('${naming.withSpaces}', () => {
|
|
931
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
932
|
+
expect(${naming.variableName}PresentationService).toBeDefined()
|
|
933
|
+
})
|
|
934
|
+
})
|
|
935
|
+
`.trim());
|
|
936
|
+
if (withWiring) wiringFolder.createFile(`wire-${naming.fileName}-presentation-service.ts`, `
|
|
937
|
+
import { wireClass } from '@domain-first/wire'
|
|
938
|
+
import { ${naming.ClassName}PresentationService } from '../../presentation/services/${naming.fileName}-presentation-service'
|
|
939
|
+
|
|
940
|
+
export const wire${naming.ClassName}PresentationService = wireClass(
|
|
941
|
+
${naming.ClassName}PresentationService,
|
|
942
|
+
[]
|
|
943
|
+
)
|
|
944
|
+
`.trim());
|
|
945
|
+
};
|
|
774
946
|
const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
775
947
|
const queriesFolder = boundedContextFolder.subitem([
|
|
776
948
|
'application',
|
|
@@ -945,6 +1117,11 @@ const scaffoldNewUseCase = async (boundedContextFolder)=>{
|
|
|
945
1117
|
message: 'Name: '
|
|
946
1118
|
});
|
|
947
1119
|
const naming = new UnknownFormatNaming(useCaseName);
|
|
1120
|
+
let scaffoldUnitTests;
|
|
1121
|
+
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
1122
|
+
message: 'Scaffold unit-tests'
|
|
1123
|
+
});
|
|
1124
|
+
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
948
1125
|
useCasesFolder.createFile(`${naming.fileName}-use-case.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
949
1126
|
import { defineHandler } from '@domain-first/handlers'
|
|
950
1127
|
|
|
@@ -967,7 +1144,24 @@ export class ${naming.ClassName}UseCase {
|
|
|
967
1144
|
|
|
968
1145
|
}
|
|
969
1146
|
`.trim());
|
|
970
|
-
if (
|
|
1147
|
+
if (scaffoldUnitTests) useCasesFolder.createFile(`${naming.fileName}-use-case.spec.ts`, `
|
|
1148
|
+
import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
|
|
1149
|
+
${withWiring ? `import { type ${naming.ClassName}UseCase } from './${naming.fileName}-use-case'
|
|
1150
|
+
import { wire${naming.ClassName}UseCase } from '../../wiring/use-cases/wire-${naming.fileName}-use-case'` : `import { ${naming.ClassName}UseCase } from './${naming.fileName}-use-case'`}
|
|
1151
|
+
|
|
1152
|
+
let ${naming.variableName}UseCase: ${naming.ClassName}UseCase
|
|
1153
|
+
|
|
1154
|
+
beforeEach(() => {
|
|
1155
|
+
${naming.variableName}UseCase = ${withWiring ? `wire${naming.ClassName}UseCase()` : `new ${naming.ClassName}UseCase()`}
|
|
1156
|
+
})
|
|
1157
|
+
|
|
1158
|
+
describe('${naming.withSpaces} use case', () => {
|
|
1159
|
+
test('can be ${withWiring ? 'wired' : 'created'}', () => {
|
|
1160
|
+
expect(${naming.variableName}UseCase).toBeDefined()
|
|
1161
|
+
})
|
|
1162
|
+
})
|
|
1163
|
+
`.trim());
|
|
1164
|
+
if (withWiring) boundedContextFolder.subitem([
|
|
971
1165
|
'wiring',
|
|
972
1166
|
'use-cases'
|
|
973
1167
|
]).createFile(`wire-${naming.fileName}-use-case.ts`, `
|
|
@@ -1171,13 +1365,11 @@ const main = async ()=>{
|
|
|
1171
1365
|
]);
|
|
1172
1366
|
const layer = await prompts_select({
|
|
1173
1367
|
message: 'Layer:',
|
|
1174
|
-
choices:
|
|
1368
|
+
choices: [
|
|
1175
1369
|
'Domain',
|
|
1176
1370
|
'Application',
|
|
1371
|
+
'Infrastructure',
|
|
1177
1372
|
'Presentation'
|
|
1178
|
-
] : [
|
|
1179
|
-
'Domain',
|
|
1180
|
-
'Application'
|
|
1181
1373
|
]
|
|
1182
1374
|
});
|
|
1183
1375
|
if ('Domain' === layer) {
|
|
@@ -1207,9 +1399,11 @@ const main = async ()=>{
|
|
|
1207
1399
|
'New Query',
|
|
1208
1400
|
'New Command',
|
|
1209
1401
|
'New Use Case',
|
|
1210
|
-
'New Port'
|
|
1402
|
+
'New Port',
|
|
1403
|
+
'New Service'
|
|
1211
1404
|
] : [
|
|
1212
|
-
'New Port'
|
|
1405
|
+
'New Port',
|
|
1406
|
+
'New Service'
|
|
1213
1407
|
]
|
|
1214
1408
|
});
|
|
1215
1409
|
switch(operation){
|
|
@@ -1221,20 +1415,37 @@ const main = async ()=>{
|
|
|
1221
1415
|
return void await scaffoldNewUseCase(boundedContextFolder);
|
|
1222
1416
|
case 'New Port':
|
|
1223
1417
|
return void await scaffoldNewApplicationPort(boundedContextFolder);
|
|
1418
|
+
case 'New Service':
|
|
1419
|
+
return void await scaffoldNewApplicationService(boundedContextFolder);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
if ('Infrastructure' === layer) {
|
|
1423
|
+
const operation = await prompts_select({
|
|
1424
|
+
message: 'Infrastructure layer operation:',
|
|
1425
|
+
choices: [
|
|
1426
|
+
'New Service'
|
|
1427
|
+
]
|
|
1428
|
+
});
|
|
1429
|
+
switch(operation){
|
|
1430
|
+
case 'New Service':
|
|
1431
|
+
return void await scaffoldNewInfrastructureService(boundedContextFolder);
|
|
1224
1432
|
}
|
|
1225
1433
|
}
|
|
1226
1434
|
if ('Presentation' === layer) {
|
|
1227
1435
|
const action = await prompts_select({
|
|
1228
1436
|
message: 'Presentation layer operation:',
|
|
1229
1437
|
choices: specificContext ? [
|
|
1230
|
-
ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers-rest') ? 'New Handlers-REST Endpoint' : void 0
|
|
1438
|
+
ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers-rest') ? 'New Handlers-REST Endpoint' : void 0,
|
|
1439
|
+
'New Service'
|
|
1231
1440
|
].filter((x)=>x) : [
|
|
1232
|
-
''
|
|
1441
|
+
'New Service'
|
|
1233
1442
|
]
|
|
1234
1443
|
});
|
|
1235
1444
|
switch(action){
|
|
1236
1445
|
case 'New Handlers-REST Endpoint':
|
|
1237
1446
|
return void await scaffoldNewHandlersRestEndpoint(boundedContextFolder);
|
|
1447
|
+
case 'New Service':
|
|
1448
|
+
return void await scaffoldNewPresentationService(boundedContextFolder);
|
|
1238
1449
|
}
|
|
1239
1450
|
}
|
|
1240
1451
|
return;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export * from './initialize';
|
|
2
2
|
export * from './scaffold-new-aggregate';
|
|
3
3
|
export * from './scaffold-new-application-port';
|
|
4
|
+
export * from './scaffold-new-application-service';
|
|
4
5
|
export * from './scaffold-new-bounded-context';
|
|
5
6
|
export * from './scaffold-new-command';
|
|
6
7
|
export * from './scaffold-new-domain-service';
|
|
7
8
|
export * from './scaffold-new-error';
|
|
8
9
|
export * from './scaffold-new-handlers-rest-endpoint';
|
|
10
|
+
export * from './scaffold-new-infrastructure-service';
|
|
11
|
+
export * from './scaffold-new-presentation-service';
|
|
9
12
|
export * from './scaffold-new-query';
|
|
10
13
|
export * from './scaffold-new-use-case';
|
|
11
14
|
export * from './scaffold-react-page';
|