@domain-first/project-structure 2.0.0 → 2.1.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 +32 -12
- package/dist/index.js +32 -12
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/scaffold-react-page.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -673,14 +673,13 @@ export const restHandlers = restWires.map(x => x().handle)
|
|
|
673
673
|
import { EndpointGenerator } from '@domain-first/handlers-rest'
|
|
674
674
|
|
|
675
675
|
export class ${endpointNaming.ClassName} {
|
|
676
|
-
constructor(
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
}
|
|
676
|
+
constructor(
|
|
677
|
+
private readonly endpointGenerator: EndpointGenerator,
|
|
678
|
+
private readonly handler: never
|
|
679
|
+
) {}
|
|
681
680
|
|
|
682
681
|
get handle() {
|
|
683
|
-
return this.endpointGenerator(this.
|
|
682
|
+
return this.endpointGenerator(this.handler.handle, {
|
|
684
683
|
route: { method: '${method}', path: ['${boundedContextFolder.name}', '${controller}'${path.length ? `, ${path.map((x)=>`'${x}'`).join(', ')}` : ''}] },
|
|
685
684
|
tags: ['${boundedContextFolder.name}: ${controller}'],
|
|
686
685
|
})
|
|
@@ -896,6 +895,23 @@ export const wire${naming.ClassName}UseCase = wireClass(
|
|
|
896
895
|
|
|
897
896
|
`.trim());
|
|
898
897
|
};
|
|
898
|
+
const scaffoldReactPage = async (presentationReactFolder)=>{
|
|
899
|
+
const name = await (0, prompts_namespaceObject.input)({
|
|
900
|
+
message: 'Provide name:'
|
|
901
|
+
});
|
|
902
|
+
const { ClassName, fileName } = new UnknownFormatNaming(name);
|
|
903
|
+
presentationReactFolder.subitem([
|
|
904
|
+
'pages'
|
|
905
|
+
]).createFile(`${fileName}-page.tsx`, `
|
|
906
|
+
import { type FC } from 'react'
|
|
907
|
+
|
|
908
|
+
export type ${ClassName}PageProps = {}
|
|
909
|
+
|
|
910
|
+
export const ${ClassName}Page: FC<${ClassName}PageProps> = (props) => {
|
|
911
|
+
return <></>
|
|
912
|
+
}
|
|
913
|
+
`.trim());
|
|
914
|
+
};
|
|
899
915
|
const scaffoldReactWidget = async (presentationReactFolder)=>{
|
|
900
916
|
const widgetName = await (0, prompts_namespaceObject.input)({
|
|
901
917
|
message: 'Name: '
|
|
@@ -1033,19 +1049,23 @@ const main = async ()=>{
|
|
|
1033
1049
|
switch(action){
|
|
1034
1050
|
case 'Scaffold React module':
|
|
1035
1051
|
{
|
|
1052
|
+
const reactFolder = new Folder(rootPath).subitem([
|
|
1053
|
+
ConfigFile.Instance.data.rootFolder,
|
|
1054
|
+
'presentation',
|
|
1055
|
+
'react'
|
|
1056
|
+
]);
|
|
1036
1057
|
const action = await (0, prompts_namespaceObject.select)({
|
|
1037
1058
|
message: 'Module: ',
|
|
1038
1059
|
choices: [
|
|
1039
|
-
'New widget'
|
|
1060
|
+
'New widget',
|
|
1061
|
+
'New page'
|
|
1040
1062
|
]
|
|
1041
1063
|
});
|
|
1042
1064
|
switch(action){
|
|
1043
1065
|
case 'New widget':
|
|
1044
|
-
return void await scaffoldReactWidget(
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
'react'
|
|
1048
|
-
]));
|
|
1066
|
+
return void await scaffoldReactWidget(reactFolder);
|
|
1067
|
+
case 'New page':
|
|
1068
|
+
return void await scaffoldReactPage(reactFolder);
|
|
1049
1069
|
default:
|
|
1050
1070
|
return;
|
|
1051
1071
|
}
|
package/dist/index.js
CHANGED
|
@@ -643,14 +643,13 @@ export const restHandlers = restWires.map(x => x().handle)
|
|
|
643
643
|
import { EndpointGenerator } from '@domain-first/handlers-rest'
|
|
644
644
|
|
|
645
645
|
export class ${endpointNaming.ClassName} {
|
|
646
|
-
constructor(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
646
|
+
constructor(
|
|
647
|
+
private readonly endpointGenerator: EndpointGenerator,
|
|
648
|
+
private readonly handler: never
|
|
649
|
+
) {}
|
|
651
650
|
|
|
652
651
|
get handle() {
|
|
653
|
-
return this.endpointGenerator(this.
|
|
652
|
+
return this.endpointGenerator(this.handler.handle, {
|
|
654
653
|
route: { method: '${method}', path: ['${boundedContextFolder.name}', '${controller}'${path.length ? `, ${path.map((x)=>`'${x}'`).join(', ')}` : ''}] },
|
|
655
654
|
tags: ['${boundedContextFolder.name}: ${controller}'],
|
|
656
655
|
})
|
|
@@ -866,6 +865,23 @@ export const wire${naming.ClassName}UseCase = wireClass(
|
|
|
866
865
|
|
|
867
866
|
`.trim());
|
|
868
867
|
};
|
|
868
|
+
const scaffoldReactPage = async (presentationReactFolder)=>{
|
|
869
|
+
const name = await input({
|
|
870
|
+
message: 'Provide name:'
|
|
871
|
+
});
|
|
872
|
+
const { ClassName, fileName } = new UnknownFormatNaming(name);
|
|
873
|
+
presentationReactFolder.subitem([
|
|
874
|
+
'pages'
|
|
875
|
+
]).createFile(`${fileName}-page.tsx`, `
|
|
876
|
+
import { type FC } from 'react'
|
|
877
|
+
|
|
878
|
+
export type ${ClassName}PageProps = {}
|
|
879
|
+
|
|
880
|
+
export const ${ClassName}Page: FC<${ClassName}PageProps> = (props) => {
|
|
881
|
+
return <></>
|
|
882
|
+
}
|
|
883
|
+
`.trim());
|
|
884
|
+
};
|
|
869
885
|
const scaffoldReactWidget = async (presentationReactFolder)=>{
|
|
870
886
|
const widgetName = await input({
|
|
871
887
|
message: 'Name: '
|
|
@@ -1003,19 +1019,23 @@ const main = async ()=>{
|
|
|
1003
1019
|
switch(action){
|
|
1004
1020
|
case 'Scaffold React module':
|
|
1005
1021
|
{
|
|
1022
|
+
const reactFolder = new Folder(rootPath).subitem([
|
|
1023
|
+
ConfigFile.Instance.data.rootFolder,
|
|
1024
|
+
'presentation',
|
|
1025
|
+
'react'
|
|
1026
|
+
]);
|
|
1006
1027
|
const action = await prompts_select({
|
|
1007
1028
|
message: 'Module: ',
|
|
1008
1029
|
choices: [
|
|
1009
|
-
'New widget'
|
|
1030
|
+
'New widget',
|
|
1031
|
+
'New page'
|
|
1010
1032
|
]
|
|
1011
1033
|
});
|
|
1012
1034
|
switch(action){
|
|
1013
1035
|
case 'New widget':
|
|
1014
|
-
return void await scaffoldReactWidget(
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
'react'
|
|
1018
|
-
]));
|
|
1036
|
+
return void await scaffoldReactWidget(reactFolder);
|
|
1037
|
+
case 'New page':
|
|
1038
|
+
return void await scaffoldReactPage(reactFolder);
|
|
1019
1039
|
default:
|
|
1020
1040
|
return;
|
|
1021
1041
|
}
|