@domain-first/project-structure 8.10.1 → 8.11.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 -7
- package/dist/115.js +142 -141
- package/dist/201.js +10 -1
- package/dist/287.js +983 -434
- package/dist/364.js +79 -0
- package/dist/38.js +29 -13
- package/dist/561.js +167 -93
- package/dist/agent-cli.d.ts +13 -2
- package/dist/agent-requests.d.ts +76 -2
- package/dist/config-file.d.ts +25 -1
- package/dist/frontend-cli.d.ts +3 -0
- package/dist/frontend-modules.d.ts +9 -0
- package/dist/graph.cjs +10 -1
- package/dist/index.cjs +3470 -2913
- package/dist/init.cjs +325 -83
- package/dist/integration.cjs +3470 -2913
- package/dist/integrations/openapi.d.ts +9 -2
- package/dist/integrations/orval.d.ts +31 -4
- package/dist/integrations/rest-endpoint-generator.d.ts +11 -7
- package/dist/integrations/storybook.d.ts +19 -1
- package/dist/lint.cjs +40 -15
- package/dist/lint.js +1 -1
- package/dist/page-router.d.ts +18 -0
- package/dist/react-module-move.d.ts +27 -12
- package/dist/react.cjs +1577 -993
- package/dist/react.js +2 -102
- package/dist/rest-adapters.d.ts +13 -0
- package/dist/svelte-agent-cli.spec.d.ts +1 -0
- package/dist/svelte.cjs +7311 -0
- package/dist/svelte.d.ts +2 -0
- package/dist/svelte.js +3 -0
- package/dist/sveltekit-app.d.ts +7 -0
- package/dist/upgrade-steps.d.ts +6 -1
- package/dist/upgrade.cjs +12 -2
- package/dist/use-cases/add-integration.d.ts +1 -1
- package/dist/use-cases/delete-react-module.d.ts +4 -4
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/move-react-module.d.ts +2 -2
- package/dist/use-cases/rest-endpoint-generator.d.ts +6 -4
- package/dist/use-cases/scaffold-svelte-modules.d.ts +22 -0
- package/package.json +2 -1
- package/skills/df-ps-implement/SKILL.md +3 -3
- package/skills/df-ps-plan-feature/SKILL.md +1 -1
- package/skills/df-ps-scaffold/SKILL.md +9 -8
- package/skills/df-ps-scaffold/references/agent-mode.md +1 -1
- package/skills/df-ps-scaffold/references/agent-operations.md +8 -4
- package/skills/df-ps-scaffold/references/generators.md +1 -1
- package/skills/df-ps-scaffold/references/work-plan.md +1 -1
- package/skills/df-ps-svelte/SKILL.md +49 -0
- package/skills/df-ps-svelte/references/generators.md +56 -0
package/dist/364.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { select as prompts_select } from "@inquirer/prompts";
|
|
3
|
+
import { frontendOperations, frontendMenu, runCLI } from "./561.js";
|
|
4
|
+
import { outdatedConfigMessage, ProjectRoot, ConfigFile, Folder } from "./201.js";
|
|
5
|
+
import { savePendingChanges } from "./287.js";
|
|
6
|
+
const texts = {
|
|
7
|
+
react: {
|
|
8
|
+
command: 'df-react',
|
|
9
|
+
help: `Usage: df-react
|
|
10
|
+
|
|
11
|
+
Scaffolds React modules of a Domain-First project: pages, widgets, UI-kit
|
|
12
|
+
components and shared hooks, and moves or renames pages and widgets.
|
|
13
|
+
Needs frontend.react in domain-first.project-structure.config.json.`,
|
|
14
|
+
notConfigured: 'React is not configured: run df-init --section frontend or add Storybook with df-integration.'
|
|
15
|
+
},
|
|
16
|
+
svelte: {
|
|
17
|
+
command: 'df-svelte',
|
|
18
|
+
help: `Usage: df-svelte
|
|
19
|
+
|
|
20
|
+
Scaffolds Svelte 5 modules of a Domain-First project: pages, widgets, UI-kit
|
|
21
|
+
components and shared hooks (.svelte.ts), and moves, renames or deletes
|
|
22
|
+
them. With SvelteKit, pages get their routes in src/routes.
|
|
23
|
+
Needs frontend.svelte in domain-first.project-structure.config.json.`,
|
|
24
|
+
notConfigured: 'Svelte is not configured: run df-init --section frontend.'
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const runFrontendCLI = (framework)=>{
|
|
28
|
+
const { command, help, notConfigured } = texts[framework];
|
|
29
|
+
return runCLI(command, async ()=>{
|
|
30
|
+
const { values } = parseArgs({
|
|
31
|
+
options: {
|
|
32
|
+
help: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
short: 'h',
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (values.help) {
|
|
40
|
+
console.log(`${help}
|
|
41
|
+
|
|
42
|
+
Options:
|
|
43
|
+
--request <json|-> execute an operation without prompts; - reads stdin
|
|
44
|
+
--describe output request schema and project IDs as JSON
|
|
45
|
+
-h, --help show this help`);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
if (!ConfigFile.exists) {
|
|
49
|
+
console.log('No domain-first.project-structure.config.json found: run df-init first to initialize the project.');
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
if (ConfigFile.outdated) {
|
|
53
|
+
console.log(outdatedConfigMessage);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
if (!ConfigFile.Instance.data.frontend?.[framework]) {
|
|
57
|
+
console.log(notConfigured);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
const folder = new Folder(new ProjectRoot().path).subitem([
|
|
61
|
+
ConfigFile.Instance.data.project.rootFolder,
|
|
62
|
+
'presentation',
|
|
63
|
+
framework
|
|
64
|
+
]);
|
|
65
|
+
const operation = await prompts_select({
|
|
66
|
+
message: 'Module: ',
|
|
67
|
+
choices: frontendMenu.map(([name, value])=>({
|
|
68
|
+
name,
|
|
69
|
+
value
|
|
70
|
+
}))
|
|
71
|
+
});
|
|
72
|
+
await frontendOperations(folder, framework)[operation]();
|
|
73
|
+
await savePendingChanges();
|
|
74
|
+
}).catch((error)=>{
|
|
75
|
+
console.error(error);
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
export { runFrontendCLI };
|
package/dist/38.js
CHANGED
|
@@ -31,7 +31,7 @@ const sourceFiles = (folder)=>{
|
|
|
31
31
|
}).flatMap((entry)=>{
|
|
32
32
|
const entryPath = node_path.join(folder, entry.name);
|
|
33
33
|
if (entry.isDirectory()) return 'node_modules' === entry.name ? [] : sourceFiles(entryPath);
|
|
34
|
-
return /\.(c|m)?tsx
|
|
34
|
+
return /\.((c|m)?tsx?|svelte)$/.test(entry.name) && !entry.name.endsWith('.d.ts') ? [
|
|
35
35
|
entryPath
|
|
36
36
|
] : [];
|
|
37
37
|
});
|
|
@@ -97,10 +97,22 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
97
97
|
const root = node_path.resolve(projectRoot, rootFolder);
|
|
98
98
|
const contextsFolder = node_path.join(root, 'bounded-contexts');
|
|
99
99
|
const sharedFolder = node_path.join(root, 'shared-kernel');
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
const frontends = [
|
|
101
|
+
'react',
|
|
102
|
+
'svelte'
|
|
103
|
+
].map((framework)=>{
|
|
104
|
+
const folder = node_path.join(root, 'presentation', framework);
|
|
105
|
+
return {
|
|
106
|
+
check: framework,
|
|
107
|
+
label: `presentation/${framework}`,
|
|
108
|
+
folder,
|
|
109
|
+
uiKit: node_path.join(folder, 'ui-kit'),
|
|
110
|
+
widgets: node_path.join(folder, 'widgets'),
|
|
111
|
+
hooks: node_path.join(folder, 'hooks'),
|
|
112
|
+
widgetFile: 'svelte' === framework ? '-widget.svelte' : '-widget.tsx'
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
const frontendOf = (file)=>frontends.find((frontend)=>inside(frontend.folder, file));
|
|
104
116
|
const inMemoryDbFile = node_path.join(sharedFolder, 'infrastructure', 'services', 'in-memory-db-infrastructure-service.ts');
|
|
105
117
|
const aliases = readAliases(projectRoot);
|
|
106
118
|
const violations = [];
|
|
@@ -130,16 +142,18 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
130
142
|
].includes(part) && !/-repository(\.tsx?)?$/.test(node_path.basename(target));
|
|
131
143
|
const widgetFolders = new Map();
|
|
132
144
|
const isWidgetFolder = (folder)=>{
|
|
133
|
-
if (!widgetFolders.has(folder)) widgetFolders.set(folder, node_fs.existsSync(folder) && node_fs.statSync(folder).isDirectory() && node_fs.readdirSync(folder).some((name)=>name.endsWith(
|
|
145
|
+
if (!widgetFolders.has(folder)) widgetFolders.set(folder, node_fs.existsSync(folder) && node_fs.statSync(folder).isDirectory() && node_fs.readdirSync(folder).some((name)=>frontends.some(({ widgetFile })=>name.endsWith(widgetFile))));
|
|
134
146
|
return widgetFolders.get(folder);
|
|
135
147
|
};
|
|
136
148
|
const widgetOf = (file)=>{
|
|
149
|
+
const widgetsFolder = frontendOf(file)?.widgets;
|
|
150
|
+
if (!widgetsFolder) return;
|
|
137
151
|
for(let folder = file; inside(widgetsFolder, folder); folder = node_path.dirname(folder))if (isWidgetFolder(folder)) return folder;
|
|
138
152
|
};
|
|
139
153
|
const files = [
|
|
140
154
|
contextsFolder,
|
|
141
155
|
sharedFolder,
|
|
142
|
-
|
|
156
|
+
...frontends.map(({ folder })=>folder)
|
|
143
157
|
].flatMap(sourceFiles);
|
|
144
158
|
for (const file of files){
|
|
145
159
|
const source = node_fs.readFileSync(file, 'utf8');
|
|
@@ -153,6 +167,7 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
153
167
|
text: node_path.basename(file)
|
|
154
168
|
});
|
|
155
169
|
const ownContext = contextOf(file);
|
|
170
|
+
const frontend = frontendOf(file);
|
|
156
171
|
const directWiring = ownContext && from?.segments[0] === 'wiring' && readWiredModule(file, boundedContextPath(contextsFolder, ownContext))?.implementations.some((implementation)=>isCrossContextImplementation(implementation.file));
|
|
157
172
|
const report = (check, rule, imported)=>violations.push({
|
|
158
173
|
check,
|
|
@@ -172,9 +187,10 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
172
187
|
} else if (inside(sharedFolder, file)) {
|
|
173
188
|
const allowed = !to || 'shared-kernel' === to.owner || 'domain' === to.segments[0] && 'errors' === to.segments[1] || file === inMemoryDbFile && isDomainModel(to.segments, target);
|
|
174
189
|
if (!allowed) report('shared-kernel', '[shared-kernel] imports a bounded context outside its domain/errors (and domain models for the in-memory DB):', imported);
|
|
175
|
-
} else if (inside(
|
|
176
|
-
const [area] = inside(
|
|
177
|
-
const
|
|
190
|
+
} else if (frontend && (inside(frontend.uiKit, file) || inside(frontend.hooks, file))) {
|
|
191
|
+
const [area] = inside(frontend.folder, target) ?? [];
|
|
192
|
+
const inUiKit = inside(frontend.uiKit, file);
|
|
193
|
+
const forbidden = inUiKit ? [
|
|
178
194
|
'widgets',
|
|
179
195
|
'pages'
|
|
180
196
|
] : [
|
|
@@ -182,11 +198,11 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
182
198
|
'widgets',
|
|
183
199
|
'pages'
|
|
184
200
|
];
|
|
185
|
-
if (targetContext || forbidden.includes(area)) report(
|
|
186
|
-
} else if (targetContext && !(imported.typeOnly && to?.segments[0] === 'presentation' && 'rest' === to.segments[1])) report(
|
|
201
|
+
if (targetContext || forbidden.includes(area)) report(frontend.check, inUiKit ? `[${frontend.label}/ui-kit] imports a bounded context, widget or page:` : `[${frontend.label}/hooks] a shared hook imports a bounded context, UI-kit, widget or page:`, imported);
|
|
202
|
+
} else if (frontend && targetContext && !(imported.typeOnly && to?.segments[0] === 'presentation' && 'rest' === to.segments[1])) report(frontend.check, `[${frontend.label}] imports a context other than \`import type\` from presentation/rest:`, imported);
|
|
187
203
|
const ownWidget = widgetOf(file);
|
|
188
204
|
const targetWidget = widgetOf(target);
|
|
189
|
-
if (ownWidget && targetWidget && targetWidget !== ownWidget) report(
|
|
205
|
+
if (frontend && ownWidget && targetWidget && targetWidget !== ownWidget) report(frontend.check, `[${frontend.label}/widgets] a widget imports another widget:`, imported);
|
|
190
206
|
if (!from || !to) continue;
|
|
191
207
|
if (crossContextAllowed) continue;
|
|
192
208
|
if (isSpec(file)) continue;
|
package/dist/561.js
CHANGED
|
@@ -3,7 +3,7 @@ import node_path from "node:path";
|
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
import zod from "zod";
|
|
5
5
|
import { implementationLabelSchema, availableDependencies, discardPendingChanges, findWiredModules, filesToOverwrite, ConfigFile, Folder, implementationKinds, ProjectRoot, pendingChanges, hasNeighboringBoundedContext, boundedContextNames } from "./201.js";
|
|
6
|
-
import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, helperImplementationTypes,
|
|
6
|
+
import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, helperImplementationTypes, scaffoldReactUIKitComponent, scaffoldNewAggregateUseCase, runWithAnswers, scaffoldNewInfrastructureService, scaffoldNewCommand, findReactModules, scaffoldNewQuery, moveBackendUnitUseCase, scaffoldReactSharedHook, moveReactModuleUseCase, reactKindTitles, deleteBackendUnitUseCase, frameworkTitles, integrationIds, deleteReactModuleUseCase, savedImplementations, RequestError, scaffoldNewApplicationService, rootControllerChoice, moduleId, assertAnswersConsumed, scaffoldNewImplementation, findRestEndpointGenerator, scaffoldReactWidget, scaffoldSvelteUIKitComponent, scaffoldNewErrorUseCase, scaffoldNewDomainService, scaffoldSvelteSharedHook, savePendingChanges, unitId, systemImplementationChoices, scaffoldSvelteWidget, scaffoldReactPage, scaffoldNewPresentationService, scaffoldNewInfrastructureHelper, integrationSpecsAvailable, scaffoldSveltePage, integrationSpecFile, findBackendUnits, scaffoldNewUseCase, integrationDescriptions, wireDependency, scaffoldNewDomainObject, scaffoldNewBoundedContextUseCase, scaffoldNewApplicationPort } from "./287.js";
|
|
7
7
|
import { restControllers } from "./115.js";
|
|
8
8
|
const agent_requests_name = implementationLabelSchema;
|
|
9
9
|
const nestedName = zod.string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*)*$/);
|
|
@@ -144,72 +144,75 @@ const scaffoldRequestSchema = zod.discriminatedUnion('operation', [
|
|
|
144
144
|
aggregate: agent_requests_name.optional()
|
|
145
145
|
})
|
|
146
146
|
]);
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
]);
|
|
147
|
+
const frontendRequestSchema = (router)=>zod.discriminatedUnion('operation', [
|
|
148
|
+
agent_requests_operation('page', {
|
|
149
|
+
...common,
|
|
150
|
+
name: nestedName
|
|
151
|
+
}),
|
|
152
|
+
agent_requests_operation('widget', {
|
|
153
|
+
...common,
|
|
154
|
+
name: nestedName,
|
|
155
|
+
widgetType: zod["enum"]([
|
|
156
|
+
'monolithic',
|
|
157
|
+
'separated',
|
|
158
|
+
'headless'
|
|
159
|
+
]).optional()
|
|
160
|
+
}),
|
|
161
|
+
agent_requests_operation('ui-kit-component', {
|
|
162
|
+
...common,
|
|
163
|
+
name: agent_requests_name
|
|
164
|
+
}),
|
|
165
|
+
agent_requests_operation('shared-hook', {
|
|
166
|
+
...common,
|
|
167
|
+
name: agent_requests_name
|
|
168
|
+
}),
|
|
169
|
+
agent_requests_operation('move-page', {
|
|
170
|
+
...common,
|
|
171
|
+
module: nestedName,
|
|
172
|
+
name: nestedName,
|
|
173
|
+
moveRoute: zod.boolean().optional().describe(`With ${router} and a route at the page path: move it too (default true). Omit it without such a route.`)
|
|
174
|
+
}),
|
|
175
|
+
agent_requests_operation('delete-page', {
|
|
176
|
+
...common,
|
|
177
|
+
module: nestedName,
|
|
178
|
+
deleteRoute: zod.boolean().optional().describe(`With ${router} and the page's own route: delete it too (default true). Omit it without such a route.`)
|
|
179
|
+
}),
|
|
180
|
+
agent_requests_operation('delete-widget', {
|
|
181
|
+
...common,
|
|
182
|
+
module: nestedName
|
|
183
|
+
}),
|
|
184
|
+
agent_requests_operation('move-ui-kit-component', {
|
|
185
|
+
...common,
|
|
186
|
+
module: agent_requests_name,
|
|
187
|
+
name: agent_requests_name
|
|
188
|
+
}),
|
|
189
|
+
agent_requests_operation('move-shared-hook', {
|
|
190
|
+
...common,
|
|
191
|
+
module: agent_requests_name,
|
|
192
|
+
name: agent_requests_name
|
|
193
|
+
}),
|
|
194
|
+
agent_requests_operation('delete-ui-kit-component', {
|
|
195
|
+
...common,
|
|
196
|
+
module: agent_requests_name
|
|
197
|
+
}),
|
|
198
|
+
agent_requests_operation('delete-shared-hook', {
|
|
199
|
+
...common,
|
|
200
|
+
module: agent_requests_name
|
|
201
|
+
}),
|
|
202
|
+
agent_requests_operation('move-widget', {
|
|
203
|
+
...common,
|
|
204
|
+
module: nestedName,
|
|
205
|
+
name: nestedName
|
|
206
|
+
})
|
|
207
|
+
]);
|
|
208
|
+
const reactRequestSchema = frontendRequestSchema('Next.js');
|
|
209
|
+
const svelteRequestSchema = frontendRequestSchema('SvelteKit');
|
|
208
210
|
const relativePath = zod.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.');
|
|
209
211
|
const integrationRequestSchema = agent_requests_operation('add', {
|
|
210
212
|
...common,
|
|
211
213
|
integrations: zod.array(zod["enum"](integrationIds)).min(1),
|
|
212
214
|
nextAdapter: zod.boolean().optional(),
|
|
215
|
+
svelteAdapter: zod.boolean().optional(),
|
|
213
216
|
configureReact: zod.boolean().optional(),
|
|
214
217
|
replaceTestingLibrary: zod.boolean().optional(),
|
|
215
218
|
integrationTestTypes: zod.array(agent_requests_name).optional().describe('testcontainers with wire: saved primary implementation types whose implementations get integration specs. Omitted: the configured list stays.'),
|
|
@@ -232,8 +235,88 @@ const integrationRequestSchema = agent_requests_operation('add', {
|
|
|
232
235
|
const requestSchemaFor = (command)=>({
|
|
233
236
|
'df-scaffold': scaffoldRequestSchema,
|
|
234
237
|
'df-react': reactRequestSchema,
|
|
238
|
+
'df-svelte': svelteRequestSchema,
|
|
235
239
|
'df-integration': integrationRequestSchema
|
|
236
240
|
})[command];
|
|
241
|
+
const frontendOperations = (folder, framework)=>{
|
|
242
|
+
const scaffold = 'svelte' === framework ? {
|
|
243
|
+
page: scaffoldSveltePage,
|
|
244
|
+
widget: scaffoldSvelteWidget,
|
|
245
|
+
'ui-kit-component': scaffoldSvelteUIKitComponent,
|
|
246
|
+
'shared-hook': scaffoldSvelteSharedHook
|
|
247
|
+
} : {
|
|
248
|
+
page: scaffoldReactPage,
|
|
249
|
+
widget: scaffoldReactWidget,
|
|
250
|
+
'ui-kit-component': scaffoldReactUIKitComponent,
|
|
251
|
+
'shared-hook': scaffoldReactSharedHook
|
|
252
|
+
};
|
|
253
|
+
const move = (kind)=>()=>moveReactModuleUseCase(folder, kind, framework);
|
|
254
|
+
const remove = (kind)=>()=>deleteReactModuleUseCase(folder, kind, framework);
|
|
255
|
+
return {
|
|
256
|
+
page: ()=>scaffold.page(folder),
|
|
257
|
+
widget: ()=>scaffold.widget(folder),
|
|
258
|
+
'ui-kit-component': ()=>scaffold['ui-kit-component'](folder),
|
|
259
|
+
'shared-hook': ()=>scaffold['shared-hook'](folder),
|
|
260
|
+
'move-page': move('page'),
|
|
261
|
+
'move-widget': move('widget'),
|
|
262
|
+
'move-ui-kit-component': move('ui-kit'),
|
|
263
|
+
'move-shared-hook': move('hook'),
|
|
264
|
+
'delete-page': remove('page'),
|
|
265
|
+
'delete-widget': remove('widget'),
|
|
266
|
+
'delete-ui-kit-component': remove('ui-kit'),
|
|
267
|
+
'delete-shared-hook': remove('hook')
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
const frontendMenu = [
|
|
271
|
+
[
|
|
272
|
+
'New widget',
|
|
273
|
+
'widget'
|
|
274
|
+
],
|
|
275
|
+
[
|
|
276
|
+
'New page',
|
|
277
|
+
'page'
|
|
278
|
+
],
|
|
279
|
+
[
|
|
280
|
+
'New UI-kit component',
|
|
281
|
+
'ui-kit-component'
|
|
282
|
+
],
|
|
283
|
+
[
|
|
284
|
+
'New shared hook',
|
|
285
|
+
'shared-hook'
|
|
286
|
+
],
|
|
287
|
+
[
|
|
288
|
+
'Move or rename widget',
|
|
289
|
+
'move-widget'
|
|
290
|
+
],
|
|
291
|
+
[
|
|
292
|
+
'Move or rename page',
|
|
293
|
+
'move-page'
|
|
294
|
+
],
|
|
295
|
+
[
|
|
296
|
+
'Move or rename UI-kit component',
|
|
297
|
+
'move-ui-kit-component'
|
|
298
|
+
],
|
|
299
|
+
[
|
|
300
|
+
'Move or rename shared hook',
|
|
301
|
+
'move-shared-hook'
|
|
302
|
+
],
|
|
303
|
+
[
|
|
304
|
+
'Delete widget',
|
|
305
|
+
'delete-widget'
|
|
306
|
+
],
|
|
307
|
+
[
|
|
308
|
+
'Delete page',
|
|
309
|
+
'delete-page'
|
|
310
|
+
],
|
|
311
|
+
[
|
|
312
|
+
'Delete UI-kit component',
|
|
313
|
+
'delete-ui-kit-component'
|
|
314
|
+
],
|
|
315
|
+
[
|
|
316
|
+
'Delete shared hook',
|
|
317
|
+
'delete-shared-hook'
|
|
318
|
+
]
|
|
319
|
+
];
|
|
237
320
|
const requireProject = ()=>{
|
|
238
321
|
try {
|
|
239
322
|
return new ProjectRoot().path;
|
|
@@ -270,12 +353,24 @@ const ownerFor = (context)=>{
|
|
|
270
353
|
});
|
|
271
354
|
return owner.folder;
|
|
272
355
|
};
|
|
356
|
+
const frontendFrameworkOf = (command)=>'df-react' === command ? 'react' : 'df-svelte' === command ? 'svelte' : void 0;
|
|
357
|
+
const frontendModules = (root, rootFolder, framework)=>[
|
|
358
|
+
'page',
|
|
359
|
+
'widget',
|
|
360
|
+
'ui-kit',
|
|
361
|
+
'hook'
|
|
362
|
+
].flatMap((kind)=>findReactModules(node_path.join(root, rootFolder, 'presentation', framework), kind, framework).map((module)=>({
|
|
363
|
+
kind,
|
|
364
|
+
name: module.name,
|
|
365
|
+
file: node_path.relative(root, module.path).split(node_path.sep).join('/')
|
|
366
|
+
})));
|
|
273
367
|
const precondition = (command)=>{
|
|
274
368
|
requireProject();
|
|
275
369
|
if (!ConfigFile.exists) throw new RequestError('CONFIG_NOT_FOUND', 'Ask the project owner to run df-init.');
|
|
276
370
|
if (ConfigFile.outdated) throw new RequestError('CONFIG_OUTDATED', 'The config has the format of an earlier major version: ask the project owner to run df-upgrade.');
|
|
277
371
|
if ('df-scaffold' === command && !ConfigFile.Instance.data.backend) throw new RequestError('BACKEND_NOT_CONFIGURED', 'Ask the project owner to run df-init --section backend.');
|
|
278
|
-
|
|
372
|
+
const framework = frontendFrameworkOf(command);
|
|
373
|
+
if (framework && !ConfigFile.Instance.data.frontend?.[framework]) throw new RequestError('FRONTEND_NOT_CONFIGURED', 'Ask the project owner to run df-init --section frontend.');
|
|
279
374
|
};
|
|
280
375
|
const describeAgentCommand = (command)=>{
|
|
281
376
|
let root;
|
|
@@ -344,16 +439,8 @@ const describeAgentCommand = (command)=>{
|
|
|
344
439
|
])) : void 0
|
|
345
440
|
})),
|
|
346
441
|
integrations: integrationDescriptionsSafe(configured),
|
|
347
|
-
reactModules: config?.frontend?.react ? [
|
|
348
|
-
|
|
349
|
-
'widget',
|
|
350
|
-
'ui-kit',
|
|
351
|
-
'hook'
|
|
352
|
-
].flatMap((kind)=>findReactModules(node_path.join(root, config.project.rootFolder, 'presentation/react'), kind).map((module)=>({
|
|
353
|
-
kind,
|
|
354
|
-
name: module.name,
|
|
355
|
-
file: relative(module.path)
|
|
356
|
-
}))) : []
|
|
442
|
+
reactModules: config?.frontend?.react ? frontendModules(root, config.project.rootFolder, 'react') : [],
|
|
443
|
+
svelteModules: config?.frontend?.svelte ? frontendModules(root, config.project.rootFolder, 'svelte') : []
|
|
357
444
|
} : null
|
|
358
445
|
};
|
|
359
446
|
};
|
|
@@ -455,29 +542,16 @@ const executeScaffold = async (request, owner)=>{
|
|
|
455
542
|
};
|
|
456
543
|
return actions[request.operation]();
|
|
457
544
|
};
|
|
458
|
-
const
|
|
545
|
+
const executeFrontend = async (request, framework)=>{
|
|
459
546
|
const folder = new Folder(requireProject()).subitem([
|
|
460
547
|
ConfigFile.Instance.data.project.rootFolder,
|
|
461
|
-
'presentation
|
|
548
|
+
'presentation',
|
|
549
|
+
framework
|
|
462
550
|
]);
|
|
463
551
|
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;
|
|
464
552
|
const kind = /^(move|delete)-/.test(request.operation) ? kindOf(request.operation) : void 0;
|
|
465
|
-
if (kind && !findReactModules(folder.path, kind).length) throw new RequestError('TARGET_NOT_FOUND', `No
|
|
466
|
-
|
|
467
|
-
page: ()=>scaffoldReactPage(folder),
|
|
468
|
-
widget: ()=>scaffoldReactWidget(folder),
|
|
469
|
-
'ui-kit-component': ()=>scaffoldReactUIKitComponent(folder),
|
|
470
|
-
'shared-hook': ()=>scaffoldReactSharedHook(folder),
|
|
471
|
-
'move-page': ()=>moveReactModuleUseCase(folder, 'page'),
|
|
472
|
-
'move-widget': ()=>moveReactModuleUseCase(folder, 'widget'),
|
|
473
|
-
'delete-page': ()=>deleteReactModuleUseCase(folder, 'page'),
|
|
474
|
-
'delete-widget': ()=>deleteReactModuleUseCase(folder, 'widget'),
|
|
475
|
-
'move-ui-kit-component': ()=>moveReactModuleUseCase(folder, 'ui-kit'),
|
|
476
|
-
'move-shared-hook': ()=>moveReactModuleUseCase(folder, 'hook'),
|
|
477
|
-
'delete-ui-kit-component': ()=>deleteReactModuleUseCase(folder, 'ui-kit'),
|
|
478
|
-
'delete-shared-hook': ()=>deleteReactModuleUseCase(folder, 'hook')
|
|
479
|
-
};
|
|
480
|
-
return actions[request.operation]();
|
|
553
|
+
if (kind && !findReactModules(folder.path, kind, framework).length) throw new RequestError('TARGET_NOT_FOUND', `No ${frameworkTitles[framework].title} ${reactKindTitles[kind][1]} here.`);
|
|
554
|
+
return frontendOperations(folder, framework)[request.operation]();
|
|
481
555
|
};
|
|
482
556
|
const executeAgentRequest = async (command, value)=>{
|
|
483
557
|
discardPendingChanges();
|
|
@@ -498,7 +572,7 @@ const executeAgentRequest = async (command, value)=>{
|
|
|
498
572
|
let nextSteps = [];
|
|
499
573
|
if ('df-scaffold' === command) if ('bounded-context' === request.operation) await scaffoldNewBoundedContextUseCase();
|
|
500
574
|
else await executeScaffold(request, owner);
|
|
501
|
-
else if (
|
|
575
|
+
else if (frontendFrameworkOf(command)) await executeFrontend(request, frontendFrameworkOf(command));
|
|
502
576
|
else nextSteps = await addIntegration({
|
|
503
577
|
save: false
|
|
504
578
|
});
|
|
@@ -583,4 +657,4 @@ const runCLI = async (command, interactive)=>{
|
|
|
583
657
|
process.exitCode = 1;
|
|
584
658
|
}
|
|
585
659
|
};
|
|
586
|
-
export { runCLI };
|
|
660
|
+
export { frontendMenu, frontendOperations, runCLI };
|
package/dist/agent-cli.d.ts
CHANGED
|
@@ -225,8 +225,8 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
225
225
|
name: z.ZodString;
|
|
226
226
|
widgetType: z.ZodOptional<z.ZodEnum<{
|
|
227
227
|
monolithic: "monolithic";
|
|
228
|
-
separated: "separated";
|
|
229
228
|
headless: "headless";
|
|
229
|
+
separated: "separated";
|
|
230
230
|
}>>;
|
|
231
231
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
232
232
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -301,6 +301,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
301
301
|
playwright: "playwright";
|
|
302
302
|
}>>;
|
|
303
303
|
nextAdapter: z.ZodOptional<z.ZodBoolean>;
|
|
304
|
+
svelteAdapter: z.ZodOptional<z.ZodBoolean>;
|
|
304
305
|
configureReact: z.ZodOptional<z.ZodBoolean>;
|
|
305
306
|
replaceTestingLibrary: z.ZodOptional<z.ZodBoolean>;
|
|
306
307
|
integrationTestTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -365,7 +366,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
365
366
|
add?: ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | undefined;
|
|
366
367
|
remove?: ("queries" | "commands" | "use-cases" | "application-ports" | "repositories" | "domain-services" | "application-services" | "infrastructure-services" | "presentation-services")[] | undefined;
|
|
367
368
|
}>> | undefined;
|
|
368
|
-
lint?: Partial<Record<"context-isolation" | "shared-kernel" | "layers" | "dependencies" | "react" | "clock" | "config", boolean>> | undefined;
|
|
369
|
+
lint?: Partial<Record<"context-isolation" | "shared-kernel" | "layers" | "dependencies" | "react" | "svelte" | "clock" | "config", boolean>> | undefined;
|
|
369
370
|
} | undefined;
|
|
370
371
|
} | undefined;
|
|
371
372
|
frontend?: {
|
|
@@ -375,6 +376,11 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
375
376
|
framework?: "react" | "next" | undefined;
|
|
376
377
|
storybookFramework?: string | undefined;
|
|
377
378
|
} | undefined;
|
|
379
|
+
svelte?: {
|
|
380
|
+
[x: string]: unknown;
|
|
381
|
+
framework?: "svelte" | "sveltekit" | undefined;
|
|
382
|
+
storybookFramework?: string | undefined;
|
|
383
|
+
} | undefined;
|
|
378
384
|
} | undefined;
|
|
379
385
|
} | undefined;
|
|
380
386
|
contexts: {
|
|
@@ -428,6 +434,11 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
428
434
|
name: string;
|
|
429
435
|
file: string;
|
|
430
436
|
}[];
|
|
437
|
+
svelteModules: {
|
|
438
|
+
kind: "page" | "widget" | "ui-kit" | "hook";
|
|
439
|
+
name: string;
|
|
440
|
+
file: string;
|
|
441
|
+
}[];
|
|
431
442
|
} | null;
|
|
432
443
|
};
|
|
433
444
|
export declare const executeAgentRequest: (command: AgentCommand, value: unknown) => Promise<{
|