@domain-first/project-structure 8.11.0 → 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 +1 -1
- package/dist/287.js +36 -967
- package/dist/364.js +3 -3
- package/dist/38.js +4 -3
- package/dist/561.js +76 -67
- package/dist/783.js +1147 -0
- package/dist/{201.js → 878.js} +455 -1
- package/dist/agent-cli.d.ts +5 -5
- package/dist/agent-requests.d.ts +9 -9
- package/dist/frontend-modules.d.ts +6 -1
- package/dist/graph.cjs +115 -4
- package/dist/graph.js +1 -1
- package/dist/index.cjs +129 -71
- package/dist/index.js +1 -1
- package/dist/init.cjs +49 -6
- package/dist/init.js +1 -1
- package/dist/integration.cjs +129 -71
- package/dist/integration.js +1 -1
- package/dist/integrations/openapi.d.ts +13 -3
- package/dist/lint.cjs +121 -9
- package/dist/lint.js +1 -1
- package/dist/react-module-move.d.ts +20 -2
- package/dist/react.cjs +185 -123
- package/dist/svelte.cjs +185 -123
- package/dist/upgrade-svelte.d.ts +15 -0
- package/dist/upgrade-svelte.spec.d.ts +1 -0
- package/dist/upgrade.cjs +296 -41
- package/dist/upgrade.js +132 -13
- package/dist/use-cases/scaffold-svelte-modules.d.ts +7 -2
- package/package.json +1 -1
- package/skills/df-ps-scaffold/SKILL.md +2 -2
- package/skills/df-ps-scaffold/references/agent-operations.md +2 -2
- package/skills/df-ps-svelte/SKILL.md +14 -9
- package/skills/df-ps-svelte/references/generators.md +5 -5
- package/dist/115.js +0 -616
package/dist/upgrade.cjs
CHANGED
|
@@ -491,7 +491,7 @@ const inMemoryDbWithIdStep = {
|
|
|
491
491
|
file.update(/\bhasId\b/.test(fixed.replace(legacyHasId, '')) ? fixed : fixed.replace(legacyHasId, ''));
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
|
-
const
|
|
494
|
+
const openapi_extractor_openapiExtractorPath = "scripts/extract-open-api-data-from-endpoint.ts";
|
|
495
495
|
const rootFolderSegments = (rootFolder, indent = 20)=>rootFolder.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment && '.' !== segment).map((segment)=>`'${segment}',\n${' '.repeat(indent)}`).join('');
|
|
496
496
|
const legacyEndpointFileLookup = (rootFolder)=>` // The controller, if any, is the first folder of the path:
|
|
497
497
|
// context-root endpoints live right in presentation/rest.
|
|
@@ -580,7 +580,8 @@ const ignoredFolders = new Set([
|
|
|
580
580
|
'coverage',
|
|
581
581
|
'storybook-static'
|
|
582
582
|
]);
|
|
583
|
-
const
|
|
583
|
+
const module_move_codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx|svelte)$/;
|
|
584
|
+
const module_move_escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
584
585
|
const module_move_walk = (folder)=>{
|
|
585
586
|
if (!external_node_fs_default().existsSync(folder)) return [];
|
|
586
587
|
return external_node_fs_default().readdirSync(folder, {
|
|
@@ -593,7 +594,7 @@ const module_move_walk = (folder)=>{
|
|
|
593
594
|
] : [];
|
|
594
595
|
});
|
|
595
596
|
};
|
|
596
|
-
const
|
|
597
|
+
const module_move_toPosix = (value)=>value.split(external_node_path_default().sep).join('/');
|
|
597
598
|
const readAliases = (projectRoot)=>{
|
|
598
599
|
const tsconfig = external_node_path_default().join(projectRoot, 'tsconfig.json');
|
|
599
600
|
if (!external_node_fs_default().existsSync(tsconfig)) return [];
|
|
@@ -611,7 +612,7 @@ const readAliases = (projectRoot)=>{
|
|
|
611
612
|
const specifierPattern = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*|\bmock\s*\(\s*)(['"])([^'"\n]+)\2/g;
|
|
612
613
|
const reExportPattern = /\bexport\s+(?:type\s+)?(?:\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s*(['"])([^'"\n]+)\1/g;
|
|
613
614
|
const importPaths = (file)=>{
|
|
614
|
-
const withoutExtension = file.replace(
|
|
615
|
+
const withoutExtension = file.replace(module_move_codeExtension, '');
|
|
615
616
|
return 'index' === external_node_path_default().basename(withoutExtension) ? [
|
|
616
617
|
withoutExtension,
|
|
617
618
|
external_node_path_default().dirname(withoutExtension)
|
|
@@ -619,7 +620,7 @@ const importPaths = (file)=>{
|
|
|
619
620
|
withoutExtension
|
|
620
621
|
];
|
|
621
622
|
};
|
|
622
|
-
const
|
|
623
|
+
const module_move_projectImports = (projectRoot)=>{
|
|
623
624
|
const aliases = readAliases(projectRoot);
|
|
624
625
|
const resolve = (specifier, fromFile)=>{
|
|
625
626
|
if (specifier.startsWith('.')) return {
|
|
@@ -633,12 +634,12 @@ const projectImports = (projectRoot)=>{
|
|
|
633
634
|
} : void 0;
|
|
634
635
|
};
|
|
635
636
|
const specifierFor = (fromFile, toPath, alias)=>{
|
|
636
|
-
const aliased = alias &&
|
|
637
|
+
const aliased = alias && module_move_toPosix(external_node_path_default().relative(alias.target, toPath));
|
|
637
638
|
if (aliased && !aliased.startsWith('..')) return `${alias.prefix}${aliased}`;
|
|
638
|
-
const relative =
|
|
639
|
+
const relative = module_move_toPosix(external_node_path_default().relative(external_node_path_default().dirname(fromFile), toPath));
|
|
639
640
|
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
640
641
|
};
|
|
641
|
-
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)=>[
|
|
642
643
|
file,
|
|
643
644
|
external_node_fs_default().readFileSync(file, 'utf8')
|
|
644
645
|
]));
|
|
@@ -652,11 +653,11 @@ const projectImports = (projectRoot)=>{
|
|
|
652
653
|
importsOf
|
|
653
654
|
};
|
|
654
655
|
};
|
|
655
|
-
const
|
|
656
|
+
const module_move_stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
|
|
656
657
|
const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
|
|
657
|
-
const { resolve, specifierFor, codeFiles } =
|
|
658
|
+
const { resolve, specifierFor, codeFiles } = module_move_projectImports(projectRoot);
|
|
658
659
|
const barrels = new Set();
|
|
659
|
-
const isBarrel = (resolved)=>barrels.has(resolved.replace(
|
|
660
|
+
const isBarrel = (resolved)=>barrels.has(resolved.replace(module_move_codeExtension, ''));
|
|
660
661
|
for(let found = true; found;){
|
|
661
662
|
found = false;
|
|
662
663
|
for (const [file, content] of codeFiles){
|
|
@@ -747,7 +748,7 @@ const contextFolders = (context)=>{
|
|
|
747
748
|
return bounded_contexts_boundedContextNames(contexts).map((name)=>boundedContextPath(contexts, name));
|
|
748
749
|
};
|
|
749
750
|
const legacyContexts = (context)=>contextFolders(context).filter(hasLegacyRootEndpoints);
|
|
750
|
-
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));
|
|
751
752
|
const intoRoot = (folder, file)=>external_node_path_default().join(folder, "(root)", external_node_path_default().relative(folder, file));
|
|
752
753
|
const rootMoves = (contextFolder)=>{
|
|
753
754
|
const { presentation, wiring } = restFolders(contextFolder);
|
|
@@ -823,10 +824,10 @@ const restRootControllerStep = {
|
|
|
823
824
|
const withoutExtension = new Map([
|
|
824
825
|
...moves
|
|
825
826
|
].map(([from, to])=>[
|
|
826
|
-
from.replace(
|
|
827
|
-
to.replace(
|
|
827
|
+
from.replace(module_move_codeExtension, ''),
|
|
828
|
+
to.replace(module_move_codeExtension, '')
|
|
828
829
|
]));
|
|
829
|
-
|
|
830
|
+
module_move_stageModuleMove({
|
|
830
831
|
projectRoot,
|
|
831
832
|
stopAt: projectRoot,
|
|
832
833
|
stopAtFor: (file)=>contexts.flatMap((folder)=>Object.values(restFolders(folder))).find((folder)=>file.startsWith(`${folder}${external_node_path_default().sep}`)),
|
|
@@ -856,22 +857,22 @@ const restRootControllerStep = {
|
|
|
856
857
|
}
|
|
857
858
|
}
|
|
858
859
|
};
|
|
859
|
-
const
|
|
860
|
+
const upgrade_rest_root_extractorFile = ()=>new file_system_File(external_node_path_default().join(new project_root_ProjectRoot().path, openapi_extractor_openapiExtractorPath));
|
|
860
861
|
const openapiExtractorRootStep = {
|
|
861
862
|
id: 'openapi-extractor-root',
|
|
862
863
|
kind: 'optional',
|
|
863
864
|
title: "Let the OpenAPI extractor find endpoints in presentation/rest/(root)/",
|
|
864
865
|
detect: (context)=>{
|
|
865
866
|
const rootFolder = rootFolderOf(context);
|
|
866
|
-
const file =
|
|
867
|
+
const file = upgrade_rest_root_extractorFile();
|
|
867
868
|
return !!rootFolder && file.exists && file.data.includes(legacyEndpointFileLookup(rootFolder));
|
|
868
869
|
},
|
|
869
870
|
plan: ()=>[
|
|
870
|
-
`${
|
|
871
|
+
`${openapi_extractor_openapiExtractorPath}: the endpoint file is looked up in the controller folder, then in (root)/`
|
|
871
872
|
],
|
|
872
873
|
apply: (context)=>{
|
|
873
874
|
const rootFolder = rootFolderOf(context);
|
|
874
|
-
const file =
|
|
875
|
+
const file = upgrade_rest_root_extractorFile();
|
|
875
876
|
file.update(file.data.replace(legacyEndpointFileLookup(rootFolder), endpointFileLookup(rootFolder)));
|
|
876
877
|
}
|
|
877
878
|
};
|
|
@@ -881,15 +882,15 @@ const openapiExtractorNestedStep = {
|
|
|
881
882
|
title: 'Let the OpenAPI extractor find endpoints of nested bounded contexts',
|
|
882
883
|
detect: (context)=>{
|
|
883
884
|
const rootFolder = rootFolderOf(context);
|
|
884
|
-
const file =
|
|
885
|
+
const file = upgrade_rest_root_extractorFile();
|
|
885
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));
|
|
886
887
|
},
|
|
887
888
|
plan: ()=>[
|
|
888
|
-
`${
|
|
889
|
+
`${openapi_extractor_openapiExtractorPath}: the context of an endpoint is looked up by the start of its route, nested contexts included`
|
|
889
890
|
],
|
|
890
891
|
apply: (context)=>{
|
|
891
892
|
const rootFolder = rootFolderOf(context);
|
|
892
|
-
const file =
|
|
893
|
+
const file = upgrade_rest_root_extractorFile();
|
|
893
894
|
file.update(file.data.replace(rootEndpointFileLookup(rootFolder), endpointFileLookup(rootFolder)));
|
|
894
895
|
}
|
|
895
896
|
};
|
|
@@ -899,16 +900,267 @@ const openapiExtractorManualStep = {
|
|
|
899
900
|
title: 'Update the OpenAPI extractor by hand',
|
|
900
901
|
detect: (context)=>{
|
|
901
902
|
const rootFolder = rootFolderOf(context);
|
|
902
|
-
const file =
|
|
903
|
+
const file = upgrade_rest_root_extractorFile();
|
|
903
904
|
if (!rootFolder || !file.exists) return false;
|
|
904
905
|
const data = file.data;
|
|
905
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)")));
|
|
906
907
|
},
|
|
907
908
|
plan: ()=>[
|
|
908
|
-
`${
|
|
909
|
+
`${openapi_extractor_openapiExtractorPath} doesn't look up endpoints in presentation/rest/(root)/: compare it with the one npx df-integration scaffolds for openapi`
|
|
909
910
|
]
|
|
910
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();
|
|
911
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;
|
|
912
1164
|
const flatConfigSchema = external_zod_default().object({
|
|
913
1165
|
rootFolder: external_zod_default().string().min(1),
|
|
914
1166
|
domainFirstPackages: external_zod_default().array(external_zod_default()["enum"](config_file_domainFirstPackages)),
|
|
@@ -962,17 +1214,17 @@ const sectionsStep = {
|
|
|
962
1214
|
};
|
|
963
1215
|
}
|
|
964
1216
|
};
|
|
965
|
-
const reactOf = (config)=>
|
|
1217
|
+
const reactOf = (config)=>upgrade_steps_record(upgrade_steps_record(config.frontend).react);
|
|
966
1218
|
const frameworkStep = {
|
|
967
1219
|
id: 'react-framework',
|
|
968
1220
|
kind: 'required',
|
|
969
1221
|
title: 'Record the frontend framework explicitly',
|
|
970
|
-
detect: ({ config })=>'react' in
|
|
1222
|
+
detect: ({ config })=>'react' in upgrade_steps_record(config.frontend) && !reactOf(config).framework,
|
|
971
1223
|
plan: ()=>[
|
|
972
1224
|
hasDependency('next') ? 'frontend.react.framework: "next" (next is in package.json)' : 'frontend.react.framework: "react" (next is not in package.json)'
|
|
973
1225
|
],
|
|
974
1226
|
apply: ({ config })=>{
|
|
975
|
-
const frontend =
|
|
1227
|
+
const frontend = upgrade_steps_record(config.frontend);
|
|
976
1228
|
config.frontend = {
|
|
977
1229
|
...frontend,
|
|
978
1230
|
react: {
|
|
@@ -991,9 +1243,9 @@ const persistenceStep = {
|
|
|
991
1243
|
id: 'persistence-default',
|
|
992
1244
|
kind: 'required',
|
|
993
1245
|
title: 'Move the default persistence implementation to saved implementation types',
|
|
994
|
-
detect: ({ config })=>'defaultPersistenceLayerImplementation' in
|
|
1246
|
+
detect: ({ config })=>'defaultPersistenceLayerImplementation' in upgrade_steps_record(config.backend),
|
|
995
1247
|
plan: ({ config })=>{
|
|
996
|
-
const label =
|
|
1248
|
+
const label = upgrade_steps_record(config.backend).defaultPersistenceLayerImplementation;
|
|
997
1249
|
if (void 0 === label) return [];
|
|
998
1250
|
return implementationLabelSchema.safeParse(label).success ? [
|
|
999
1251
|
`defaultPersistenceLayerImplementation "${label}" → first primary type of backend.implementations.${persistenceKinds.join(', ')}`
|
|
@@ -1002,11 +1254,11 @@ const persistenceStep = {
|
|
|
1002
1254
|
];
|
|
1003
1255
|
},
|
|
1004
1256
|
apply: ({ config })=>{
|
|
1005
|
-
const { defaultPersistenceLayerImplementation: label, ...backend } =
|
|
1006
|
-
const implementations =
|
|
1257
|
+
const { defaultPersistenceLayerImplementation: label, ...backend } = upgrade_steps_record(config.backend);
|
|
1258
|
+
const implementations = upgrade_steps_record(backend.implementations);
|
|
1007
1259
|
if (implementationLabelSchema.safeParse(label).success) {
|
|
1008
1260
|
for (const kind of persistenceKinds){
|
|
1009
|
-
const group =
|
|
1261
|
+
const group = upgrade_steps_record(implementations[kind]);
|
|
1010
1262
|
const primary = Array.isArray(group.primary) ? group.primary : [];
|
|
1011
1263
|
implementations[kind] = {
|
|
1012
1264
|
primary: [
|
|
@@ -1029,12 +1281,15 @@ const upgradeSteps = [
|
|
|
1029
1281
|
openapiExtractorRootStep,
|
|
1030
1282
|
openapiExtractorNestedStep,
|
|
1031
1283
|
openapiExtractorManualStep,
|
|
1032
|
-
inMemoryDbWithIdStep
|
|
1284
|
+
inMemoryDbWithIdStep,
|
|
1285
|
+
svelteSwaggerPageStep,
|
|
1286
|
+
svelteSwaggerPackagesStep,
|
|
1287
|
+
svelteModelsStep
|
|
1033
1288
|
];
|
|
1034
1289
|
const skillsNote = 'Update the agent skills to this version: npx df-skills';
|
|
1035
1290
|
const planUpgrade = async (config, acceptOptional = ()=>true, steps = upgradeSteps)=>{
|
|
1036
1291
|
const context = {
|
|
1037
|
-
config: structuredClone(
|
|
1292
|
+
config: structuredClone(upgrade_steps_record(config))
|
|
1038
1293
|
};
|
|
1039
1294
|
const original = JSON.stringify(context.config);
|
|
1040
1295
|
const planned = [];
|
|
@@ -1069,7 +1324,7 @@ Options:
|
|
|
1069
1324
|
--dry-run show the plan without writing anything
|
|
1070
1325
|
--yes apply without asking, optional steps included
|
|
1071
1326
|
-h, --help show this help`;
|
|
1072
|
-
const { values } = (0, external_node_util_namespaceObject.parseArgs)({
|
|
1327
|
+
const { values: upgrade_values } = (0, external_node_util_namespaceObject.parseArgs)({
|
|
1073
1328
|
options: {
|
|
1074
1329
|
help: {
|
|
1075
1330
|
type: 'boolean',
|
|
@@ -1087,7 +1342,7 @@ const { values } = (0, external_node_util_namespaceObject.parseArgs)({
|
|
|
1087
1342
|
}
|
|
1088
1343
|
}
|
|
1089
1344
|
});
|
|
1090
|
-
if (
|
|
1345
|
+
if (upgrade_values.help) {
|
|
1091
1346
|
console.log(help);
|
|
1092
1347
|
process.exit(0);
|
|
1093
1348
|
}
|
|
@@ -1095,7 +1350,7 @@ const printStep = ({ step, changes })=>{
|
|
|
1095
1350
|
console.log(`\n${step.title}${'optional' === step.kind ? ' (optional)' : ''}`);
|
|
1096
1351
|
for (const change of changes)console.log(` ${change}`);
|
|
1097
1352
|
};
|
|
1098
|
-
const
|
|
1353
|
+
const upgrade_run = async ()=>{
|
|
1099
1354
|
const root = new project_root_ProjectRoot().path;
|
|
1100
1355
|
const configPath = external_node_path_default().join(root, configFileName);
|
|
1101
1356
|
if (!config_file_ConfigFile.exists) {
|
|
@@ -1109,9 +1364,9 @@ const run = async ()=>{
|
|
|
1109
1364
|
console.log(`${configFileName} is not valid JSON: fix it first.`);
|
|
1110
1365
|
process.exit(1);
|
|
1111
1366
|
}
|
|
1112
|
-
const dryRun =
|
|
1367
|
+
const dryRun = upgrade_values['dry-run'];
|
|
1113
1368
|
const { planned, changed, config } = await planUpgrade(raw, (entry)=>{
|
|
1114
|
-
if (dryRun ||
|
|
1369
|
+
if (dryRun || upgrade_values.yes) return true;
|
|
1115
1370
|
printStep(entry);
|
|
1116
1371
|
return (0, prompts_namespaceObject.confirm)({
|
|
1117
1372
|
message: 'Apply this optional step?',
|
|
@@ -1126,7 +1381,7 @@ const run = async ()=>{
|
|
|
1126
1381
|
skillsNote
|
|
1127
1382
|
];
|
|
1128
1383
|
if (dryRun) return void console.log('\nDry run: nothing was written.');
|
|
1129
|
-
if (!
|
|
1384
|
+
if (!upgrade_values.yes && !await (0, prompts_namespaceObject.confirm)({
|
|
1130
1385
|
message: 'Apply?',
|
|
1131
1386
|
default: true
|
|
1132
1387
|
})) {
|
|
@@ -1140,7 +1395,7 @@ const run = async ()=>{
|
|
|
1140
1395
|
console.log('\nDo it yourself:');
|
|
1141
1396
|
for (const note of manual)console.log(` ${note}`);
|
|
1142
1397
|
};
|
|
1143
|
-
|
|
1398
|
+
upgrade_run().catch((error)=>{
|
|
1144
1399
|
console.error(error instanceof Error ? error.message : error);
|
|
1145
1400
|
process.exitCode = 1;
|
|
1146
1401
|
});
|