@domain-first/project-structure 8.2.0 → 8.4.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 -1
- package/dist/287.js +333 -30
- package/dist/561.js +75 -32
- package/dist/agent-cli.d.ts +40 -1
- package/dist/agent-requests.d.ts +78 -0
- package/dist/backend-module-move.d.ts +16 -0
- package/dist/index.cjs +383 -35
- package/dist/index.js +4 -2
- package/dist/init.cjs +55 -55
- package/dist/integration.cjs +406 -60
- package/dist/react-module-move.d.ts +47 -3
- package/dist/react.cjs +425 -61
- package/dist/react.js +20 -2
- package/dist/use-cases/delete-backend-unit.d.ts +6 -0
- package/dist/use-cases/delete-react-module.d.ts +8 -0
- package/dist/use-cases/index.d.ts +2 -0
- package/package.json +1 -1
- package/skills/df-ps-react/SKILL.md +5 -3
- package/skills/df-ps-react/references/generators.md +8 -0
- package/skills/df-ps-scaffold/SKILL.md +5 -4
- package/skills/df-ps-scaffold/references/agent-mode.md +1 -0
- package/skills/df-ps-scaffold/references/agent-operations.md +7 -0
- package/skills/df-ps-scaffold/references/units/delete.md +19 -0
- package/skills/df-ps-scaffold/scripts/drive.mjs +5 -0
package/dist/integration.cjs
CHANGED
|
@@ -3127,68 +3127,68 @@ const named = {
|
|
|
3127
3127
|
...agent_requests_owner,
|
|
3128
3128
|
name: agent_requests_name
|
|
3129
3129
|
};
|
|
3130
|
-
const
|
|
3130
|
+
const agent_requests_operation = (value, shape)=>external_zod_default().strictObject({
|
|
3131
3131
|
operation: external_zod_default().literal(value),
|
|
3132
3132
|
...shape
|
|
3133
3133
|
});
|
|
3134
3134
|
const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operation', [
|
|
3135
|
-
|
|
3135
|
+
agent_requests_operation('bounded-context', {
|
|
3136
3136
|
...common,
|
|
3137
3137
|
name: agent_requests_name.refine((value)=>'shared-kernel' !== value, 'shared-kernel is reserved for the Shared Kernel.')
|
|
3138
3138
|
}),
|
|
3139
|
-
|
|
3139
|
+
agent_requests_operation('aggregate', {
|
|
3140
3140
|
...named,
|
|
3141
3141
|
withRepository: external_zod_default().boolean().optional(),
|
|
3142
3142
|
implementation: agent_requests_implementation.optional(),
|
|
3143
3143
|
testImplementation: agent_requests_implementation.optional(),
|
|
3144
3144
|
...agent_requests_wired
|
|
3145
3145
|
}),
|
|
3146
|
-
|
|
3146
|
+
agent_requests_operation('entity', {
|
|
3147
3147
|
...named,
|
|
3148
3148
|
aggregate: agent_requests_name.optional()
|
|
3149
3149
|
}),
|
|
3150
|
-
|
|
3150
|
+
agent_requests_operation('value-object', {
|
|
3151
3151
|
...named,
|
|
3152
3152
|
aggregate: agent_requests_name.optional()
|
|
3153
3153
|
}),
|
|
3154
|
-
|
|
3154
|
+
agent_requests_operation('error', {
|
|
3155
3155
|
...named,
|
|
3156
3156
|
namespace: agent_requests_name.optional()
|
|
3157
3157
|
}),
|
|
3158
|
-
|
|
3159
|
-
|
|
3158
|
+
agent_requests_operation('error-namespace', named),
|
|
3159
|
+
agent_requests_operation('domain-service', {
|
|
3160
3160
|
...named,
|
|
3161
3161
|
...agent_requests_wired
|
|
3162
3162
|
}),
|
|
3163
|
-
|
|
3163
|
+
agent_requests_operation('application-service', {
|
|
3164
3164
|
...named,
|
|
3165
3165
|
...agent_requests_wired
|
|
3166
3166
|
}),
|
|
3167
|
-
|
|
3167
|
+
agent_requests_operation('infrastructure-service', {
|
|
3168
3168
|
...named,
|
|
3169
3169
|
...agent_requests_wired
|
|
3170
3170
|
}),
|
|
3171
|
-
|
|
3171
|
+
agent_requests_operation('presentation-service', {
|
|
3172
3172
|
...named,
|
|
3173
3173
|
...agent_requests_wired
|
|
3174
3174
|
}),
|
|
3175
|
-
|
|
3175
|
+
agent_requests_operation('use-case', {
|
|
3176
3176
|
...named,
|
|
3177
3177
|
...agent_requests_wired
|
|
3178
3178
|
}),
|
|
3179
|
-
|
|
3179
|
+
agent_requests_operation('command', {
|
|
3180
3180
|
...named,
|
|
3181
3181
|
...agent_requests_implementations
|
|
3182
3182
|
}),
|
|
3183
|
-
|
|
3183
|
+
agent_requests_operation('query', {
|
|
3184
3184
|
...named,
|
|
3185
3185
|
...agent_requests_implementations
|
|
3186
3186
|
}),
|
|
3187
|
-
|
|
3187
|
+
agent_requests_operation('port', {
|
|
3188
3188
|
...named,
|
|
3189
3189
|
...agent_requests_implementations
|
|
3190
3190
|
}),
|
|
3191
|
-
|
|
3191
|
+
agent_requests_operation('implementation', {
|
|
3192
3192
|
...common,
|
|
3193
3193
|
...agent_requests_owner,
|
|
3194
3194
|
contract: agent_requests_id.describe('Exact contract ID from --describe.'),
|
|
@@ -3196,7 +3196,7 @@ const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operati
|
|
|
3196
3196
|
environments: external_zod_default().array(agent_requests_name).min(1).optional().describe('Required when the contract wire is envBranchedWire; omit it otherwise.'),
|
|
3197
3197
|
...agent_requests_wired
|
|
3198
3198
|
}),
|
|
3199
|
-
|
|
3199
|
+
agent_requests_operation('endpoint', {
|
|
3200
3200
|
...common,
|
|
3201
3201
|
...agent_requests_owner,
|
|
3202
3202
|
controller: agent_requests_name,
|
|
@@ -3210,13 +3210,18 @@ const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operati
|
|
|
3210
3210
|
path: external_zod_default().string().regex(/^(?:\/?(?:[a-zA-Z0-9_-]+|:[a-zA-Z][a-zA-Z0-9_]*))*\/?$/),
|
|
3211
3211
|
handler: agent_requests_id.optional().describe('Exact handler module ID from --describe. Required when the context has wired queries, commands or use cases; omit it otherwise.')
|
|
3212
3212
|
}),
|
|
3213
|
-
|
|
3213
|
+
agent_requests_operation('wire-dependency', {
|
|
3214
3214
|
...common,
|
|
3215
3215
|
...agent_requests_owner,
|
|
3216
3216
|
module: agent_requests_id.describe('Exact wiring target ID, including implementation class, from --describe.'),
|
|
3217
3217
|
dependencies: agent_requests_dependencies
|
|
3218
3218
|
}),
|
|
3219
|
-
|
|
3219
|
+
agent_requests_operation('delete', {
|
|
3220
|
+
...common,
|
|
3221
|
+
...agent_requests_owner,
|
|
3222
|
+
module: agent_requests_id.describe('Exact unit ID from --describe. Refused while other files use it.')
|
|
3223
|
+
}),
|
|
3224
|
+
agent_requests_operation('move', {
|
|
3220
3225
|
...common,
|
|
3221
3226
|
...agent_requests_owner,
|
|
3222
3227
|
module: agent_requests_id.describe('Exact unit ID from --describe.'),
|
|
@@ -3226,11 +3231,11 @@ const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operati
|
|
|
3226
3231
|
})
|
|
3227
3232
|
]);
|
|
3228
3233
|
const reactRequestSchema = external_zod_default().discriminatedUnion('operation', [
|
|
3229
|
-
|
|
3234
|
+
agent_requests_operation('page', {
|
|
3230
3235
|
...common,
|
|
3231
3236
|
name: agent_requests_nestedName
|
|
3232
3237
|
}),
|
|
3233
|
-
|
|
3238
|
+
agent_requests_operation('widget', {
|
|
3234
3239
|
...common,
|
|
3235
3240
|
name: agent_requests_nestedName,
|
|
3236
3241
|
widgetType: external_zod_default()["enum"]([
|
|
@@ -3239,28 +3244,55 @@ const reactRequestSchema = external_zod_default().discriminatedUnion('operation'
|
|
|
3239
3244
|
'headless'
|
|
3240
3245
|
]).optional()
|
|
3241
3246
|
}),
|
|
3242
|
-
|
|
3247
|
+
agent_requests_operation('ui-kit-component', {
|
|
3243
3248
|
...common,
|
|
3244
3249
|
name: agent_requests_name
|
|
3245
3250
|
}),
|
|
3246
|
-
|
|
3251
|
+
agent_requests_operation('shared-hook', {
|
|
3247
3252
|
...common,
|
|
3248
3253
|
name: agent_requests_name
|
|
3249
3254
|
}),
|
|
3250
|
-
|
|
3255
|
+
agent_requests_operation('move-page', {
|
|
3251
3256
|
...common,
|
|
3252
3257
|
module: agent_requests_nestedName,
|
|
3253
3258
|
name: agent_requests_nestedName,
|
|
3254
3259
|
moveRoute: external_zod_default().boolean().optional().describe('With Next.js and a route at the page path: move it too (default true). Omit it without such a route.')
|
|
3255
3260
|
}),
|
|
3256
|
-
|
|
3261
|
+
agent_requests_operation('delete-page', {
|
|
3262
|
+
...common,
|
|
3263
|
+
module: agent_requests_nestedName,
|
|
3264
|
+
deleteRoute: external_zod_default().boolean().optional().describe("With Next.js and the page's own route: delete it too (default true). Omit it without such a route.")
|
|
3265
|
+
}),
|
|
3266
|
+
agent_requests_operation('delete-widget', {
|
|
3267
|
+
...common,
|
|
3268
|
+
module: agent_requests_nestedName
|
|
3269
|
+
}),
|
|
3270
|
+
agent_requests_operation('move-ui-kit-component', {
|
|
3271
|
+
...common,
|
|
3272
|
+
module: agent_requests_name,
|
|
3273
|
+
name: agent_requests_name
|
|
3274
|
+
}),
|
|
3275
|
+
agent_requests_operation('move-shared-hook', {
|
|
3276
|
+
...common,
|
|
3277
|
+
module: agent_requests_name,
|
|
3278
|
+
name: agent_requests_name
|
|
3279
|
+
}),
|
|
3280
|
+
agent_requests_operation('delete-ui-kit-component', {
|
|
3281
|
+
...common,
|
|
3282
|
+
module: agent_requests_name
|
|
3283
|
+
}),
|
|
3284
|
+
agent_requests_operation('delete-shared-hook', {
|
|
3285
|
+
...common,
|
|
3286
|
+
module: agent_requests_name
|
|
3287
|
+
}),
|
|
3288
|
+
agent_requests_operation('move-widget', {
|
|
3257
3289
|
...common,
|
|
3258
3290
|
module: agent_requests_nestedName,
|
|
3259
3291
|
name: agent_requests_nestedName
|
|
3260
3292
|
})
|
|
3261
3293
|
]);
|
|
3262
3294
|
const agent_requests_relativePath = external_zod_default().string().regex(/^[a-zA-Z0-9_.-]+(?:\/[a-zA-Z0-9_.-]+)*$/).refine((value)=>!value.split('/').some((part)=>'.' === part || '..' === part), 'Use a project-relative path without . or .. segments.');
|
|
3263
|
-
const integrationRequestSchema =
|
|
3295
|
+
const integrationRequestSchema = agent_requests_operation('add', {
|
|
3264
3296
|
...common,
|
|
3265
3297
|
integrations: external_zod_default().array(external_zod_default()["enum"](integrationIds)).min(1),
|
|
3266
3298
|
nextAdapter: external_zod_default().boolean().optional(),
|
|
@@ -3756,6 +3788,75 @@ const projectRelative = (fromFile, toFile)=>{
|
|
|
3756
3788
|
const relative = toPosix(external_node_path_default().relative(external_node_path_default().dirname(fromFile), toFile.replace(codeExtension, '')));
|
|
3757
3789
|
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
3758
3790
|
};
|
|
3791
|
+
const importSpecifier = /(?:\bfrom\s*|\bimport\s*\(\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"\n]+)\1/g;
|
|
3792
|
+
const backend_module_move_importLine = /^\s*(?:import|export)\b[^'"\n]*\bfrom\s*(['"])([^'"\n]+)\1;?\s*$/;
|
|
3793
|
+
const deleteBackendUnit = (projectRoot, rootFolderPath, unit)=>{
|
|
3794
|
+
const files = [
|
|
3795
|
+
...unitMoves(unit, unit).keys()
|
|
3796
|
+
];
|
|
3797
|
+
const fileSet = new Set(files);
|
|
3798
|
+
const stems = new Set(files.map((file)=>file.replace(codeExtension, '')));
|
|
3799
|
+
const aggregateFolder = 'aggregate' === unit.kind ? external_node_path_default().join(unit.ownerPath, 'domain/aggregates', unit.name) : void 0;
|
|
3800
|
+
const parentAggregate = unit.aggregate ? external_node_path_default().join(unit.ownerPath, 'domain/aggregates', unit.aggregate) : void 0;
|
|
3801
|
+
const isUnit = (resolved)=>stems.has(resolved) || !!aggregateFolder && (resolved === aggregateFolder || resolved.startsWith(`${aggregateFolder}${external_node_path_default().sep}`));
|
|
3802
|
+
const isParentBarrel = (resolved)=>!!parentAggregate && (resolved === parentAggregate || resolved === external_node_path_default().join(parentAggregate, 'index'));
|
|
3803
|
+
const { codeFiles, resolve } = projectImports(projectRoot);
|
|
3804
|
+
const resolved = (specifier, file)=>resolve(specifier, file)?.resolved;
|
|
3805
|
+
const withoutUnitImports = (content, file)=>content.split('\n').filter((line)=>{
|
|
3806
|
+
const specifier = line.match(backend_module_move_importLine)?.[2];
|
|
3807
|
+
const target = specifier && resolved(specifier, file);
|
|
3808
|
+
return !(target && isUnit(target));
|
|
3809
|
+
}).join('\n');
|
|
3810
|
+
const cleaned = new Map();
|
|
3811
|
+
const inMemoryDb = inMemoryDbFile(rootFolderPath);
|
|
3812
|
+
if ('aggregate' === unit.kind && codeFiles.has(inMemoryDb)) {
|
|
3813
|
+
const section = new UnknownFormatNaming(plural(unit.name));
|
|
3814
|
+
const original = codeFiles.get(inMemoryDb);
|
|
3815
|
+
const content = withoutUnitImports(original.replace(new RegExp(`^[ \\t]*${escapeRegExp(section.variableName)}\\s*=\\s*this\\.section<[^\\n]*\\n?`, 'm'), ''), inMemoryDb);
|
|
3816
|
+
if (content !== original) cleaned.set(inMemoryDb, content);
|
|
3817
|
+
}
|
|
3818
|
+
if (parentAggregate) {
|
|
3819
|
+
const index = external_node_path_default().join(parentAggregate, 'index.ts');
|
|
3820
|
+
const original = codeFiles.get(index);
|
|
3821
|
+
if (void 0 !== original) {
|
|
3822
|
+
const content = withoutUnitImports(original, index);
|
|
3823
|
+
if (content !== original) cleaned.set(index, content);
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
const ClassName = new UnknownFormatNaming(unit.name).ClassName;
|
|
3827
|
+
const namedImports = /import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*(['"])([^'"\n]+)\2/g;
|
|
3828
|
+
const usedBy = [];
|
|
3829
|
+
const relative = (file)=>toPosix(external_node_path_default().relative(projectRoot, file));
|
|
3830
|
+
for (const [file, original] of codeFiles){
|
|
3831
|
+
if (fileSet.has(file)) continue;
|
|
3832
|
+
const content = cleaned.get(file) ?? original;
|
|
3833
|
+
for (const [, , specifier] of content.matchAll(importSpecifier)){
|
|
3834
|
+
const target = resolved(specifier, file);
|
|
3835
|
+
if (target && isUnit(target)) usedBy.push([
|
|
3836
|
+
relative(file),
|
|
3837
|
+
relative(target)
|
|
3838
|
+
]);
|
|
3839
|
+
}
|
|
3840
|
+
for (const [, names, , specifier] of content.matchAll(namedImports)){
|
|
3841
|
+
const target = resolved(specifier, file);
|
|
3842
|
+
if (target && isParentBarrel(target) && new RegExp(`(?<![\\w$])${ClassName}(?![\\w$])`).test(names)) usedBy.push([
|
|
3843
|
+
relative(file),
|
|
3844
|
+
`${relative(target)} (${ClassName})`
|
|
3845
|
+
]);
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
if (usedBy.length) return {
|
|
3849
|
+
usedBy
|
|
3850
|
+
};
|
|
3851
|
+
for (const file of files)new file_system_File(file).delete(rootFolderPath);
|
|
3852
|
+
for (const [file, content] of cleaned)new file_system_File(file).update(content);
|
|
3853
|
+
return {
|
|
3854
|
+
deleted: files,
|
|
3855
|
+
updated: [
|
|
3856
|
+
...cleaned.keys()
|
|
3857
|
+
]
|
|
3858
|
+
};
|
|
3859
|
+
};
|
|
3759
3860
|
const contractKinds = [
|
|
3760
3861
|
'aggregate',
|
|
3761
3862
|
'command',
|
|
@@ -3889,6 +3990,66 @@ const inMemoryRepositoryWiring = (ownerFolder, unit, wireFile)=>(implementation,
|
|
|
3889
3990
|
wireInMemoryDb(wireFile, implementation.className);
|
|
3890
3991
|
return true;
|
|
3891
3992
|
};
|
|
3993
|
+
const reactKindLayouts = {
|
|
3994
|
+
page: {
|
|
3995
|
+
folder: 'pages',
|
|
3996
|
+
nested: true,
|
|
3997
|
+
inFolder: false,
|
|
3998
|
+
ownFile: (fileBase)=>new RegExp(`^${escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
3999
|
+
target: (reactFolder, { folders, fileName })=>external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page.tsx`),
|
|
4000
|
+
classPrefix: '(use)?',
|
|
4001
|
+
classSuffix: 'Page'
|
|
4002
|
+
},
|
|
4003
|
+
widget: {
|
|
4004
|
+
folder: 'widgets',
|
|
4005
|
+
nested: true,
|
|
4006
|
+
inFolder: true,
|
|
4007
|
+
target: (reactFolder, { folders, folderName })=>external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName),
|
|
4008
|
+
classPrefix: '(use)?',
|
|
4009
|
+
classSuffix: 'Widget|UIModel',
|
|
4010
|
+
storyTitle: (segments)=>[
|
|
4011
|
+
'Widgets',
|
|
4012
|
+
...segments
|
|
4013
|
+
].join('/')
|
|
4014
|
+
},
|
|
4015
|
+
'ui-kit': {
|
|
4016
|
+
folder: 'ui-kit',
|
|
4017
|
+
nested: false,
|
|
4018
|
+
inFolder: true,
|
|
4019
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, 'ui-kit', fileName),
|
|
4020
|
+
classPrefix: '()',
|
|
4021
|
+
classSuffix: 'Props(?![\\w$])|(?![\\w$])',
|
|
4022
|
+
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
4023
|
+
},
|
|
4024
|
+
hook: {
|
|
4025
|
+
folder: 'hooks',
|
|
4026
|
+
nested: false,
|
|
4027
|
+
inFolder: false,
|
|
4028
|
+
ownFile: (fileBase)=>new RegExp(`^use-${escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
4029
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, 'hooks', `use-${fileName}.ts`),
|
|
4030
|
+
classPrefix: '(use)',
|
|
4031
|
+
classSuffix: '(?![\\w$])'
|
|
4032
|
+
}
|
|
4033
|
+
};
|
|
4034
|
+
const reactKindTitles = {
|
|
4035
|
+
page: [
|
|
4036
|
+
'Page',
|
|
4037
|
+
'pages'
|
|
4038
|
+
],
|
|
4039
|
+
widget: [
|
|
4040
|
+
'Widget',
|
|
4041
|
+
'widgets'
|
|
4042
|
+
],
|
|
4043
|
+
'ui-kit': [
|
|
4044
|
+
'UI-kit component',
|
|
4045
|
+
'UI-kit components'
|
|
4046
|
+
],
|
|
4047
|
+
hook: [
|
|
4048
|
+
'Shared hook',
|
|
4049
|
+
'shared hooks'
|
|
4050
|
+
]
|
|
4051
|
+
};
|
|
4052
|
+
const reactModuleName = (kind, rawName)=>'hook' === kind ? rawName.trim().replace(/^use-/, '') : rawName;
|
|
3892
4053
|
const react_module_move_nestedName = (folders, fileBase)=>{
|
|
3893
4054
|
const prefix = `${folders.join('-')}-`;
|
|
3894
4055
|
const last = folders.length && fileBase.startsWith(prefix) ? fileBase.slice(prefix.length) : fileBase;
|
|
@@ -3902,8 +4063,36 @@ const declaredClassName = (filePath, suffix, name)=>{
|
|
|
3902
4063
|
const declared = content.match(new RegExp(`export\\s+(?:const|function)\\s+(\\w+)${suffix}\\b`))?.[1];
|
|
3903
4064
|
return declared ?? new NestedName(name).ClassName;
|
|
3904
4065
|
};
|
|
4066
|
+
const findUiKit = (reactFolder)=>{
|
|
4067
|
+
const root = external_node_path_default().join(reactFolder, 'ui-kit');
|
|
4068
|
+
if (!external_node_fs_default().existsSync(root)) return [];
|
|
4069
|
+
return external_node_fs_default().readdirSync(root, {
|
|
4070
|
+
withFileTypes: true
|
|
4071
|
+
}).filter((entry)=>entry.isDirectory() && external_node_fs_default().existsSync(external_node_path_default().join(root, entry.name, `${entry.name}.tsx`))).map(({ name })=>({
|
|
4072
|
+
kind: 'ui-kit',
|
|
4073
|
+
name,
|
|
4074
|
+
path: external_node_path_default().join(root, name),
|
|
4075
|
+
fileBase: name,
|
|
4076
|
+
ClassName: declaredClassName(external_node_path_default().join(root, name, `${name}.tsx`), '', name)
|
|
4077
|
+
}));
|
|
4078
|
+
};
|
|
4079
|
+
const findHooks = (reactFolder)=>{
|
|
4080
|
+
const root = external_node_path_default().join(reactFolder, 'hooks');
|
|
4081
|
+
if (!external_node_fs_default().existsSync(root)) return [];
|
|
4082
|
+
return external_node_fs_default().readdirSync(root).filter((file)=>/^use-.+\.tsx?$/.test(file) && !/\.(spec|test)\./.test(file)).map((file)=>{
|
|
4083
|
+
const name = file.replace(/^use-/, '').replace(/\.tsx?$/, '');
|
|
4084
|
+
const content = external_node_fs_default().readFileSync(external_node_path_default().join(root, file), 'utf8');
|
|
4085
|
+
return {
|
|
4086
|
+
kind: 'hook',
|
|
4087
|
+
name,
|
|
4088
|
+
path: external_node_path_default().join(root, file),
|
|
4089
|
+
fileBase: name,
|
|
4090
|
+
ClassName: content.match(/export\s+(?:const|function)\s+use(\w+)\b/)?.[1] ?? new NestedName(name).ClassName
|
|
4091
|
+
};
|
|
4092
|
+
});
|
|
4093
|
+
};
|
|
3905
4094
|
const findReactModules = (reactFolder, kind)=>{
|
|
3906
|
-
const modules = 'page' === kind ? module_move_walk(external_node_path_default().join(reactFolder, 'pages')).filter((file)=>file.endsWith('-page.tsx')).map((file)=>{
|
|
4095
|
+
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)=>{
|
|
3907
4096
|
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);
|
|
3908
4097
|
const fileBase = external_node_path_default().basename(file, '-page.tsx');
|
|
3909
4098
|
const name = react_module_move_nestedName(folders, fileBase);
|
|
@@ -3927,19 +4116,17 @@ const findReactModules = (reactFolder, kind)=>{
|
|
|
3927
4116
|
});
|
|
3928
4117
|
return modules.sort((a, b)=>a.name.localeCompare(b.name));
|
|
3929
4118
|
};
|
|
3930
|
-
const react_module_move_targetPath = (reactFolder, module, rawName)=>
|
|
3931
|
-
const { folders, folderName, fileName } = new NestedName(rawName);
|
|
3932
|
-
return 'page' === module.kind ? external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page.tsx`) : external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName);
|
|
3933
|
-
};
|
|
4119
|
+
const react_module_move_targetPath = (reactFolder, module, rawName)=>reactKindLayouts[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName)));
|
|
3934
4120
|
const validateMove = (reactFolder, module, rawName)=>{
|
|
3935
4121
|
const nameError = NestedName.validate(rawName);
|
|
3936
4122
|
if (true !== nameError) return nameError;
|
|
4123
|
+
if (!reactKindLayouts[module.kind].nested && /[\\/]/.test(rawName)) return 'UI-kit components and shared hooks have no folders: enter a name without "/"';
|
|
3937
4124
|
const target = react_module_move_targetPath(reactFolder, module, rawName);
|
|
3938
4125
|
if (target !== module.path && external_node_fs_default().existsSync(target)) return `${external_node_path_default().relative(reactFolder, target)} already exists`;
|
|
3939
4126
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
3940
4127
|
return true;
|
|
3941
4128
|
};
|
|
3942
|
-
const
|
|
4129
|
+
const react_module_move_routeFolder = (appFolder, rawName)=>{
|
|
3943
4130
|
const { folders, folderName } = new NestedName(rawName);
|
|
3944
4131
|
return external_node_path_default().join(appFolder, ...folders, folderName);
|
|
3945
4132
|
};
|
|
@@ -3947,13 +4134,14 @@ const routeFiles = (folder)=>external_node_fs_default().existsSync(folder) ? ext
|
|
|
3947
4134
|
withFileTypes: true
|
|
3948
4135
|
}).filter((entry)=>entry.isFile()).map((entry)=>external_node_path_default().join(folder, entry.name)) : [];
|
|
3949
4136
|
const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
3950
|
-
const
|
|
4137
|
+
const layout = reactKindLayouts[module.kind];
|
|
4138
|
+
const newName = new NestedName(reactModuleName(module.kind, rawName));
|
|
3951
4139
|
const target = react_module_move_targetPath(reactFolder, module, rawName);
|
|
3952
4140
|
const newClassName = newName.ClassName;
|
|
3953
|
-
const renameFile = (name)=>name.replace(new RegExp(`^(use-)?${escapeRegExp(module.fileBase)}(?=[-.])`), (_, use = '')=>`${use}${newName.fileName}`);
|
|
3954
|
-
const oldFolder =
|
|
3955
|
-
const newFolder =
|
|
3956
|
-
const ownsPath = (candidate)=>
|
|
4141
|
+
const renameFile = (name)=>name.replace(new RegExp(`^(use-)?${escapeRegExp(module.fileBase)}(?=[-.]|$)`), (_, use = '')=>`${use}${newName.fileName}`);
|
|
4142
|
+
const oldFolder = layout.inFolder ? module.path : external_node_path_default().dirname(module.path);
|
|
4143
|
+
const newFolder = layout.inFolder ? target : external_node_path_default().dirname(target);
|
|
4144
|
+
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));
|
|
3957
4145
|
const routeFileSet = new Set(route ? routeFiles(route.from) : []);
|
|
3958
4146
|
const routeTarget = (candidate)=>{
|
|
3959
4147
|
if (!route) return;
|
|
@@ -3973,7 +4161,7 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
3973
4161
|
segments[last] = renameFile(segments[last]);
|
|
3974
4162
|
return external_node_path_default().join(newFolder, ...segments);
|
|
3975
4163
|
};
|
|
3976
|
-
const moduleFiles =
|
|
4164
|
+
const moduleFiles = reactModuleFiles(module);
|
|
3977
4165
|
const moves = new Map([
|
|
3978
4166
|
...moduleFiles,
|
|
3979
4167
|
...routeFileSet
|
|
@@ -3981,14 +4169,14 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
3981
4169
|
file,
|
|
3982
4170
|
movedPath(file) ?? file
|
|
3983
4171
|
]));
|
|
3984
|
-
const
|
|
3985
|
-
const
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
const
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
].
|
|
4172
|
+
const classPattern = new RegExp(`(?<![\\w$])${layout.classPrefix}${escapeRegExp(module.ClassName)}(?=${layout.classSuffix})`, 'g');
|
|
4173
|
+
const oldTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
|
|
4174
|
+
module.ClassName
|
|
4175
|
+
] : module.name.split('/').map((segment)=>new NestedName(segment).ClassName));
|
|
4176
|
+
const titlePattern = oldTitle && new RegExp(`(['"\`])${escapeRegExp(oldTitle)}\\1`, 'g');
|
|
4177
|
+
const newTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
|
|
4178
|
+
newClassName
|
|
4179
|
+
] : newName.classNameSegments);
|
|
3992
4180
|
return stageModuleMove({
|
|
3993
4181
|
projectRoot,
|
|
3994
4182
|
stopAt: reactFolder,
|
|
@@ -3996,11 +4184,57 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
3996
4184
|
moves,
|
|
3997
4185
|
movedPath,
|
|
3998
4186
|
rename: (content, { moved })=>{
|
|
3999
|
-
const renamed = content.replace(classPattern, (_, use
|
|
4000
|
-
return moved &&
|
|
4187
|
+
const renamed = content.replace(classPattern, (_, use)=>`${use ?? ''}${newClassName}`);
|
|
4188
|
+
return moved && titlePattern ? renamed.replace(titlePattern, (_, quote)=>`${quote}${newTitle}${quote}`) : renamed;
|
|
4001
4189
|
}
|
|
4002
4190
|
});
|
|
4003
4191
|
};
|
|
4192
|
+
const pageRouteFolder = (appFolder, page)=>{
|
|
4193
|
+
const folder = react_module_move_routeFolder(appFolder, page.name);
|
|
4194
|
+
const routePage = external_node_path_default().join(folder, 'page.tsx');
|
|
4195
|
+
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;
|
|
4196
|
+
};
|
|
4197
|
+
const reactModuleFiles = (module)=>{
|
|
4198
|
+
const layout = reactKindLayouts[module.kind];
|
|
4199
|
+
if (layout.inFolder) return module_move_walk(module.path);
|
|
4200
|
+
const folder = external_node_path_default().dirname(module.path);
|
|
4201
|
+
const own = layout.ownFile(module.fileBase);
|
|
4202
|
+
return external_node_fs_default().readdirSync(folder, {
|
|
4203
|
+
withFileTypes: true
|
|
4204
|
+
}).filter((entry)=>entry.isFile() && own.test(entry.name)).map((entry)=>external_node_path_default().join(folder, entry.name));
|
|
4205
|
+
};
|
|
4206
|
+
const react_module_move_importSpecifier = /(?:\bfrom\s*|\bimport\s*\(\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"\n]+)\1/g;
|
|
4207
|
+
const deleteReactModule = (projectRoot, reactFolder, module, route)=>{
|
|
4208
|
+
const moduleFiles = reactModuleFiles(module);
|
|
4209
|
+
const routeFileList = route ? routeFiles(route.folder) : [];
|
|
4210
|
+
const own = new Set([
|
|
4211
|
+
...moduleFiles,
|
|
4212
|
+
...routeFileList
|
|
4213
|
+
]);
|
|
4214
|
+
const stems = new Set(moduleFiles.map((file)=>file.replace(codeExtension, '')));
|
|
4215
|
+
const isModule = (resolved)=>stems.has(resolved) || reactKindLayouts[module.kind].inFolder && (resolved === module.path || resolved.startsWith(`${module.path}${external_node_path_default().sep}`));
|
|
4216
|
+
const { codeFiles, resolve } = projectImports(projectRoot);
|
|
4217
|
+
const relative = (file)=>toPosix(external_node_path_default().relative(projectRoot, file));
|
|
4218
|
+
const usedBy = [];
|
|
4219
|
+
for (const [file, content] of codeFiles)if (!own.has(file)) for (const [, , specifier] of content.matchAll(react_module_move_importSpecifier)){
|
|
4220
|
+
const target = resolve(specifier, file)?.resolved;
|
|
4221
|
+
if (target && isModule(target)) usedBy.push([
|
|
4222
|
+
relative(file),
|
|
4223
|
+
relative(target)
|
|
4224
|
+
]);
|
|
4225
|
+
}
|
|
4226
|
+
if (usedBy.length) return {
|
|
4227
|
+
usedBy
|
|
4228
|
+
};
|
|
4229
|
+
for (const file of moduleFiles)new file_system_File(file).delete(reactFolder);
|
|
4230
|
+
for (const file of routeFileList)new file_system_File(file).delete(route.appFolder);
|
|
4231
|
+
return {
|
|
4232
|
+
deleted: [
|
|
4233
|
+
...moduleFiles,
|
|
4234
|
+
...routeFileList
|
|
4235
|
+
]
|
|
4236
|
+
};
|
|
4237
|
+
};
|
|
4004
4238
|
const systemImplementationChoices = (kind, crossContext = false)=>{
|
|
4005
4239
|
if ('ports' === kind) return crossContext ? [
|
|
4006
4240
|
{
|
|
@@ -4015,6 +4249,108 @@ const systemImplementationChoices = (kind, crossContext = false)=>{
|
|
|
4015
4249
|
}
|
|
4016
4250
|
] : [];
|
|
4017
4251
|
};
|
|
4252
|
+
const deleteBackendUnitUseCase = async (ownerFolder)=>{
|
|
4253
|
+
const root = new project_root_ProjectRoot().path;
|
|
4254
|
+
const rootFolderPath = external_node_path_default().join(root, config_file_ConfigFile.Instance.data.project.rootFolder);
|
|
4255
|
+
const units = findBackendUnits(ownerFolder.path);
|
|
4256
|
+
if (!units.length) return void report('No modules generated by df-scaffold were found here.');
|
|
4257
|
+
const unit = await interaction_select({
|
|
4258
|
+
key: 'module',
|
|
4259
|
+
id: unitId,
|
|
4260
|
+
message: 'Module to delete:',
|
|
4261
|
+
choices: Object.keys(kindLayouts).flatMap((kind)=>{
|
|
4262
|
+
const group = units.filter((x)=>x.kind === kind);
|
|
4263
|
+
return group.length ? [
|
|
4264
|
+
new prompts_namespaceObject.Separator(`── ${kindLayouts[group[0].kind].title}`),
|
|
4265
|
+
...group.map((value)=>({
|
|
4266
|
+
name: value.aggregate ? `${value.name} (${value.aggregate})` : value.name,
|
|
4267
|
+
value
|
|
4268
|
+
}))
|
|
4269
|
+
] : [];
|
|
4270
|
+
}),
|
|
4271
|
+
pageSize: 20
|
|
4272
|
+
});
|
|
4273
|
+
const result = deleteBackendUnit(root, rootFolderPath, unit);
|
|
4274
|
+
if (result.usedBy) {
|
|
4275
|
+
if (isNonInteractive()) throw new RequestError('DELETE_NOT_ALLOWED', 'Other files still use the module.', {
|
|
4276
|
+
usedBy: result.usedBy
|
|
4277
|
+
});
|
|
4278
|
+
report([
|
|
4279
|
+
'Nothing was deleted: these files still use it.',
|
|
4280
|
+
...result.usedBy.map(([file, used])=>` ${file} → ${used}`),
|
|
4281
|
+
'Remove those uses first (Wire dependency edits wiring; imports and constructor parameters are yours).'
|
|
4282
|
+
].join('\n'));
|
|
4283
|
+
return;
|
|
4284
|
+
}
|
|
4285
|
+
const relative = (file)=>external_node_path_default().relative(root, file);
|
|
4286
|
+
report([
|
|
4287
|
+
'Files to delete:',
|
|
4288
|
+
...result.deleted.map((file)=>` ${relative(file)}`),
|
|
4289
|
+
...result.updated.length ? [
|
|
4290
|
+
'Files to update:',
|
|
4291
|
+
...result.updated.map((file)=>` ${relative(file)}`)
|
|
4292
|
+
] : []
|
|
4293
|
+
].join('\n'));
|
|
4294
|
+
if (!await interaction_confirm({
|
|
4295
|
+
key: 'apply',
|
|
4296
|
+
message: 'Delete?',
|
|
4297
|
+
default: false
|
|
4298
|
+
})) {
|
|
4299
|
+
discardPendingChanges();
|
|
4300
|
+
report('Cancelled: nothing was deleted.');
|
|
4301
|
+
}
|
|
4302
|
+
};
|
|
4303
|
+
const deleteReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
4304
|
+
const reactFolder = presentationReactFolder.path;
|
|
4305
|
+
const modules = findReactModules(reactFolder, kind);
|
|
4306
|
+
if (!modules.length) return void report(`No ${reactKindTitles[kind][1]} generated by df-react were found.`);
|
|
4307
|
+
const module = await interaction_select({
|
|
4308
|
+
key: 'module',
|
|
4309
|
+
id: (value)=>value.name,
|
|
4310
|
+
message: `${reactKindTitles[kind][0]} to delete:`,
|
|
4311
|
+
choices: modules.map((value)=>({
|
|
4312
|
+
name: value.name,
|
|
4313
|
+
value,
|
|
4314
|
+
description: external_node_path_default().relative(reactFolder, value.path)
|
|
4315
|
+
}))
|
|
4316
|
+
});
|
|
4317
|
+
const root = new project_root_ProjectRoot().path;
|
|
4318
|
+
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4319
|
+
const appFolder = external_node_path_default().join(root, nextAppFolder(root));
|
|
4320
|
+
const routeFolder = 'page' === kind && usesNext() ? pageRouteFolder(appFolder, module) : void 0;
|
|
4321
|
+
const withRoute = !!routeFolder && await interaction_confirm({
|
|
4322
|
+
key: 'deleteRoute',
|
|
4323
|
+
message: `Delete its Next.js route too: ${relative(routeFolder)}? Its URL stops working.`,
|
|
4324
|
+
default: true
|
|
4325
|
+
});
|
|
4326
|
+
const result = deleteReactModule(root, reactFolder, module, withRoute && routeFolder ? {
|
|
4327
|
+
appFolder,
|
|
4328
|
+
folder: routeFolder
|
|
4329
|
+
} : void 0);
|
|
4330
|
+
if (result.usedBy) {
|
|
4331
|
+
if (isNonInteractive()) throw new RequestError('DELETE_NOT_ALLOWED', `Other files still use the ${kind}.`, {
|
|
4332
|
+
usedBy: result.usedBy
|
|
4333
|
+
});
|
|
4334
|
+
report([
|
|
4335
|
+
'Nothing was deleted: these files still use it.',
|
|
4336
|
+
...result.usedBy.map(([file, used])=>` ${file} → ${used}`),
|
|
4337
|
+
'Remove those uses first.'
|
|
4338
|
+
].join('\n'));
|
|
4339
|
+
return;
|
|
4340
|
+
}
|
|
4341
|
+
report([
|
|
4342
|
+
'Files to delete:',
|
|
4343
|
+
...result.deleted.map((file)=>` ${relative(file)}`)
|
|
4344
|
+
].join('\n'));
|
|
4345
|
+
if (!await interaction_confirm({
|
|
4346
|
+
key: 'apply',
|
|
4347
|
+
message: 'Delete?',
|
|
4348
|
+
default: false
|
|
4349
|
+
})) {
|
|
4350
|
+
discardPendingChanges();
|
|
4351
|
+
report('Cancelled: nothing was deleted.');
|
|
4352
|
+
}
|
|
4353
|
+
};
|
|
4018
4354
|
Symbol('create-test-branch');
|
|
4019
4355
|
Symbol('no-test-branch');
|
|
4020
4356
|
const noAggregate = 'No aggregate';
|
|
@@ -4118,11 +4454,10 @@ const moveBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
4118
4454
|
const promptRouteMove = async (root, page, newName)=>{
|
|
4119
4455
|
if (!usesNext()) return;
|
|
4120
4456
|
const appFolder = external_node_path_default().join(root, nextAppFolder(root));
|
|
4121
|
-
const from =
|
|
4122
|
-
const to =
|
|
4457
|
+
const from = pageRouteFolder(appFolder, page);
|
|
4458
|
+
const to = react_module_move_routeFolder(appFolder, newName);
|
|
4123
4459
|
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4124
|
-
|
|
4125
|
-
if (from === to || !external_node_fs_default().existsSync(routePage) || !new RegExp(`\\b${page.ClassName}Page\\b`).test(external_node_fs_default().readFileSync(routePage, 'utf8'))) return;
|
|
4460
|
+
if (!from || from === to) return;
|
|
4126
4461
|
if (external_node_fs_default().existsSync(external_node_path_default().join(to, 'page.tsx'))) return void report(`${relative(to)}/page.tsx already exists: the route ${relative(from)} stays.`);
|
|
4127
4462
|
const move = await interaction_confirm({
|
|
4128
4463
|
key: 'moveRoute',
|
|
@@ -4138,11 +4473,11 @@ const promptRouteMove = async (root, page, newName)=>{
|
|
|
4138
4473
|
const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
4139
4474
|
const reactFolder = presentationReactFolder.path;
|
|
4140
4475
|
const modules = findReactModules(reactFolder, kind);
|
|
4141
|
-
if (!modules.length) return void report(`No ${kind}
|
|
4476
|
+
if (!modules.length) return void report(`No ${reactKindTitles[kind][1]} generated by df-react were found.`);
|
|
4142
4477
|
const module = await interaction_select({
|
|
4143
4478
|
key: 'module',
|
|
4144
4479
|
id: (value)=>value.name,
|
|
4145
|
-
message:
|
|
4480
|
+
message: `${reactKindTitles[kind][0]}:`,
|
|
4146
4481
|
choices: modules.map((value)=>({
|
|
4147
4482
|
name: value.name,
|
|
4148
4483
|
value,
|
|
@@ -4151,7 +4486,7 @@ const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
|
4151
4486
|
});
|
|
4152
4487
|
const name = await interaction_input({
|
|
4153
4488
|
key: 'name',
|
|
4154
|
-
message: 'New name (folders split by "/"):',
|
|
4489
|
+
message: reactKindLayouts[kind].nested ? 'New name (folders split by "/"):' : 'New name:',
|
|
4155
4490
|
default: module.name,
|
|
4156
4491
|
validate: (value)=>validateMove(reactFolder, module, value)
|
|
4157
4492
|
});
|
|
@@ -5507,7 +5842,9 @@ const describeAgentCommand = (command)=>{
|
|
|
5507
5842
|
integrations: integrationDescriptionsSafe(configured),
|
|
5508
5843
|
reactModules: config?.frontend?.react ? [
|
|
5509
5844
|
'page',
|
|
5510
|
-
'widget'
|
|
5845
|
+
'widget',
|
|
5846
|
+
'ui-kit',
|
|
5847
|
+
'hook'
|
|
5511
5848
|
].flatMap((kind)=>findReactModules(external_node_path_default().join(root, config.project.rootFolder, 'presentation/react'), kind).map((module)=>({
|
|
5512
5849
|
kind,
|
|
5513
5850
|
name: module.name,
|
|
@@ -5578,7 +5915,7 @@ const executeScaffold = async (request, owner)=>{
|
|
|
5578
5915
|
'errors'
|
|
5579
5916
|
]).content.fileNames.includes(request.namespace)) throw new RequestError('TARGET_NOT_FOUND', `Unknown namespace: ${request.namespace}.`);
|
|
5580
5917
|
if ('implementation' === request.operation && !findContracts(owner.path).length) throw new RequestError('TARGET_NOT_FOUND', 'No contracts in this context.');
|
|
5581
|
-
if ('move' === request.operation && !findBackendUnits(owner.path).length) throw new RequestError('TARGET_NOT_FOUND', 'No modules in this context.');
|
|
5918
|
+
if (('move' === request.operation || 'delete' === request.operation) && !findBackendUnits(owner.path).length) throw new RequestError('TARGET_NOT_FOUND', 'No modules in this context.');
|
|
5582
5919
|
if ('wire-dependency' === request.operation && (!config_file_ConfigFile.backend.domainFirstPackages.includes('@domain-first/wire') || !findWiredModules(owner.path).length)) throw new RequestError('TARGET_NOT_FOUND', 'No wired modules in this context.');
|
|
5583
5920
|
if ('endpoint' === request.operation) {
|
|
5584
5921
|
if (!config_file_ConfigFile.backend.domainFirstPackages.includes('@domain-first/handlers-rest') || !findRestEndpointGenerator(new file_system_Folder(requireProject()).subitem([
|
|
@@ -5607,7 +5944,8 @@ const executeScaffold = async (request, owner)=>{
|
|
|
5607
5944
|
implementation: ()=>scaffoldNewImplementation(owner),
|
|
5608
5945
|
endpoint: ()=>scaffoldNewHandlersRestEndpoint(owner),
|
|
5609
5946
|
'wire-dependency': ()=>wireDependency(owner),
|
|
5610
|
-
move: ()=>moveBackendUnitUseCase(owner)
|
|
5947
|
+
move: ()=>moveBackendUnitUseCase(owner),
|
|
5948
|
+
delete: ()=>deleteBackendUnitUseCase(owner)
|
|
5611
5949
|
};
|
|
5612
5950
|
return actions[request.operation]();
|
|
5613
5951
|
};
|
|
@@ -5616,14 +5954,22 @@ const executeReact = async (request)=>{
|
|
|
5616
5954
|
config_file_ConfigFile.Instance.data.project.rootFolder,
|
|
5617
5955
|
'presentation/react'
|
|
5618
5956
|
]);
|
|
5619
|
-
|
|
5957
|
+
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;
|
|
5958
|
+
const kind = /^(move|delete)-/.test(request.operation) ? kindOf(request.operation) : void 0;
|
|
5959
|
+
if (kind && !findReactModules(folder.path, kind).length) throw new RequestError('TARGET_NOT_FOUND', `No React ${reactKindTitles[kind][1]} here.`);
|
|
5620
5960
|
const actions = {
|
|
5621
5961
|
page: ()=>scaffoldReactPage(folder),
|
|
5622
5962
|
widget: ()=>scaffoldReactWidget(folder),
|
|
5623
5963
|
'ui-kit-component': ()=>scaffoldReactUIKitComponent(folder),
|
|
5624
5964
|
'shared-hook': ()=>scaffoldReactSharedHook(folder),
|
|
5625
5965
|
'move-page': ()=>moveReactModuleUseCase(folder, 'page'),
|
|
5626
|
-
'move-widget': ()=>moveReactModuleUseCase(folder, 'widget')
|
|
5966
|
+
'move-widget': ()=>moveReactModuleUseCase(folder, 'widget'),
|
|
5967
|
+
'delete-page': ()=>deleteReactModuleUseCase(folder, 'page'),
|
|
5968
|
+
'delete-widget': ()=>deleteReactModuleUseCase(folder, 'widget'),
|
|
5969
|
+
'move-ui-kit-component': ()=>moveReactModuleUseCase(folder, 'ui-kit'),
|
|
5970
|
+
'move-shared-hook': ()=>moveReactModuleUseCase(folder, 'hook'),
|
|
5971
|
+
'delete-ui-kit-component': ()=>deleteReactModuleUseCase(folder, 'ui-kit'),
|
|
5972
|
+
'delete-shared-hook': ()=>deleteReactModuleUseCase(folder, 'hook')
|
|
5627
5973
|
};
|
|
5628
5974
|
return actions[request.operation]();
|
|
5629
5975
|
};
|