@domain-first/project-structure 8.10.0 → 8.11.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/README.md +17 -7
- package/dist/115.js +142 -141
- package/dist/201.js +10 -1
- package/dist/287.js +983 -434
- package/dist/364.js +79 -0
- package/dist/38.js +29 -13
- package/dist/561.js +167 -93
- package/dist/agent-cli.d.ts +13 -2
- package/dist/agent-requests.d.ts +76 -2
- package/dist/config-file.d.ts +25 -1
- package/dist/frontend-cli.d.ts +3 -0
- package/dist/frontend-modules.d.ts +9 -0
- package/dist/graph.cjs +10 -1
- package/dist/index.cjs +3470 -2913
- package/dist/init.cjs +325 -83
- package/dist/integration.cjs +3470 -2913
- package/dist/integrations/openapi.d.ts +9 -2
- package/dist/integrations/orval.d.ts +31 -4
- package/dist/integrations/rest-endpoint-generator.d.ts +11 -7
- package/dist/integrations/storybook.d.ts +19 -1
- package/dist/lint.cjs +40 -15
- package/dist/lint.js +1 -1
- package/dist/page-router.d.ts +18 -0
- package/dist/react-module-move.d.ts +27 -12
- package/dist/react.cjs +1577 -993
- package/dist/react.js +2 -102
- package/dist/rest-adapters.d.ts +13 -0
- package/dist/svelte-agent-cli.spec.d.ts +1 -0
- package/dist/svelte.cjs +7311 -0
- package/dist/svelte.d.ts +2 -0
- package/dist/svelte.js +3 -0
- package/dist/sveltekit-app.d.ts +7 -0
- package/dist/upgrade-steps.d.ts +6 -1
- package/dist/upgrade.cjs +12 -2
- package/dist/use-cases/add-integration.d.ts +1 -1
- package/dist/use-cases/delete-react-module.d.ts +4 -4
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/move-react-module.d.ts +2 -2
- package/dist/use-cases/rest-endpoint-generator.d.ts +6 -4
- package/dist/use-cases/scaffold-svelte-modules.d.ts +22 -0
- package/package.json +2 -1
- package/skills/df-ps-implement/SKILL.md +3 -3
- package/skills/df-ps-plan-feature/SKILL.md +2 -2
- package/skills/df-ps-scaffold/SKILL.md +11 -10
- package/skills/df-ps-scaffold/references/agent-mode.md +1 -1
- package/skills/df-ps-scaffold/references/agent-operations.md +8 -4
- package/skills/df-ps-scaffold/references/generators.md +1 -1
- package/skills/df-ps-scaffold/references/work-plan.md +1 -1
- package/skills/df-ps-svelte/SKILL.md +49 -0
- package/skills/df-ps-svelte/references/generators.md +56 -0
package/dist/init.cjs
CHANGED
|
@@ -306,6 +306,7 @@ const lintChecks = [
|
|
|
306
306
|
'layers',
|
|
307
307
|
'dependencies',
|
|
308
308
|
'react',
|
|
309
|
+
'svelte',
|
|
309
310
|
'clock',
|
|
310
311
|
'config'
|
|
311
312
|
];
|
|
@@ -350,8 +351,16 @@ const reactConfigSchema = external_zod_default().object({
|
|
|
350
351
|
]).optional(),
|
|
351
352
|
storybookFramework: external_zod_default().string().optional()
|
|
352
353
|
}).passthrough();
|
|
354
|
+
const svelteConfigSchema = external_zod_default().object({
|
|
355
|
+
framework: external_zod_default()["enum"]([
|
|
356
|
+
'svelte',
|
|
357
|
+
'sveltekit'
|
|
358
|
+
]).optional(),
|
|
359
|
+
storybookFramework: external_zod_default().string().optional()
|
|
360
|
+
}).passthrough();
|
|
353
361
|
const frontendConfigSchema = external_zod_default().object({
|
|
354
|
-
react: reactConfigSchema.optional()
|
|
362
|
+
react: reactConfigSchema.optional(),
|
|
363
|
+
svelte: svelteConfigSchema.optional()
|
|
355
364
|
}).passthrough();
|
|
356
365
|
const configSchema = external_zod_default().object({
|
|
357
366
|
project: projectConfigSchema,
|
|
@@ -860,7 +869,80 @@ const next_app_nextAppFolder = (root)=>[
|
|
|
860
869
|
'app',
|
|
861
870
|
'src/app'
|
|
862
871
|
].find((folder)=>new file_system_Folder(external_node_path_default().join(root, folder)).exists) ?? 'app';
|
|
872
|
+
const sveltekit_app_usesSvelteKit = ()=>config_file_ConfigFile.exists && config_file_ConfigFile.Instance.data.frontend?.svelte?.framework === 'sveltekit';
|
|
873
|
+
const sveltekit_app_svelteKitRoutesFolder = (root)=>[
|
|
874
|
+
'src/routes',
|
|
875
|
+
'routes'
|
|
876
|
+
].find((folder)=>new file_system_Folder(external_node_path_default().join(root, folder)).exists) ?? 'src/routes';
|
|
863
877
|
require("node:module");
|
|
878
|
+
new Set([
|
|
879
|
+
'node_modules',
|
|
880
|
+
'.git',
|
|
881
|
+
'.next',
|
|
882
|
+
'.svelte-kit',
|
|
883
|
+
'dist',
|
|
884
|
+
'build',
|
|
885
|
+
'out',
|
|
886
|
+
'coverage',
|
|
887
|
+
'storybook-static'
|
|
888
|
+
]);
|
|
889
|
+
const module_move_escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
890
|
+
const frontendExtensions = {
|
|
891
|
+
react: {
|
|
892
|
+
component: '.tsx',
|
|
893
|
+
hook: '.ts'
|
|
894
|
+
},
|
|
895
|
+
svelte: {
|
|
896
|
+
component: '.svelte',
|
|
897
|
+
hook: '.svelte.ts'
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
const react_module_move_kindLayouts = (framework)=>{
|
|
901
|
+
const { component, hook } = frontendExtensions[framework];
|
|
902
|
+
return {
|
|
903
|
+
page: {
|
|
904
|
+
folder: 'pages',
|
|
905
|
+
nested: true,
|
|
906
|
+
inFolder: false,
|
|
907
|
+
ownFile: (fileBase)=>new RegExp(`^${module_move_escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
908
|
+
target: (reactFolder, { folders, fileName })=>external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page${component}`),
|
|
909
|
+
classPrefix: '(use)?',
|
|
910
|
+
classSuffix: 'Page'
|
|
911
|
+
},
|
|
912
|
+
widget: {
|
|
913
|
+
folder: 'widgets',
|
|
914
|
+
nested: true,
|
|
915
|
+
inFolder: true,
|
|
916
|
+
target: (reactFolder, { folders, folderName })=>external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName),
|
|
917
|
+
classPrefix: '(use)?',
|
|
918
|
+
classSuffix: 'Widget|UIModel',
|
|
919
|
+
storyTitle: (segments)=>[
|
|
920
|
+
'Widgets',
|
|
921
|
+
...segments
|
|
922
|
+
].join('/')
|
|
923
|
+
},
|
|
924
|
+
'ui-kit': {
|
|
925
|
+
folder: 'ui-kit',
|
|
926
|
+
nested: false,
|
|
927
|
+
inFolder: true,
|
|
928
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, 'ui-kit', fileName),
|
|
929
|
+
classPrefix: '()',
|
|
930
|
+
classSuffix: 'Props(?![\\w$])|(?![\\w$])',
|
|
931
|
+
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
932
|
+
},
|
|
933
|
+
hook: {
|
|
934
|
+
folder: 'hooks',
|
|
935
|
+
nested: false,
|
|
936
|
+
inFolder: false,
|
|
937
|
+
ownFile: (fileBase)=>new RegExp(`^use-${module_move_escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
938
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, 'hooks', `use-${fileName}${hook}`),
|
|
939
|
+
classPrefix: '(use)',
|
|
940
|
+
classSuffix: '(?![\\w$])'
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
};
|
|
944
|
+
react_module_move_kindLayouts('react');
|
|
945
|
+
react_module_move_kindLayouts('svelte');
|
|
864
946
|
const gitignore_addGitignoreEntry = (root, entry)=>{
|
|
865
947
|
const gitignore = new file_system_File(external_node_path_default().join(root, '.gitignore'));
|
|
866
948
|
const ignored = gitignore.exists ? gitignore.data : '';
|
|
@@ -868,6 +950,28 @@ const gitignore_addGitignoreEntry = (root, entry)=>{
|
|
|
868
950
|
const newline = ignored.includes('\r\n') ? '\r\n' : '\n';
|
|
869
951
|
gitignore.update(`${ignored}${ignored && !ignored.endsWith('\n') ? newline : ''}${entry}${newline}`);
|
|
870
952
|
};
|
|
953
|
+
JSON.stringify({
|
|
954
|
+
private: true,
|
|
955
|
+
dependencies: {
|
|
956
|
+
'@tanstack/svelte-query': '^6.0.0'
|
|
957
|
+
}
|
|
958
|
+
}, null, 4);
|
|
959
|
+
const rest_adapters_restAdapters = {
|
|
960
|
+
next: {
|
|
961
|
+
package: '@domain-first/handlers-next',
|
|
962
|
+
adapter: 'nextAdapter',
|
|
963
|
+
endpoints: 'nextEndpoints',
|
|
964
|
+
key: 'nextAdapter',
|
|
965
|
+
routePath: (root)=>external_node_path_default().posix.join(next_app_nextAppFolder(root), 'api/[...path]/route.ts')
|
|
966
|
+
},
|
|
967
|
+
svelte: {
|
|
968
|
+
package: '@domain-first/handlers-svelte',
|
|
969
|
+
adapter: 'svelteAdapter',
|
|
970
|
+
endpoints: 'svelteEndpoints',
|
|
971
|
+
key: 'svelteAdapter',
|
|
972
|
+
routePath: (root)=>external_node_path_default().posix.join(sveltekit_app_svelteKitRoutesFolder(root), 'api/[...path]/+server.ts')
|
|
973
|
+
}
|
|
974
|
+
};
|
|
871
975
|
class unknown_format_naming_UnknownFormatNaming {
|
|
872
976
|
rawSource;
|
|
873
977
|
camelCase;
|
|
@@ -942,15 +1046,16 @@ export const wire${naming.ClassName}PresentationService = wireClass(
|
|
|
942
1046
|
`.trim());
|
|
943
1047
|
};
|
|
944
1048
|
const rest_endpoint_generator_name = 'rest-endpoint-generator';
|
|
945
|
-
const scaffoldRestEndpointGenerator = (sharedFolder, {
|
|
946
|
-
const
|
|
1049
|
+
const scaffoldRestEndpointGenerator = (sharedFolder, { adapter: framework } = {})=>createPresentationService(sharedFolder, rest_endpoint_generator_name, (className)=>{
|
|
1050
|
+
const known = framework && rest_adapters_restAdapters[framework];
|
|
1051
|
+
const adapter = known ? known.adapter : 'adapter';
|
|
947
1052
|
return `
|
|
948
1053
|
import {
|
|
949
|
-
${
|
|
1054
|
+
${known ? '' : ' type Adapter,\n'} type EndpointGenerator,
|
|
950
1055
|
createEndpoint,
|
|
951
1056
|
invalidRequest
|
|
952
1057
|
} from '@domain-first/handlers-rest'
|
|
953
|
-
${
|
|
1058
|
+
${known ? `import { ${known.adapter} } from '${known.package}'` : `
|
|
954
1059
|
/**
|
|
955
1060
|
* The adapter of your HTTP framework.
|
|
956
1061
|
*/
|
|
@@ -975,16 +1080,17 @@ const rest_endpoint_generator_findRestEndpointGenerator = (sharedFolder)=>{
|
|
|
975
1080
|
wireFile: external_node_path_default().join(sharedFolder.path, 'wiring', 'presentation-services', `wire-${rest_endpoint_generator_name}-presentation-service.ts`)
|
|
976
1081
|
};
|
|
977
1082
|
};
|
|
978
|
-
const
|
|
979
|
-
const
|
|
980
|
-
|
|
1083
|
+
const catchAllRoute = (adapter, restHandlersImport)=>{
|
|
1084
|
+
const { endpoints, package: packageName } = rest_adapters_restAdapters[adapter];
|
|
1085
|
+
return `
|
|
1086
|
+
import { ${endpoints} } from '${packageName}'
|
|
981
1087
|
${restHandlersImport ? `import { restHandlers } from '${restHandlersImport}'
|
|
982
1088
|
|
|
983
|
-
const handler =
|
|
1089
|
+
const handler = ${endpoints}(restHandlers)` : `
|
|
984
1090
|
/**
|
|
985
1091
|
* Pass the endpoints' handle here; their paths are relative to this route's folder.
|
|
986
1092
|
*/
|
|
987
|
-
const handler =
|
|
1093
|
+
const handler = ${endpoints}([])`}
|
|
988
1094
|
|
|
989
1095
|
export const GET = handler
|
|
990
1096
|
export const POST = handler
|
|
@@ -992,14 +1098,15 @@ export const PUT = handler
|
|
|
992
1098
|
export const PATCH = handler
|
|
993
1099
|
export const DELETE = handler
|
|
994
1100
|
`.trim();
|
|
995
|
-
|
|
1101
|
+
};
|
|
1102
|
+
const scaffoldCatchAllRoute = (root, adapter)=>{
|
|
996
1103
|
const { rootFolder } = config_file_ConfigFile.Instance.data.project;
|
|
997
1104
|
const { domainFirstPackages } = config_file_ConfigFile.backend;
|
|
998
|
-
const routePath =
|
|
1105
|
+
const routePath = rest_adapters_restAdapters[adapter].routePath(root);
|
|
999
1106
|
const routeFile = external_node_path_default().join(root, routePath);
|
|
1000
1107
|
if (new file_system_File(routeFile).exists) return [];
|
|
1001
1108
|
if (!domainFirstPackages.includes('@domain-first/wire')) {
|
|
1002
|
-
new file_system_File(routeFile).data =
|
|
1109
|
+
new file_system_File(routeFile).data = catchAllRoute(adapter, void 0);
|
|
1003
1110
|
return [];
|
|
1004
1111
|
}
|
|
1005
1112
|
const restFolder = new file_system_Folder(root).subitem([
|
|
@@ -1007,16 +1114,21 @@ const rest_endpoint_generator_scaffoldNextRoute = (root)=>{
|
|
|
1007
1114
|
'presentation',
|
|
1008
1115
|
'rest'
|
|
1009
1116
|
]);
|
|
1010
|
-
new file_system_File(routeFile).data =
|
|
1117
|
+
new file_system_File(routeFile).data = catchAllRoute(adapter, wiring_relativeImport(routeFile, restFolder.path));
|
|
1011
1118
|
return new file_system_File(external_node_path_default().join(restFolder.path, 'index.ts')).exists ? [] : [
|
|
1012
1119
|
`${routePath} serves restHandlers from ${external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'), 'presentation/rest/index.ts')}, which appears with the first REST endpoint — generate one with df-scaffold (Presentation → New Handlers-REST Endpoint) and the route compiles`
|
|
1013
1120
|
];
|
|
1014
1121
|
};
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1122
|
+
const frameworkRestAdapter = ()=>next_app_usesNext() ? 'next' : sveltekit_app_usesSvelteKit() ? 'svelte' : void 0;
|
|
1123
|
+
const askRestAdapter = async ({ adapter = frameworkRestAdapter() } = {})=>{
|
|
1124
|
+
if (!adapter) return;
|
|
1125
|
+
const { key, package: packageName } = rest_adapters_restAdapters[adapter];
|
|
1126
|
+
return await interaction_confirm({
|
|
1127
|
+
key,
|
|
1128
|
+
message: `Use ${packageName} for REST endpoints`
|
|
1129
|
+
}) ? adapter : void 0;
|
|
1130
|
+
};
|
|
1131
|
+
const scaffoldRestEndpointGeneratorFiles = ({ adapter })=>{
|
|
1020
1132
|
const root = new project_root_ProjectRoot().path;
|
|
1021
1133
|
const generatorExisted = rest_endpoint_generator_restEndpointGeneratorApplied();
|
|
1022
1134
|
const routeNotes = file_system_withoutOverwrites(()=>{
|
|
@@ -1024,18 +1136,19 @@ const scaffoldRestEndpointGeneratorFiles = ({ withNextAdapter })=>{
|
|
|
1024
1136
|
config_file_ConfigFile.Instance.data.project.rootFolder,
|
|
1025
1137
|
'shared-kernel'
|
|
1026
1138
|
]), {
|
|
1027
|
-
|
|
1139
|
+
adapter
|
|
1028
1140
|
});
|
|
1029
|
-
return
|
|
1141
|
+
return adapter ? scaffoldCatchAllRoute(root, adapter) : [];
|
|
1030
1142
|
});
|
|
1031
|
-
if (!
|
|
1143
|
+
if (!adapter) return [];
|
|
1144
|
+
const { adapter: adapterName, package: packageName } = rest_adapters_restAdapters[adapter];
|
|
1032
1145
|
return [
|
|
1033
1146
|
...missingPackages([
|
|
1034
|
-
|
|
1147
|
+
packageName
|
|
1035
1148
|
]),
|
|
1036
1149
|
...routeNotes,
|
|
1037
1150
|
...generatorExisted ? [
|
|
1038
|
-
|
|
1151
|
+
`the existing endpoint generator was kept — pass ${adapterName} from ${packageName} to its createEndpoint calls`
|
|
1039
1152
|
] : []
|
|
1040
1153
|
];
|
|
1041
1154
|
};
|
|
@@ -1044,6 +1157,73 @@ const rest_endpoint_generator_restEndpointGeneratorApplied = ()=>Boolean(rest_en
|
|
|
1044
1157
|
'shared-kernel'
|
|
1045
1158
|
])));
|
|
1046
1159
|
const storybookFrameworkPackage = '@storybook/react-vite';
|
|
1160
|
+
const svelteStorybookPackages = {
|
|
1161
|
+
svelte: '@storybook/svelte-vite',
|
|
1162
|
+
sveltekit: '@storybook/sveltekit'
|
|
1163
|
+
};
|
|
1164
|
+
const storybookPackageFor = (framework)=>'svelte' === framework || 'sveltekit' === framework ? svelteStorybookPackages[framework] : storybookFrameworkPackage;
|
|
1165
|
+
const storybookPreview = (frameworkPackage)=>`import type { Preview } from '${frameworkPackage}';
|
|
1166
|
+
|
|
1167
|
+
const preview: Preview = {
|
|
1168
|
+
parameters: {
|
|
1169
|
+
controls: {
|
|
1170
|
+
matchers: {
|
|
1171
|
+
color: /(background|color)$/i,
|
|
1172
|
+
date: /Date$/i
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1178
|
+
export default preview;
|
|
1179
|
+
`;
|
|
1180
|
+
const svelteStorybookFiles = (relativeProjectRoot, frameworkPackage)=>{
|
|
1181
|
+
const withPlugin = frameworkPackage === svelteStorybookPackages.svelte;
|
|
1182
|
+
return {
|
|
1183
|
+
'main.ts': `import { resolve } from 'node:path';
|
|
1184
|
+
import type { StorybookConfig } from '${frameworkPackage}';
|
|
1185
|
+
|
|
1186
|
+
const projectRoot = resolve(import.meta.dirname, ${JSON.stringify(relativeProjectRoot)});
|
|
1187
|
+
|
|
1188
|
+
const config: StorybookConfig = {
|
|
1189
|
+
stories: ['../**/*.mdx', '../**/*.stories.@(ts|svelte)'],
|
|
1190
|
+
framework: {
|
|
1191
|
+
name: '${frameworkPackage}',
|
|
1192
|
+
options: {}
|
|
1193
|
+
},
|
|
1194
|
+
core: {
|
|
1195
|
+
disableTelemetry: true
|
|
1196
|
+
},
|
|
1197
|
+
async viteFinal(viteConfig) {
|
|
1198
|
+
const { mergeConfig } = await import('vite');
|
|
1199
|
+
${withPlugin ? ` const { svelte } = await import('@sveltejs/vite-plugin-svelte');
|
|
1200
|
+
const hasSvelte = (viteConfig.plugins ?? [])
|
|
1201
|
+
.flat(Infinity)
|
|
1202
|
+
.some(
|
|
1203
|
+
(plugin) =>
|
|
1204
|
+
!!plugin &&
|
|
1205
|
+
typeof plugin === 'object' &&
|
|
1206
|
+
'name' in plugin &&
|
|
1207
|
+
String(plugin.name).startsWith('vite-plugin-svelte')
|
|
1208
|
+
);
|
|
1209
|
+
|
|
1210
|
+
return mergeConfig(viteConfig, {
|
|
1211
|
+
plugins: hasSvelte ? [] : [svelte()],` : `
|
|
1212
|
+
return mergeConfig(viteConfig, {`}
|
|
1213
|
+
resolve: {
|
|
1214
|
+
alias: {
|
|
1215
|
+
'@': projectRoot
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1222
|
+
export default config;
|
|
1223
|
+
`,
|
|
1224
|
+
'preview.ts': storybookPreview(frameworkPackage)
|
|
1225
|
+
};
|
|
1226
|
+
};
|
|
1047
1227
|
const storybookFiles = (relativeProjectRoot)=>({
|
|
1048
1228
|
'main.ts': `import { resolve } from 'node:path';
|
|
1049
1229
|
import react from '@vitejs/plugin-react';
|
|
@@ -1076,32 +1256,79 @@ const config: StorybookConfig = {
|
|
|
1076
1256
|
|
|
1077
1257
|
export default config;
|
|
1078
1258
|
`,
|
|
1079
|
-
'preview.ts':
|
|
1080
|
-
|
|
1081
|
-
const preview: Preview = {
|
|
1082
|
-
parameters: {
|
|
1083
|
-
controls: {
|
|
1084
|
-
matchers: {
|
|
1085
|
-
color: /(background|color)$/i,
|
|
1086
|
-
date: /Date$/i
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
1091
|
-
|
|
1092
|
-
export default preview;
|
|
1093
|
-
`
|
|
1259
|
+
'preview.ts': storybookPreview(storybookFrameworkPackage)
|
|
1094
1260
|
});
|
|
1095
|
-
const storybookScripts = (rootFolder)=>{
|
|
1096
|
-
const folder = external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'),
|
|
1261
|
+
const storybookScripts = (rootFolder, family = 'react')=>{
|
|
1262
|
+
const folder = external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'), `presentation/${family}`);
|
|
1097
1263
|
const quote = (value)=>JSON.stringify(value);
|
|
1098
1264
|
return {
|
|
1099
1265
|
storybook: `storybook dev -p 6006 -c ${quote(`${folder}/.storybook`)}`,
|
|
1100
1266
|
'build-storybook': `storybook build -c ${quote(`${folder}/.storybook`)} -o ${quote(`${folder}/storybook-static`)}`
|
|
1101
1267
|
};
|
|
1102
1268
|
};
|
|
1269
|
+
const addSvelteStorybook = async ()=>{
|
|
1270
|
+
const config = config_file_ConfigFile.Instance.data;
|
|
1271
|
+
const svelte = config.frontend?.svelte ?? {};
|
|
1272
|
+
const frameworkPackage = svelteStorybookPackages['sveltekit' === svelte.framework ? 'sveltekit' : 'svelte'];
|
|
1273
|
+
const root = new project_root_ProjectRoot().path;
|
|
1274
|
+
const manifestFile = new file_system_File(external_node_path_default().join(root, 'package.json'));
|
|
1275
|
+
const manifest = JSON.parse(manifestFile.data);
|
|
1276
|
+
const selected = await package_scripts_addPackageScripts(manifestFile, storybookScripts(config.project.rootFolder, 'svelte'));
|
|
1277
|
+
const folder = new file_system_Folder(root).subitem([
|
|
1278
|
+
config.project.rootFolder,
|
|
1279
|
+
'presentation',
|
|
1280
|
+
'svelte',
|
|
1281
|
+
'.storybook'
|
|
1282
|
+
]);
|
|
1283
|
+
for (const [name, content] of Object.entries(svelteStorybookFiles(external_node_path_default().relative(folder.path, root).split(external_node_path_default().sep).join('/'), frameworkPackage))){
|
|
1284
|
+
const file = new file_system_File(external_node_path_default().join(folder.path, name));
|
|
1285
|
+
if (!file.exists || file.data !== content) file.data = content;
|
|
1286
|
+
}
|
|
1287
|
+
if (svelte.storybookFramework !== frameworkPackage) config_file_ConfigFile.update({
|
|
1288
|
+
frontend: {
|
|
1289
|
+
...config.frontend,
|
|
1290
|
+
svelte: {
|
|
1291
|
+
...svelte,
|
|
1292
|
+
storybookFramework: frameworkPackage
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
const buildFolder = external_node_path_default().posix.join(config.project.rootFolder.replaceAll('\\', '/'), 'presentation/svelte/storybook-static');
|
|
1297
|
+
gitignore_addGitignoreEntry(root, `/${buildFolder}/`);
|
|
1298
|
+
const dependencies = {
|
|
1299
|
+
...manifest.dependencies,
|
|
1300
|
+
...manifest.devDependencies
|
|
1301
|
+
};
|
|
1302
|
+
const missing = [
|
|
1303
|
+
'storybook',
|
|
1304
|
+
frameworkPackage,
|
|
1305
|
+
'vite',
|
|
1306
|
+
...frameworkPackage === svelteStorybookPackages.svelte ? [
|
|
1307
|
+
'@sveltejs/vite-plugin-svelte'
|
|
1308
|
+
] : []
|
|
1309
|
+
].filter((name)=>!dependencies[name]);
|
|
1310
|
+
const missingSvelte = ('sveltekit' === svelte.framework ? [
|
|
1311
|
+
'@sveltejs/kit',
|
|
1312
|
+
'svelte'
|
|
1313
|
+
] : [
|
|
1314
|
+
'svelte'
|
|
1315
|
+
]).filter((name)=>!dependencies[name]);
|
|
1316
|
+
return [
|
|
1317
|
+
...missing.length ? [
|
|
1318
|
+
`npm install --save-dev ${missing.join(' ')}`
|
|
1319
|
+
] : [],
|
|
1320
|
+
...missingSvelte.length ? [
|
|
1321
|
+
`npm install ${missingSvelte.join(' ')}`
|
|
1322
|
+
] : [],
|
|
1323
|
+
...package_scripts_describeScripts(selected, {
|
|
1324
|
+
storybook: 'start Storybook on http://localhost:6006',
|
|
1325
|
+
'build-storybook': `build static Storybook into ${buildFolder}`
|
|
1326
|
+
})
|
|
1327
|
+
];
|
|
1328
|
+
};
|
|
1103
1329
|
const storybook_addStorybook = async ()=>{
|
|
1104
1330
|
const config = config_file_ConfigFile.Instance.data;
|
|
1331
|
+
if (config.frontend?.svelte) return addSvelteStorybook();
|
|
1105
1332
|
if ((!config.frontend?.react || config.frontend?.react?.storybookFramework && config.frontend?.react?.storybookFramework !== storybookFrameworkPackage) && !await interaction_confirm({
|
|
1106
1333
|
key: 'configureReact',
|
|
1107
1334
|
requestRequired: true,
|
|
@@ -1160,16 +1387,6 @@ const storybook_addStorybook = async ()=>{
|
|
|
1160
1387
|
})
|
|
1161
1388
|
];
|
|
1162
1389
|
};
|
|
1163
|
-
new Set([
|
|
1164
|
-
'node_modules',
|
|
1165
|
-
'.git',
|
|
1166
|
-
'.next',
|
|
1167
|
-
'dist',
|
|
1168
|
-
'build',
|
|
1169
|
-
'out',
|
|
1170
|
-
'coverage',
|
|
1171
|
-
'storybook-static'
|
|
1172
|
-
]);
|
|
1173
1390
|
const serviceLayout = (layer)=>({
|
|
1174
1391
|
title: `${layer[0].toUpperCase()}${layer.slice(1)} services`,
|
|
1175
1392
|
core: (ClassName)=>`${ClassName}${layer[0].toUpperCase()}${layer.slice(1)}Service`,
|
|
@@ -1397,9 +1614,27 @@ const configureBackend = async (config)=>{
|
|
|
1397
1614
|
if (envBranches && !envBranchedWireExisted) notes.push(`${rootFolderName}/shared-kernel/wiring/env-branched-wire.ts doesn't compile until you write currentBranch: return the branch this process runs in (${envBranches.names.join(', ')})`);
|
|
1398
1615
|
return notes;
|
|
1399
1616
|
};
|
|
1617
|
+
const frontendPackages = {
|
|
1618
|
+
react: [
|
|
1619
|
+
'react',
|
|
1620
|
+
'react-dom'
|
|
1621
|
+
],
|
|
1622
|
+
next: [
|
|
1623
|
+
'next',
|
|
1624
|
+
'react',
|
|
1625
|
+
'react-dom'
|
|
1626
|
+
],
|
|
1627
|
+
svelte: [
|
|
1628
|
+
'svelte'
|
|
1629
|
+
],
|
|
1630
|
+
sveltekit: [
|
|
1631
|
+
'@sveltejs/kit',
|
|
1632
|
+
'svelte'
|
|
1633
|
+
]
|
|
1634
|
+
};
|
|
1635
|
+
const savedFrontendChoice = ({ frontend })=>frontend?.react?.framework ?? frontend?.svelte?.framework ?? (frontend?.react ? 'react' : frontend?.svelte ? 'svelte' : void 0);
|
|
1400
1636
|
const configureFrontend = async (config)=>{
|
|
1401
|
-
const
|
|
1402
|
-
const framework = await (0, prompts_namespaceObject.select)({
|
|
1637
|
+
const choice = await (0, prompts_namespaceObject.select)({
|
|
1403
1638
|
message: 'Frontend framework:',
|
|
1404
1639
|
choices: [
|
|
1405
1640
|
{
|
|
@@ -1409,51 +1644,58 @@ const configureFrontend = async (config)=>{
|
|
|
1409
1644
|
{
|
|
1410
1645
|
name: 'Next.js',
|
|
1411
1646
|
value: 'next'
|
|
1647
|
+
},
|
|
1648
|
+
{
|
|
1649
|
+
name: 'Svelte',
|
|
1650
|
+
value: 'svelte'
|
|
1651
|
+
},
|
|
1652
|
+
{
|
|
1653
|
+
name: 'SvelteKit',
|
|
1654
|
+
value: 'sveltekit'
|
|
1412
1655
|
}
|
|
1413
1656
|
],
|
|
1414
|
-
default:
|
|
1657
|
+
default: savedFrontendChoice(config) ?? (hasDependency('next') ? 'next' : hasDependency('@sveltejs/kit') ? 'sveltekit' : hasDependency('svelte') ? 'svelte' : 'react')
|
|
1415
1658
|
});
|
|
1416
|
-
const
|
|
1417
|
-
|
|
1418
|
-
|
|
1659
|
+
const family = 'react' === choice || 'next' === choice ? 'react' : 'svelte';
|
|
1660
|
+
const adapter = 'next' === choice ? 'next' : 'sveltekit' === choice ? 'svelte' : void 0;
|
|
1661
|
+
const restAdapter = adapter && config.backend ? {
|
|
1662
|
+
adapter: await askRestAdapter({
|
|
1663
|
+
adapter
|
|
1664
|
+
})
|
|
1665
|
+
} : {
|
|
1666
|
+
adapter: void 0
|
|
1667
|
+
};
|
|
1668
|
+
const current = config.frontend?.[family];
|
|
1419
1669
|
const withStorybook = await (0, prompts_namespaceObject.confirm)({
|
|
1420
1670
|
message: 'Use Storybook',
|
|
1421
|
-
default:
|
|
1671
|
+
default: current ? Boolean(current.storybookFramework) : true
|
|
1422
1672
|
});
|
|
1423
|
-
const
|
|
1673
|
+
const { react, svelte, ...otherSettings } = config.frontend ?? {};
|
|
1424
1674
|
config_file_ConfigFile.update({
|
|
1425
1675
|
frontend: {
|
|
1426
|
-
...
|
|
1427
|
-
|
|
1428
|
-
...
|
|
1429
|
-
framework,
|
|
1430
|
-
storybookFramework
|
|
1676
|
+
...otherSettings,
|
|
1677
|
+
[family]: {
|
|
1678
|
+
...current,
|
|
1679
|
+
framework: choice,
|
|
1680
|
+
storybookFramework: withStorybook ? storybookPackageFor(choice) : void 0
|
|
1431
1681
|
}
|
|
1432
1682
|
}
|
|
1433
1683
|
});
|
|
1434
1684
|
return {
|
|
1435
|
-
|
|
1685
|
+
restAdapter,
|
|
1436
1686
|
nextSteps: [
|
|
1437
|
-
...missingPackages(
|
|
1438
|
-
'next',
|
|
1439
|
-
'react',
|
|
1440
|
-
'react-dom'
|
|
1441
|
-
] : [
|
|
1442
|
-
'react',
|
|
1443
|
-
'react-dom'
|
|
1444
|
-
]),
|
|
1687
|
+
...missingPackages(frontendPackages[choice]),
|
|
1445
1688
|
...withStorybook ? await storybook_addStorybook() : []
|
|
1446
1689
|
]
|
|
1447
1690
|
};
|
|
1448
1691
|
};
|
|
1449
|
-
const configureRest = async (
|
|
1692
|
+
const configureRest = async (restAdapter)=>{
|
|
1450
1693
|
const backend = config_file_ConfigFile.Instance.data.backend;
|
|
1451
1694
|
if (!backend) return [];
|
|
1452
1695
|
const withRest = backend.domainFirstPackages.includes('@domain-first/handlers-rest');
|
|
1453
|
-
const
|
|
1454
|
-
if (
|
|
1455
|
-
if (
|
|
1456
|
-
if (withNextAdapter && !withRest) config_file_ConfigFile.update({
|
|
1696
|
+
const adapter = restAdapter?.adapter ?? (restAdapter ? void 0 : await askRestAdapter());
|
|
1697
|
+
if (!withRest && !adapter) return [];
|
|
1698
|
+
if (adapter && !withRest) config_file_ConfigFile.update({
|
|
1457
1699
|
backend: {
|
|
1458
1700
|
...backend,
|
|
1459
1701
|
domainFirstPackages: [
|
|
@@ -1463,7 +1705,7 @@ const configureRest = async (withNextAdapter)=>{
|
|
|
1463
1705
|
}
|
|
1464
1706
|
});
|
|
1465
1707
|
return scaffoldRestEndpointGeneratorFiles({
|
|
1466
|
-
|
|
1708
|
+
adapter
|
|
1467
1709
|
});
|
|
1468
1710
|
};
|
|
1469
1711
|
const initializeUseCase = async (section)=>{
|
|
@@ -1500,7 +1742,7 @@ const initializeUseCase = async (section)=>{
|
|
|
1500
1742
|
}
|
|
1501
1743
|
const nextSteps = [];
|
|
1502
1744
|
let backendConfigured = false;
|
|
1503
|
-
let
|
|
1745
|
+
let restAdapter;
|
|
1504
1746
|
for (const currentSection of sections){
|
|
1505
1747
|
console.log(`\n${currentSection[0].toUpperCase()}${currentSection.slice(1)} configuration`);
|
|
1506
1748
|
if (!section && sections.length > 1 && !await (0, prompts_namespaceObject.confirm)({
|
|
@@ -1523,14 +1765,14 @@ const initializeUseCase = async (section)=>{
|
|
|
1523
1765
|
case 'frontend':
|
|
1524
1766
|
{
|
|
1525
1767
|
const frontend = await configureFrontend(config);
|
|
1526
|
-
|
|
1768
|
+
restAdapter = frontend.restAdapter;
|
|
1527
1769
|
nextSteps.push(...frontend.nextSteps);
|
|
1528
1770
|
break;
|
|
1529
1771
|
}
|
|
1530
1772
|
}
|
|
1531
1773
|
}
|
|
1532
|
-
if (backendConfigured ||
|
|
1533
|
-
const restSteps = await configureRest(
|
|
1774
|
+
if (backendConfigured || restAdapter?.adapter) {
|
|
1775
|
+
const restSteps = await configureRest(restAdapter);
|
|
1534
1776
|
nextSteps.push(...missingDomainFirstPackages(), ...restSteps);
|
|
1535
1777
|
}
|
|
1536
1778
|
return nextSteps;
|