@domain-first/project-structure 8.10.1 → 8.12.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/287.js +406 -788
- package/dist/364.js +79 -0
- package/dist/38.js +31 -14
- package/dist/561.js +179 -96
- package/dist/783.js +1147 -0
- package/dist/{201.js → 878.js} +465 -2
- package/dist/agent-cli.d.ts +17 -6
- package/dist/agent-requests.d.ts +82 -8
- package/dist/config-file.d.ts +25 -1
- package/dist/frontend-cli.d.ts +3 -0
- package/dist/frontend-modules.d.ts +14 -0
- package/dist/graph.cjs +125 -5
- package/dist/graph.js +1 -1
- package/dist/index.cjs +3545 -2930
- package/dist/index.js +1 -1
- package/dist/init.cjs +368 -83
- package/dist/init.js +1 -1
- package/dist/integration.cjs +3545 -2930
- package/dist/integration.js +1 -1
- package/dist/integrations/openapi.d.ts +19 -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 +159 -22
- package/dist/lint.js +2 -2
- package/dist/page-router.d.ts +18 -0
- package/dist/react-module-move.d.ts +47 -14
- package/dist/react.cjs +1645 -999
- 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 +7373 -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-svelte.d.ts +15 -0
- package/dist/upgrade-svelte.spec.d.ts +1 -0
- package/dist/upgrade.cjs +307 -42
- package/dist/upgrade.js +132 -13
- 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 +27 -0
- package/package.json +2 -1
- package/skills/df-ps-implement/SKILL.md +3 -3
- package/skills/df-ps-plan-feature/SKILL.md +1 -1
- package/skills/df-ps-scaffold/SKILL.md +9 -8
- 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 +54 -0
- package/skills/df-ps-svelte/references/generators.md +56 -0
- package/dist/115.js +0 -615
package/dist/svelte.d.ts
ADDED
package/dist/svelte.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** SvelteKit is used only when the config selects it explicitly. */
|
|
2
|
+
export declare const usesSvelteKit: () => boolean;
|
|
3
|
+
/**
|
|
4
|
+
* The routes folder: `src/routes`, SvelteKit's default, or `routes` when
|
|
5
|
+
* only that one exists.
|
|
6
|
+
*/
|
|
7
|
+
export declare const svelteKitRoutesFolder: (root: string) => string;
|
package/dist/upgrade-steps.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export declare const planUpgrade: (config: unknown, acceptOptional?: (step: Plan
|
|
|
81
81
|
add?: ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | undefined;
|
|
82
82
|
remove?: ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | undefined;
|
|
83
83
|
}>> | undefined;
|
|
84
|
-
lint?: Partial<Record<"context-isolation" | "shared-kernel" | "layers" | "dependencies" | "react" | "clock" | "config", boolean>> | undefined;
|
|
84
|
+
lint?: Partial<Record<"context-isolation" | "shared-kernel" | "layers" | "dependencies" | "react" | "svelte" | "clock" | "config", boolean>> | undefined;
|
|
85
85
|
} | undefined;
|
|
86
86
|
} | undefined;
|
|
87
87
|
frontend?: {
|
|
@@ -91,6 +91,11 @@ export declare const planUpgrade: (config: unknown, acceptOptional?: (step: Plan
|
|
|
91
91
|
framework?: "react" | "next" | undefined;
|
|
92
92
|
storybookFramework?: string | undefined;
|
|
93
93
|
} | undefined;
|
|
94
|
+
svelte?: {
|
|
95
|
+
[x: string]: unknown;
|
|
96
|
+
framework?: "svelte" | "sveltekit" | undefined;
|
|
97
|
+
storybookFramework?: string | undefined;
|
|
98
|
+
} | undefined;
|
|
94
99
|
} | undefined;
|
|
95
100
|
} | undefined;
|
|
96
101
|
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { UpgradeStep } from './upgrade-steps';
|
|
2
|
+
/**
|
|
3
|
+
* Regenerates the Svelte Swagger UI page on `swagger-ui-dist`: `swagger-ui`
|
|
4
|
+
* renders with the project's React, and React 19 (brought by Storybook)
|
|
5
|
+
* has no `createRoot` in `react-dom`, so the page fails in the browser.
|
|
6
|
+
*/
|
|
7
|
+
export declare const svelteSwaggerPageStep: UpgradeStep;
|
|
8
|
+
/** Packages of the old Svelte Swagger UI page, to replace by hand. */
|
|
9
|
+
export declare const svelteSwaggerPackagesStep: UpgradeStep;
|
|
10
|
+
/**
|
|
11
|
+
* Svelte has no hooks: widget UI models move to `model/create-*.svelte.ts`
|
|
12
|
+
* and shared hooks to `shared/model/create-*.svelte.ts`, `useN` becomes
|
|
13
|
+
* `createN`, and imports follow.
|
|
14
|
+
*/
|
|
15
|
+
export declare const svelteModelsStep: UpgradeStep;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/upgrade.cjs
CHANGED
|
@@ -257,6 +257,7 @@ const lintChecks = [
|
|
|
257
257
|
'layers',
|
|
258
258
|
'dependencies',
|
|
259
259
|
'react',
|
|
260
|
+
'svelte',
|
|
260
261
|
'clock',
|
|
261
262
|
'config'
|
|
262
263
|
];
|
|
@@ -301,8 +302,16 @@ const reactConfigSchema = external_zod_default().object({
|
|
|
301
302
|
]).optional(),
|
|
302
303
|
storybookFramework: external_zod_default().string().optional()
|
|
303
304
|
}).passthrough();
|
|
305
|
+
const svelteConfigSchema = external_zod_default().object({
|
|
306
|
+
framework: external_zod_default()["enum"]([
|
|
307
|
+
'svelte',
|
|
308
|
+
'sveltekit'
|
|
309
|
+
]).optional(),
|
|
310
|
+
storybookFramework: external_zod_default().string().optional()
|
|
311
|
+
}).passthrough();
|
|
304
312
|
const frontendConfigSchema = external_zod_default().object({
|
|
305
|
-
react: reactConfigSchema.optional()
|
|
313
|
+
react: reactConfigSchema.optional(),
|
|
314
|
+
svelte: svelteConfigSchema.optional()
|
|
306
315
|
}).passthrough();
|
|
307
316
|
const configSchema = external_zod_default().object({
|
|
308
317
|
project: projectConfigSchema,
|
|
@@ -482,7 +491,7 @@ const inMemoryDbWithIdStep = {
|
|
|
482
491
|
file.update(/\bhasId\b/.test(fixed.replace(legacyHasId, '')) ? fixed : fixed.replace(legacyHasId, ''));
|
|
483
492
|
}
|
|
484
493
|
};
|
|
485
|
-
const
|
|
494
|
+
const openapi_extractor_openapiExtractorPath = "scripts/extract-open-api-data-from-endpoint.ts";
|
|
486
495
|
const rootFolderSegments = (rootFolder, indent = 20)=>rootFolder.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment && '.' !== segment).map((segment)=>`'${segment}',\n${' '.repeat(indent)}`).join('');
|
|
487
496
|
const legacyEndpointFileLookup = (rootFolder)=>` // The controller, if any, is the first folder of the path:
|
|
488
497
|
// context-root endpoints live right in presentation/rest.
|
|
@@ -564,13 +573,15 @@ const ignoredFolders = new Set([
|
|
|
564
573
|
'node_modules',
|
|
565
574
|
'.git',
|
|
566
575
|
'.next',
|
|
576
|
+
'.svelte-kit',
|
|
567
577
|
'dist',
|
|
568
578
|
'build',
|
|
569
579
|
'out',
|
|
570
580
|
'coverage',
|
|
571
581
|
'storybook-static'
|
|
572
582
|
]);
|
|
573
|
-
const
|
|
583
|
+
const module_move_codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx|svelte)$/;
|
|
584
|
+
const module_move_escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
574
585
|
const module_move_walk = (folder)=>{
|
|
575
586
|
if (!external_node_fs_default().existsSync(folder)) return [];
|
|
576
587
|
return external_node_fs_default().readdirSync(folder, {
|
|
@@ -583,7 +594,7 @@ const module_move_walk = (folder)=>{
|
|
|
583
594
|
] : [];
|
|
584
595
|
});
|
|
585
596
|
};
|
|
586
|
-
const
|
|
597
|
+
const module_move_toPosix = (value)=>value.split(external_node_path_default().sep).join('/');
|
|
587
598
|
const readAliases = (projectRoot)=>{
|
|
588
599
|
const tsconfig = external_node_path_default().join(projectRoot, 'tsconfig.json');
|
|
589
600
|
if (!external_node_fs_default().existsSync(tsconfig)) return [];
|
|
@@ -601,7 +612,7 @@ const readAliases = (projectRoot)=>{
|
|
|
601
612
|
const specifierPattern = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*|\bmock\s*\(\s*)(['"])([^'"\n]+)\2/g;
|
|
602
613
|
const reExportPattern = /\bexport\s+(?:type\s+)?(?:\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s*(['"])([^'"\n]+)\1/g;
|
|
603
614
|
const importPaths = (file)=>{
|
|
604
|
-
const withoutExtension = file.replace(
|
|
615
|
+
const withoutExtension = file.replace(module_move_codeExtension, '');
|
|
605
616
|
return 'index' === external_node_path_default().basename(withoutExtension) ? [
|
|
606
617
|
withoutExtension,
|
|
607
618
|
external_node_path_default().dirname(withoutExtension)
|
|
@@ -609,7 +620,7 @@ const importPaths = (file)=>{
|
|
|
609
620
|
withoutExtension
|
|
610
621
|
];
|
|
611
622
|
};
|
|
612
|
-
const
|
|
623
|
+
const module_move_projectImports = (projectRoot)=>{
|
|
613
624
|
const aliases = readAliases(projectRoot);
|
|
614
625
|
const resolve = (specifier, fromFile)=>{
|
|
615
626
|
if (specifier.startsWith('.')) return {
|
|
@@ -623,12 +634,12 @@ const projectImports = (projectRoot)=>{
|
|
|
623
634
|
} : void 0;
|
|
624
635
|
};
|
|
625
636
|
const specifierFor = (fromFile, toPath, alias)=>{
|
|
626
|
-
const aliased = alias &&
|
|
637
|
+
const aliased = alias && module_move_toPosix(external_node_path_default().relative(alias.target, toPath));
|
|
627
638
|
if (aliased && !aliased.startsWith('..')) return `${alias.prefix}${aliased}`;
|
|
628
|
-
const relative =
|
|
639
|
+
const relative = module_move_toPosix(external_node_path_default().relative(external_node_path_default().dirname(fromFile), toPath));
|
|
629
640
|
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
630
641
|
};
|
|
631
|
-
const codeFiles = new Map(module_move_walk(projectRoot).filter((file)=>
|
|
642
|
+
const codeFiles = new Map(module_move_walk(projectRoot).filter((file)=>module_move_codeExtension.test(file)).map((file)=>[
|
|
632
643
|
file,
|
|
633
644
|
external_node_fs_default().readFileSync(file, 'utf8')
|
|
634
645
|
]));
|
|
@@ -642,11 +653,11 @@ const projectImports = (projectRoot)=>{
|
|
|
642
653
|
importsOf
|
|
643
654
|
};
|
|
644
655
|
};
|
|
645
|
-
const
|
|
656
|
+
const module_move_stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
|
|
646
657
|
const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
|
|
647
|
-
const { resolve, specifierFor, codeFiles } =
|
|
658
|
+
const { resolve, specifierFor, codeFiles } = module_move_projectImports(projectRoot);
|
|
648
659
|
const barrels = new Set();
|
|
649
|
-
const isBarrel = (resolved)=>barrels.has(resolved.replace(
|
|
660
|
+
const isBarrel = (resolved)=>barrels.has(resolved.replace(module_move_codeExtension, ''));
|
|
650
661
|
for(let found = true; found;){
|
|
651
662
|
found = false;
|
|
652
663
|
for (const [file, content] of codeFiles){
|
|
@@ -737,7 +748,7 @@ const contextFolders = (context)=>{
|
|
|
737
748
|
return bounded_contexts_boundedContextNames(contexts).map((name)=>boundedContextPath(contexts, name));
|
|
738
749
|
};
|
|
739
750
|
const legacyContexts = (context)=>contextFolders(context).filter(hasLegacyRootEndpoints);
|
|
740
|
-
const upgrade_rest_root_relative = (file)=>
|
|
751
|
+
const upgrade_rest_root_relative = (file)=>module_move_toPosix(external_node_path_default().relative(new project_root_ProjectRoot().path, file));
|
|
741
752
|
const intoRoot = (folder, file)=>external_node_path_default().join(folder, "(root)", external_node_path_default().relative(folder, file));
|
|
742
753
|
const rootMoves = (contextFolder)=>{
|
|
743
754
|
const { presentation, wiring } = restFolders(contextFolder);
|
|
@@ -813,10 +824,10 @@ const restRootControllerStep = {
|
|
|
813
824
|
const withoutExtension = new Map([
|
|
814
825
|
...moves
|
|
815
826
|
].map(([from, to])=>[
|
|
816
|
-
from.replace(
|
|
817
|
-
to.replace(
|
|
827
|
+
from.replace(module_move_codeExtension, ''),
|
|
828
|
+
to.replace(module_move_codeExtension, '')
|
|
818
829
|
]));
|
|
819
|
-
|
|
830
|
+
module_move_stageModuleMove({
|
|
820
831
|
projectRoot,
|
|
821
832
|
stopAt: projectRoot,
|
|
822
833
|
stopAtFor: (file)=>contexts.flatMap((folder)=>Object.values(restFolders(folder))).find((folder)=>file.startsWith(`${folder}${external_node_path_default().sep}`)),
|
|
@@ -846,22 +857,22 @@ const restRootControllerStep = {
|
|
|
846
857
|
}
|
|
847
858
|
}
|
|
848
859
|
};
|
|
849
|
-
const
|
|
860
|
+
const upgrade_rest_root_extractorFile = ()=>new file_system_File(external_node_path_default().join(new project_root_ProjectRoot().path, openapi_extractor_openapiExtractorPath));
|
|
850
861
|
const openapiExtractorRootStep = {
|
|
851
862
|
id: 'openapi-extractor-root',
|
|
852
863
|
kind: 'optional',
|
|
853
864
|
title: "Let the OpenAPI extractor find endpoints in presentation/rest/(root)/",
|
|
854
865
|
detect: (context)=>{
|
|
855
866
|
const rootFolder = rootFolderOf(context);
|
|
856
|
-
const file =
|
|
867
|
+
const file = upgrade_rest_root_extractorFile();
|
|
857
868
|
return !!rootFolder && file.exists && file.data.includes(legacyEndpointFileLookup(rootFolder));
|
|
858
869
|
},
|
|
859
870
|
plan: ()=>[
|
|
860
|
-
`${
|
|
871
|
+
`${openapi_extractor_openapiExtractorPath}: the endpoint file is looked up in the controller folder, then in (root)/`
|
|
861
872
|
],
|
|
862
873
|
apply: (context)=>{
|
|
863
874
|
const rootFolder = rootFolderOf(context);
|
|
864
|
-
const file =
|
|
875
|
+
const file = upgrade_rest_root_extractorFile();
|
|
865
876
|
file.update(file.data.replace(legacyEndpointFileLookup(rootFolder), endpointFileLookup(rootFolder)));
|
|
866
877
|
}
|
|
867
878
|
};
|
|
@@ -871,15 +882,15 @@ const openapiExtractorNestedStep = {
|
|
|
871
882
|
title: 'Let the OpenAPI extractor find endpoints of nested bounded contexts',
|
|
872
883
|
detect: (context)=>{
|
|
873
884
|
const rootFolder = rootFolderOf(context);
|
|
874
|
-
const file =
|
|
885
|
+
const file = upgrade_rest_root_extractorFile();
|
|
875
886
|
return !!rootFolder && file.exists && file.data.includes(rootEndpointFileLookup(rootFolder)) && contextFolders(context).some((folder)=>external_node_path_default().relative(external_node_path_default().join(new project_root_ProjectRoot().path, rootFolder, 'bounded-contexts'), folder).includes(external_node_path_default().sep));
|
|
876
887
|
},
|
|
877
888
|
plan: ()=>[
|
|
878
|
-
`${
|
|
889
|
+
`${openapi_extractor_openapiExtractorPath}: the context of an endpoint is looked up by the start of its route, nested contexts included`
|
|
879
890
|
],
|
|
880
891
|
apply: (context)=>{
|
|
881
892
|
const rootFolder = rootFolderOf(context);
|
|
882
|
-
const file =
|
|
893
|
+
const file = upgrade_rest_root_extractorFile();
|
|
883
894
|
file.update(file.data.replace(rootEndpointFileLookup(rootFolder), endpointFileLookup(rootFolder)));
|
|
884
895
|
}
|
|
885
896
|
};
|
|
@@ -889,16 +900,267 @@ const openapiExtractorManualStep = {
|
|
|
889
900
|
title: 'Update the OpenAPI extractor by hand',
|
|
890
901
|
detect: (context)=>{
|
|
891
902
|
const rootFolder = rootFolderOf(context);
|
|
892
|
-
const file =
|
|
903
|
+
const file = upgrade_rest_root_extractorFile();
|
|
893
904
|
if (!rootFolder || !file.exists) return false;
|
|
894
905
|
const data = file.data;
|
|
895
906
|
return !data.includes(endpointFileLookup(rootFolder)) && !data.includes(rootEndpointFileLookup(rootFolder)) && !data.includes(legacyEndpointFileLookup(rootFolder)) && contextFolders(context).some((folder)=>hasLegacyRootEndpoints(folder) || external_node_fs_default().existsSync(external_node_path_default().join(restFolders(folder).presentation, "(root)")));
|
|
896
907
|
},
|
|
897
908
|
plan: ()=>[
|
|
898
|
-
`${
|
|
909
|
+
`${openapi_extractor_openapiExtractorPath} doesn't look up endpoints in presentation/rest/(root)/: compare it with the one npx df-integration scaffolds for openapi`
|
|
899
910
|
]
|
|
900
911
|
};
|
|
912
|
+
const external_node_async_hooks_namespaceObject = require("node:async_hooks");
|
|
913
|
+
new external_node_async_hooks_namespaceObject.AsyncLocalStorage();
|
|
914
|
+
const frontendExtensions = {
|
|
915
|
+
react: {
|
|
916
|
+
component: '.tsx',
|
|
917
|
+
hook: '.ts'
|
|
918
|
+
},
|
|
919
|
+
svelte: {
|
|
920
|
+
component: '.svelte',
|
|
921
|
+
hook: '.svelte.ts'
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
const frontendLogicNaming = {
|
|
925
|
+
react: {
|
|
926
|
+
prefix: 'use',
|
|
927
|
+
shared: [
|
|
928
|
+
'hooks'
|
|
929
|
+
],
|
|
930
|
+
widgetModel: 'hooks'
|
|
931
|
+
},
|
|
932
|
+
svelte: {
|
|
933
|
+
prefix: 'create',
|
|
934
|
+
shared: [
|
|
935
|
+
'shared',
|
|
936
|
+
'model'
|
|
937
|
+
],
|
|
938
|
+
widgetModel: 'model'
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
const kindLayouts = (framework)=>{
|
|
942
|
+
const { component, hook } = frontendExtensions[framework];
|
|
943
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
944
|
+
return {
|
|
945
|
+
page: {
|
|
946
|
+
folder: 'pages',
|
|
947
|
+
nested: true,
|
|
948
|
+
inFolder: false,
|
|
949
|
+
ownFile: (fileBase)=>new RegExp(`^${module_move_escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
950
|
+
target: (reactFolder, { folders, fileName })=>external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page${component}`),
|
|
951
|
+
classPrefix: `(${prefix})?`,
|
|
952
|
+
classSuffix: 'Page'
|
|
953
|
+
},
|
|
954
|
+
widget: {
|
|
955
|
+
folder: 'widgets',
|
|
956
|
+
nested: true,
|
|
957
|
+
inFolder: true,
|
|
958
|
+
target: (reactFolder, { folders, folderName })=>external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName),
|
|
959
|
+
classPrefix: `(${prefix})?`,
|
|
960
|
+
classSuffix: 'Widget|UIModel',
|
|
961
|
+
storyTitle: (segments)=>[
|
|
962
|
+
'Widgets',
|
|
963
|
+
...segments
|
|
964
|
+
].join('/')
|
|
965
|
+
},
|
|
966
|
+
'ui-kit': {
|
|
967
|
+
folder: 'ui-kit',
|
|
968
|
+
nested: false,
|
|
969
|
+
inFolder: true,
|
|
970
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, 'ui-kit', fileName),
|
|
971
|
+
classPrefix: '()',
|
|
972
|
+
classSuffix: 'Props(?![\\w$])|(?![\\w$])',
|
|
973
|
+
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
974
|
+
},
|
|
975
|
+
hook: {
|
|
976
|
+
folder: shared.join('/'),
|
|
977
|
+
nested: false,
|
|
978
|
+
inFolder: false,
|
|
979
|
+
ownFile: (fileBase)=>new RegExp(`^${prefix}-${module_move_escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
980
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, ...shared, `${prefix}-${fileName}${hook}`),
|
|
981
|
+
classPrefix: `(${prefix})`,
|
|
982
|
+
classSuffix: '(?![\\w$])'
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
};
|
|
986
|
+
kindLayouts('react');
|
|
987
|
+
kindLayouts('svelte');
|
|
988
|
+
const reactKindTitles = {
|
|
989
|
+
page: [
|
|
990
|
+
'Page',
|
|
991
|
+
'pages'
|
|
992
|
+
],
|
|
993
|
+
widget: [
|
|
994
|
+
'Widget',
|
|
995
|
+
'widgets'
|
|
996
|
+
],
|
|
997
|
+
'ui-kit': [
|
|
998
|
+
'UI-kit component',
|
|
999
|
+
'UI-kit components'
|
|
1000
|
+
],
|
|
1001
|
+
hook: [
|
|
1002
|
+
'Shared hook',
|
|
1003
|
+
'shared hooks'
|
|
1004
|
+
]
|
|
1005
|
+
};
|
|
1006
|
+
({
|
|
1007
|
+
...reactKindTitles,
|
|
1008
|
+
hook: [
|
|
1009
|
+
'Shared model',
|
|
1010
|
+
'shared models'
|
|
1011
|
+
]
|
|
1012
|
+
});
|
|
1013
|
+
const swaggerPagePath = (rootFolder, framework = 'react')=>external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'), 'svelte' === framework ? 'presentation/svelte/pages/swagger-page.svelte' : 'presentation/react/pages/swagger-page.tsx');
|
|
1014
|
+
const specImportOf = (pagePath, outputPath)=>{
|
|
1015
|
+
const specImport = external_node_path_default().posix.relative(external_node_path_default().posix.dirname(pagePath), outputPath);
|
|
1016
|
+
return specImport.startsWith('.') ? specImport : `./${specImport}`;
|
|
1017
|
+
};
|
|
1018
|
+
const svelteKitStaticFolder = 'static/';
|
|
1019
|
+
const svelteKitStaticUrl = (outputPath)=>outputPath.startsWith(svelteKitStaticFolder) ? `/${outputPath.slice(svelteKitStaticFolder.length)}` : void 0;
|
|
1020
|
+
const svelteSwaggerPage = (rootFolder, outputPath, url)=>`
|
|
1021
|
+
<script lang="ts" module>
|
|
1022
|
+
export type SwaggerPageProps = {}
|
|
1023
|
+
</script>
|
|
1024
|
+
|
|
1025
|
+
<script lang="ts">
|
|
1026
|
+
import 'swagger-ui-dist/swagger-ui.css'
|
|
1027
|
+
import type { SwaggerUIBundle as SwaggerUIBundleType } from 'swagger-ui-dist'
|
|
1028
|
+
import { onMount } from 'svelte'${url ? '' : `
|
|
1029
|
+
import spec from '${specImportOf(swaggerPagePath(rootFolder, 'svelte'), outputPath)}'`}
|
|
1030
|
+
|
|
1031
|
+
let props: SwaggerPageProps = $props()
|
|
1032
|
+
let container: HTMLDivElement
|
|
1033
|
+
|
|
1034
|
+
onMount(async () => {
|
|
1035
|
+
// Self-contained bundle: React is bundled inside, no react deps in the project
|
|
1036
|
+
const { default: SwaggerUIBundle } = (await import(
|
|
1037
|
+
// @ts-expect-error -- swagger-ui-dist ships no types for this entry point
|
|
1038
|
+
'swagger-ui-dist/swagger-ui-bundle.js'
|
|
1039
|
+
)) as { default: SwaggerUIBundleType }
|
|
1040
|
+
|
|
1041
|
+
SwaggerUIBundle({ domNode: container, ${url ? `url: '${url}'` : 'spec'}, displayOperationId: true })
|
|
1042
|
+
})
|
|
1043
|
+
</script>
|
|
1044
|
+
|
|
1045
|
+
<div bind:this={container}></div>
|
|
1046
|
+
`.trim();
|
|
901
1047
|
const record = (value)=>'object' != typeof value || null === value || Array.isArray(value) ? {} : value;
|
|
1048
|
+
const svelteOf = ({ config })=>'svelte' in record(config.frontend) ? record(record(config.frontend).svelte) : void 0;
|
|
1049
|
+
const upgrade_svelte_rootFolderOf = ({ config })=>{
|
|
1050
|
+
const rootFolder = record(config.project).rootFolder;
|
|
1051
|
+
return 'string' == typeof rootFolder ? rootFolder : void 0;
|
|
1052
|
+
};
|
|
1053
|
+
const upgrade_svelte_relative = (file)=>module_move_toPosix(external_node_path_default().relative(new project_root_ProjectRoot().path, file));
|
|
1054
|
+
const svelteFolder = (context)=>{
|
|
1055
|
+
const rootFolder = upgrade_svelte_rootFolderOf(context);
|
|
1056
|
+
return svelteOf(context) && rootFolder ? external_node_path_default().join(new project_root_ProjectRoot().path, rootFolder, 'presentation', 'svelte') : void 0;
|
|
1057
|
+
};
|
|
1058
|
+
const legacySwaggerPage = (context)=>{
|
|
1059
|
+
const rootFolder = upgrade_svelte_rootFolderOf(context);
|
|
1060
|
+
if (!svelteOf(context) || !rootFolder) return;
|
|
1061
|
+
const file = new file_system_File(external_node_path_default().join(new project_root_ProjectRoot().path, swaggerPagePath(rootFolder, 'svelte')));
|
|
1062
|
+
return file.exists && /swagger-ui\/dist\/swagger-ui\.css|import\(\s*['"]swagger-ui['"]\s*\)/.test(file.data) ? file : void 0;
|
|
1063
|
+
};
|
|
1064
|
+
const importedSpecPath = (page)=>{
|
|
1065
|
+
const specifier = page.data.match(/import\s+spec\s+from\s+['"]([^'"]+)['"]/)?.[1];
|
|
1066
|
+
return specifier?.startsWith('.') ? upgrade_svelte_relative(external_node_path_default().resolve(external_node_path_default().dirname(page.path), specifier)) : void 0;
|
|
1067
|
+
};
|
|
1068
|
+
const svelteSwaggerPageStep = {
|
|
1069
|
+
id: 'svelte-swagger-ui-dist',
|
|
1070
|
+
kind: 'optional',
|
|
1071
|
+
title: 'Render the Svelte Swagger UI page with swagger-ui-dist',
|
|
1072
|
+
detect: (context)=>{
|
|
1073
|
+
const page = legacySwaggerPage(context);
|
|
1074
|
+
return !!page && !!importedSpecPath(page);
|
|
1075
|
+
},
|
|
1076
|
+
plan: (context)=>{
|
|
1077
|
+
const page = legacySwaggerPage(context);
|
|
1078
|
+
return [
|
|
1079
|
+
`${upgrade_svelte_relative(page.path)}: regenerated on swagger-ui-dist/swagger-ui-bundle.js, which bundles its own React`
|
|
1080
|
+
];
|
|
1081
|
+
},
|
|
1082
|
+
apply: (context)=>{
|
|
1083
|
+
const page = legacySwaggerPage(context);
|
|
1084
|
+
const outputPath = importedSpecPath(page);
|
|
1085
|
+
const sveltekit = svelteOf(context)?.framework === 'sveltekit';
|
|
1086
|
+
page.update(svelteSwaggerPage(upgrade_svelte_rootFolderOf(context), outputPath, sveltekit ? svelteKitStaticUrl(outputPath) : void 0));
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
const svelteSwaggerPackagesStep = {
|
|
1090
|
+
id: 'svelte-swagger-ui-dist-packages',
|
|
1091
|
+
kind: 'manual',
|
|
1092
|
+
title: 'Replace swagger-ui with swagger-ui-dist',
|
|
1093
|
+
detect: (context)=>!!svelteOf(context) && hasDependency('swagger-ui'),
|
|
1094
|
+
plan: ()=>[
|
|
1095
|
+
`npm uninstall swagger-ui${hasDependency('@types/swagger-ui') ? ' @types/swagger-ui' : ''}`,
|
|
1096
|
+
...hasDependency('swagger-ui-dist') ? [] : [
|
|
1097
|
+
'npm install swagger-ui-dist'
|
|
1098
|
+
],
|
|
1099
|
+
...hasDependency('@types/swagger-ui-dist') ? [] : [
|
|
1100
|
+
'npm install --save-dev @types/swagger-ui-dist'
|
|
1101
|
+
]
|
|
1102
|
+
]
|
|
1103
|
+
};
|
|
1104
|
+
const legacyFunctionNames = (file)=>[
|
|
1105
|
+
...external_node_fs_default().readFileSync(file, 'utf8').matchAll(/export\s+(?:const|function)\s+use(\w+)\b/g)
|
|
1106
|
+
].map(([, name])=>[
|
|
1107
|
+
`use${name}`,
|
|
1108
|
+
`create${name}`
|
|
1109
|
+
]);
|
|
1110
|
+
const legacyModels = (context)=>{
|
|
1111
|
+
const folder = svelteFolder(context);
|
|
1112
|
+
if (!folder) return [];
|
|
1113
|
+
const isModule = (file)=>/^use-.+\.svelte\.[jt]s$/.test(external_node_path_default().basename(file)) && !/\.(spec|test)\./.test(file);
|
|
1114
|
+
const renamed = (file)=>external_node_path_default().basename(file).replace(/^use-/, 'create-');
|
|
1115
|
+
const widgetModels = module_move_walk(external_node_path_default().join(folder, 'widgets')).filter((file)=>'hooks' === external_node_path_default().basename(external_node_path_default().dirname(file)) && /-ui-model\./.test(file) && isModule(file)).map((file)=>({
|
|
1116
|
+
from: file,
|
|
1117
|
+
to: external_node_path_default().join(external_node_path_default().dirname(external_node_path_default().dirname(file)), 'model', renamed(file))
|
|
1118
|
+
}));
|
|
1119
|
+
const sharedFolder = external_node_path_default().join(folder, 'hooks');
|
|
1120
|
+
const sharedHooks = external_node_fs_default().existsSync(sharedFolder) ? external_node_fs_default().readdirSync(sharedFolder).map((name)=>external_node_path_default().join(sharedFolder, name)).filter(isModule).map((file)=>({
|
|
1121
|
+
from: file,
|
|
1122
|
+
to: external_node_path_default().join(folder, 'shared', 'model', renamed(file))
|
|
1123
|
+
})) : [];
|
|
1124
|
+
return [
|
|
1125
|
+
...widgetModels,
|
|
1126
|
+
...sharedHooks
|
|
1127
|
+
].filter(({ to })=>!external_node_fs_default().existsSync(to)).map((move)=>({
|
|
1128
|
+
...move,
|
|
1129
|
+
names: legacyFunctionNames(move.from)
|
|
1130
|
+
}));
|
|
1131
|
+
};
|
|
1132
|
+
const svelteModelsStep = {
|
|
1133
|
+
id: 'svelte-models',
|
|
1134
|
+
kind: 'optional',
|
|
1135
|
+
title: 'Rename Svelte hooks to models: model/create-*.svelte.ts',
|
|
1136
|
+
detect: (context)=>legacyModels(context).length > 0,
|
|
1137
|
+
plan: (context)=>legacyModels(context).flatMap(({ from, to, names })=>[
|
|
1138
|
+
`${upgrade_svelte_relative(from)} → ${upgrade_svelte_relative(to)}`,
|
|
1139
|
+
...names.map(([from, to])=>` ${from} → ${to}`)
|
|
1140
|
+
]),
|
|
1141
|
+
apply: (context)=>{
|
|
1142
|
+
const models = legacyModels(context);
|
|
1143
|
+
const moves = new Map(models.map(({ from, to })=>[
|
|
1144
|
+
from,
|
|
1145
|
+
to
|
|
1146
|
+
]));
|
|
1147
|
+
const withoutExtension = new Map(models.map(({ from, to })=>[
|
|
1148
|
+
from.replace(module_move_codeExtension, ''),
|
|
1149
|
+
to.replace(module_move_codeExtension, '')
|
|
1150
|
+
]));
|
|
1151
|
+
const names = models.flatMap((model)=>model.names);
|
|
1152
|
+
const namePattern = names.length && new RegExp(`(?<![\\w$])(${names.map(([from])=>module_move_escapeRegExp(from)).join('|')})(?![\\w$])`, 'g');
|
|
1153
|
+
const renames = new Map(names);
|
|
1154
|
+
module_move_stageModuleMove({
|
|
1155
|
+
projectRoot: new project_root_ProjectRoot().path,
|
|
1156
|
+
stopAt: svelteFolder(context),
|
|
1157
|
+
moves,
|
|
1158
|
+
movedPath: (candidate)=>moves.get(candidate) ?? withoutExtension.get(candidate),
|
|
1159
|
+
rename: (content)=>namePattern ? content.replace(namePattern, (name)=>renames.get(name) ?? name) : content
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
const upgrade_steps_record = (value)=>'object' != typeof value || null === value || Array.isArray(value) ? {} : value;
|
|
902
1164
|
const flatConfigSchema = external_zod_default().object({
|
|
903
1165
|
rootFolder: external_zod_default().string().min(1),
|
|
904
1166
|
domainFirstPackages: external_zod_default().array(external_zod_default()["enum"](config_file_domainFirstPackages)),
|
|
@@ -952,17 +1214,17 @@ const sectionsStep = {
|
|
|
952
1214
|
};
|
|
953
1215
|
}
|
|
954
1216
|
};
|
|
955
|
-
const reactOf = (config)=>
|
|
1217
|
+
const reactOf = (config)=>upgrade_steps_record(upgrade_steps_record(config.frontend).react);
|
|
956
1218
|
const frameworkStep = {
|
|
957
1219
|
id: 'react-framework',
|
|
958
1220
|
kind: 'required',
|
|
959
1221
|
title: 'Record the frontend framework explicitly',
|
|
960
|
-
detect: ({ config })=>'react' in
|
|
1222
|
+
detect: ({ config })=>'react' in upgrade_steps_record(config.frontend) && !reactOf(config).framework,
|
|
961
1223
|
plan: ()=>[
|
|
962
1224
|
hasDependency('next') ? 'frontend.react.framework: "next" (next is in package.json)' : 'frontend.react.framework: "react" (next is not in package.json)'
|
|
963
1225
|
],
|
|
964
1226
|
apply: ({ config })=>{
|
|
965
|
-
const frontend =
|
|
1227
|
+
const frontend = upgrade_steps_record(config.frontend);
|
|
966
1228
|
config.frontend = {
|
|
967
1229
|
...frontend,
|
|
968
1230
|
react: {
|
|
@@ -981,9 +1243,9 @@ const persistenceStep = {
|
|
|
981
1243
|
id: 'persistence-default',
|
|
982
1244
|
kind: 'required',
|
|
983
1245
|
title: 'Move the default persistence implementation to saved implementation types',
|
|
984
|
-
detect: ({ config })=>'defaultPersistenceLayerImplementation' in
|
|
1246
|
+
detect: ({ config })=>'defaultPersistenceLayerImplementation' in upgrade_steps_record(config.backend),
|
|
985
1247
|
plan: ({ config })=>{
|
|
986
|
-
const label =
|
|
1248
|
+
const label = upgrade_steps_record(config.backend).defaultPersistenceLayerImplementation;
|
|
987
1249
|
if (void 0 === label) return [];
|
|
988
1250
|
return implementationLabelSchema.safeParse(label).success ? [
|
|
989
1251
|
`defaultPersistenceLayerImplementation "${label}" → first primary type of backend.implementations.${persistenceKinds.join(', ')}`
|
|
@@ -992,11 +1254,11 @@ const persistenceStep = {
|
|
|
992
1254
|
];
|
|
993
1255
|
},
|
|
994
1256
|
apply: ({ config })=>{
|
|
995
|
-
const { defaultPersistenceLayerImplementation: label, ...backend } =
|
|
996
|
-
const implementations =
|
|
1257
|
+
const { defaultPersistenceLayerImplementation: label, ...backend } = upgrade_steps_record(config.backend);
|
|
1258
|
+
const implementations = upgrade_steps_record(backend.implementations);
|
|
997
1259
|
if (implementationLabelSchema.safeParse(label).success) {
|
|
998
1260
|
for (const kind of persistenceKinds){
|
|
999
|
-
const group =
|
|
1261
|
+
const group = upgrade_steps_record(implementations[kind]);
|
|
1000
1262
|
const primary = Array.isArray(group.primary) ? group.primary : [];
|
|
1001
1263
|
implementations[kind] = {
|
|
1002
1264
|
primary: [
|
|
@@ -1019,12 +1281,15 @@ const upgradeSteps = [
|
|
|
1019
1281
|
openapiExtractorRootStep,
|
|
1020
1282
|
openapiExtractorNestedStep,
|
|
1021
1283
|
openapiExtractorManualStep,
|
|
1022
|
-
inMemoryDbWithIdStep
|
|
1284
|
+
inMemoryDbWithIdStep,
|
|
1285
|
+
svelteSwaggerPageStep,
|
|
1286
|
+
svelteSwaggerPackagesStep,
|
|
1287
|
+
svelteModelsStep
|
|
1023
1288
|
];
|
|
1024
1289
|
const skillsNote = 'Update the agent skills to this version: npx df-skills';
|
|
1025
1290
|
const planUpgrade = async (config, acceptOptional = ()=>true, steps = upgradeSteps)=>{
|
|
1026
1291
|
const context = {
|
|
1027
|
-
config: structuredClone(
|
|
1292
|
+
config: structuredClone(upgrade_steps_record(config))
|
|
1028
1293
|
};
|
|
1029
1294
|
const original = JSON.stringify(context.config);
|
|
1030
1295
|
const planned = [];
|
|
@@ -1059,7 +1324,7 @@ Options:
|
|
|
1059
1324
|
--dry-run show the plan without writing anything
|
|
1060
1325
|
--yes apply without asking, optional steps included
|
|
1061
1326
|
-h, --help show this help`;
|
|
1062
|
-
const { values } = (0, external_node_util_namespaceObject.parseArgs)({
|
|
1327
|
+
const { values: upgrade_values } = (0, external_node_util_namespaceObject.parseArgs)({
|
|
1063
1328
|
options: {
|
|
1064
1329
|
help: {
|
|
1065
1330
|
type: 'boolean',
|
|
@@ -1077,7 +1342,7 @@ const { values } = (0, external_node_util_namespaceObject.parseArgs)({
|
|
|
1077
1342
|
}
|
|
1078
1343
|
}
|
|
1079
1344
|
});
|
|
1080
|
-
if (
|
|
1345
|
+
if (upgrade_values.help) {
|
|
1081
1346
|
console.log(help);
|
|
1082
1347
|
process.exit(0);
|
|
1083
1348
|
}
|
|
@@ -1085,7 +1350,7 @@ const printStep = ({ step, changes })=>{
|
|
|
1085
1350
|
console.log(`\n${step.title}${'optional' === step.kind ? ' (optional)' : ''}`);
|
|
1086
1351
|
for (const change of changes)console.log(` ${change}`);
|
|
1087
1352
|
};
|
|
1088
|
-
const
|
|
1353
|
+
const upgrade_run = async ()=>{
|
|
1089
1354
|
const root = new project_root_ProjectRoot().path;
|
|
1090
1355
|
const configPath = external_node_path_default().join(root, configFileName);
|
|
1091
1356
|
if (!config_file_ConfigFile.exists) {
|
|
@@ -1099,9 +1364,9 @@ const run = async ()=>{
|
|
|
1099
1364
|
console.log(`${configFileName} is not valid JSON: fix it first.`);
|
|
1100
1365
|
process.exit(1);
|
|
1101
1366
|
}
|
|
1102
|
-
const dryRun =
|
|
1367
|
+
const dryRun = upgrade_values['dry-run'];
|
|
1103
1368
|
const { planned, changed, config } = await planUpgrade(raw, (entry)=>{
|
|
1104
|
-
if (dryRun ||
|
|
1369
|
+
if (dryRun || upgrade_values.yes) return true;
|
|
1105
1370
|
printStep(entry);
|
|
1106
1371
|
return (0, prompts_namespaceObject.confirm)({
|
|
1107
1372
|
message: 'Apply this optional step?',
|
|
@@ -1116,7 +1381,7 @@ const run = async ()=>{
|
|
|
1116
1381
|
skillsNote
|
|
1117
1382
|
];
|
|
1118
1383
|
if (dryRun) return void console.log('\nDry run: nothing was written.');
|
|
1119
|
-
if (!
|
|
1384
|
+
if (!upgrade_values.yes && !await (0, prompts_namespaceObject.confirm)({
|
|
1120
1385
|
message: 'Apply?',
|
|
1121
1386
|
default: true
|
|
1122
1387
|
})) {
|
|
@@ -1130,7 +1395,7 @@ const run = async ()=>{
|
|
|
1130
1395
|
console.log('\nDo it yourself:');
|
|
1131
1396
|
for (const note of manual)console.log(` ${note}`);
|
|
1132
1397
|
};
|
|
1133
|
-
|
|
1398
|
+
upgrade_run().catch((error)=>{
|
|
1134
1399
|
console.error(error instanceof Error ? error.message : error);
|
|
1135
1400
|
process.exitCode = 1;
|
|
1136
1401
|
});
|