@domain-first/project-structure 8.2.0 → 8.3.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 +221 -6
- package/dist/561.js +22 -5
- package/dist/agent-cli.d.ts +17 -0
- package/dist/agent-requests.d.ts +34 -0
- package/dist/backend-module-move.d.ts +16 -0
- package/dist/index.cjs +244 -10
- package/dist/index.js +4 -2
- package/dist/init.cjs +55 -55
- package/dist/integration.cjs +241 -9
- package/dist/react-module-move.d.ts +21 -0
- package/dist/react.cjs +248 -10
- package/dist/react.js +8 -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 +4 -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 +3 -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
|
@@ -3216,6 +3216,11 @@ const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operati
|
|
|
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
|
+
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
|
+
}),
|
|
3219
3224
|
operation('move', {
|
|
3220
3225
|
...common,
|
|
3221
3226
|
...agent_requests_owner,
|
|
@@ -3253,6 +3258,15 @@ const reactRequestSchema = external_zod_default().discriminatedUnion('operation'
|
|
|
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
|
}),
|
|
3261
|
+
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
|
+
operation('delete-widget', {
|
|
3267
|
+
...common,
|
|
3268
|
+
module: agent_requests_nestedName
|
|
3269
|
+
}),
|
|
3256
3270
|
operation('move-widget', {
|
|
3257
3271
|
...common,
|
|
3258
3272
|
module: agent_requests_nestedName,
|
|
@@ -3756,6 +3770,75 @@ const projectRelative = (fromFile, toFile)=>{
|
|
|
3756
3770
|
const relative = toPosix(external_node_path_default().relative(external_node_path_default().dirname(fromFile), toFile.replace(codeExtension, '')));
|
|
3757
3771
|
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
3758
3772
|
};
|
|
3773
|
+
const importSpecifier = /(?:\bfrom\s*|\bimport\s*\(\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"\n]+)\1/g;
|
|
3774
|
+
const backend_module_move_importLine = /^\s*(?:import|export)\b[^'"\n]*\bfrom\s*(['"])([^'"\n]+)\1;?\s*$/;
|
|
3775
|
+
const deleteBackendUnit = (projectRoot, rootFolderPath, unit)=>{
|
|
3776
|
+
const files = [
|
|
3777
|
+
...unitMoves(unit, unit).keys()
|
|
3778
|
+
];
|
|
3779
|
+
const fileSet = new Set(files);
|
|
3780
|
+
const stems = new Set(files.map((file)=>file.replace(codeExtension, '')));
|
|
3781
|
+
const aggregateFolder = 'aggregate' === unit.kind ? external_node_path_default().join(unit.ownerPath, 'domain/aggregates', unit.name) : void 0;
|
|
3782
|
+
const parentAggregate = unit.aggregate ? external_node_path_default().join(unit.ownerPath, 'domain/aggregates', unit.aggregate) : void 0;
|
|
3783
|
+
const isUnit = (resolved)=>stems.has(resolved) || !!aggregateFolder && (resolved === aggregateFolder || resolved.startsWith(`${aggregateFolder}${external_node_path_default().sep}`));
|
|
3784
|
+
const isParentBarrel = (resolved)=>!!parentAggregate && (resolved === parentAggregate || resolved === external_node_path_default().join(parentAggregate, 'index'));
|
|
3785
|
+
const { codeFiles, resolve } = projectImports(projectRoot);
|
|
3786
|
+
const resolved = (specifier, file)=>resolve(specifier, file)?.resolved;
|
|
3787
|
+
const withoutUnitImports = (content, file)=>content.split('\n').filter((line)=>{
|
|
3788
|
+
const specifier = line.match(backend_module_move_importLine)?.[2];
|
|
3789
|
+
const target = specifier && resolved(specifier, file);
|
|
3790
|
+
return !(target && isUnit(target));
|
|
3791
|
+
}).join('\n');
|
|
3792
|
+
const cleaned = new Map();
|
|
3793
|
+
const inMemoryDb = inMemoryDbFile(rootFolderPath);
|
|
3794
|
+
if ('aggregate' === unit.kind && codeFiles.has(inMemoryDb)) {
|
|
3795
|
+
const section = new UnknownFormatNaming(plural(unit.name));
|
|
3796
|
+
const original = codeFiles.get(inMemoryDb);
|
|
3797
|
+
const content = withoutUnitImports(original.replace(new RegExp(`^[ \\t]*${escapeRegExp(section.variableName)}\\s*=\\s*this\\.section<[^\\n]*\\n?`, 'm'), ''), inMemoryDb);
|
|
3798
|
+
if (content !== original) cleaned.set(inMemoryDb, content);
|
|
3799
|
+
}
|
|
3800
|
+
if (parentAggregate) {
|
|
3801
|
+
const index = external_node_path_default().join(parentAggregate, 'index.ts');
|
|
3802
|
+
const original = codeFiles.get(index);
|
|
3803
|
+
if (void 0 !== original) {
|
|
3804
|
+
const content = withoutUnitImports(original, index);
|
|
3805
|
+
if (content !== original) cleaned.set(index, content);
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
const ClassName = new UnknownFormatNaming(unit.name).ClassName;
|
|
3809
|
+
const namedImports = /import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*(['"])([^'"\n]+)\2/g;
|
|
3810
|
+
const usedBy = [];
|
|
3811
|
+
const relative = (file)=>toPosix(external_node_path_default().relative(projectRoot, file));
|
|
3812
|
+
for (const [file, original] of codeFiles){
|
|
3813
|
+
if (fileSet.has(file)) continue;
|
|
3814
|
+
const content = cleaned.get(file) ?? original;
|
|
3815
|
+
for (const [, , specifier] of content.matchAll(importSpecifier)){
|
|
3816
|
+
const target = resolved(specifier, file);
|
|
3817
|
+
if (target && isUnit(target)) usedBy.push([
|
|
3818
|
+
relative(file),
|
|
3819
|
+
relative(target)
|
|
3820
|
+
]);
|
|
3821
|
+
}
|
|
3822
|
+
for (const [, names, , specifier] of content.matchAll(namedImports)){
|
|
3823
|
+
const target = resolved(specifier, file);
|
|
3824
|
+
if (target && isParentBarrel(target) && new RegExp(`(?<![\\w$])${ClassName}(?![\\w$])`).test(names)) usedBy.push([
|
|
3825
|
+
relative(file),
|
|
3826
|
+
`${relative(target)} (${ClassName})`
|
|
3827
|
+
]);
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
if (usedBy.length) return {
|
|
3831
|
+
usedBy
|
|
3832
|
+
};
|
|
3833
|
+
for (const file of files)new file_system_File(file).delete(rootFolderPath);
|
|
3834
|
+
for (const [file, content] of cleaned)new file_system_File(file).update(content);
|
|
3835
|
+
return {
|
|
3836
|
+
deleted: files,
|
|
3837
|
+
updated: [
|
|
3838
|
+
...cleaned.keys()
|
|
3839
|
+
]
|
|
3840
|
+
};
|
|
3841
|
+
};
|
|
3759
3842
|
const contractKinds = [
|
|
3760
3843
|
'aggregate',
|
|
3761
3844
|
'command',
|
|
@@ -3939,7 +4022,7 @@ const validateMove = (reactFolder, module, rawName)=>{
|
|
|
3939
4022
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
3940
4023
|
return true;
|
|
3941
4024
|
};
|
|
3942
|
-
const
|
|
4025
|
+
const react_module_move_routeFolder = (appFolder, rawName)=>{
|
|
3943
4026
|
const { folders, folderName } = new NestedName(rawName);
|
|
3944
4027
|
return external_node_path_default().join(appFolder, ...folders, folderName);
|
|
3945
4028
|
};
|
|
@@ -4001,6 +4084,51 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
4001
4084
|
}
|
|
4002
4085
|
});
|
|
4003
4086
|
};
|
|
4087
|
+
const pageRouteFolder = (appFolder, page)=>{
|
|
4088
|
+
const folder = react_module_move_routeFolder(appFolder, page.name);
|
|
4089
|
+
const routePage = external_node_path_default().join(folder, 'page.tsx');
|
|
4090
|
+
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
|
+
};
|
|
4092
|
+
const reactModuleFiles = (module)=>{
|
|
4093
|
+
if ('widget' === module.kind) return module_move_walk(module.path);
|
|
4094
|
+
const folder = external_node_path_default().dirname(module.path);
|
|
4095
|
+
const own = new RegExp(`^${escapeRegExp(module.fileBase)}-page(?:\\.|$)`);
|
|
4096
|
+
return external_node_fs_default().readdirSync(folder, {
|
|
4097
|
+
withFileTypes: true
|
|
4098
|
+
}).filter((entry)=>entry.isFile() && own.test(entry.name)).map((entry)=>external_node_path_default().join(folder, entry.name));
|
|
4099
|
+
};
|
|
4100
|
+
const react_module_move_importSpecifier = /(?:\bfrom\s*|\bimport\s*\(\s*|\brequire\s*\(\s*|\bimport\s+)(['"])([^'"\n]+)\1/g;
|
|
4101
|
+
const deleteReactModule = (projectRoot, reactFolder, module, route)=>{
|
|
4102
|
+
const moduleFiles = reactModuleFiles(module);
|
|
4103
|
+
const routeFileList = route ? routeFiles(route.folder) : [];
|
|
4104
|
+
const own = new Set([
|
|
4105
|
+
...moduleFiles,
|
|
4106
|
+
...routeFileList
|
|
4107
|
+
]);
|
|
4108
|
+
const stems = new Set(moduleFiles.map((file)=>file.replace(codeExtension, '')));
|
|
4109
|
+
const isModule = (resolved)=>stems.has(resolved) || 'widget' === module.kind && (resolved === module.path || resolved.startsWith(`${module.path}${external_node_path_default().sep}`));
|
|
4110
|
+
const { codeFiles, resolve } = projectImports(projectRoot);
|
|
4111
|
+
const relative = (file)=>toPosix(external_node_path_default().relative(projectRoot, file));
|
|
4112
|
+
const usedBy = [];
|
|
4113
|
+
for (const [file, content] of codeFiles)if (!own.has(file)) for (const [, , specifier] of content.matchAll(react_module_move_importSpecifier)){
|
|
4114
|
+
const target = resolve(specifier, file)?.resolved;
|
|
4115
|
+
if (target && isModule(target)) usedBy.push([
|
|
4116
|
+
relative(file),
|
|
4117
|
+
relative(target)
|
|
4118
|
+
]);
|
|
4119
|
+
}
|
|
4120
|
+
if (usedBy.length) return {
|
|
4121
|
+
usedBy
|
|
4122
|
+
};
|
|
4123
|
+
for (const file of moduleFiles)new file_system_File(file).delete(reactFolder);
|
|
4124
|
+
for (const file of routeFileList)new file_system_File(file).delete(route.appFolder);
|
|
4125
|
+
return {
|
|
4126
|
+
deleted: [
|
|
4127
|
+
...moduleFiles,
|
|
4128
|
+
...routeFileList
|
|
4129
|
+
]
|
|
4130
|
+
};
|
|
4131
|
+
};
|
|
4004
4132
|
const systemImplementationChoices = (kind, crossContext = false)=>{
|
|
4005
4133
|
if ('ports' === kind) return crossContext ? [
|
|
4006
4134
|
{
|
|
@@ -4015,6 +4143,108 @@ const systemImplementationChoices = (kind, crossContext = false)=>{
|
|
|
4015
4143
|
}
|
|
4016
4144
|
] : [];
|
|
4017
4145
|
};
|
|
4146
|
+
const deleteBackendUnitUseCase = async (ownerFolder)=>{
|
|
4147
|
+
const root = new project_root_ProjectRoot().path;
|
|
4148
|
+
const rootFolderPath = external_node_path_default().join(root, config_file_ConfigFile.Instance.data.project.rootFolder);
|
|
4149
|
+
const units = findBackendUnits(ownerFolder.path);
|
|
4150
|
+
if (!units.length) return void report('No modules generated by df-scaffold were found here.');
|
|
4151
|
+
const unit = await interaction_select({
|
|
4152
|
+
key: 'module',
|
|
4153
|
+
id: unitId,
|
|
4154
|
+
message: 'Module to delete:',
|
|
4155
|
+
choices: Object.keys(kindLayouts).flatMap((kind)=>{
|
|
4156
|
+
const group = units.filter((x)=>x.kind === kind);
|
|
4157
|
+
return group.length ? [
|
|
4158
|
+
new prompts_namespaceObject.Separator(`── ${kindLayouts[group[0].kind].title}`),
|
|
4159
|
+
...group.map((value)=>({
|
|
4160
|
+
name: value.aggregate ? `${value.name} (${value.aggregate})` : value.name,
|
|
4161
|
+
value
|
|
4162
|
+
}))
|
|
4163
|
+
] : [];
|
|
4164
|
+
}),
|
|
4165
|
+
pageSize: 20
|
|
4166
|
+
});
|
|
4167
|
+
const result = deleteBackendUnit(root, rootFolderPath, unit);
|
|
4168
|
+
if (result.usedBy) {
|
|
4169
|
+
if (isNonInteractive()) throw new RequestError('DELETE_NOT_ALLOWED', 'Other files still use the module.', {
|
|
4170
|
+
usedBy: result.usedBy
|
|
4171
|
+
});
|
|
4172
|
+
report([
|
|
4173
|
+
'Nothing was deleted: these files still use it.',
|
|
4174
|
+
...result.usedBy.map(([file, used])=>` ${file} → ${used}`),
|
|
4175
|
+
'Remove those uses first (Wire dependency edits wiring; imports and constructor parameters are yours).'
|
|
4176
|
+
].join('\n'));
|
|
4177
|
+
return;
|
|
4178
|
+
}
|
|
4179
|
+
const relative = (file)=>external_node_path_default().relative(root, file);
|
|
4180
|
+
report([
|
|
4181
|
+
'Files to delete:',
|
|
4182
|
+
...result.deleted.map((file)=>` ${relative(file)}`),
|
|
4183
|
+
...result.updated.length ? [
|
|
4184
|
+
'Files to update:',
|
|
4185
|
+
...result.updated.map((file)=>` ${relative(file)}`)
|
|
4186
|
+
] : []
|
|
4187
|
+
].join('\n'));
|
|
4188
|
+
if (!await interaction_confirm({
|
|
4189
|
+
key: 'apply',
|
|
4190
|
+
message: 'Delete?',
|
|
4191
|
+
default: false
|
|
4192
|
+
})) {
|
|
4193
|
+
discardPendingChanges();
|
|
4194
|
+
report('Cancelled: nothing was deleted.');
|
|
4195
|
+
}
|
|
4196
|
+
};
|
|
4197
|
+
const deleteReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
4198
|
+
const reactFolder = presentationReactFolder.path;
|
|
4199
|
+
const modules = findReactModules(reactFolder, kind);
|
|
4200
|
+
if (!modules.length) return void report(`No ${kind}s generated by df-react were found.`);
|
|
4201
|
+
const module = await interaction_select({
|
|
4202
|
+
key: 'module',
|
|
4203
|
+
id: (value)=>value.name,
|
|
4204
|
+
message: 'page' === kind ? 'Page to delete:' : 'Widget to delete:',
|
|
4205
|
+
choices: modules.map((value)=>({
|
|
4206
|
+
name: value.name,
|
|
4207
|
+
value,
|
|
4208
|
+
description: external_node_path_default().relative(reactFolder, value.path)
|
|
4209
|
+
}))
|
|
4210
|
+
});
|
|
4211
|
+
const root = new project_root_ProjectRoot().path;
|
|
4212
|
+
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4213
|
+
const appFolder = external_node_path_default().join(root, nextAppFolder(root));
|
|
4214
|
+
const routeFolder = 'page' === kind && usesNext() ? pageRouteFolder(appFolder, module) : void 0;
|
|
4215
|
+
const withRoute = !!routeFolder && await interaction_confirm({
|
|
4216
|
+
key: 'deleteRoute',
|
|
4217
|
+
message: `Delete its Next.js route too: ${relative(routeFolder)}? Its URL stops working.`,
|
|
4218
|
+
default: true
|
|
4219
|
+
});
|
|
4220
|
+
const result = deleteReactModule(root, reactFolder, module, withRoute && routeFolder ? {
|
|
4221
|
+
appFolder,
|
|
4222
|
+
folder: routeFolder
|
|
4223
|
+
} : void 0);
|
|
4224
|
+
if (result.usedBy) {
|
|
4225
|
+
if (isNonInteractive()) throw new RequestError('DELETE_NOT_ALLOWED', `Other files still use the ${kind}.`, {
|
|
4226
|
+
usedBy: result.usedBy
|
|
4227
|
+
});
|
|
4228
|
+
report([
|
|
4229
|
+
'Nothing was deleted: these files still use it.',
|
|
4230
|
+
...result.usedBy.map(([file, used])=>` ${file} → ${used}`),
|
|
4231
|
+
'Remove those uses first.'
|
|
4232
|
+
].join('\n'));
|
|
4233
|
+
return;
|
|
4234
|
+
}
|
|
4235
|
+
report([
|
|
4236
|
+
'Files to delete:',
|
|
4237
|
+
...result.deleted.map((file)=>` ${relative(file)}`)
|
|
4238
|
+
].join('\n'));
|
|
4239
|
+
if (!await interaction_confirm({
|
|
4240
|
+
key: 'apply',
|
|
4241
|
+
message: 'Delete?',
|
|
4242
|
+
default: false
|
|
4243
|
+
})) {
|
|
4244
|
+
discardPendingChanges();
|
|
4245
|
+
report('Cancelled: nothing was deleted.');
|
|
4246
|
+
}
|
|
4247
|
+
};
|
|
4018
4248
|
Symbol('create-test-branch');
|
|
4019
4249
|
Symbol('no-test-branch');
|
|
4020
4250
|
const noAggregate = 'No aggregate';
|
|
@@ -4118,11 +4348,10 @@ const moveBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
4118
4348
|
const promptRouteMove = async (root, page, newName)=>{
|
|
4119
4349
|
if (!usesNext()) return;
|
|
4120
4350
|
const appFolder = external_node_path_default().join(root, nextAppFolder(root));
|
|
4121
|
-
const from =
|
|
4122
|
-
const to =
|
|
4351
|
+
const from = pageRouteFolder(appFolder, page);
|
|
4352
|
+
const to = react_module_move_routeFolder(appFolder, newName);
|
|
4123
4353
|
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;
|
|
4354
|
+
if (!from || from === to) return;
|
|
4126
4355
|
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
4356
|
const move = await interaction_confirm({
|
|
4128
4357
|
key: 'moveRoute',
|
|
@@ -5578,7 +5807,7 @@ const executeScaffold = async (request, owner)=>{
|
|
|
5578
5807
|
'errors'
|
|
5579
5808
|
]).content.fileNames.includes(request.namespace)) throw new RequestError('TARGET_NOT_FOUND', `Unknown namespace: ${request.namespace}.`);
|
|
5580
5809
|
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.');
|
|
5810
|
+
if (('move' === request.operation || 'delete' === request.operation) && !findBackendUnits(owner.path).length) throw new RequestError('TARGET_NOT_FOUND', 'No modules in this context.');
|
|
5582
5811
|
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
5812
|
if ('endpoint' === request.operation) {
|
|
5584
5813
|
if (!config_file_ConfigFile.backend.domainFirstPackages.includes('@domain-first/handlers-rest') || !findRestEndpointGenerator(new file_system_Folder(requireProject()).subitem([
|
|
@@ -5607,7 +5836,8 @@ const executeScaffold = async (request, owner)=>{
|
|
|
5607
5836
|
implementation: ()=>scaffoldNewImplementation(owner),
|
|
5608
5837
|
endpoint: ()=>scaffoldNewHandlersRestEndpoint(owner),
|
|
5609
5838
|
'wire-dependency': ()=>wireDependency(owner),
|
|
5610
|
-
move: ()=>moveBackendUnitUseCase(owner)
|
|
5839
|
+
move: ()=>moveBackendUnitUseCase(owner),
|
|
5840
|
+
delete: ()=>deleteBackendUnitUseCase(owner)
|
|
5611
5841
|
};
|
|
5612
5842
|
return actions[request.operation]();
|
|
5613
5843
|
};
|
|
@@ -5616,14 +5846,16 @@ const executeReact = async (request)=>{
|
|
|
5616
5846
|
config_file_ConfigFile.Instance.data.project.rootFolder,
|
|
5617
5847
|
'presentation/react'
|
|
5618
5848
|
]);
|
|
5619
|
-
if (request.operation
|
|
5849
|
+
if (/^(move|delete)-/.test(request.operation) && !findReactModules(folder.path, request.operation.endsWith('-page') ? 'page' : 'widget').length) throw new RequestError('TARGET_NOT_FOUND', `No React ${request.operation.endsWith('-page') ? 'pages' : 'widgets'} here.`);
|
|
5620
5850
|
const actions = {
|
|
5621
5851
|
page: ()=>scaffoldReactPage(folder),
|
|
5622
5852
|
widget: ()=>scaffoldReactWidget(folder),
|
|
5623
5853
|
'ui-kit-component': ()=>scaffoldReactUIKitComponent(folder),
|
|
5624
5854
|
'shared-hook': ()=>scaffoldReactSharedHook(folder),
|
|
5625
5855
|
'move-page': ()=>moveReactModuleUseCase(folder, 'page'),
|
|
5626
|
-
'move-widget': ()=>moveReactModuleUseCase(folder, 'widget')
|
|
5856
|
+
'move-widget': ()=>moveReactModuleUseCase(folder, 'widget'),
|
|
5857
|
+
'delete-page': ()=>deleteReactModuleUseCase(folder, 'page'),
|
|
5858
|
+
'delete-widget': ()=>deleteReactModuleUseCase(folder, 'widget')
|
|
5627
5859
|
};
|
|
5628
5860
|
return actions[request.operation]();
|
|
5629
5861
|
};
|
|
@@ -33,3 +33,24 @@ export declare const routeFiles: (folder: string) => string[];
|
|
|
33
33
|
* files of that Next.js route folder move too.
|
|
34
34
|
*/
|
|
35
35
|
export declare const moveReactModule: (projectRoot: string, reactFolder: string, module: ReactModule, rawName: string, route?: RouteMove) => MovePlan;
|
|
36
|
+
/**
|
|
37
|
+
* The route folder of a page with Next.js: `<app>/<name>/` when its
|
|
38
|
+
* `page.tsx` renders the page. Undefined for other routes or none.
|
|
39
|
+
*/
|
|
40
|
+
export declare const pageRouteFolder: (appFolder: string, page: ReactModule) => string | undefined;
|
|
41
|
+
export type ReactDeleteResult = {
|
|
42
|
+
/** Files outside the module that still import it: [file, import]. */
|
|
43
|
+
usedBy: [string, string][];
|
|
44
|
+
} | {
|
|
45
|
+
deleted: string[];
|
|
46
|
+
usedBy?: undefined;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Stages the deletion of a page or widget with its files, and with `route`
|
|
50
|
+
* the files of that Next.js route folder too. Nothing is staged while other
|
|
51
|
+
* files still import the module; those imports are returned instead.
|
|
52
|
+
*/
|
|
53
|
+
export declare const deleteReactModule: (projectRoot: string, reactFolder: string, module: ReactModule, route?: {
|
|
54
|
+
appFolder: string;
|
|
55
|
+
folder: string;
|
|
56
|
+
}) => ReactDeleteResult;
|