@domain-first/project-structure 2.3.1 → 2.4.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 +24 -2
- package/dist/index.js +24 -2
- package/package.json +1 -1
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
|
+
`);
|
|
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 '
|
|
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());
|
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
|
+
`);
|
|
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 '
|
|
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());
|