@domain-first/project-structure 8.1.1 → 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 +17 -2
- package/dist/201.js +1 -1
- package/dist/287.js +278 -9
- package/dist/38.js +268 -0
- 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/graph.cjs +933 -0
- package/dist/graph.d.ts +2 -0
- package/dist/graph.js +337 -0
- package/dist/index.cjs +300 -12
- package/dist/index.js +4 -2
- package/dist/init.cjs +111 -57
- package/dist/integration.cjs +297 -11
- package/dist/interaction.d.ts +9 -0
- package/dist/interaction.spec.d.ts +1 -0
- package/dist/lint.js +8 -273
- package/dist/project-graph.d.ts +53 -0
- package/dist/project-graph.spec.d.ts +1 -0
- package/dist/project-lint.d.ts +10 -0
- package/dist/react-module-move.d.ts +21 -0
- package/dist/react.cjs +304 -12
- 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 +3 -2
- package/skills/df-ps-plan-feature/SKILL.md +2 -0
- 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
|
@@ -1149,6 +1149,7 @@ const missing_domain_first_packages_missingPackages = (packages)=>{
|
|
|
1149
1149
|
};
|
|
1150
1150
|
const external_node_async_hooks_namespaceObject = require("node:async_hooks");
|
|
1151
1151
|
const prompts_namespaceObject = require("@inquirer/prompts");
|
|
1152
|
+
const isSeparator = (choice)=>'function' == typeof prompts_namespaceObject.Separator && choice instanceof prompts_namespaceObject.Separator || 'object' == typeof choice && null !== choice && 'separator' === choice.type;
|
|
1152
1153
|
class RequestError extends Error {
|
|
1153
1154
|
code;
|
|
1154
1155
|
details;
|
|
@@ -1224,7 +1225,7 @@ const interaction_confirm = async (config)=>{
|
|
|
1224
1225
|
});
|
|
1225
1226
|
return value;
|
|
1226
1227
|
};
|
|
1227
|
-
const choicesOf = (config)=>config.choices.filter((choice)=>!(choice
|
|
1228
|
+
const choicesOf = (config)=>config.choices.filter((choice)=>!isSeparator(choice)).map((choice)=>'object' == typeof choice && null !== choice && 'value' in choice ? choice : {
|
|
1228
1229
|
value: choice
|
|
1229
1230
|
});
|
|
1230
1231
|
const choiceId = (choice, id)=>id?.(choice.value) ?? choice.value;
|
|
@@ -1237,9 +1238,62 @@ const resolveChoice = (value, choices, key, id)=>{
|
|
|
1237
1238
|
});
|
|
1238
1239
|
return matches[0].value;
|
|
1239
1240
|
};
|
|
1241
|
+
const searchThreshold = 10;
|
|
1242
|
+
const choiceLabel = (choice)=>choice.name ?? String(choice.value);
|
|
1243
|
+
const filterChoices = (choices, term)=>{
|
|
1244
|
+
const text = (term ?? '').trim().toLowerCase();
|
|
1245
|
+
const words = text.split(/\s+/).filter(Boolean);
|
|
1246
|
+
if (!words.length) return [
|
|
1247
|
+
...choices
|
|
1248
|
+
];
|
|
1249
|
+
const groups = [
|
|
1250
|
+
{
|
|
1251
|
+
matches: []
|
|
1252
|
+
}
|
|
1253
|
+
];
|
|
1254
|
+
for (const choice of choices){
|
|
1255
|
+
if (isSeparator(choice)) {
|
|
1256
|
+
groups.push({
|
|
1257
|
+
separator: choice,
|
|
1258
|
+
matches: []
|
|
1259
|
+
});
|
|
1260
|
+
continue;
|
|
1261
|
+
}
|
|
1262
|
+
const normalized = 'object' == typeof choice && null !== choice && 'value' in choice ? choice : {
|
|
1263
|
+
value: choice
|
|
1264
|
+
};
|
|
1265
|
+
const label = choiceLabel(normalized).toLowerCase();
|
|
1266
|
+
if (words.every((word)=>label.includes(word))) groups.at(-1)?.matches.push({
|
|
1267
|
+
choice: normalized,
|
|
1268
|
+
prefix: label.startsWith(text)
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
const byPrefix = (items, prefix)=>[
|
|
1272
|
+
...items.filter(prefix),
|
|
1273
|
+
...items.filter((item)=>!prefix(item))
|
|
1274
|
+
];
|
|
1275
|
+
const [ungrouped, ...grouped] = groups;
|
|
1276
|
+
return [
|
|
1277
|
+
ungrouped,
|
|
1278
|
+
...byPrefix(grouped.filter(({ matches })=>matches.length), ({ matches })=>matches.some(({ prefix })=>prefix))
|
|
1279
|
+
].flatMap(({ separator, matches })=>[
|
|
1280
|
+
...separator ? [
|
|
1281
|
+
separator
|
|
1282
|
+
] : [],
|
|
1283
|
+
...byPrefix(matches, ({ prefix })=>prefix).map(({ choice })=>choice)
|
|
1284
|
+
]);
|
|
1285
|
+
};
|
|
1240
1286
|
const interaction_select = async (config)=>{
|
|
1241
1287
|
const { key, id, ...interactive } = config;
|
|
1242
|
-
if (!isNonInteractive())
|
|
1288
|
+
if (!isNonInteractive()) {
|
|
1289
|
+
if (choicesOf(config).length <= searchThreshold) return (0, prompts_namespaceObject.select)(interactive);
|
|
1290
|
+
return (0, prompts_namespaceObject.search)({
|
|
1291
|
+
message: `${config.message.trimEnd()} (type to filter)`,
|
|
1292
|
+
source: (term)=>filterChoices(config.choices, term),
|
|
1293
|
+
pageSize: config.pageSize,
|
|
1294
|
+
default: config.default
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1243
1297
|
const field = requireKey(key);
|
|
1244
1298
|
const value = answerFor(field, config.default);
|
|
1245
1299
|
if (void 0 === value) throw interaction_missing(field);
|
|
@@ -3162,6 +3216,11 @@ const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operati
|
|
|
3162
3216
|
module: agent_requests_id.describe('Exact wiring target ID, including implementation class, from --describe.'),
|
|
3163
3217
|
dependencies: agent_requests_dependencies
|
|
3164
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
|
+
}),
|
|
3165
3224
|
operation('move', {
|
|
3166
3225
|
...common,
|
|
3167
3226
|
...agent_requests_owner,
|
|
@@ -3199,6 +3258,15 @@ const reactRequestSchema = external_zod_default().discriminatedUnion('operation'
|
|
|
3199
3258
|
name: agent_requests_nestedName,
|
|
3200
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.')
|
|
3201
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
|
+
}),
|
|
3202
3270
|
operation('move-widget', {
|
|
3203
3271
|
...common,
|
|
3204
3272
|
module: agent_requests_nestedName,
|
|
@@ -3702,6 +3770,75 @@ const projectRelative = (fromFile, toFile)=>{
|
|
|
3702
3770
|
const relative = toPosix(external_node_path_default().relative(external_node_path_default().dirname(fromFile), toFile.replace(codeExtension, '')));
|
|
3703
3771
|
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
3704
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
|
+
};
|
|
3705
3842
|
const contractKinds = [
|
|
3706
3843
|
'aggregate',
|
|
3707
3844
|
'command',
|
|
@@ -3885,7 +4022,7 @@ const validateMove = (reactFolder, module, rawName)=>{
|
|
|
3885
4022
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
3886
4023
|
return true;
|
|
3887
4024
|
};
|
|
3888
|
-
const
|
|
4025
|
+
const react_module_move_routeFolder = (appFolder, rawName)=>{
|
|
3889
4026
|
const { folders, folderName } = new NestedName(rawName);
|
|
3890
4027
|
return external_node_path_default().join(appFolder, ...folders, folderName);
|
|
3891
4028
|
};
|
|
@@ -3947,6 +4084,51 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
3947
4084
|
}
|
|
3948
4085
|
});
|
|
3949
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
|
+
};
|
|
3950
4132
|
const systemImplementationChoices = (kind, crossContext = false)=>{
|
|
3951
4133
|
if ('ports' === kind) return crossContext ? [
|
|
3952
4134
|
{
|
|
@@ -3961,6 +4143,108 @@ const systemImplementationChoices = (kind, crossContext = false)=>{
|
|
|
3961
4143
|
}
|
|
3962
4144
|
] : [];
|
|
3963
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
|
+
};
|
|
3964
4248
|
Symbol('create-test-branch');
|
|
3965
4249
|
Symbol('no-test-branch');
|
|
3966
4250
|
const noAggregate = 'No aggregate';
|
|
@@ -4064,11 +4348,10 @@ const moveBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
4064
4348
|
const promptRouteMove = async (root, page, newName)=>{
|
|
4065
4349
|
if (!usesNext()) return;
|
|
4066
4350
|
const appFolder = external_node_path_default().join(root, nextAppFolder(root));
|
|
4067
|
-
const from =
|
|
4068
|
-
const to =
|
|
4351
|
+
const from = pageRouteFolder(appFolder, page);
|
|
4352
|
+
const to = react_module_move_routeFolder(appFolder, newName);
|
|
4069
4353
|
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4070
|
-
|
|
4071
|
-
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;
|
|
4072
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.`);
|
|
4073
4356
|
const move = await interaction_confirm({
|
|
4074
4357
|
key: 'moveRoute',
|
|
@@ -5524,7 +5807,7 @@ const executeScaffold = async (request, owner)=>{
|
|
|
5524
5807
|
'errors'
|
|
5525
5808
|
]).content.fileNames.includes(request.namespace)) throw new RequestError('TARGET_NOT_FOUND', `Unknown namespace: ${request.namespace}.`);
|
|
5526
5809
|
if ('implementation' === request.operation && !findContracts(owner.path).length) throw new RequestError('TARGET_NOT_FOUND', 'No contracts in this context.');
|
|
5527
|
-
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.');
|
|
5528
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.');
|
|
5529
5812
|
if ('endpoint' === request.operation) {
|
|
5530
5813
|
if (!config_file_ConfigFile.backend.domainFirstPackages.includes('@domain-first/handlers-rest') || !findRestEndpointGenerator(new file_system_Folder(requireProject()).subitem([
|
|
@@ -5553,7 +5836,8 @@ const executeScaffold = async (request, owner)=>{
|
|
|
5553
5836
|
implementation: ()=>scaffoldNewImplementation(owner),
|
|
5554
5837
|
endpoint: ()=>scaffoldNewHandlersRestEndpoint(owner),
|
|
5555
5838
|
'wire-dependency': ()=>wireDependency(owner),
|
|
5556
|
-
move: ()=>moveBackendUnitUseCase(owner)
|
|
5839
|
+
move: ()=>moveBackendUnitUseCase(owner),
|
|
5840
|
+
delete: ()=>deleteBackendUnitUseCase(owner)
|
|
5557
5841
|
};
|
|
5558
5842
|
return actions[request.operation]();
|
|
5559
5843
|
};
|
|
@@ -5562,14 +5846,16 @@ const executeReact = async (request)=>{
|
|
|
5562
5846
|
config_file_ConfigFile.Instance.data.project.rootFolder,
|
|
5563
5847
|
'presentation/react'
|
|
5564
5848
|
]);
|
|
5565
|
-
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.`);
|
|
5566
5850
|
const actions = {
|
|
5567
5851
|
page: ()=>scaffoldReactPage(folder),
|
|
5568
5852
|
widget: ()=>scaffoldReactWidget(folder),
|
|
5569
5853
|
'ui-kit-component': ()=>scaffoldReactUIKitComponent(folder),
|
|
5570
5854
|
'shared-hook': ()=>scaffoldReactSharedHook(folder),
|
|
5571
5855
|
'move-page': ()=>moveReactModuleUseCase(folder, 'page'),
|
|
5572
|
-
'move-widget': ()=>moveReactModuleUseCase(folder, 'widget')
|
|
5856
|
+
'move-widget': ()=>moveReactModuleUseCase(folder, 'widget'),
|
|
5857
|
+
'delete-page': ()=>deleteReactModuleUseCase(folder, 'page'),
|
|
5858
|
+
'delete-widget': ()=>deleteReactModuleUseCase(folder, 'widget')
|
|
5573
5859
|
};
|
|
5574
5860
|
return actions[request.operation]();
|
|
5575
5861
|
};
|
package/dist/interaction.d.ts
CHANGED
|
@@ -35,6 +35,15 @@ type SelectConfig<T> = {
|
|
|
35
35
|
loop?: boolean;
|
|
36
36
|
id?: (value: T) => string;
|
|
37
37
|
};
|
|
38
|
+
/** Longer menus get a search field: typing filters the choices. */
|
|
39
|
+
export declare const searchThreshold = 10;
|
|
40
|
+
/**
|
|
41
|
+
* The choices whose label contains every typed word, in any case. Labels
|
|
42
|
+
* that start with the typed text come first, and so do their groups, so
|
|
43
|
+
* the highlighted choice is the one a prefix names. A group separator
|
|
44
|
+
* stays only when a choice of its group is left.
|
|
45
|
+
*/
|
|
46
|
+
export declare const filterChoices: <T>(choices: SelectConfig<T>["choices"], term: string | undefined) => (Separator | T | Choice<T>)[];
|
|
38
47
|
export declare const select: <T>(config: SelectConfig<T>) => Promise<T>;
|
|
39
48
|
export declare const checkbox: <T>(config: Omit<SelectConfig<T>, "default"> & {
|
|
40
49
|
required?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|