@domain-first/project-structure 8.3.0 → 8.5.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 +5 -4
- package/dist/287.js +118 -30
- package/dist/38.js +23 -11
- package/dist/561.js +59 -33
- package/dist/870.js +2 -1
- package/dist/agent-cli.d.ts +24 -2
- package/dist/agent-requests.d.ts +44 -0
- package/dist/config-file.d.ts +4 -1
- package/dist/graph.cjs +2 -1
- package/dist/index.cjs +148 -33
- package/dist/init.cjs +2 -1
- package/dist/integration.cjs +177 -62
- package/dist/lint.cjs +27 -13
- package/dist/lint.js +2 -1
- package/dist/react-module-move.d.ts +26 -3
- package/dist/react.cjs +190 -63
- package/dist/react.js +13 -1
- package/dist/upgrade-steps.d.ts +1 -1
- package/dist/upgrade.cjs +2 -1
- package/package.json +1 -1
- package/skills/df-ps-implement/SKILL.md +2 -1
- package/skills/df-ps-react/SKILL.md +4 -4
- package/skills/df-ps-react/references/generators.md +4 -0
- package/skills/df-ps-scaffold/SKILL.md +1 -1
- package/skills/df-ps-scaffold/references/agent-operations.md +4 -0
- package/skills/df-ps-scaffold/references/choosing-components.md +2 -1
- package/skills/df-ps-scaffold/references/units/port.md +2 -2
package/dist/agent-requests.d.ts
CHANGED
|
@@ -220,6 +220,28 @@ export declare const reactRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
220
220
|
module: z.ZodString;
|
|
221
221
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
222
222
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
223
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
224
|
+
operation: z.ZodLiteral<"move-ui-kit-component">;
|
|
225
|
+
module: z.ZodString;
|
|
226
|
+
name: z.ZodString;
|
|
227
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
228
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
229
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
230
|
+
operation: z.ZodLiteral<"move-shared-hook">;
|
|
231
|
+
module: z.ZodString;
|
|
232
|
+
name: z.ZodString;
|
|
233
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
234
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
235
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
236
|
+
operation: z.ZodLiteral<"delete-ui-kit-component">;
|
|
237
|
+
module: z.ZodString;
|
|
238
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
239
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
240
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
241
|
+
operation: z.ZodLiteral<"delete-shared-hook">;
|
|
242
|
+
module: z.ZodString;
|
|
243
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
244
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
223
245
|
}, z.core.$strict>, z.ZodObject<{
|
|
224
246
|
operation: z.ZodLiteral<"move-widget">;
|
|
225
247
|
module: z.ZodString;
|
|
@@ -482,6 +504,28 @@ export declare const requestSchemaFor: (command: AgentCommand) => z.ZodDiscrimin
|
|
|
482
504
|
module: z.ZodString;
|
|
483
505
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
484
506
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
507
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
508
|
+
operation: z.ZodLiteral<"move-ui-kit-component">;
|
|
509
|
+
module: z.ZodString;
|
|
510
|
+
name: z.ZodString;
|
|
511
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
512
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
513
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
514
|
+
operation: z.ZodLiteral<"move-shared-hook">;
|
|
515
|
+
module: z.ZodString;
|
|
516
|
+
name: z.ZodString;
|
|
517
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
518
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
519
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
520
|
+
operation: z.ZodLiteral<"delete-ui-kit-component">;
|
|
521
|
+
module: z.ZodString;
|
|
522
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
523
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
524
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
525
|
+
operation: z.ZodLiteral<"delete-shared-hook">;
|
|
526
|
+
module: z.ZodString;
|
|
527
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
528
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
485
529
|
}, z.core.$strict>, z.ZodObject<{
|
|
486
530
|
operation: z.ZodLiteral<"move-widget">;
|
|
487
531
|
module: z.ZodString;
|
package/dist/config-file.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import z from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* `df-lint` checks that `backend.rules.lint` can turn off.
|
|
4
4
|
*/
|
|
5
|
-
export declare const lintChecks: readonly ["context-isolation", "shared-kernel", "layers", "dependencies", "react", "clock"];
|
|
5
|
+
export declare const lintChecks: readonly ["context-isolation", "shared-kernel", "layers", "dependencies", "react", "clock", "config"];
|
|
6
6
|
export type LintCheck = (typeof lintChecks)[number];
|
|
7
7
|
export declare const configFileName = "domain-first.project-structure.config.json";
|
|
8
8
|
export declare const projectConfigSchema: z.ZodObject<{
|
|
@@ -61,6 +61,7 @@ export declare const rulesSchema: z.ZodObject<{
|
|
|
61
61
|
dependencies: "dependencies";
|
|
62
62
|
react: "react";
|
|
63
63
|
clock: "clock";
|
|
64
|
+
config: "config";
|
|
64
65
|
}> & z.core.$partial, z.ZodBoolean>>;
|
|
65
66
|
}, z.core.$strip>;
|
|
66
67
|
export declare const branchNameSchema: z.ZodString;
|
|
@@ -148,6 +149,7 @@ export declare const backendConfigSchema: z.ZodObject<{
|
|
|
148
149
|
dependencies: "dependencies";
|
|
149
150
|
react: "react";
|
|
150
151
|
clock: "clock";
|
|
152
|
+
config: "config";
|
|
151
153
|
}> & z.core.$partial, z.ZodBoolean>>;
|
|
152
154
|
}, z.core.$strip>>;
|
|
153
155
|
}, z.core.$loose>;
|
|
@@ -246,6 +248,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
246
248
|
dependencies: "dependencies";
|
|
247
249
|
react: "react";
|
|
248
250
|
clock: "clock";
|
|
251
|
+
config: "config";
|
|
249
252
|
}> & z.core.$partial, z.ZodBoolean>>;
|
|
250
253
|
}, z.core.$strip>>;
|
|
251
254
|
}, z.core.$loose>>;
|
package/dist/graph.cjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -370,7 +370,8 @@ const lintChecks = [
|
|
|
370
370
|
'layers',
|
|
371
371
|
'dependencies',
|
|
372
372
|
'react',
|
|
373
|
-
'clock'
|
|
373
|
+
'clock',
|
|
374
|
+
'config'
|
|
374
375
|
];
|
|
375
376
|
const config_file_configFileName = 'domain-first.project-structure.config.json';
|
|
376
377
|
const projectConfigSchema = external_zod_default().object({
|
|
@@ -3267,6 +3268,24 @@ const reactRequestSchema = external_zod_default().discriminatedUnion('operation'
|
|
|
3267
3268
|
...common,
|
|
3268
3269
|
module: agent_requests_nestedName
|
|
3269
3270
|
}),
|
|
3271
|
+
agent_requests_operation('move-ui-kit-component', {
|
|
3272
|
+
...common,
|
|
3273
|
+
module: agent_requests_name,
|
|
3274
|
+
name: agent_requests_name
|
|
3275
|
+
}),
|
|
3276
|
+
agent_requests_operation('move-shared-hook', {
|
|
3277
|
+
...common,
|
|
3278
|
+
module: agent_requests_name,
|
|
3279
|
+
name: agent_requests_name
|
|
3280
|
+
}),
|
|
3281
|
+
agent_requests_operation('delete-ui-kit-component', {
|
|
3282
|
+
...common,
|
|
3283
|
+
module: agent_requests_name
|
|
3284
|
+
}),
|
|
3285
|
+
agent_requests_operation('delete-shared-hook', {
|
|
3286
|
+
...common,
|
|
3287
|
+
module: agent_requests_name
|
|
3288
|
+
}),
|
|
3270
3289
|
agent_requests_operation('move-widget', {
|
|
3271
3290
|
...common,
|
|
3272
3291
|
module: agent_requests_nestedName,
|
|
@@ -3972,6 +3991,66 @@ const inMemoryRepositoryWiring = (ownerFolder, unit, wireFile)=>(implementation,
|
|
|
3972
3991
|
wireInMemoryDb(wireFile, implementation.className);
|
|
3973
3992
|
return true;
|
|
3974
3993
|
};
|
|
3994
|
+
const reactKindLayouts = {
|
|
3995
|
+
page: {
|
|
3996
|
+
folder: 'pages',
|
|
3997
|
+
nested: true,
|
|
3998
|
+
inFolder: false,
|
|
3999
|
+
ownFile: (fileBase)=>new RegExp(`^${escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
4000
|
+
target: (reactFolder, { folders, fileName })=>external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page.tsx`),
|
|
4001
|
+
classPrefix: '(use)?',
|
|
4002
|
+
classSuffix: 'Page'
|
|
4003
|
+
},
|
|
4004
|
+
widget: {
|
|
4005
|
+
folder: 'widgets',
|
|
4006
|
+
nested: true,
|
|
4007
|
+
inFolder: true,
|
|
4008
|
+
target: (reactFolder, { folders, folderName })=>external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName),
|
|
4009
|
+
classPrefix: '(use)?',
|
|
4010
|
+
classSuffix: 'Widget|UIModel',
|
|
4011
|
+
storyTitle: (segments)=>[
|
|
4012
|
+
'Widgets',
|
|
4013
|
+
...segments
|
|
4014
|
+
].join('/')
|
|
4015
|
+
},
|
|
4016
|
+
'ui-kit': {
|
|
4017
|
+
folder: 'ui-kit',
|
|
4018
|
+
nested: false,
|
|
4019
|
+
inFolder: true,
|
|
4020
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, 'ui-kit', fileName),
|
|
4021
|
+
classPrefix: '()',
|
|
4022
|
+
classSuffix: 'Props(?![\\w$])|(?![\\w$])',
|
|
4023
|
+
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
4024
|
+
},
|
|
4025
|
+
hook: {
|
|
4026
|
+
folder: 'hooks',
|
|
4027
|
+
nested: false,
|
|
4028
|
+
inFolder: false,
|
|
4029
|
+
ownFile: (fileBase)=>new RegExp(`^use-${escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
4030
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, 'hooks', `use-${fileName}.ts`),
|
|
4031
|
+
classPrefix: '(use)',
|
|
4032
|
+
classSuffix: '(?![\\w$])'
|
|
4033
|
+
}
|
|
4034
|
+
};
|
|
4035
|
+
const reactKindTitles = {
|
|
4036
|
+
page: [
|
|
4037
|
+
'Page',
|
|
4038
|
+
'pages'
|
|
4039
|
+
],
|
|
4040
|
+
widget: [
|
|
4041
|
+
'Widget',
|
|
4042
|
+
'widgets'
|
|
4043
|
+
],
|
|
4044
|
+
'ui-kit': [
|
|
4045
|
+
'UI-kit component',
|
|
4046
|
+
'UI-kit components'
|
|
4047
|
+
],
|
|
4048
|
+
hook: [
|
|
4049
|
+
'Shared hook',
|
|
4050
|
+
'shared hooks'
|
|
4051
|
+
]
|
|
4052
|
+
};
|
|
4053
|
+
const reactModuleName = (kind, rawName)=>'hook' === kind ? rawName.trim().replace(/^use-/, '') : rawName;
|
|
3975
4054
|
const react_module_move_nestedName = (folders, fileBase)=>{
|
|
3976
4055
|
const prefix = `${folders.join('-')}-`;
|
|
3977
4056
|
const last = folders.length && fileBase.startsWith(prefix) ? fileBase.slice(prefix.length) : fileBase;
|
|
@@ -3985,8 +4064,36 @@ const declaredClassName = (filePath, suffix, name)=>{
|
|
|
3985
4064
|
const declared = content.match(new RegExp(`export\\s+(?:const|function)\\s+(\\w+)${suffix}\\b`))?.[1];
|
|
3986
4065
|
return declared ?? new NestedName(name).ClassName;
|
|
3987
4066
|
};
|
|
4067
|
+
const findUiKit = (reactFolder)=>{
|
|
4068
|
+
const root = external_node_path_default().join(reactFolder, 'ui-kit');
|
|
4069
|
+
if (!external_node_fs_default().existsSync(root)) return [];
|
|
4070
|
+
return external_node_fs_default().readdirSync(root, {
|
|
4071
|
+
withFileTypes: true
|
|
4072
|
+
}).filter((entry)=>entry.isDirectory() && external_node_fs_default().existsSync(external_node_path_default().join(root, entry.name, `${entry.name}.tsx`))).map(({ name })=>({
|
|
4073
|
+
kind: 'ui-kit',
|
|
4074
|
+
name,
|
|
4075
|
+
path: external_node_path_default().join(root, name),
|
|
4076
|
+
fileBase: name,
|
|
4077
|
+
ClassName: declaredClassName(external_node_path_default().join(root, name, `${name}.tsx`), '', name)
|
|
4078
|
+
}));
|
|
4079
|
+
};
|
|
4080
|
+
const findHooks = (reactFolder)=>{
|
|
4081
|
+
const root = external_node_path_default().join(reactFolder, 'hooks');
|
|
4082
|
+
if (!external_node_fs_default().existsSync(root)) return [];
|
|
4083
|
+
return external_node_fs_default().readdirSync(root).filter((file)=>/^use-.+\.tsx?$/.test(file) && !/\.(spec|test)\./.test(file)).map((file)=>{
|
|
4084
|
+
const name = file.replace(/^use-/, '').replace(/\.tsx?$/, '');
|
|
4085
|
+
const content = external_node_fs_default().readFileSync(external_node_path_default().join(root, file), 'utf8');
|
|
4086
|
+
return {
|
|
4087
|
+
kind: 'hook',
|
|
4088
|
+
name,
|
|
4089
|
+
path: external_node_path_default().join(root, file),
|
|
4090
|
+
fileBase: name,
|
|
4091
|
+
ClassName: content.match(/export\s+(?:const|function)\s+use(\w+)\b/)?.[1] ?? new NestedName(name).ClassName
|
|
4092
|
+
};
|
|
4093
|
+
});
|
|
4094
|
+
};
|
|
3988
4095
|
const findReactModules = (reactFolder, kind)=>{
|
|
3989
|
-
const modules = 'page' === kind ? module_move_walk(external_node_path_default().join(reactFolder, 'pages')).filter((file)=>file.endsWith('-page.tsx')).map((file)=>{
|
|
4096
|
+
const modules = 'ui-kit' === kind ? findUiKit(reactFolder) : 'hook' === kind ? findHooks(reactFolder) : 'page' === kind ? module_move_walk(external_node_path_default().join(reactFolder, 'pages')).filter((file)=>file.endsWith('-page.tsx')).map((file)=>{
|
|
3990
4097
|
const folders = external_node_path_default().relative(external_node_path_default().join(reactFolder, 'pages'), external_node_path_default().dirname(file)).split(external_node_path_default().sep).filter((segment)=>!!segment);
|
|
3991
4098
|
const fileBase = external_node_path_default().basename(file, '-page.tsx');
|
|
3992
4099
|
const name = react_module_move_nestedName(folders, fileBase);
|
|
@@ -4010,13 +4117,11 @@ const findReactModules = (reactFolder, kind)=>{
|
|
|
4010
4117
|
});
|
|
4011
4118
|
return modules.sort((a, b)=>a.name.localeCompare(b.name));
|
|
4012
4119
|
};
|
|
4013
|
-
const react_module_move_targetPath = (reactFolder, module, rawName)=>
|
|
4014
|
-
const { folders, folderName, fileName } = new NestedName(rawName);
|
|
4015
|
-
return 'page' === module.kind ? external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page.tsx`) : external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName);
|
|
4016
|
-
};
|
|
4120
|
+
const react_module_move_targetPath = (reactFolder, module, rawName)=>reactKindLayouts[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName)));
|
|
4017
4121
|
const validateMove = (reactFolder, module, rawName)=>{
|
|
4018
4122
|
const nameError = NestedName.validate(rawName);
|
|
4019
4123
|
if (true !== nameError) return nameError;
|
|
4124
|
+
if (!reactKindLayouts[module.kind].nested && /[\\/]/.test(rawName)) return 'UI-kit components and shared hooks have no folders: enter a name without "/"';
|
|
4020
4125
|
const target = react_module_move_targetPath(reactFolder, module, rawName);
|
|
4021
4126
|
if (target !== module.path && external_node_fs_default().existsSync(target)) return `${external_node_path_default().relative(reactFolder, target)} already exists`;
|
|
4022
4127
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
@@ -4030,13 +4135,14 @@ const routeFiles = (folder)=>external_node_fs_default().existsSync(folder) ? ext
|
|
|
4030
4135
|
withFileTypes: true
|
|
4031
4136
|
}).filter((entry)=>entry.isFile()).map((entry)=>external_node_path_default().join(folder, entry.name)) : [];
|
|
4032
4137
|
const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
4033
|
-
const
|
|
4138
|
+
const layout = reactKindLayouts[module.kind];
|
|
4139
|
+
const newName = new NestedName(reactModuleName(module.kind, rawName));
|
|
4034
4140
|
const target = react_module_move_targetPath(reactFolder, module, rawName);
|
|
4035
4141
|
const newClassName = newName.ClassName;
|
|
4036
|
-
const renameFile = (name)=>name.replace(new RegExp(`^(use-)?${escapeRegExp(module.fileBase)}(?=[-.])`), (_, use = '')=>`${use}${newName.fileName}`);
|
|
4037
|
-
const oldFolder =
|
|
4038
|
-
const newFolder =
|
|
4039
|
-
const ownsPath = (candidate)=>
|
|
4142
|
+
const renameFile = (name)=>name.replace(new RegExp(`^(use-)?${escapeRegExp(module.fileBase)}(?=[-.]|$)`), (_, use = '')=>`${use}${newName.fileName}`);
|
|
4143
|
+
const oldFolder = layout.inFolder ? module.path : external_node_path_default().dirname(module.path);
|
|
4144
|
+
const newFolder = layout.inFolder ? target : external_node_path_default().dirname(target);
|
|
4145
|
+
const ownsPath = (candidate)=>layout.inFolder ? candidate === oldFolder || candidate.startsWith(`${oldFolder}${external_node_path_default().sep}`) : external_node_path_default().dirname(candidate) === oldFolder && layout.ownFile(module.fileBase).test(external_node_path_default().basename(candidate));
|
|
4040
4146
|
const routeFileSet = new Set(route ? routeFiles(route.from) : []);
|
|
4041
4147
|
const routeTarget = (candidate)=>{
|
|
4042
4148
|
if (!route) return;
|
|
@@ -4056,7 +4162,7 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
4056
4162
|
segments[last] = renameFile(segments[last]);
|
|
4057
4163
|
return external_node_path_default().join(newFolder, ...segments);
|
|
4058
4164
|
};
|
|
4059
|
-
const moduleFiles =
|
|
4165
|
+
const moduleFiles = reactModuleFiles(module);
|
|
4060
4166
|
const moves = new Map([
|
|
4061
4167
|
...moduleFiles,
|
|
4062
4168
|
...routeFileSet
|
|
@@ -4064,14 +4170,14 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
4064
4170
|
file,
|
|
4065
4171
|
movedPath(file) ?? file
|
|
4066
4172
|
]));
|
|
4067
|
-
const
|
|
4068
|
-
const
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
const
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
].
|
|
4173
|
+
const classPattern = new RegExp(`(?<![\\w$])${layout.classPrefix}${escapeRegExp(module.ClassName)}(?=${layout.classSuffix})`, 'g');
|
|
4174
|
+
const oldTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
|
|
4175
|
+
module.ClassName
|
|
4176
|
+
] : module.name.split('/').map((segment)=>new NestedName(segment).ClassName));
|
|
4177
|
+
const titlePattern = oldTitle && new RegExp(`(['"\`])${escapeRegExp(oldTitle)}\\1`, 'g');
|
|
4178
|
+
const newTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
|
|
4179
|
+
newClassName
|
|
4180
|
+
] : newName.classNameSegments);
|
|
4075
4181
|
return stageModuleMove({
|
|
4076
4182
|
projectRoot,
|
|
4077
4183
|
stopAt: reactFolder,
|
|
@@ -4079,8 +4185,8 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
4079
4185
|
moves,
|
|
4080
4186
|
movedPath,
|
|
4081
4187
|
rename: (content, { moved })=>{
|
|
4082
|
-
const renamed = content.replace(classPattern, (_, use
|
|
4083
|
-
return moved &&
|
|
4188
|
+
const renamed = content.replace(classPattern, (_, use)=>`${use ?? ''}${newClassName}`);
|
|
4189
|
+
return moved && titlePattern ? renamed.replace(titlePattern, (_, quote)=>`${quote}${newTitle}${quote}`) : renamed;
|
|
4084
4190
|
}
|
|
4085
4191
|
});
|
|
4086
4192
|
};
|
|
@@ -4090,9 +4196,10 @@ const pageRouteFolder = (appFolder, page)=>{
|
|
|
4090
4196
|
return external_node_fs_default().existsSync(routePage) && new RegExp(`(?<![\\w$])${page.ClassName}Page(?![\\w$])`).test(external_node_fs_default().readFileSync(routePage, 'utf8')) ? folder : void 0;
|
|
4091
4197
|
};
|
|
4092
4198
|
const reactModuleFiles = (module)=>{
|
|
4093
|
-
|
|
4199
|
+
const layout = reactKindLayouts[module.kind];
|
|
4200
|
+
if (layout.inFolder) return module_move_walk(module.path);
|
|
4094
4201
|
const folder = external_node_path_default().dirname(module.path);
|
|
4095
|
-
const own =
|
|
4202
|
+
const own = layout.ownFile(module.fileBase);
|
|
4096
4203
|
return external_node_fs_default().readdirSync(folder, {
|
|
4097
4204
|
withFileTypes: true
|
|
4098
4205
|
}).filter((entry)=>entry.isFile() && own.test(entry.name)).map((entry)=>external_node_path_default().join(folder, entry.name));
|
|
@@ -4106,7 +4213,7 @@ const deleteReactModule = (projectRoot, reactFolder, module, route)=>{
|
|
|
4106
4213
|
...routeFileList
|
|
4107
4214
|
]);
|
|
4108
4215
|
const stems = new Set(moduleFiles.map((file)=>file.replace(codeExtension, '')));
|
|
4109
|
-
const isModule = (resolved)=>stems.has(resolved) ||
|
|
4216
|
+
const isModule = (resolved)=>stems.has(resolved) || reactKindLayouts[module.kind].inFolder && (resolved === module.path || resolved.startsWith(`${module.path}${external_node_path_default().sep}`));
|
|
4110
4217
|
const { codeFiles, resolve } = projectImports(projectRoot);
|
|
4111
4218
|
const relative = (file)=>toPosix(external_node_path_default().relative(projectRoot, file));
|
|
4112
4219
|
const usedBy = [];
|
|
@@ -4197,11 +4304,11 @@ const deleteBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
4197
4304
|
const deleteReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
4198
4305
|
const reactFolder = presentationReactFolder.path;
|
|
4199
4306
|
const modules = findReactModules(reactFolder, kind);
|
|
4200
|
-
if (!modules.length) return void report(`No ${kind}
|
|
4307
|
+
if (!modules.length) return void report(`No ${reactKindTitles[kind][1]} generated by df-react were found.`);
|
|
4201
4308
|
const module = await interaction_select({
|
|
4202
4309
|
key: 'module',
|
|
4203
4310
|
id: (value)=>value.name,
|
|
4204
|
-
message:
|
|
4311
|
+
message: `${reactKindTitles[kind][0]} to delete:`,
|
|
4205
4312
|
choices: modules.map((value)=>({
|
|
4206
4313
|
name: value.name,
|
|
4207
4314
|
value,
|
|
@@ -4367,11 +4474,11 @@ const promptRouteMove = async (root, page, newName)=>{
|
|
|
4367
4474
|
const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
4368
4475
|
const reactFolder = presentationReactFolder.path;
|
|
4369
4476
|
const modules = findReactModules(reactFolder, kind);
|
|
4370
|
-
if (!modules.length) return void report(`No ${kind}
|
|
4477
|
+
if (!modules.length) return void report(`No ${reactKindTitles[kind][1]} generated by df-react were found.`);
|
|
4371
4478
|
const module = await interaction_select({
|
|
4372
4479
|
key: 'module',
|
|
4373
4480
|
id: (value)=>value.name,
|
|
4374
|
-
message:
|
|
4481
|
+
message: `${reactKindTitles[kind][0]}:`,
|
|
4375
4482
|
choices: modules.map((value)=>({
|
|
4376
4483
|
name: value.name,
|
|
4377
4484
|
value,
|
|
@@ -4380,7 +4487,7 @@ const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
|
4380
4487
|
});
|
|
4381
4488
|
const name = await interaction_input({
|
|
4382
4489
|
key: 'name',
|
|
4383
|
-
message: 'New name (folders split by "/"):',
|
|
4490
|
+
message: reactKindLayouts[kind].nested ? 'New name (folders split by "/"):' : 'New name:',
|
|
4384
4491
|
default: module.name,
|
|
4385
4492
|
validate: (value)=>validateMove(reactFolder, module, value)
|
|
4386
4493
|
});
|
|
@@ -5736,7 +5843,9 @@ const describeAgentCommand = (command)=>{
|
|
|
5736
5843
|
integrations: integrationDescriptionsSafe(configured),
|
|
5737
5844
|
reactModules: config?.frontend?.react ? [
|
|
5738
5845
|
'page',
|
|
5739
|
-
'widget'
|
|
5846
|
+
'widget',
|
|
5847
|
+
'ui-kit',
|
|
5848
|
+
'hook'
|
|
5740
5849
|
].flatMap((kind)=>findReactModules(external_node_path_default().join(root, config.project.rootFolder, 'presentation/react'), kind).map((module)=>({
|
|
5741
5850
|
kind,
|
|
5742
5851
|
name: module.name,
|
|
@@ -5846,7 +5955,9 @@ const executeReact = async (request)=>{
|
|
|
5846
5955
|
config_file_ConfigFile.Instance.data.project.rootFolder,
|
|
5847
5956
|
'presentation/react'
|
|
5848
5957
|
]);
|
|
5849
|
-
|
|
5958
|
+
const kindOf = (operation)=>operation.endsWith('-page') ? 'page' : operation.endsWith('-widget') ? 'widget' : operation.endsWith('-ui-kit-component') ? 'ui-kit' : operation.endsWith('-shared-hook') ? 'hook' : void 0;
|
|
5959
|
+
const kind = /^(move|delete)-/.test(request.operation) ? kindOf(request.operation) : void 0;
|
|
5960
|
+
if (kind && !findReactModules(folder.path, kind).length) throw new RequestError('TARGET_NOT_FOUND', `No React ${reactKindTitles[kind][1]} here.`);
|
|
5850
5961
|
const actions = {
|
|
5851
5962
|
page: ()=>scaffoldReactPage(folder),
|
|
5852
5963
|
widget: ()=>scaffoldReactWidget(folder),
|
|
@@ -5855,7 +5966,11 @@ const executeReact = async (request)=>{
|
|
|
5855
5966
|
'move-page': ()=>moveReactModuleUseCase(folder, 'page'),
|
|
5856
5967
|
'move-widget': ()=>moveReactModuleUseCase(folder, 'widget'),
|
|
5857
5968
|
'delete-page': ()=>deleteReactModuleUseCase(folder, 'page'),
|
|
5858
|
-
'delete-widget': ()=>deleteReactModuleUseCase(folder, 'widget')
|
|
5969
|
+
'delete-widget': ()=>deleteReactModuleUseCase(folder, 'widget'),
|
|
5970
|
+
'move-ui-kit-component': ()=>moveReactModuleUseCase(folder, 'ui-kit'),
|
|
5971
|
+
'move-shared-hook': ()=>moveReactModuleUseCase(folder, 'hook'),
|
|
5972
|
+
'delete-ui-kit-component': ()=>deleteReactModuleUseCase(folder, 'ui-kit'),
|
|
5973
|
+
'delete-shared-hook': ()=>deleteReactModuleUseCase(folder, 'hook')
|
|
5859
5974
|
};
|
|
5860
5975
|
return actions[request.operation]();
|
|
5861
5976
|
};
|
package/dist/init.cjs
CHANGED
|
@@ -298,7 +298,8 @@ const lintChecks = [
|
|
|
298
298
|
'layers',
|
|
299
299
|
'dependencies',
|
|
300
300
|
'react',
|
|
301
|
-
'clock'
|
|
301
|
+
'clock',
|
|
302
|
+
'config'
|
|
302
303
|
];
|
|
303
304
|
const config_file_configFileName = 'domain-first.project-structure.config.json';
|
|
304
305
|
const projectConfigSchema = external_zod_default().object({
|