@domain-first/project-structure 8.0.0 → 8.1.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 +1 -1
- package/dist/287.js +52 -7
- package/dist/561.js +2 -1
- package/dist/agent-cli.d.ts +1 -0
- package/dist/agent-requests.d.ts +2 -0
- package/dist/index.cjs +54 -8
- package/dist/integration.cjs +54 -8
- package/dist/module-move.d.ts +6 -2
- package/dist/react-module-move.d.ts +17 -2
- package/dist/react.cjs +54 -8
- package/package.json +1 -1
- package/skills/df-ps-react/SKILL.md +1 -1
- package/skills/df-ps-scaffold/references/agent-operations.md +1 -1
package/README.md
CHANGED
|
@@ -265,7 +265,7 @@ admin/panel/users → pages/admin/panel/admin-panel-users-page.tsx (AdminPane
|
|
|
265
265
|
|
|
266
266
|
With Next.js, a new page also gets its App Router route, `app/admin/panel/users/page.tsx`, which renders `AdminPanelUsersPage`. An existing route is never overwritten.
|
|
267
267
|
|
|
268
|
-
**Move or rename page** and **Move or rename widget** move the files and update every import in the project.
|
|
268
|
+
**Move or rename page** and **Move or rename widget** move the files and update every import in the project. With Next.js, moving a page also offers to move its route, `app/admin/users/` → `app/backoffice/users/`, since its URL changes with it.
|
|
269
269
|
|
|
270
270
|
### How to add tooling
|
|
271
271
|
|
package/dist/287.js
CHANGED
|
@@ -2211,7 +2211,8 @@ const projectImports = (projectRoot)=>{
|
|
|
2211
2211
|
importsOf
|
|
2212
2212
|
};
|
|
2213
2213
|
};
|
|
2214
|
-
const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content })=>{
|
|
2214
|
+
const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
|
|
2215
|
+
const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
|
|
2215
2216
|
const { resolve, specifierFor, codeFiles } = projectImports(projectRoot);
|
|
2216
2217
|
const barrels = new Set();
|
|
2217
2218
|
const isBarrel = (resolved)=>barrels.has(resolved.replace(codeExtension, ''));
|
|
@@ -2248,14 +2249,14 @@ const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyF
|
|
|
2248
2249
|
moved: moves.has(oldFile)
|
|
2249
2250
|
});
|
|
2250
2251
|
};
|
|
2251
|
-
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new File(file).moveTo(newFile,
|
|
2252
|
+
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new File(file).moveTo(newFile, stopFor(file));
|
|
2252
2253
|
const updated = [];
|
|
2253
2254
|
for (const [file, content] of codeFiles){
|
|
2254
2255
|
const newFile = moves.get(file);
|
|
2255
2256
|
const next = rewrite(content, file, newFile ?? file);
|
|
2256
2257
|
if (newFile && newFile !== file) {
|
|
2257
2258
|
new File(newFile).data = next;
|
|
2258
|
-
new File(file).delete(
|
|
2259
|
+
new File(file).delete(stopFor(file));
|
|
2259
2260
|
} else if (next !== content) {
|
|
2260
2261
|
new File(file).update(next);
|
|
2261
2262
|
if (!newFile) updated.push(file);
|
|
@@ -2779,7 +2780,14 @@ const validateMove = (reactFolder, module, rawName)=>{
|
|
|
2779
2780
|
if (target.startsWith(`${module.path}${node_path.sep}`)) return 'A widget cannot be moved into itself';
|
|
2780
2781
|
return true;
|
|
2781
2782
|
};
|
|
2782
|
-
const
|
|
2783
|
+
const routeFolder = (appFolder, rawName)=>{
|
|
2784
|
+
const { folders, folderName } = new NestedName(rawName);
|
|
2785
|
+
return node_path.join(appFolder, ...folders, folderName);
|
|
2786
|
+
};
|
|
2787
|
+
const routeFiles = (folder)=>node_fs.existsSync(folder) ? node_fs.readdirSync(folder, {
|
|
2788
|
+
withFileTypes: true
|
|
2789
|
+
}).filter((entry)=>entry.isFile()).map((entry)=>node_path.join(folder, entry.name)) : [];
|
|
2790
|
+
const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
2783
2791
|
const newName = new NestedName(rawName);
|
|
2784
2792
|
const target = targetPath(reactFolder, module, rawName);
|
|
2785
2793
|
const newClassName = newName.ClassName;
|
|
@@ -2787,7 +2795,19 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
2787
2795
|
const oldFolder = 'page' === module.kind ? node_path.dirname(module.path) : module.path;
|
|
2788
2796
|
const newFolder = 'page' === module.kind ? node_path.dirname(target) : target;
|
|
2789
2797
|
const ownsPath = (candidate)=>'page' === module.kind ? node_path.dirname(candidate) === oldFolder && new RegExp(`^${escapeRegExp(module.fileBase)}-page(?:\\.|$)`).test(node_path.basename(candidate)) : candidate === oldFolder || candidate.startsWith(`${oldFolder}${node_path.sep}`);
|
|
2798
|
+
const routeFileSet = new Set(route ? routeFiles(route.from) : []);
|
|
2799
|
+
const routeTarget = (candidate)=>{
|
|
2800
|
+
if (!route) return;
|
|
2801
|
+
const file = [
|
|
2802
|
+
...routeFileSet
|
|
2803
|
+
].find((x)=>x === candidate || x.replace(codeExtension, '') === candidate);
|
|
2804
|
+
if (!file) return;
|
|
2805
|
+
const moved = node_path.join(route.to, node_path.relative(route.from, file));
|
|
2806
|
+
return file === candidate ? moved : moved.replace(codeExtension, '');
|
|
2807
|
+
};
|
|
2790
2808
|
const movedPath = (candidate)=>{
|
|
2809
|
+
const routed = routeTarget(candidate);
|
|
2810
|
+
if (routed) return routed;
|
|
2791
2811
|
if (!ownsPath(candidate)) return;
|
|
2792
2812
|
const segments = node_path.relative(oldFolder, candidate).split(node_path.sep);
|
|
2793
2813
|
const last = segments.length - 1;
|
|
@@ -2795,7 +2815,10 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
2795
2815
|
return node_path.join(newFolder, ...segments);
|
|
2796
2816
|
};
|
|
2797
2817
|
const moduleFiles = 'page' === module.kind ? node_fs.readdirSync(oldFolder).map((name)=>node_path.join(oldFolder, name)).filter((file)=>node_fs.statSync(file).isFile() && ownsPath(file)) : walk(oldFolder);
|
|
2798
|
-
const moves = new Map(
|
|
2818
|
+
const moves = new Map([
|
|
2819
|
+
...moduleFiles,
|
|
2820
|
+
...routeFileSet
|
|
2821
|
+
].map((file)=>[
|
|
2799
2822
|
file,
|
|
2800
2823
|
movedPath(file) ?? file
|
|
2801
2824
|
]));
|
|
@@ -2810,6 +2833,7 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
2810
2833
|
return stageModuleMove({
|
|
2811
2834
|
projectRoot,
|
|
2812
2835
|
stopAt: reactFolder,
|
|
2836
|
+
stopAtFor: (file)=>route && routeFileSet.has(file) ? route.appFolder : void 0,
|
|
2813
2837
|
moves,
|
|
2814
2838
|
movedPath,
|
|
2815
2839
|
rename: (content, { moved })=>{
|
|
@@ -3208,6 +3232,26 @@ const moveBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
3208
3232
|
report('Cancelled: nothing was written.');
|
|
3209
3233
|
}
|
|
3210
3234
|
};
|
|
3235
|
+
const promptRouteMove = async (root, page, newName)=>{
|
|
3236
|
+
if (!usesNext()) return;
|
|
3237
|
+
const appFolder = node_path.join(root, nextAppFolder(root));
|
|
3238
|
+
const from = routeFolder(appFolder, page.name);
|
|
3239
|
+
const to = routeFolder(appFolder, newName);
|
|
3240
|
+
const relative = (file)=>node_path.relative(root, file).split(node_path.sep).join('/');
|
|
3241
|
+
const routePage = node_path.join(from, 'page.tsx');
|
|
3242
|
+
if (from === to || !node_fs.existsSync(routePage) || !new RegExp(`\\b${page.ClassName}Page\\b`).test(node_fs.readFileSync(routePage, 'utf8'))) return;
|
|
3243
|
+
if (node_fs.existsSync(node_path.join(to, 'page.tsx'))) return void report(`${relative(to)}/page.tsx already exists: the route ${relative(from)} stays.`);
|
|
3244
|
+
const move = await interaction_confirm({
|
|
3245
|
+
key: 'moveRoute',
|
|
3246
|
+
message: `Move the Next.js route too: ${relative(from)} → ${relative(to)}? Its URL changes.`,
|
|
3247
|
+
default: true
|
|
3248
|
+
});
|
|
3249
|
+
return move ? {
|
|
3250
|
+
appFolder,
|
|
3251
|
+
from,
|
|
3252
|
+
to
|
|
3253
|
+
} : void 0;
|
|
3254
|
+
};
|
|
3211
3255
|
const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
3212
3256
|
const reactFolder = presentationReactFolder.path;
|
|
3213
3257
|
const modules = findReactModules(reactFolder, kind);
|
|
@@ -3229,9 +3273,10 @@ const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
|
3229
3273
|
validate: (value)=>validateMove(reactFolder, module, value)
|
|
3230
3274
|
});
|
|
3231
3275
|
const root = new ProjectRoot().path;
|
|
3232
|
-
const
|
|
3276
|
+
const relative = (file)=>node_path.relative(root, file).split(node_path.sep).join('/');
|
|
3277
|
+
const route = 'page' === kind ? await promptRouteMove(root, module, name) : void 0;
|
|
3278
|
+
const { moves, updated } = moveReactModule(root, reactFolder, module, name, route);
|
|
3233
3279
|
if (!moves.length && !updated.length) return void report('Nothing to change.');
|
|
3234
|
-
const relative = (file)=>node_path.relative(root, file);
|
|
3235
3280
|
report([
|
|
3236
3281
|
'Files to move:',
|
|
3237
3282
|
...moves.map(([from, to])=>` ${relative(from)} → ${relative(to)}`),
|
package/dist/561.js
CHANGED
|
@@ -156,7 +156,8 @@ const reactRequestSchema = zod.discriminatedUnion('operation', [
|
|
|
156
156
|
operation('move-page', {
|
|
157
157
|
...common,
|
|
158
158
|
module: nestedName,
|
|
159
|
-
name: nestedName
|
|
159
|
+
name: nestedName,
|
|
160
|
+
moveRoute: zod.boolean().optional().describe('With Next.js and a route at the page path: move it too (default true). Omit it without such a route.')
|
|
160
161
|
}),
|
|
161
162
|
operation('move-widget', {
|
|
162
163
|
...common,
|
package/dist/agent-cli.d.ts
CHANGED
|
@@ -221,6 +221,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
221
221
|
operation: z.ZodLiteral<"move-page">;
|
|
222
222
|
module: z.ZodString;
|
|
223
223
|
name: z.ZodString;
|
|
224
|
+
moveRoute: z.ZodOptional<z.ZodBoolean>;
|
|
224
225
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
225
226
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
226
227
|
}, z.core.$strict>, z.ZodObject<{
|
package/dist/agent-requests.d.ts
CHANGED
|
@@ -200,6 +200,7 @@ export declare const reactRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
200
200
|
operation: z.ZodLiteral<"move-page">;
|
|
201
201
|
module: z.ZodString;
|
|
202
202
|
name: z.ZodString;
|
|
203
|
+
moveRoute: z.ZodOptional<z.ZodBoolean>;
|
|
203
204
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
204
205
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
205
206
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -444,6 +445,7 @@ export declare const requestSchemaFor: (command: AgentCommand) => z.ZodDiscrimin
|
|
|
444
445
|
operation: z.ZodLiteral<"move-page">;
|
|
445
446
|
module: z.ZodString;
|
|
446
447
|
name: z.ZodString;
|
|
448
|
+
moveRoute: z.ZodOptional<z.ZodBoolean>;
|
|
447
449
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
448
450
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
449
451
|
}, z.core.$strict>, z.ZodObject<{
|
package/dist/index.cjs
CHANGED
|
@@ -3196,7 +3196,8 @@ const reactRequestSchema = external_zod_default().discriminatedUnion('operation'
|
|
|
3196
3196
|
agent_requests_operation('move-page', {
|
|
3197
3197
|
...common,
|
|
3198
3198
|
module: agent_requests_nestedName,
|
|
3199
|
-
name: agent_requests_nestedName
|
|
3199
|
+
name: agent_requests_nestedName,
|
|
3200
|
+
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.')
|
|
3200
3201
|
}),
|
|
3201
3202
|
agent_requests_operation('move-widget', {
|
|
3202
3203
|
...common,
|
|
@@ -3315,7 +3316,8 @@ const projectImports = (projectRoot)=>{
|
|
|
3315
3316
|
importsOf
|
|
3316
3317
|
};
|
|
3317
3318
|
};
|
|
3318
|
-
const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content })=>{
|
|
3319
|
+
const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
|
|
3320
|
+
const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
|
|
3319
3321
|
const { resolve, specifierFor, codeFiles } = projectImports(projectRoot);
|
|
3320
3322
|
const barrels = new Set();
|
|
3321
3323
|
const isBarrel = (resolved)=>barrels.has(resolved.replace(codeExtension, ''));
|
|
@@ -3352,14 +3354,14 @@ const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyF
|
|
|
3352
3354
|
moved: moves.has(oldFile)
|
|
3353
3355
|
});
|
|
3354
3356
|
};
|
|
3355
|
-
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new file_system_File(file).moveTo(newFile,
|
|
3357
|
+
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new file_system_File(file).moveTo(newFile, stopFor(file));
|
|
3356
3358
|
const updated = [];
|
|
3357
3359
|
for (const [file, content] of codeFiles){
|
|
3358
3360
|
const newFile = moves.get(file);
|
|
3359
3361
|
const next = rewrite(content, file, newFile ?? file);
|
|
3360
3362
|
if (newFile && newFile !== file) {
|
|
3361
3363
|
new file_system_File(newFile).data = next;
|
|
3362
|
-
new file_system_File(file).delete(
|
|
3364
|
+
new file_system_File(file).delete(stopFor(file));
|
|
3363
3365
|
} else if (next !== content) {
|
|
3364
3366
|
new file_system_File(file).update(next);
|
|
3365
3367
|
if (!newFile) updated.push(file);
|
|
@@ -3883,7 +3885,14 @@ const validateMove = (reactFolder, module, rawName)=>{
|
|
|
3883
3885
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
3884
3886
|
return true;
|
|
3885
3887
|
};
|
|
3886
|
-
const
|
|
3888
|
+
const routeFolder = (appFolder, rawName)=>{
|
|
3889
|
+
const { folders, folderName } = new NestedName(rawName);
|
|
3890
|
+
return external_node_path_default().join(appFolder, ...folders, folderName);
|
|
3891
|
+
};
|
|
3892
|
+
const routeFiles = (folder)=>external_node_fs_default().existsSync(folder) ? external_node_fs_default().readdirSync(folder, {
|
|
3893
|
+
withFileTypes: true
|
|
3894
|
+
}).filter((entry)=>entry.isFile()).map((entry)=>external_node_path_default().join(folder, entry.name)) : [];
|
|
3895
|
+
const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
3887
3896
|
const newName = new NestedName(rawName);
|
|
3888
3897
|
const target = react_module_move_targetPath(reactFolder, module, rawName);
|
|
3889
3898
|
const newClassName = newName.ClassName;
|
|
@@ -3891,7 +3900,19 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
3891
3900
|
const oldFolder = 'page' === module.kind ? external_node_path_default().dirname(module.path) : module.path;
|
|
3892
3901
|
const newFolder = 'page' === module.kind ? external_node_path_default().dirname(target) : target;
|
|
3893
3902
|
const ownsPath = (candidate)=>'page' === module.kind ? external_node_path_default().dirname(candidate) === oldFolder && new RegExp(`^${escapeRegExp(module.fileBase)}-page(?:\\.|$)`).test(external_node_path_default().basename(candidate)) : candidate === oldFolder || candidate.startsWith(`${oldFolder}${external_node_path_default().sep}`);
|
|
3903
|
+
const routeFileSet = new Set(route ? routeFiles(route.from) : []);
|
|
3904
|
+
const routeTarget = (candidate)=>{
|
|
3905
|
+
if (!route) return;
|
|
3906
|
+
const file = [
|
|
3907
|
+
...routeFileSet
|
|
3908
|
+
].find((x)=>x === candidate || x.replace(codeExtension, '') === candidate);
|
|
3909
|
+
if (!file) return;
|
|
3910
|
+
const moved = external_node_path_default().join(route.to, external_node_path_default().relative(route.from, file));
|
|
3911
|
+
return file === candidate ? moved : moved.replace(codeExtension, '');
|
|
3912
|
+
};
|
|
3894
3913
|
const movedPath = (candidate)=>{
|
|
3914
|
+
const routed = routeTarget(candidate);
|
|
3915
|
+
if (routed) return routed;
|
|
3895
3916
|
if (!ownsPath(candidate)) return;
|
|
3896
3917
|
const segments = external_node_path_default().relative(oldFolder, candidate).split(external_node_path_default().sep);
|
|
3897
3918
|
const last = segments.length - 1;
|
|
@@ -3899,7 +3920,10 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
3899
3920
|
return external_node_path_default().join(newFolder, ...segments);
|
|
3900
3921
|
};
|
|
3901
3922
|
const moduleFiles = 'page' === module.kind ? external_node_fs_default().readdirSync(oldFolder).map((name)=>external_node_path_default().join(oldFolder, name)).filter((file)=>external_node_fs_default().statSync(file).isFile() && ownsPath(file)) : module_move_walk(oldFolder);
|
|
3902
|
-
const moves = new Map(
|
|
3923
|
+
const moves = new Map([
|
|
3924
|
+
...moduleFiles,
|
|
3925
|
+
...routeFileSet
|
|
3926
|
+
].map((file)=>[
|
|
3903
3927
|
file,
|
|
3904
3928
|
movedPath(file) ?? file
|
|
3905
3929
|
]));
|
|
@@ -3914,6 +3938,7 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
3914
3938
|
return stageModuleMove({
|
|
3915
3939
|
projectRoot,
|
|
3916
3940
|
stopAt: reactFolder,
|
|
3941
|
+
stopAtFor: (file)=>route && routeFileSet.has(file) ? route.appFolder : void 0,
|
|
3917
3942
|
moves,
|
|
3918
3943
|
movedPath,
|
|
3919
3944
|
rename: (content, { moved })=>{
|
|
@@ -4036,6 +4061,26 @@ const moveBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
4036
4061
|
report('Cancelled: nothing was written.');
|
|
4037
4062
|
}
|
|
4038
4063
|
};
|
|
4064
|
+
const promptRouteMove = async (root, page, newName)=>{
|
|
4065
|
+
if (!usesNext()) return;
|
|
4066
|
+
const appFolder = external_node_path_default().join(root, nextAppFolder(root));
|
|
4067
|
+
const from = routeFolder(appFolder, page.name);
|
|
4068
|
+
const to = routeFolder(appFolder, newName);
|
|
4069
|
+
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4070
|
+
const routePage = external_node_path_default().join(from, 'page.tsx');
|
|
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;
|
|
4072
|
+
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
|
+
const move = await interaction_confirm({
|
|
4074
|
+
key: 'moveRoute',
|
|
4075
|
+
message: `Move the Next.js route too: ${relative(from)} → ${relative(to)}? Its URL changes.`,
|
|
4076
|
+
default: true
|
|
4077
|
+
});
|
|
4078
|
+
return move ? {
|
|
4079
|
+
appFolder,
|
|
4080
|
+
from,
|
|
4081
|
+
to
|
|
4082
|
+
} : void 0;
|
|
4083
|
+
};
|
|
4039
4084
|
const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
4040
4085
|
const reactFolder = presentationReactFolder.path;
|
|
4041
4086
|
const modules = findReactModules(reactFolder, kind);
|
|
@@ -4057,9 +4102,10 @@ const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
|
4057
4102
|
validate: (value)=>validateMove(reactFolder, module, value)
|
|
4058
4103
|
});
|
|
4059
4104
|
const root = new project_root_ProjectRoot().path;
|
|
4060
|
-
const
|
|
4105
|
+
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4106
|
+
const route = 'page' === kind ? await promptRouteMove(root, module, name) : void 0;
|
|
4107
|
+
const { moves, updated } = moveReactModule(root, reactFolder, module, name, route);
|
|
4061
4108
|
if (!moves.length && !updated.length) return void report('Nothing to change.');
|
|
4062
|
-
const relative = (file)=>external_node_path_default().relative(root, file);
|
|
4063
4109
|
report([
|
|
4064
4110
|
'Files to move:',
|
|
4065
4111
|
...moves.map(([from, to])=>` ${relative(from)} → ${relative(to)}`),
|
package/dist/integration.cjs
CHANGED
|
@@ -3196,7 +3196,8 @@ const reactRequestSchema = external_zod_default().discriminatedUnion('operation'
|
|
|
3196
3196
|
operation('move-page', {
|
|
3197
3197
|
...common,
|
|
3198
3198
|
module: agent_requests_nestedName,
|
|
3199
|
-
name: agent_requests_nestedName
|
|
3199
|
+
name: agent_requests_nestedName,
|
|
3200
|
+
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.')
|
|
3200
3201
|
}),
|
|
3201
3202
|
operation('move-widget', {
|
|
3202
3203
|
...common,
|
|
@@ -3315,7 +3316,8 @@ const projectImports = (projectRoot)=>{
|
|
|
3315
3316
|
importsOf
|
|
3316
3317
|
};
|
|
3317
3318
|
};
|
|
3318
|
-
const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content })=>{
|
|
3319
|
+
const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
|
|
3320
|
+
const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
|
|
3319
3321
|
const { resolve, specifierFor, codeFiles } = projectImports(projectRoot);
|
|
3320
3322
|
const barrels = new Set();
|
|
3321
3323
|
const isBarrel = (resolved)=>barrels.has(resolved.replace(codeExtension, ''));
|
|
@@ -3352,14 +3354,14 @@ const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyF
|
|
|
3352
3354
|
moved: moves.has(oldFile)
|
|
3353
3355
|
});
|
|
3354
3356
|
};
|
|
3355
|
-
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new file_system_File(file).moveTo(newFile,
|
|
3357
|
+
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new file_system_File(file).moveTo(newFile, stopFor(file));
|
|
3356
3358
|
const updated = [];
|
|
3357
3359
|
for (const [file, content] of codeFiles){
|
|
3358
3360
|
const newFile = moves.get(file);
|
|
3359
3361
|
const next = rewrite(content, file, newFile ?? file);
|
|
3360
3362
|
if (newFile && newFile !== file) {
|
|
3361
3363
|
new file_system_File(newFile).data = next;
|
|
3362
|
-
new file_system_File(file).delete(
|
|
3364
|
+
new file_system_File(file).delete(stopFor(file));
|
|
3363
3365
|
} else if (next !== content) {
|
|
3364
3366
|
new file_system_File(file).update(next);
|
|
3365
3367
|
if (!newFile) updated.push(file);
|
|
@@ -3883,7 +3885,14 @@ const validateMove = (reactFolder, module, rawName)=>{
|
|
|
3883
3885
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
3884
3886
|
return true;
|
|
3885
3887
|
};
|
|
3886
|
-
const
|
|
3888
|
+
const routeFolder = (appFolder, rawName)=>{
|
|
3889
|
+
const { folders, folderName } = new NestedName(rawName);
|
|
3890
|
+
return external_node_path_default().join(appFolder, ...folders, folderName);
|
|
3891
|
+
};
|
|
3892
|
+
const routeFiles = (folder)=>external_node_fs_default().existsSync(folder) ? external_node_fs_default().readdirSync(folder, {
|
|
3893
|
+
withFileTypes: true
|
|
3894
|
+
}).filter((entry)=>entry.isFile()).map((entry)=>external_node_path_default().join(folder, entry.name)) : [];
|
|
3895
|
+
const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
3887
3896
|
const newName = new NestedName(rawName);
|
|
3888
3897
|
const target = react_module_move_targetPath(reactFolder, module, rawName);
|
|
3889
3898
|
const newClassName = newName.ClassName;
|
|
@@ -3891,7 +3900,19 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
3891
3900
|
const oldFolder = 'page' === module.kind ? external_node_path_default().dirname(module.path) : module.path;
|
|
3892
3901
|
const newFolder = 'page' === module.kind ? external_node_path_default().dirname(target) : target;
|
|
3893
3902
|
const ownsPath = (candidate)=>'page' === module.kind ? external_node_path_default().dirname(candidate) === oldFolder && new RegExp(`^${escapeRegExp(module.fileBase)}-page(?:\\.|$)`).test(external_node_path_default().basename(candidate)) : candidate === oldFolder || candidate.startsWith(`${oldFolder}${external_node_path_default().sep}`);
|
|
3903
|
+
const routeFileSet = new Set(route ? routeFiles(route.from) : []);
|
|
3904
|
+
const routeTarget = (candidate)=>{
|
|
3905
|
+
if (!route) return;
|
|
3906
|
+
const file = [
|
|
3907
|
+
...routeFileSet
|
|
3908
|
+
].find((x)=>x === candidate || x.replace(codeExtension, '') === candidate);
|
|
3909
|
+
if (!file) return;
|
|
3910
|
+
const moved = external_node_path_default().join(route.to, external_node_path_default().relative(route.from, file));
|
|
3911
|
+
return file === candidate ? moved : moved.replace(codeExtension, '');
|
|
3912
|
+
};
|
|
3894
3913
|
const movedPath = (candidate)=>{
|
|
3914
|
+
const routed = routeTarget(candidate);
|
|
3915
|
+
if (routed) return routed;
|
|
3895
3916
|
if (!ownsPath(candidate)) return;
|
|
3896
3917
|
const segments = external_node_path_default().relative(oldFolder, candidate).split(external_node_path_default().sep);
|
|
3897
3918
|
const last = segments.length - 1;
|
|
@@ -3899,7 +3920,10 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
3899
3920
|
return external_node_path_default().join(newFolder, ...segments);
|
|
3900
3921
|
};
|
|
3901
3922
|
const moduleFiles = 'page' === module.kind ? external_node_fs_default().readdirSync(oldFolder).map((name)=>external_node_path_default().join(oldFolder, name)).filter((file)=>external_node_fs_default().statSync(file).isFile() && ownsPath(file)) : module_move_walk(oldFolder);
|
|
3902
|
-
const moves = new Map(
|
|
3923
|
+
const moves = new Map([
|
|
3924
|
+
...moduleFiles,
|
|
3925
|
+
...routeFileSet
|
|
3926
|
+
].map((file)=>[
|
|
3903
3927
|
file,
|
|
3904
3928
|
movedPath(file) ?? file
|
|
3905
3929
|
]));
|
|
@@ -3914,6 +3938,7 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
3914
3938
|
return stageModuleMove({
|
|
3915
3939
|
projectRoot,
|
|
3916
3940
|
stopAt: reactFolder,
|
|
3941
|
+
stopAtFor: (file)=>route && routeFileSet.has(file) ? route.appFolder : void 0,
|
|
3917
3942
|
moves,
|
|
3918
3943
|
movedPath,
|
|
3919
3944
|
rename: (content, { moved })=>{
|
|
@@ -4036,6 +4061,26 @@ const moveBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
4036
4061
|
report('Cancelled: nothing was written.');
|
|
4037
4062
|
}
|
|
4038
4063
|
};
|
|
4064
|
+
const promptRouteMove = async (root, page, newName)=>{
|
|
4065
|
+
if (!usesNext()) return;
|
|
4066
|
+
const appFolder = external_node_path_default().join(root, nextAppFolder(root));
|
|
4067
|
+
const from = routeFolder(appFolder, page.name);
|
|
4068
|
+
const to = routeFolder(appFolder, newName);
|
|
4069
|
+
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4070
|
+
const routePage = external_node_path_default().join(from, 'page.tsx');
|
|
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;
|
|
4072
|
+
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
|
+
const move = await interaction_confirm({
|
|
4074
|
+
key: 'moveRoute',
|
|
4075
|
+
message: `Move the Next.js route too: ${relative(from)} → ${relative(to)}? Its URL changes.`,
|
|
4076
|
+
default: true
|
|
4077
|
+
});
|
|
4078
|
+
return move ? {
|
|
4079
|
+
appFolder,
|
|
4080
|
+
from,
|
|
4081
|
+
to
|
|
4082
|
+
} : void 0;
|
|
4083
|
+
};
|
|
4039
4084
|
const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
4040
4085
|
const reactFolder = presentationReactFolder.path;
|
|
4041
4086
|
const modules = findReactModules(reactFolder, kind);
|
|
@@ -4057,9 +4102,10 @@ const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
|
4057
4102
|
validate: (value)=>validateMove(reactFolder, module, value)
|
|
4058
4103
|
});
|
|
4059
4104
|
const root = new project_root_ProjectRoot().path;
|
|
4060
|
-
const
|
|
4105
|
+
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4106
|
+
const route = 'page' === kind ? await promptRouteMove(root, module, name) : void 0;
|
|
4107
|
+
const { moves, updated } = moveReactModule(root, reactFolder, module, name, route);
|
|
4061
4108
|
if (!moves.length && !updated.length) return void report('Nothing to change.');
|
|
4062
|
-
const relative = (file)=>external_node_path_default().relative(root, file);
|
|
4063
4109
|
report([
|
|
4064
4110
|
'Files to move:',
|
|
4065
4111
|
...moves.map(([from, to])=>` ${relative(from)} → ${relative(to)}`),
|
package/dist/module-move.d.ts
CHANGED
|
@@ -31,8 +31,12 @@ export type MovePlan = {
|
|
|
31
31
|
};
|
|
32
32
|
export type ModuleMove = {
|
|
33
33
|
projectRoot: string;
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Folders emptied by the move are removed up to this one (exclusive),
|
|
36
|
+
* or up to the folder `stopAtFor` gives for a file outside it.
|
|
37
|
+
*/
|
|
35
38
|
stopAt: string;
|
|
39
|
+
stopAtFor?: (file: string) => string | undefined;
|
|
36
40
|
/** Old path → new path of every file of the module. */
|
|
37
41
|
moves: Map<string, string>;
|
|
38
42
|
/**
|
|
@@ -54,5 +58,5 @@ export type ModuleMove = {
|
|
|
54
58
|
* Stages the move with pending changes: files of the module, its imports
|
|
55
59
|
* of other files, and every import of it in the project.
|
|
56
60
|
*/
|
|
57
|
-
export declare const stageModuleMove: ({ projectRoot, stopAt, moves, movedPath, rename, everyFile }: ModuleMove) => MovePlan;
|
|
61
|
+
export declare const stageModuleMove: ({ projectRoot, stopAt, moves, movedPath, rename, everyFile, stopAtFor }: ModuleMove) => MovePlan;
|
|
58
62
|
export {};
|
|
@@ -13,8 +13,23 @@ export type ReactModule = {
|
|
|
13
13
|
};
|
|
14
14
|
export declare const findReactModules: (reactFolder: string, kind: ReactModuleKind) => ReactModule[];
|
|
15
15
|
export declare const validateMove: (reactFolder: string, module: ReactModule, rawName: string) => string | true;
|
|
16
|
+
/** A Next.js App Router route folder moved with a page. */
|
|
17
|
+
export type RouteMove = {
|
|
18
|
+
/** The App Router folder, e.g. `<root>/app`. */
|
|
19
|
+
appFolder: string;
|
|
20
|
+
from: string;
|
|
21
|
+
to: string;
|
|
22
|
+
};
|
|
23
|
+
/** The route folder of a nested page name: `admin/users` → `<app>/admin/users`. */
|
|
24
|
+
export declare const routeFolder: (appFolder: string, rawName: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* The files of a route segment itself: `page.tsx`, `layout.tsx` and the
|
|
27
|
+
* like. Subfolders are other routes and stay.
|
|
28
|
+
*/
|
|
29
|
+
export declare const routeFiles: (folder: string) => string[];
|
|
16
30
|
/**
|
|
17
31
|
* Stages the move with pending changes: files of the module, its imports
|
|
18
|
-
* of other files, and every import of it in the project.
|
|
32
|
+
* of other files, and every import of it in the project. With `route`, the
|
|
33
|
+
* files of that Next.js route folder move too.
|
|
19
34
|
*/
|
|
20
|
-
export declare const moveReactModule: (projectRoot: string, reactFolder: string, module: ReactModule, rawName: string) => MovePlan;
|
|
35
|
+
export declare const moveReactModule: (projectRoot: string, reactFolder: string, module: ReactModule, rawName: string, route?: RouteMove) => MovePlan;
|
package/dist/react.cjs
CHANGED
|
@@ -3196,7 +3196,8 @@ const reactRequestSchema = external_zod_default().discriminatedUnion('operation'
|
|
|
3196
3196
|
operation('move-page', {
|
|
3197
3197
|
...common,
|
|
3198
3198
|
module: agent_requests_nestedName,
|
|
3199
|
-
name: agent_requests_nestedName
|
|
3199
|
+
name: agent_requests_nestedName,
|
|
3200
|
+
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.')
|
|
3200
3201
|
}),
|
|
3201
3202
|
operation('move-widget', {
|
|
3202
3203
|
...common,
|
|
@@ -3315,7 +3316,8 @@ const projectImports = (projectRoot)=>{
|
|
|
3315
3316
|
importsOf
|
|
3316
3317
|
};
|
|
3317
3318
|
};
|
|
3318
|
-
const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content })=>{
|
|
3319
|
+
const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyFile = (content)=>content, stopAtFor })=>{
|
|
3320
|
+
const stopFor = (file)=>stopAtFor?.(file) ?? stopAt;
|
|
3319
3321
|
const { resolve, specifierFor, codeFiles } = projectImports(projectRoot);
|
|
3320
3322
|
const barrels = new Set();
|
|
3321
3323
|
const isBarrel = (resolved)=>barrels.has(resolved.replace(codeExtension, ''));
|
|
@@ -3352,14 +3354,14 @@ const stageModuleMove = ({ projectRoot, stopAt, moves, movedPath, rename, everyF
|
|
|
3352
3354
|
moved: moves.has(oldFile)
|
|
3353
3355
|
});
|
|
3354
3356
|
};
|
|
3355
|
-
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new file_system_File(file).moveTo(newFile,
|
|
3357
|
+
for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new file_system_File(file).moveTo(newFile, stopFor(file));
|
|
3356
3358
|
const updated = [];
|
|
3357
3359
|
for (const [file, content] of codeFiles){
|
|
3358
3360
|
const newFile = moves.get(file);
|
|
3359
3361
|
const next = rewrite(content, file, newFile ?? file);
|
|
3360
3362
|
if (newFile && newFile !== file) {
|
|
3361
3363
|
new file_system_File(newFile).data = next;
|
|
3362
|
-
new file_system_File(file).delete(
|
|
3364
|
+
new file_system_File(file).delete(stopFor(file));
|
|
3363
3365
|
} else if (next !== content) {
|
|
3364
3366
|
new file_system_File(file).update(next);
|
|
3365
3367
|
if (!newFile) updated.push(file);
|
|
@@ -3883,7 +3885,14 @@ const validateMove = (reactFolder, module, rawName)=>{
|
|
|
3883
3885
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
3884
3886
|
return true;
|
|
3885
3887
|
};
|
|
3886
|
-
const
|
|
3888
|
+
const routeFolder = (appFolder, rawName)=>{
|
|
3889
|
+
const { folders, folderName } = new NestedName(rawName);
|
|
3890
|
+
return external_node_path_default().join(appFolder, ...folders, folderName);
|
|
3891
|
+
};
|
|
3892
|
+
const routeFiles = (folder)=>external_node_fs_default().existsSync(folder) ? external_node_fs_default().readdirSync(folder, {
|
|
3893
|
+
withFileTypes: true
|
|
3894
|
+
}).filter((entry)=>entry.isFile()).map((entry)=>external_node_path_default().join(folder, entry.name)) : [];
|
|
3895
|
+
const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
3887
3896
|
const newName = new NestedName(rawName);
|
|
3888
3897
|
const target = react_module_move_targetPath(reactFolder, module, rawName);
|
|
3889
3898
|
const newClassName = newName.ClassName;
|
|
@@ -3891,7 +3900,19 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
3891
3900
|
const oldFolder = 'page' === module.kind ? external_node_path_default().dirname(module.path) : module.path;
|
|
3892
3901
|
const newFolder = 'page' === module.kind ? external_node_path_default().dirname(target) : target;
|
|
3893
3902
|
const ownsPath = (candidate)=>'page' === module.kind ? external_node_path_default().dirname(candidate) === oldFolder && new RegExp(`^${escapeRegExp(module.fileBase)}-page(?:\\.|$)`).test(external_node_path_default().basename(candidate)) : candidate === oldFolder || candidate.startsWith(`${oldFolder}${external_node_path_default().sep}`);
|
|
3903
|
+
const routeFileSet = new Set(route ? routeFiles(route.from) : []);
|
|
3904
|
+
const routeTarget = (candidate)=>{
|
|
3905
|
+
if (!route) return;
|
|
3906
|
+
const file = [
|
|
3907
|
+
...routeFileSet
|
|
3908
|
+
].find((x)=>x === candidate || x.replace(codeExtension, '') === candidate);
|
|
3909
|
+
if (!file) return;
|
|
3910
|
+
const moved = external_node_path_default().join(route.to, external_node_path_default().relative(route.from, file));
|
|
3911
|
+
return file === candidate ? moved : moved.replace(codeExtension, '');
|
|
3912
|
+
};
|
|
3894
3913
|
const movedPath = (candidate)=>{
|
|
3914
|
+
const routed = routeTarget(candidate);
|
|
3915
|
+
if (routed) return routed;
|
|
3895
3916
|
if (!ownsPath(candidate)) return;
|
|
3896
3917
|
const segments = external_node_path_default().relative(oldFolder, candidate).split(external_node_path_default().sep);
|
|
3897
3918
|
const last = segments.length - 1;
|
|
@@ -3899,7 +3920,10 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
3899
3920
|
return external_node_path_default().join(newFolder, ...segments);
|
|
3900
3921
|
};
|
|
3901
3922
|
const moduleFiles = 'page' === module.kind ? external_node_fs_default().readdirSync(oldFolder).map((name)=>external_node_path_default().join(oldFolder, name)).filter((file)=>external_node_fs_default().statSync(file).isFile() && ownsPath(file)) : module_move_walk(oldFolder);
|
|
3902
|
-
const moves = new Map(
|
|
3923
|
+
const moves = new Map([
|
|
3924
|
+
...moduleFiles,
|
|
3925
|
+
...routeFileSet
|
|
3926
|
+
].map((file)=>[
|
|
3903
3927
|
file,
|
|
3904
3928
|
movedPath(file) ?? file
|
|
3905
3929
|
]));
|
|
@@ -3914,6 +3938,7 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
|
|
|
3914
3938
|
return stageModuleMove({
|
|
3915
3939
|
projectRoot,
|
|
3916
3940
|
stopAt: reactFolder,
|
|
3941
|
+
stopAtFor: (file)=>route && routeFileSet.has(file) ? route.appFolder : void 0,
|
|
3917
3942
|
moves,
|
|
3918
3943
|
movedPath,
|
|
3919
3944
|
rename: (content, { moved })=>{
|
|
@@ -4036,6 +4061,26 @@ const moveBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
4036
4061
|
report('Cancelled: nothing was written.');
|
|
4037
4062
|
}
|
|
4038
4063
|
};
|
|
4064
|
+
const promptRouteMove = async (root, page, newName)=>{
|
|
4065
|
+
if (!usesNext()) return;
|
|
4066
|
+
const appFolder = external_node_path_default().join(root, nextAppFolder(root));
|
|
4067
|
+
const from = routeFolder(appFolder, page.name);
|
|
4068
|
+
const to = routeFolder(appFolder, newName);
|
|
4069
|
+
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4070
|
+
const routePage = external_node_path_default().join(from, 'page.tsx');
|
|
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;
|
|
4072
|
+
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
|
+
const move = await interaction_confirm({
|
|
4074
|
+
key: 'moveRoute',
|
|
4075
|
+
message: `Move the Next.js route too: ${relative(from)} → ${relative(to)}? Its URL changes.`,
|
|
4076
|
+
default: true
|
|
4077
|
+
});
|
|
4078
|
+
return move ? {
|
|
4079
|
+
appFolder,
|
|
4080
|
+
from,
|
|
4081
|
+
to
|
|
4082
|
+
} : void 0;
|
|
4083
|
+
};
|
|
4039
4084
|
const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
4040
4085
|
const reactFolder = presentationReactFolder.path;
|
|
4041
4086
|
const modules = findReactModules(reactFolder, kind);
|
|
@@ -4057,9 +4102,10 @@ const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
|
4057
4102
|
validate: (value)=>validateMove(reactFolder, module, value)
|
|
4058
4103
|
});
|
|
4059
4104
|
const root = new project_root_ProjectRoot().path;
|
|
4060
|
-
const
|
|
4105
|
+
const relative = (file)=>external_node_path_default().relative(root, file).split(external_node_path_default().sep).join('/');
|
|
4106
|
+
const route = 'page' === kind ? await promptRouteMove(root, module, name) : void 0;
|
|
4107
|
+
const { moves, updated } = moveReactModule(root, reactFolder, module, name, route);
|
|
4061
4108
|
if (!moves.length && !updated.length) return void report('Nothing to change.');
|
|
4062
|
-
const relative = (file)=>external_node_path_default().relative(root, file);
|
|
4063
4109
|
report([
|
|
4064
4110
|
'Files to move:',
|
|
4065
4111
|
...moves.map(([from, to])=>` ${relative(from)} → ${relative(to)}`),
|
package/package.json
CHANGED
|
@@ -60,7 +60,7 @@ If the CLI cannot run, report the failure and give the user the prepared JSON co
|
|
|
60
60
|
|
|
61
61
|
### Moving and renaming
|
|
62
62
|
|
|
63
|
-
Moving or renaming a page or widget is a df-react run (`Move or rename page` / `Move or rename widget`): it creates the files at the new paths, so it needs an approved plan. Don't move, rename, or copy their files by hand, and don't rename their `<Name>Page…`, `<Name>Widget…`, or `use<Name>UIModel` by hand: df-react keeps file names, code names, story titles, and imports in sync. List each move as a run: old → new name, the files to move (`→`), and the files whose imports change (`~`).
|
|
63
|
+
Moving or renaming a page or widget is a df-react run (`Move or rename page` / `Move or rename widget`): it creates the files at the new paths, so it needs an approved plan. With Next.js, moving a page can also move its App Router route and so change its URL: state in the plan whether the route moves (`moveRoute`), and ask the user when the request doesn't say. Don't move, rename, or copy their files by hand, and don't rename their `<Name>Page…`, `<Name>Widget…`, or `use<Name>UIModel` by hand: df-react keeps file names, code names, story titles, and imports in sync. List each move as a run: old → new name, the files to move (`→`), and the files whose imports change (`~`).
|
|
64
64
|
|
|
65
65
|
### Files you may create by hand
|
|
66
66
|
|
|
@@ -116,7 +116,7 @@ The owner configures frontend first. React and Next.js use the same operations.
|
|
|
116
116
|
| `widget` | `name` | Nested names allowed. `widgetType`: `separated` (default), `headless`, `monolithic`; use the JSON value `separated`, not the menu label `with separated ui`. |
|
|
117
117
|
| `ui-kit-component` | `name` | Single kebab-case name; stories follow config. |
|
|
118
118
|
| `shared-hook` | `name` | Single kebab-case name, preferably without `use-`; a leading `use-` is stripped. |
|
|
119
|
-
| `move-page` | `module`, `name` | `module` is the existing nested page name from discovery; `name` is the target nested name. With Next.js
|
|
119
|
+
| `move-page` | `module`, `name` | `module` is the existing nested page name from discovery; `name` is the target nested name. With Next.js and a route at the page path that renders the page, `moveRoute` (default true) moves that route folder's own files to the new path, changing the URL; `false` keeps the route with its import updated. Omit `moveRoute` when there is no such route. |
|
|
120
120
|
| `move-widget` | `module`, `name` | Same for widgets. Files, imports, code names and generated story titles follow the move. |
|
|
121
121
|
|
|
122
122
|
All support `dryRun` and `overwrite`. Use CLI moves even for a rename or folder regrouping; an existing target or a move into itself is rejected.
|