@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/{201.js → 878.js}
RENAMED
|
@@ -472,6 +472,7 @@ const lintChecks = [
|
|
|
472
472
|
'layers',
|
|
473
473
|
'dependencies',
|
|
474
474
|
'react',
|
|
475
|
+
'svelte',
|
|
475
476
|
'clock',
|
|
476
477
|
'config'
|
|
477
478
|
];
|
|
@@ -516,8 +517,16 @@ const reactConfigSchema = zod.object({
|
|
|
516
517
|
]).optional(),
|
|
517
518
|
storybookFramework: zod.string().optional()
|
|
518
519
|
}).passthrough();
|
|
520
|
+
const svelteConfigSchema = zod.object({
|
|
521
|
+
framework: zod["enum"]([
|
|
522
|
+
'svelte',
|
|
523
|
+
'sveltekit'
|
|
524
|
+
]).optional(),
|
|
525
|
+
storybookFramework: zod.string().optional()
|
|
526
|
+
}).passthrough();
|
|
519
527
|
const frontendConfigSchema = zod.object({
|
|
520
|
-
react: reactConfigSchema.optional()
|
|
528
|
+
react: reactConfigSchema.optional(),
|
|
529
|
+
svelte: svelteConfigSchema.optional()
|
|
521
530
|
}).passthrough();
|
|
522
531
|
const configSchema = zod.object({
|
|
523
532
|
project: projectConfigSchema,
|
|
@@ -1032,4 +1041,458 @@ const compilerOption = (configFile, name, seen = new Set())=>{
|
|
|
1032
1041
|
if (void 0 !== value) return value;
|
|
1033
1042
|
}
|
|
1034
1043
|
};
|
|
1035
|
-
|
|
1044
|
+
const ignoredFolders = new Set([
|
|
1045
|
+
'node_modules',
|
|
1046
|
+
'.git',
|
|
1047
|
+
'.next',
|
|
1048
|
+
'.svelte-kit',
|
|
1049
|
+
'dist',
|
|
1050
|
+
'build',
|
|
1051
|
+
'out',
|
|
1052
|
+
'coverage',
|
|
1053
|
+
'storybook-static'
|
|
1054
|
+
]);
|
|
1055
|
+
const codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx|svelte)$/;
|
|
1056
|
+
const escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1057
|
+
const module_move_walk = (folder)=>{
|
|
1058
|
+
if (!node_fs.existsSync(folder)) return [];
|
|
1059
|
+
return node_fs.readdirSync(folder, {
|
|
1060
|
+
withFileTypes: true
|
|
1061
|
+
}).flatMap((entry)=>{
|
|
1062
|
+
const entryPath = node_path.join(folder, entry.name);
|
|
1063
|
+
if (entry.isDirectory()) return ignoredFolders.has(entry.name) ? [] : module_move_walk(entryPath);
|
|
1064
|
+
return entry.isFile() ? [
|
|
1065
|
+
entryPath
|
|
1066
|
+
] : [];
|
|
1067
|
+
});
|
|
1068
|
+
};
|
|
1069
|
+
const toPosix = (value)=>value.split(node_path.sep).join('/');
|
|
1070
|
+
const readAliases = (projectRoot)=>{
|
|
1071
|
+
const tsconfig = node_path.join(projectRoot, 'tsconfig.json');
|
|
1072
|
+
if (!node_fs.existsSync(tsconfig)) return [];
|
|
1073
|
+
try {
|
|
1074
|
+
const { compilerOptions = {} } = JSON.parse(stripJsonComments(node_fs.readFileSync(tsconfig, 'utf8')));
|
|
1075
|
+
const base = node_path.resolve(projectRoot, compilerOptions.baseUrl ?? '.');
|
|
1076
|
+
return Object.entries(compilerOptions.paths ?? {}).filter(([pattern, targets])=>pattern.endsWith('*') && targets[0]?.endsWith('*')).map(([pattern, [target]])=>({
|
|
1077
|
+
prefix: pattern.slice(0, -1),
|
|
1078
|
+
target: node_path.resolve(base, target.slice(0, -1))
|
|
1079
|
+
}));
|
|
1080
|
+
} catch {
|
|
1081
|
+
return [];
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
const specifierPattern = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*|\bmock\s*\(\s*)(['"])([^'"\n]+)\2/g;
|
|
1085
|
+
const reExportPattern = /\bexport\s+(?:type\s+)?(?:\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s*(['"])([^'"\n]+)\1/g;
|
|
1086
|
+
const importPaths = (file)=>{
|
|
1087
|
+
const withoutExtension = file.replace(codeExtension, '');
|
|
1088
|
+
return 'index' === node_path.basename(withoutExtension) ? [
|
|
1089
|
+
withoutExtension,
|
|
1090
|
+
node_path.dirname(withoutExtension)
|
|
1091
|
+
] : [
|
|
1092
|
+
withoutExtension
|
|
1093
|
+
];
|
|
1094
|
+
};
|
|
1095
|
+
const projectImports = (projectRoot)=>{
|
|
1096
|
+
const aliases = readAliases(projectRoot);
|
|
1097
|
+
const resolve = (specifier, fromFile)=>{
|
|
1098
|
+
if (specifier.startsWith('.')) return {
|
|
1099
|
+
resolved: node_path.resolve(node_path.dirname(fromFile), specifier),
|
|
1100
|
+
alias: void 0
|
|
1101
|
+
};
|
|
1102
|
+
const alias = aliases.find(({ prefix })=>specifier.startsWith(prefix));
|
|
1103
|
+
return alias ? {
|
|
1104
|
+
resolved: node_path.resolve(alias.target, specifier.slice(alias.prefix.length)),
|
|
1105
|
+
alias
|
|
1106
|
+
} : void 0;
|
|
1107
|
+
};
|
|
1108
|
+
const specifierFor = (fromFile, toPath, alias)=>{
|
|
1109
|
+
const aliased = alias && toPosix(node_path.relative(alias.target, toPath));
|
|
1110
|
+
if (aliased && !aliased.startsWith('..')) return `${alias.prefix}${aliased}`;
|
|
1111
|
+
const relative = toPosix(node_path.relative(node_path.dirname(fromFile), toPath));
|
|
1112
|
+
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
1113
|
+
};
|
|
1114
|
+
const codeFiles = new Map(module_move_walk(projectRoot).filter((file)=>codeExtension.test(file)).map((file)=>[
|
|
1115
|
+
file,
|
|
1116
|
+
node_fs.readFileSync(file, 'utf8')
|
|
1117
|
+
]));
|
|
1118
|
+
const importsOf = (file)=>[
|
|
1119
|
+
...(codeFiles.get(file) ?? '').matchAll(specifierPattern)
|
|
1120
|
+
].map(([, , , specifier])=>resolve(specifier, file)?.resolved).filter((resolved)=>!!resolved);
|
|
1121
|
+
return {
|
|
1122
|
+
resolve,
|
|
1123
|
+
specifierFor,
|
|
1124
|
+
codeFiles,
|
|
1125
|
+
importsOf
|
|
1126
|
+
};
|
|
1127
|
+
};
|
|
1128
|
+
const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
|
|
1129
|
+
const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
|
|
1130
|
+
const { resolve, specifierFor, codeFiles } = projectImports(projectRoot);
|
|
1131
|
+
const barrels = new Set();
|
|
1132
|
+
const isBarrel = (resolved)=>barrels.has(resolved.replace(codeExtension, ''));
|
|
1133
|
+
for(let found = true; found;){
|
|
1134
|
+
found = false;
|
|
1135
|
+
for (const [file, content] of codeFiles){
|
|
1136
|
+
if (moves.has(file) || isBarrel(file)) continue;
|
|
1137
|
+
const reExportsModule = [
|
|
1138
|
+
...content.matchAll(reExportPattern)
|
|
1139
|
+
].some(([, , specifier])=>{
|
|
1140
|
+
const resolution = resolve(specifier, file);
|
|
1141
|
+
return !!resolution && (!!movedPath(resolution.resolved) || isBarrel(resolution.resolved));
|
|
1142
|
+
});
|
|
1143
|
+
if (reExportsModule) {
|
|
1144
|
+
for (const importPath of importPaths(file))barrels.add(importPath);
|
|
1145
|
+
found = true;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
const rewrite = (content, oldFile, newFile)=>{
|
|
1150
|
+
let referencesModule = false;
|
|
1151
|
+
const rewritten = content.replace(specifierPattern, (match, keyword, quote, specifier)=>{
|
|
1152
|
+
const resolution = resolve(specifier, oldFile);
|
|
1153
|
+
if (!resolution) return match;
|
|
1154
|
+
const moved = movedPath(resolution.resolved);
|
|
1155
|
+
if (moved || isBarrel(resolution.resolved)) referencesModule = true;
|
|
1156
|
+
if (!moved && oldFile === newFile) return match;
|
|
1157
|
+
const next = specifierFor(newFile, moved ?? resolution.resolved, resolution.alias);
|
|
1158
|
+
return `${keyword}${quote}${next}${quote}`;
|
|
1159
|
+
});
|
|
1160
|
+
const changed = everyFile(rewritten);
|
|
1161
|
+
if (!referencesModule && !moves.has(oldFile)) return changed;
|
|
1162
|
+
return rename(changed, {
|
|
1163
|
+
moved: moves.has(oldFile)
|
|
1164
|
+
});
|
|
1165
|
+
};
|
|
1166
|
+
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new File(file).moveTo(newFile, stopFor(file));
|
|
1167
|
+
const updated = [];
|
|
1168
|
+
for (const [file, content] of codeFiles){
|
|
1169
|
+
const newFile = moves.get(file);
|
|
1170
|
+
const next = rewrite(content, file, newFile ?? file);
|
|
1171
|
+
if (newFile && newFile !== file) {
|
|
1172
|
+
new File(newFile).data = next;
|
|
1173
|
+
new File(file).delete(stopFor(file));
|
|
1174
|
+
} else if (next !== content) {
|
|
1175
|
+
new File(file).update(next);
|
|
1176
|
+
if (!newFile) updated.push(file);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
return {
|
|
1180
|
+
moves: [
|
|
1181
|
+
...moves
|
|
1182
|
+
].filter(([from, to])=>from !== to),
|
|
1183
|
+
updated
|
|
1184
|
+
};
|
|
1185
|
+
};
|
|
1186
|
+
const frontendExtensions = {
|
|
1187
|
+
react: {
|
|
1188
|
+
component: '.tsx',
|
|
1189
|
+
hook: '.ts'
|
|
1190
|
+
},
|
|
1191
|
+
svelte: {
|
|
1192
|
+
component: '.svelte',
|
|
1193
|
+
hook: '.svelte.ts'
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
const frontendLogicNaming = {
|
|
1197
|
+
react: {
|
|
1198
|
+
prefix: 'use',
|
|
1199
|
+
shared: [
|
|
1200
|
+
'hooks'
|
|
1201
|
+
],
|
|
1202
|
+
widgetModel: 'hooks'
|
|
1203
|
+
},
|
|
1204
|
+
svelte: {
|
|
1205
|
+
prefix: 'create',
|
|
1206
|
+
shared: [
|
|
1207
|
+
'shared',
|
|
1208
|
+
'model'
|
|
1209
|
+
],
|
|
1210
|
+
widgetModel: 'model'
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
const kindLayouts = (framework)=>{
|
|
1214
|
+
const { component, hook } = frontendExtensions[framework];
|
|
1215
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
1216
|
+
return {
|
|
1217
|
+
page: {
|
|
1218
|
+
folder: 'pages',
|
|
1219
|
+
nested: true,
|
|
1220
|
+
inFolder: false,
|
|
1221
|
+
ownFile: (fileBase)=>new RegExp(`^${escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
1222
|
+
target: (reactFolder, { folders, fileName })=>node_path.join(reactFolder, 'pages', ...folders, `${fileName}-page${component}`),
|
|
1223
|
+
classPrefix: `(${prefix})?`,
|
|
1224
|
+
classSuffix: 'Page'
|
|
1225
|
+
},
|
|
1226
|
+
widget: {
|
|
1227
|
+
folder: 'widgets',
|
|
1228
|
+
nested: true,
|
|
1229
|
+
inFolder: true,
|
|
1230
|
+
target: (reactFolder, { folders, folderName })=>node_path.join(reactFolder, 'widgets', ...folders, folderName),
|
|
1231
|
+
classPrefix: `(${prefix})?`,
|
|
1232
|
+
classSuffix: 'Widget|UIModel',
|
|
1233
|
+
storyTitle: (segments)=>[
|
|
1234
|
+
'Widgets',
|
|
1235
|
+
...segments
|
|
1236
|
+
].join('/')
|
|
1237
|
+
},
|
|
1238
|
+
'ui-kit': {
|
|
1239
|
+
folder: 'ui-kit',
|
|
1240
|
+
nested: false,
|
|
1241
|
+
inFolder: true,
|
|
1242
|
+
target: (reactFolder, { fileName })=>node_path.join(reactFolder, 'ui-kit', fileName),
|
|
1243
|
+
classPrefix: '()',
|
|
1244
|
+
classSuffix: 'Props(?![\\w$])|(?![\\w$])',
|
|
1245
|
+
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
1246
|
+
},
|
|
1247
|
+
hook: {
|
|
1248
|
+
folder: shared.join('/'),
|
|
1249
|
+
nested: false,
|
|
1250
|
+
inFolder: false,
|
|
1251
|
+
ownFile: (fileBase)=>new RegExp(`^${prefix}-${escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
1252
|
+
target: (reactFolder, { fileName })=>node_path.join(reactFolder, ...shared, `${prefix}-${fileName}${hook}`),
|
|
1253
|
+
classPrefix: `(${prefix})`,
|
|
1254
|
+
classSuffix: '(?![\\w$])'
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
};
|
|
1258
|
+
const reactKindLayouts = kindLayouts('react');
|
|
1259
|
+
const svelteKindLayouts = kindLayouts('svelte');
|
|
1260
|
+
const frontendKindLayouts = (framework)=>'svelte' === framework ? svelteKindLayouts : reactKindLayouts;
|
|
1261
|
+
const reactKindTitles = {
|
|
1262
|
+
page: [
|
|
1263
|
+
'Page',
|
|
1264
|
+
'pages'
|
|
1265
|
+
],
|
|
1266
|
+
widget: [
|
|
1267
|
+
'Widget',
|
|
1268
|
+
'widgets'
|
|
1269
|
+
],
|
|
1270
|
+
'ui-kit': [
|
|
1271
|
+
'UI-kit component',
|
|
1272
|
+
'UI-kit components'
|
|
1273
|
+
],
|
|
1274
|
+
hook: [
|
|
1275
|
+
'Shared hook',
|
|
1276
|
+
'shared hooks'
|
|
1277
|
+
]
|
|
1278
|
+
};
|
|
1279
|
+
const svelteKindTitles = {
|
|
1280
|
+
...reactKindTitles,
|
|
1281
|
+
hook: [
|
|
1282
|
+
'Shared model',
|
|
1283
|
+
'shared models'
|
|
1284
|
+
]
|
|
1285
|
+
};
|
|
1286
|
+
const frontendKindTitles = (framework)=>'svelte' === framework ? svelteKindTitles : reactKindTitles;
|
|
1287
|
+
const reactModuleName = (kind, rawName, framework = 'react')=>'hook' === kind ? rawName.trim().replace(new RegExp(`^${frontendLogicNaming[framework].prefix}-`), '') : rawName;
|
|
1288
|
+
const nestedName = (folders, fileBase)=>{
|
|
1289
|
+
const prefix = `${folders.join('-')}-`;
|
|
1290
|
+
const last = folders.length && fileBase.startsWith(prefix) ? fileBase.slice(prefix.length) : fileBase;
|
|
1291
|
+
return [
|
|
1292
|
+
...folders,
|
|
1293
|
+
last
|
|
1294
|
+
].join('/');
|
|
1295
|
+
};
|
|
1296
|
+
const declaredClassName = (filePaths, suffix, name)=>{
|
|
1297
|
+
for (const filePath of filePaths){
|
|
1298
|
+
if (!node_fs.existsSync(filePath)) continue;
|
|
1299
|
+
const declared = node_fs.readFileSync(filePath, 'utf8').match(new RegExp(`(?:export\\s+(?:const|function)|\\bdefault\\s+as)\\s+(\\w+)${suffix}\\b`))?.[1];
|
|
1300
|
+
if (declared) return declared;
|
|
1301
|
+
}
|
|
1302
|
+
return new NestedName(name).ClassName;
|
|
1303
|
+
};
|
|
1304
|
+
const findUiKit = (reactFolder, framework)=>{
|
|
1305
|
+
const { component } = frontendExtensions[framework];
|
|
1306
|
+
const root = node_path.join(reactFolder, 'ui-kit');
|
|
1307
|
+
if (!node_fs.existsSync(root)) return [];
|
|
1308
|
+
return node_fs.readdirSync(root, {
|
|
1309
|
+
withFileTypes: true
|
|
1310
|
+
}).filter((entry)=>entry.isDirectory() && node_fs.existsSync(node_path.join(root, entry.name, `${entry.name}${component}`))).map(({ name })=>({
|
|
1311
|
+
kind: 'ui-kit',
|
|
1312
|
+
name,
|
|
1313
|
+
path: node_path.join(root, name),
|
|
1314
|
+
fileBase: name,
|
|
1315
|
+
ClassName: declaredClassName([
|
|
1316
|
+
node_path.join(root, name, `${name}${component}`),
|
|
1317
|
+
node_path.join(root, name, 'index.ts')
|
|
1318
|
+
], '', name)
|
|
1319
|
+
}));
|
|
1320
|
+
};
|
|
1321
|
+
const hookFile = {
|
|
1322
|
+
react: /\.tsx?$/,
|
|
1323
|
+
svelte: /\.svelte\.[jt]s$/
|
|
1324
|
+
};
|
|
1325
|
+
const findHooks = (reactFolder, framework)=>{
|
|
1326
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
1327
|
+
const root = node_path.join(reactFolder, ...shared);
|
|
1328
|
+
if (!node_fs.existsSync(root)) return [];
|
|
1329
|
+
const extension = hookFile[framework];
|
|
1330
|
+
const ownPrefix = new RegExp(`^${prefix}-`);
|
|
1331
|
+
return node_fs.readdirSync(root).filter((file)=>ownPrefix.test(file) && extension.test(file) && !/\.(spec|test)\./.test(file)).map((file)=>{
|
|
1332
|
+
const name = file.replace(ownPrefix, '').replace(extension, '');
|
|
1333
|
+
const content = node_fs.readFileSync(node_path.join(root, file), 'utf8');
|
|
1334
|
+
return {
|
|
1335
|
+
kind: 'hook',
|
|
1336
|
+
name,
|
|
1337
|
+
path: node_path.join(root, file),
|
|
1338
|
+
fileBase: name,
|
|
1339
|
+
ClassName: content.match(new RegExp(`export\\s+(?:const|function)\\s+${prefix}(\\w+)\\b`))?.[1] ?? new NestedName(name).ClassName
|
|
1340
|
+
};
|
|
1341
|
+
});
|
|
1342
|
+
};
|
|
1343
|
+
const findReactModules = (reactFolder, kind, framework = 'react')=>{
|
|
1344
|
+
const { component } = frontendExtensions[framework];
|
|
1345
|
+
const modules = 'ui-kit' === kind ? findUiKit(reactFolder, framework) : 'hook' === kind ? findHooks(reactFolder, framework) : 'page' === kind ? module_move_walk(node_path.join(reactFolder, 'pages')).filter((file)=>file.endsWith(`-page${component}`)).map((file)=>{
|
|
1346
|
+
const folders = node_path.relative(node_path.join(reactFolder, 'pages'), node_path.dirname(file)).split(node_path.sep).filter((segment)=>!!segment);
|
|
1347
|
+
const fileBase = node_path.basename(file, `-page${component}`);
|
|
1348
|
+
const name = nestedName(folders, fileBase);
|
|
1349
|
+
return {
|
|
1350
|
+
kind,
|
|
1351
|
+
name,
|
|
1352
|
+
path: file,
|
|
1353
|
+
fileBase,
|
|
1354
|
+
ClassName: declaredClassName([
|
|
1355
|
+
file
|
|
1356
|
+
], 'Page', name)
|
|
1357
|
+
};
|
|
1358
|
+
}) : module_move_walk(node_path.join(reactFolder, 'widgets')).filter((file)=>file.endsWith(`-widget${component}`)).map((file)=>{
|
|
1359
|
+
const folder = node_path.dirname(file);
|
|
1360
|
+
const name = toPosix(node_path.relative(node_path.join(reactFolder, 'widgets'), folder));
|
|
1361
|
+
return {
|
|
1362
|
+
kind,
|
|
1363
|
+
name,
|
|
1364
|
+
path: folder,
|
|
1365
|
+
fileBase: node_path.basename(file, `-widget${component}`),
|
|
1366
|
+
ClassName: declaredClassName([
|
|
1367
|
+
file,
|
|
1368
|
+
node_path.join(folder, 'index.ts')
|
|
1369
|
+
], 'Widget', name)
|
|
1370
|
+
};
|
|
1371
|
+
});
|
|
1372
|
+
return modules.sort((a, b)=>a.name.localeCompare(b.name));
|
|
1373
|
+
};
|
|
1374
|
+
const react_module_move_targetPath = (reactFolder, module, rawName, framework)=>frontendKindLayouts(framework)[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName, framework)));
|
|
1375
|
+
const validateMove = (reactFolder, module, rawName, framework = 'react')=>{
|
|
1376
|
+
const nameError = NestedName.validate(rawName);
|
|
1377
|
+
if (true !== nameError) return nameError;
|
|
1378
|
+
if (!frontendKindLayouts(framework)[module.kind].nested && /[\\/]/.test(rawName)) return `UI-kit components and ${frontendKindTitles(framework).hook[1]} have no folders: enter a name without "/"`;
|
|
1379
|
+
const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
|
|
1380
|
+
if (target !== module.path && node_fs.existsSync(target)) return `${node_path.relative(reactFolder, target)} already exists`;
|
|
1381
|
+
if (target.startsWith(`${module.path}${node_path.sep}`)) return 'A widget cannot be moved into itself';
|
|
1382
|
+
return true;
|
|
1383
|
+
};
|
|
1384
|
+
const routeFolder = (appFolder, rawName)=>{
|
|
1385
|
+
const { folders, folderName } = new NestedName(rawName);
|
|
1386
|
+
return node_path.join(appFolder, ...folders, folderName);
|
|
1387
|
+
};
|
|
1388
|
+
const routeFiles = (folder)=>node_fs.existsSync(folder) ? node_fs.readdirSync(folder, {
|
|
1389
|
+
withFileTypes: true
|
|
1390
|
+
}).filter((entry)=>entry.isFile()).map((entry)=>node_path.join(folder, entry.name)) : [];
|
|
1391
|
+
const moveReactModule = (projectRoot, reactFolder, module, rawName, route, framework = 'react')=>{
|
|
1392
|
+
const layout = frontendKindLayouts(framework)[module.kind];
|
|
1393
|
+
const newName = new NestedName(reactModuleName(module.kind, rawName, framework));
|
|
1394
|
+
const { prefix } = frontendLogicNaming[framework];
|
|
1395
|
+
const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
|
|
1396
|
+
const newClassName = newName.ClassName;
|
|
1397
|
+
const renameFile = (name)=>name.replace(new RegExp(`^(${prefix}-)?${escapeRegExp(module.fileBase)}(?=[-.]|$)`), (_, own = '')=>`${own}${newName.fileName}`);
|
|
1398
|
+
const oldFolder = layout.inFolder ? module.path : node_path.dirname(module.path);
|
|
1399
|
+
const newFolder = layout.inFolder ? target : node_path.dirname(target);
|
|
1400
|
+
const ownsPath = (candidate)=>layout.inFolder ? candidate === oldFolder || candidate.startsWith(`${oldFolder}${node_path.sep}`) : node_path.dirname(candidate) === oldFolder && layout.ownFile(module.fileBase).test(node_path.basename(candidate));
|
|
1401
|
+
const routeFileSet = new Set(route ? routeFiles(route.from) : []);
|
|
1402
|
+
const routeTarget = (candidate)=>{
|
|
1403
|
+
if (!route) return;
|
|
1404
|
+
const file = [
|
|
1405
|
+
...routeFileSet
|
|
1406
|
+
].find((x)=>x === candidate || x.replace(codeExtension, '') === candidate);
|
|
1407
|
+
if (!file) return;
|
|
1408
|
+
const moved = node_path.join(route.to, node_path.relative(route.from, file));
|
|
1409
|
+
return file === candidate ? moved : moved.replace(codeExtension, '');
|
|
1410
|
+
};
|
|
1411
|
+
const movedPath = (candidate)=>{
|
|
1412
|
+
const routed = routeTarget(candidate);
|
|
1413
|
+
if (routed) return routed;
|
|
1414
|
+
if (!ownsPath(candidate)) return;
|
|
1415
|
+
const segments = node_path.relative(oldFolder, candidate).split(node_path.sep);
|
|
1416
|
+
const last = segments.length - 1;
|
|
1417
|
+
segments[last] = renameFile(segments[last]);
|
|
1418
|
+
return node_path.join(newFolder, ...segments);
|
|
1419
|
+
};
|
|
1420
|
+
const moduleFiles = reactModuleFiles(module, framework);
|
|
1421
|
+
const moves = new Map([
|
|
1422
|
+
...moduleFiles,
|
|
1423
|
+
...routeFileSet
|
|
1424
|
+
].map((file)=>[
|
|
1425
|
+
file,
|
|
1426
|
+
movedPath(file) ?? file
|
|
1427
|
+
]));
|
|
1428
|
+
const classPattern = new RegExp(`(?<![\\w$])${layout.classPrefix}${escapeRegExp(module.ClassName)}(?=${layout.classSuffix})`, 'g');
|
|
1429
|
+
const oldTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
|
|
1430
|
+
module.ClassName
|
|
1431
|
+
] : module.name.split('/').map((segment)=>new NestedName(segment).ClassName));
|
|
1432
|
+
const titlePattern = oldTitle && new RegExp(`(['"\`])${escapeRegExp(oldTitle)}\\1`, 'g');
|
|
1433
|
+
const newTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
|
|
1434
|
+
newClassName
|
|
1435
|
+
] : newName.classNameSegments);
|
|
1436
|
+
return stageModuleMove({
|
|
1437
|
+
projectRoot,
|
|
1438
|
+
stopAt: reactFolder,
|
|
1439
|
+
stopAtFor: (file)=>route && routeFileSet.has(file) ? route.appFolder : void 0,
|
|
1440
|
+
moves,
|
|
1441
|
+
movedPath,
|
|
1442
|
+
rename: (content, { moved })=>{
|
|
1443
|
+
const renamed = content.replace(classPattern, (_, use)=>`${use ?? ''}${newClassName}`);
|
|
1444
|
+
return moved && titlePattern ? renamed.replace(titlePattern, (_, quote)=>`${quote}${newTitle}${quote}`) : renamed;
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
};
|
|
1448
|
+
const routePageFile = {
|
|
1449
|
+
react: 'page.tsx',
|
|
1450
|
+
svelte: '+page.svelte'
|
|
1451
|
+
};
|
|
1452
|
+
const pageRouteFolder = (appFolder, page, framework = 'react')=>{
|
|
1453
|
+
const folder = routeFolder(appFolder, page.name);
|
|
1454
|
+
const routePage = node_path.join(folder, routePageFile[framework]);
|
|
1455
|
+
return node_fs.existsSync(routePage) && new RegExp(`(?<![\\w$])${page.ClassName}Page(?![\\w$])`).test(node_fs.readFileSync(routePage, 'utf8')) ? folder : void 0;
|
|
1456
|
+
};
|
|
1457
|
+
const reactModuleFiles = (module, framework)=>{
|
|
1458
|
+
const layout = frontendKindLayouts(framework)[module.kind];
|
|
1459
|
+
if (layout.inFolder) return module_move_walk(module.path);
|
|
1460
|
+
const folder = node_path.dirname(module.path);
|
|
1461
|
+
const own = layout.ownFile(module.fileBase);
|
|
1462
|
+
return node_fs.readdirSync(folder, {
|
|
1463
|
+
withFileTypes: true
|
|
1464
|
+
}).filter((entry)=>entry.isFile() && own.test(entry.name)).map((entry)=>node_path.join(folder, entry.name));
|
|
1465
|
+
};
|
|
1466
|
+
const importSpecifier = /(?:\bfrom\s*|\bimport\s*\(\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"\n]+)\1/g;
|
|
1467
|
+
const deleteReactModule = (projectRoot, reactFolder, module, route, framework = 'react')=>{
|
|
1468
|
+
const moduleFiles = reactModuleFiles(module, framework);
|
|
1469
|
+
const routeFileList = route ? routeFiles(route.folder) : [];
|
|
1470
|
+
const own = new Set([
|
|
1471
|
+
...moduleFiles,
|
|
1472
|
+
...routeFileList
|
|
1473
|
+
]);
|
|
1474
|
+
const stems = new Set(moduleFiles.map((file)=>file.replace(codeExtension, '')));
|
|
1475
|
+
const isModule = (resolved)=>stems.has(resolved) || moduleFiles.includes(resolved) || frontendKindLayouts(framework)[module.kind].inFolder && (resolved === module.path || resolved.startsWith(`${module.path}${node_path.sep}`));
|
|
1476
|
+
const { codeFiles, resolve } = projectImports(projectRoot);
|
|
1477
|
+
const relative = (file)=>toPosix(node_path.relative(projectRoot, file));
|
|
1478
|
+
const usedBy = [];
|
|
1479
|
+
for (const [file, content] of codeFiles)if (!own.has(file)) for (const [, , specifier] of content.matchAll(importSpecifier)){
|
|
1480
|
+
const target = resolve(specifier, file)?.resolved;
|
|
1481
|
+
if (target && isModule(target)) usedBy.push([
|
|
1482
|
+
relative(file),
|
|
1483
|
+
relative(target)
|
|
1484
|
+
]);
|
|
1485
|
+
}
|
|
1486
|
+
if (usedBy.length) return {
|
|
1487
|
+
usedBy
|
|
1488
|
+
};
|
|
1489
|
+
for (const file of moduleFiles)new File(file).delete(reactFolder);
|
|
1490
|
+
for (const file of routeFileList)new File(file).delete(route.appFolder);
|
|
1491
|
+
return {
|
|
1492
|
+
deleted: [
|
|
1493
|
+
...moduleFiles,
|
|
1494
|
+
...routeFileList
|
|
1495
|
+
]
|
|
1496
|
+
};
|
|
1497
|
+
};
|
|
1498
|
+
export { ConfigFile, File, Folder, NestedName, ProjectRoot, UnknownFormatNaming, addBranchedImplementation, addClassMember, addConstructorParameters, addImport, addWireDependencies, availableDependencies, boundedContextLocation, boundedContextName, boundedContextNames, boundedContextPath, boundedContextsFolderName, branchNameSchema, canDependOn, codeExtension, compilerOption, configFileName, configSchema, configuredDependencyRules, crossContextImplementation, crossContextImportAllowed, defaultDependencyRules, deleteReactModule, discardPendingChanges, domainFirstPackages, escapeRegExp, fileModuleKind, filesToOverwrite, findReactModules, findWiredModules, frontendKindLayouts, frontendKindTitles, frontendLogicNaming, hasNeighboringBoundedContext, implementationKinds, implementationLabelSchema, implementationType, isCrossContextImplementation, isOutdatedConfig, isSuggestedFor, moduleKindOf, module_move_walk, moveReactModule, namedImportFiles, outdatedConfigMessage, pageRouteFolder, pendingChanges, projectImports, readWiredModule, relativeImport, routeFolder, routePageFile, rulesSchema, scaffoldBackendRules, splitContextSegments, stageModuleMove, toPosix, validateBoundedContextName, validateMove, wireBranches, wireDependencies, wiredDependencyNames, wiring_layers, withoutOverwrites, writePendingChanges };
|
package/dist/agent-cli.d.ts
CHANGED
|
@@ -225,8 +225,8 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
225
225
|
name: z.ZodString;
|
|
226
226
|
widgetType: z.ZodOptional<z.ZodEnum<{
|
|
227
227
|
monolithic: "monolithic";
|
|
228
|
-
separated: "separated";
|
|
229
228
|
headless: "headless";
|
|
229
|
+
separated: "separated";
|
|
230
230
|
}>>;
|
|
231
231
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
232
232
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -236,7 +236,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
236
236
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
237
237
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
238
238
|
}, z.core.$strict>, z.ZodObject<{
|
|
239
|
-
operation: z.ZodLiteral<"shared-hook">;
|
|
239
|
+
operation: z.ZodLiteral<"shared-hook" | "shared-model">;
|
|
240
240
|
name: z.ZodString;
|
|
241
241
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
242
242
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -265,7 +265,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
265
265
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
266
266
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
267
267
|
}, z.core.$strict>, z.ZodObject<{
|
|
268
|
-
operation: z.ZodLiteral<"move-shared-hook">;
|
|
268
|
+
operation: z.ZodLiteral<"move-shared-hook" | "move-shared-model">;
|
|
269
269
|
module: z.ZodString;
|
|
270
270
|
name: z.ZodString;
|
|
271
271
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -276,7 +276,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
276
276
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
277
277
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
278
278
|
}, z.core.$strict>, z.ZodObject<{
|
|
279
|
-
operation: z.ZodLiteral<"delete-shared-hook">;
|
|
279
|
+
operation: z.ZodLiteral<"delete-shared-hook" | "delete-shared-model">;
|
|
280
280
|
module: z.ZodString;
|
|
281
281
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
282
282
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -301,6 +301,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
301
301
|
playwright: "playwright";
|
|
302
302
|
}>>;
|
|
303
303
|
nextAdapter: z.ZodOptional<z.ZodBoolean>;
|
|
304
|
+
svelteAdapter: z.ZodOptional<z.ZodBoolean>;
|
|
304
305
|
configureReact: z.ZodOptional<z.ZodBoolean>;
|
|
305
306
|
replaceTestingLibrary: z.ZodOptional<z.ZodBoolean>;
|
|
306
307
|
integrationTestTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -365,7 +366,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
365
366
|
add?: ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | undefined;
|
|
366
367
|
remove?: ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | undefined;
|
|
367
368
|
}>> | undefined;
|
|
368
|
-
lint?: Partial<Record<"context-isolation" | "shared-kernel" | "layers" | "dependencies" | "react" | "clock" | "config", boolean>> | undefined;
|
|
369
|
+
lint?: Partial<Record<"context-isolation" | "shared-kernel" | "layers" | "dependencies" | "react" | "svelte" | "clock" | "config", boolean>> | undefined;
|
|
369
370
|
} | undefined;
|
|
370
371
|
} | undefined;
|
|
371
372
|
frontend?: {
|
|
@@ -375,6 +376,11 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
375
376
|
framework?: "react" | "next" | undefined;
|
|
376
377
|
storybookFramework?: string | undefined;
|
|
377
378
|
} | undefined;
|
|
379
|
+
svelte?: {
|
|
380
|
+
[x: string]: unknown;
|
|
381
|
+
framework?: "svelte" | "sveltekit" | undefined;
|
|
382
|
+
storybookFramework?: string | undefined;
|
|
383
|
+
} | undefined;
|
|
378
384
|
} | undefined;
|
|
379
385
|
} | undefined;
|
|
380
386
|
contexts: {
|
|
@@ -424,7 +430,12 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
424
430
|
available: boolean;
|
|
425
431
|
}[];
|
|
426
432
|
reactModules: {
|
|
427
|
-
kind:
|
|
433
|
+
kind: string;
|
|
434
|
+
name: string;
|
|
435
|
+
file: string;
|
|
436
|
+
}[];
|
|
437
|
+
svelteModules: {
|
|
438
|
+
kind: string;
|
|
428
439
|
name: string;
|
|
429
440
|
file: string;
|
|
430
441
|
}[];
|