@domain-first/project-structure 2.3.1 → 2.5.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 CHANGED
@@ -481,6 +481,10 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
481
481
  const commandName = await (0, prompts_namespaceObject.input)({
482
482
  message: 'Name: '
483
483
  });
484
+ let scaffoldUnitTests;
485
+ if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
486
+ message: 'Scaffold unit-tests'
487
+ });
484
488
  const naming = new UnknownFormatNaming(commandName);
485
489
  const commandType = await (0, prompts_namespaceObject.select)({
486
490
  choices: [
@@ -490,6 +494,25 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
490
494
  message: 'Command type'
491
495
  });
492
496
  const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === commandType;
497
+ if (scaffoldUnitTests) commandsFolder.subitem([
498
+ isOrchestrator ? 'orchestration' : 'execution'
499
+ ]).createFile(`${naming.fileName}-command.spec.ts`, `
500
+ import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
501
+ import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
502
+ import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'
503
+
504
+ let ${naming.variableName}Command: ${naming.ClassName}Command
505
+
506
+ beforeEach(() => {
507
+ ${naming.variableName}Command = wire${naming.ClassName}Command()
508
+ })
509
+
510
+ describe('${naming.withSpaces} command', () => {
511
+ test('can be wired', () => {
512
+ expect(${naming.variableName}Command).toBeDefined()
513
+ })
514
+ })
515
+ `.trim());
493
516
  if (!isOrchestrator) {
494
517
  const implementationType = await (0, prompts_namespaceObject.input)({
495
518
  message: 'Command infrastructure implementation type:',
@@ -603,11 +626,10 @@ export class ${naming.ClassName}Command {
603
626
  }`.trim());
604
627
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
605
628
  'wiring',
606
- 'application',
607
629
  'commands'
608
630
  ]).createFile(`wire-${naming.fileName}-command.ts`, `
609
631
  import { wireClass } from '@domain-first/wire'
610
- import { ${naming.ClassName}Command } from '../../../application/commands/orchestration/${naming.fileName}-command'
632
+ import { ${naming.ClassName}Command } from '../../application/commands/orchestration/${naming.fileName}-command'
611
633
 
612
634
  export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
613
635
  `.trim());
@@ -792,6 +814,10 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
792
814
  message: 'Name: '
793
815
  });
794
816
  const naming = new UnknownFormatNaming(queryName);
817
+ let scaffoldUnitTests;
818
+ if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
819
+ message: 'Scaffold unit-tests'
820
+ });
795
821
  const queryType = await (0, prompts_namespaceObject.select)({
796
822
  choices: [
797
823
  'Execution (with infrastructure implementation)',
@@ -800,6 +826,25 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
800
826
  message: 'Query type'
801
827
  });
802
828
  const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === queryType;
829
+ if (scaffoldUnitTests) queriesFolder.subitem([
830
+ isOrchestrator ? 'orchestration' : 'execution'
831
+ ]).createFile(`${naming.fileName}-query.spec.ts`, `
832
+ import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
833
+ import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
834
+ import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'
835
+
836
+ let ${naming.variableName}Query: ${naming.ClassName}Query
837
+
838
+ beforeEach(() => {
839
+ ${naming.variableName}Query = wire${naming.ClassName}Query()
840
+ })
841
+
842
+ describe('${naming.withSpaces} query', () => {
843
+ test('can be wired', () => {
844
+ expect(${naming.variableName}Query).toBeDefined()
845
+ })
846
+ })
847
+ `.trim());
803
848
  if (!isOrchestrator) {
804
849
  const implementationType = await (0, prompts_namespaceObject.input)({
805
850
  message: 'Query infrastructure implementation type:',
@@ -913,11 +958,10 @@ export class ${naming.ClassName}Query {
913
958
  }`.trim());
914
959
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
915
960
  'wiring',
916
- 'application',
917
961
  'queries'
918
962
  ]).createFile(`wire-${naming.fileName}-query.ts`, `
919
963
  import { wireClass } from '@domain-first/wire'
920
- import { ${naming.ClassName}Query } from '../../../application/queries/orchestration/${naming.fileName}-query'
964
+ import { ${naming.ClassName}Query } from '../../application/queries/orchestration/${naming.fileName}-query'
921
965
 
922
966
  export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
923
967
  `.trim());
package/dist/index.js CHANGED
@@ -451,6 +451,10 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
451
451
  const commandName = await input({
452
452
  message: 'Name: '
453
453
  });
454
+ let scaffoldUnitTests;
455
+ if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
456
+ message: 'Scaffold unit-tests'
457
+ });
454
458
  const naming = new UnknownFormatNaming(commandName);
455
459
  const commandType = await prompts_select({
456
460
  choices: [
@@ -460,6 +464,25 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
460
464
  message: 'Command type'
461
465
  });
462
466
  const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === commandType;
467
+ if (scaffoldUnitTests) commandsFolder.subitem([
468
+ isOrchestrator ? 'orchestration' : 'execution'
469
+ ]).createFile(`${naming.fileName}-command.spec.ts`, `
470
+ import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
471
+ import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
472
+ import { wire${naming.ClassName}Command } from '../../../wiring/commands/wire-${naming.fileName}-command'
473
+
474
+ let ${naming.variableName}Command: ${naming.ClassName}Command
475
+
476
+ beforeEach(() => {
477
+ ${naming.variableName}Command = wire${naming.ClassName}Command()
478
+ })
479
+
480
+ describe('${naming.withSpaces} command', () => {
481
+ test('can be wired', () => {
482
+ expect(${naming.variableName}Command).toBeDefined()
483
+ })
484
+ })
485
+ `.trim());
463
486
  if (!isOrchestrator) {
464
487
  const implementationType = await input({
465
488
  message: 'Command infrastructure implementation type:',
@@ -573,11 +596,10 @@ export class ${naming.ClassName}Command {
573
596
  }`.trim());
574
597
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
575
598
  'wiring',
576
- 'application',
577
599
  'commands'
578
600
  ]).createFile(`wire-${naming.fileName}-command.ts`, `
579
601
  import { wireClass } from '@domain-first/wire'
580
- import { ${naming.ClassName}Command } from '../../../application/commands/orchestration/${naming.fileName}-command'
602
+ import { ${naming.ClassName}Command } from '../../application/commands/orchestration/${naming.fileName}-command'
581
603
 
582
604
  export const wire${naming.ClassName}Command = wireClass(${naming.ClassName}Command, [])
583
605
  `.trim());
@@ -762,6 +784,10 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
762
784
  message: 'Name: '
763
785
  });
764
786
  const naming = new UnknownFormatNaming(queryName);
787
+ let scaffoldUnitTests;
788
+ if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
789
+ message: 'Scaffold unit-tests'
790
+ });
765
791
  const queryType = await prompts_select({
766
792
  choices: [
767
793
  'Execution (with infrastructure implementation)',
@@ -770,6 +796,25 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
770
796
  message: 'Query type'
771
797
  });
772
798
  const isOrchestrator = 'Orchestrator (no infrastructure implementation)' === queryType;
799
+ if (scaffoldUnitTests) queriesFolder.subitem([
800
+ isOrchestrator ? 'orchestration' : 'execution'
801
+ ]).createFile(`${naming.fileName}-query.spec.ts`, `
802
+ import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
803
+ import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
804
+ import { wire${naming.ClassName}Query } from '../../../wiring/queries/wire-${naming.fileName}-query'
805
+
806
+ let ${naming.variableName}Query: ${naming.ClassName}Query
807
+
808
+ beforeEach(() => {
809
+ ${naming.variableName}Query = wire${naming.ClassName}Query()
810
+ })
811
+
812
+ describe('${naming.withSpaces} query', () => {
813
+ test('can be wired', () => {
814
+ expect(${naming.variableName}Query).toBeDefined()
815
+ })
816
+ })
817
+ `.trim());
773
818
  if (!isOrchestrator) {
774
819
  const implementationType = await input({
775
820
  message: 'Query infrastructure implementation type:',
@@ -883,11 +928,10 @@ export class ${naming.ClassName}Query {
883
928
  }`.trim());
884
929
  if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) boundedContextFolder.subitem([
885
930
  'wiring',
886
- 'application',
887
931
  'queries'
888
932
  ]).createFile(`wire-${naming.fileName}-query.ts`, `
889
933
  import { wireClass } from '@domain-first/wire'
890
- import { ${naming.ClassName}Query } from '../../../application/queries/orchestration/${naming.fileName}-query'
934
+ import { ${naming.ClassName}Query } from '../../application/queries/orchestration/${naming.fileName}-query'
891
935
 
892
936
  export const wire${naming.ClassName}Query = wireClass(${naming.ClassName}Query, [])
893
937
  `.trim());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@domain-first/project-structure",
3
3
  "description": "Build and manage your Domain-First project structure with CLI",
4
- "version": "2.3.1",
4
+ "version": "2.5.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",