@domain-first/project-structure 7.0.0 → 7.1.1
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 +4 -0
- package/dist/287.js +546 -89
- package/dist/backend-module-move.d.ts +53 -0
- package/dist/backend-module-move.spec.d.ts +1 -0
- package/dist/in-memory-db.d.ts +5 -0
- package/dist/index.cjs +573 -9
- package/dist/index.js +4 -2
- package/dist/init.cjs +61 -0
- package/dist/integration.cjs +61 -0
- package/dist/module-move.d.ts +58 -0
- package/dist/react-module-move.d.ts +2 -6
- package/dist/react.cjs +184 -97
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/move-backend-unit.d.ts +7 -0
- package/package.json +1 -1
- package/skills/df-ps-implement/SKILL.md +1 -1
- package/skills/df-ps-scaffold/SKILL.md +3 -2
- package/skills/df-ps-scaffold/references/units/move-or-rename.md +21 -0
|
@@ -10,7 +10,7 @@ Generated files contain placeholders: empty classes, `{}` schemas, `[]` dependen
|
|
|
10
10
|
## Ground rules
|
|
11
11
|
|
|
12
12
|
- New files need an approved work plan (`df-ps-scaffold`, rule 1) and come only via df-scaffold or its listed exceptions (rule 2). Edits to existing files don't need approval; report them.
|
|
13
|
-
- Keep generated names and paths: barrels, wiring, specs, and `presentation/rest/wires.ts` import them.
|
|
13
|
+
- Keep generated names and paths: barrels, wiring, specs, and `presentation/rest/wires.ts` import them. To rename or move a module, use `Move or rename` of df-scaffold (`df-ps-scaffold/references/units/move-or-rename.md`), never by hand.
|
|
14
14
|
- Layers: domain imports nothing from other layers. Application uses domain and its own abstractions. Infrastructure implements repositories, contracts, and ports, and may use application ports (of its context and the Shared Kernel), never other application modules. Infrastructure needing logic from an application service means the logic is misplaced: pure logic without ports → a domain service; logic over ports → call those ports directly; technical logic (mapping, retries, formatting for an external API) → an infrastructure service. Presentation calls application handlers. Only `wiring/` knows concrete classes.
|
|
15
15
|
- Constructors take abstractions (`OrderRepository`, abstract `PlaceOrderCommand`, port `PaymentGateway`), never `PrismaOrderRepository`.
|
|
16
16
|
- Implementation order: domain → application → schema tool runs (migrations, only if infrastructure needs data the database lacks) → infrastructure (repositories, commands/queries, adapters) → endpoints → other tool runs (OpenAPI, API client) → React. Widgets need the regenerated client. How to run tools and handle their output: the project's scripts skill (`project-scripts`), if there is one.
|
|
@@ -75,7 +75,7 @@ Anything else (helpers, types, constants, mappers, wiring, barrels): put it in a
|
|
|
75
75
|
|
|
76
76
|
If the CLI can't run, give the user the menu path and answers to run `npx df-scaffold` (or `npx df-react` for React modules) themselves (`! npx df-scaffold`). Never hand-write its output. Missing generated files are only recreated by re-running the generator, as an approved overwrite.
|
|
77
77
|
|
|
78
|
-
Moving or renaming a
|
|
78
|
+
Moving or renaming a module (aggregate, entity, value object, service, port, query, command, use case) is a df-scaffold run, `Move or rename` (`references/units/move-or-rename.md`); a page or widget, a df-react run (`df-ps-react`). Never by hand: it creates files at the new paths, so it needs an approved plan.
|
|
79
79
|
|
|
80
80
|
### 3. New dependencies only through df-scaffold
|
|
81
81
|
|
|
@@ -106,6 +106,7 @@ One file per unit in `references/units/`: when to choose it, how to generate it
|
|
|
106
106
|
| Port + adapters | `port.md` | Application → New Port |
|
|
107
107
|
| REST endpoint | `endpoint.md` | Presentation → New Handlers-REST Endpoint |
|
|
108
108
|
| Dependency of an existing module | `wire-dependency.md` | Wire dependency |
|
|
109
|
+
| Moving or renaming a module | `move-or-rename.md` | Move or rename |
|
|
109
110
|
| React modules | `df-ps-react` skill | `df-react` |
|
|
110
111
|
|
|
111
112
|
## Preparing runs
|
|
@@ -143,7 +144,7 @@ Check every run: exit code 0, no `WARNING`/`ABORTED`, and exactly the planned fi
|
|
|
143
144
|
| Infrastructure | New Service | New Service |
|
|
144
145
|
| Presentation | New Handlers-REST Endpoint (needs handlers-rest), New Service | New Service |
|
|
145
146
|
|
|
146
|
-
With `@domain-first/wire`, the layer menu of a context and of the Shared Kernel also has `Wire dependency`: it adds dependencies to an existing wired module.
|
|
147
|
+
With `@domain-first/wire`, the layer menu of a context and of the Shared Kernel also has `Wire dependency`: it adds dependencies to an existing wired module. Every layer menu has `Move or rename`.
|
|
147
148
|
|
|
148
149
|
The main menu also has `Scaffold new bounded context`. React modules come from a separate CLI, `df-react`: see `df-ps-react`.
|
|
149
150
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Move or rename
|
|
2
|
+
|
|
3
|
+
When: a module's name no longer fits, or it belongs elsewhere: another bounded context, the Shared Kernel (entities, value objects, services, ports only), or in or out of an aggregate. Never move, rename or copy module files by hand, and never rename their classes, wires or parameters by hand: the CLI keeps files, names and imports in sync.
|
|
4
|
+
|
|
5
|
+
## Generate (context and Shared Kernel)
|
|
6
|
+
|
|
7
|
+
Prompts: `Module:` (select, grouped by kind; entities and value objects of an aggregate show it: `order-line (order)`) → `Move to:` (`Bounded Context: <current> (stays)`, other contexts, `Shared Kernel` for the kinds it has) → `Aggregate:` (entities and value objects only, when the target context has aggregates: `No aggregate` or one of them) → `New name:` (default: the current one) → `Apply?`.
|
|
8
|
+
|
|
9
|
+
`… "pick:Move or rename" pick:order "pick:Bounded Context: sales" text:purchase yes`
|
|
10
|
+
`… "pick:Move or rename" pick:money "pick:Shared Kernel" default yes`
|
|
11
|
+
`… "pick:Move or rename" pick:order-line "pick:Bounded Context: sales" "pick:No aggregate" default yes`
|
|
12
|
+
|
|
13
|
+
Every file of the module moves (contract, implementations, wire, specs; an aggregate with its whole folder), every import of it follows, and derived names change in the module and its importers: `OrderRepository`, `PrismaOrderRepository`, `wireOrderRepository`, dependents' `orderRepository` parameters, an aggregate's in-memory DB section. An entity leaving its aggregate is no longer re-exported there; its importers import its file.
|
|
14
|
+
|
|
15
|
+
Before `Apply?` the CLI lists the files to move and to update: check them against the plan. A move that would make a context import another one prints `Nothing was moved: these imports would cross a bounded context boundary.` with the imports: nothing changed. Fix the design instead (`../choosing-components.md`, step 9: the other context gets its own query or command), or move the dependency first.
|
|
16
|
+
|
|
17
|
+
In the plan, list a move as a run: old → new place and name, the files to move (`→`) and the files whose imports or names change (`~`).
|
|
18
|
+
|
|
19
|
+
## Implement
|
|
20
|
+
|
|
21
|
+
Nothing to fill in. Re-read the moved module's files: names inside method bodies that only resemble the old name (local variables, strings, comments) are not renamed. Run `npx df-lint` and the project's tsc/tests.
|