@domain-first/project-structure 6.0.0 → 7.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 +20 -19
- package/dist/201.js +46 -35
- package/dist/287.js +1762 -1250
- package/dist/backend-module-move.d.ts +53 -0
- package/dist/backend-module-move.spec.d.ts +1 -0
- package/dist/config-file.d.ts +2 -2
- package/dist/dependency-rules.d.ts +1 -1
- package/dist/file-system.d.ts +5 -0
- package/dist/in-memory-db.d.ts +9 -0
- package/dist/index.cjs +534 -804
- package/dist/index.js +9 -47
- package/dist/init.cjs +913 -0
- package/dist/init.d.ts +2 -0
- package/dist/init.js +36 -0
- package/dist/integration.cjs +457 -33
- package/dist/integration.js +4 -4
- package/dist/integrations/in-memory-db.d.ts +6 -0
- package/dist/integrations/index.d.ts +2 -0
- package/dist/integrations/missing-domain-first-packages.d.ts +8 -0
- package/dist/integrations/rest-endpoint-generator.d.ts +18 -0
- package/dist/integrations/rest-endpoint-generator.spec.d.ts +1 -0
- package/dist/lint.cjs +8 -8
- package/dist/lint.js +7 -7
- package/dist/module-move.d.ts +58 -0
- package/dist/print-next-steps.d.ts +2 -2
- package/dist/react-module-move.d.ts +2 -6
- package/dist/react.cjs +986 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +73 -0
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/move-backend-unit.d.ts +7 -0
- package/dist/use-cases/rest-endpoint-generator.d.ts +1 -1
- package/package.json +3 -1
- package/skills/df-ps-implement/SKILL.md +11 -56
- package/skills/df-ps-plan-feature/SKILL.md +6 -6
- package/skills/df-ps-project-scripts/SKILL.md +1 -1
- package/skills/df-ps-react/SKILL.md +82 -0
- package/skills/df-ps-react/references/generators.md +80 -0
- package/skills/df-ps-scaffold/SKILL.md +39 -20
- package/skills/df-ps-scaffold/references/choosing-components.md +7 -28
- package/skills/df-ps-scaffold/references/generators.md +6 -179
- package/skills/df-ps-scaffold/references/units/aggregate.md +47 -0
- package/skills/df-ps-scaffold/references/units/bounded-context.md +13 -0
- package/skills/df-ps-scaffold/references/units/command-query.md +32 -0
- package/skills/df-ps-scaffold/references/units/endpoint.md +28 -0
- package/skills/df-ps-scaffold/references/units/entity-value-object.md +27 -0
- package/skills/df-ps-scaffold/references/units/errors.md +26 -0
- package/skills/df-ps-scaffold/references/units/move-or-rename.md +21 -0
- package/skills/df-ps-scaffold/references/units/port.md +23 -0
- package/skills/df-ps-scaffold/references/units/services.md +28 -0
- package/skills/df-ps-scaffold/references/units/use-case.md +25 -0
- package/skills/df-ps-scaffold/references/units/wire-dependency.md +15 -0
- package/skills/df-ps-scaffold/scripts/drive.mjs +12 -4
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
export * from './in-memory-db';
|
|
1
2
|
export * from './missing-domain-first-packages';
|
|
2
3
|
export * from './openapi';
|
|
3
4
|
export * from './orval';
|
|
4
5
|
export * from './package-scripts';
|
|
5
6
|
export * from './playwright';
|
|
6
7
|
export * from './prisma';
|
|
8
|
+
export * from './rest-endpoint-generator';
|
|
7
9
|
export * from './storybook';
|
|
8
10
|
export * from './testcontainers';
|
|
9
11
|
export * from './vitest';
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the project's manifest declares `name` in any dependency group.
|
|
3
|
+
*/
|
|
4
|
+
export declare const hasDependency: (name: string) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The install command for the packages the manifest doesn't declare.
|
|
7
|
+
*/
|
|
8
|
+
export declare const missingPackages: (packages: string[]) => string[];
|
|
1
9
|
export declare const missingDomainFirstPackages: () => string[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The catch-all route serving every endpoint, relative to the project root.
|
|
3
|
+
*/
|
|
4
|
+
export declare const nextRoutePath: (root: string) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Asked only in projects with `next` among their dependencies.
|
|
7
|
+
*/
|
|
8
|
+
export declare const askNextAdapter: () => Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* The Shared Kernel endpoint generator and, with the Next adapter, the
|
|
11
|
+
* catch-all route. Existing files are kept: the generator is edited by
|
|
12
|
+
* hand.
|
|
13
|
+
*/
|
|
14
|
+
export declare const scaffoldRestEndpointGeneratorFiles: ({ withNextAdapter }: {
|
|
15
|
+
withNextAdapter: boolean;
|
|
16
|
+
}) => string[];
|
|
17
|
+
export declare const addRestEndpointGenerator: () => Promise<string[]>;
|
|
18
|
+
export declare const restEndpointGeneratorApplied: () => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/lint.cjs
CHANGED
|
@@ -223,7 +223,7 @@ class ProjectRoot {
|
|
|
223
223
|
}
|
|
224
224
|
const lintChecks = [
|
|
225
225
|
'context-isolation',
|
|
226
|
-
'shared-
|
|
226
|
+
'shared-kernel',
|
|
227
227
|
'layers',
|
|
228
228
|
'dependencies',
|
|
229
229
|
'react',
|
|
@@ -624,7 +624,7 @@ const isOwnContract = (file, target)=>baseName(file).endsWith(`-${baseName(targe
|
|
|
624
624
|
const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
625
625
|
const root = external_node_path_default().resolve(projectRoot, rootFolder);
|
|
626
626
|
const contextsFolder = external_node_path_default().join(root, 'bounded-contexts');
|
|
627
|
-
const sharedFolder = external_node_path_default().join(root, 'shared');
|
|
627
|
+
const sharedFolder = external_node_path_default().join(root, 'shared-kernel');
|
|
628
628
|
const reactFolder = external_node_path_default().join(root, 'presentation', 'react');
|
|
629
629
|
const uiKitFolder = external_node_path_default().join(reactFolder, 'ui-kit');
|
|
630
630
|
const widgetsFolder = external_node_path_default().join(reactFolder, 'widgets');
|
|
@@ -643,7 +643,7 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
643
643
|
}
|
|
644
644
|
const inShared = inside(sharedFolder, file);
|
|
645
645
|
return inShared && {
|
|
646
|
-
owner: 'shared',
|
|
646
|
+
owner: 'shared-kernel',
|
|
647
647
|
segments: inShared
|
|
648
648
|
};
|
|
649
649
|
};
|
|
@@ -684,8 +684,8 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
684
684
|
if (ownContext) {
|
|
685
685
|
if (targetContext && targetContext !== ownContext) report('context-isolation', `[${ownContext}] imports another context:`, imported);
|
|
686
686
|
} else if (inside(sharedFolder, file)) {
|
|
687
|
-
const allowed = !to || 'shared' === to.owner || 'domain' === to.segments[0] && 'errors' === to.segments[1] || file === inMemoryDbFile && isDomainModel(to.segments, target);
|
|
688
|
-
if (!allowed) report('shared-
|
|
687
|
+
const allowed = !to || 'shared-kernel' === to.owner || 'domain' === to.segments[0] && 'errors' === to.segments[1] || file === inMemoryDbFile && isDomainModel(to.segments, target);
|
|
688
|
+
if (!allowed) report('shared-kernel', '[shared-kernel] imports a bounded context outside its domain/errors (and domain models for the in-memory DB):', imported);
|
|
689
689
|
} else if (inside(uiKitFolder, file) || inside(hooksFolder, file)) {
|
|
690
690
|
const [area] = inside(reactFolder, target) ?? [];
|
|
691
691
|
const forbidden = inside(uiKitFolder, file) ? [
|
|
@@ -717,12 +717,12 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
717
717
|
};
|
|
718
718
|
const wiringViolations = (projectRoot, rootFolder, rules)=>{
|
|
719
719
|
const root = external_node_path_default().resolve(projectRoot, rootFolder);
|
|
720
|
-
const sharedFolder = external_node_path_default().join(root, 'shared');
|
|
720
|
+
const sharedFolder = external_node_path_default().join(root, 'shared-kernel');
|
|
721
721
|
const contextsFolder = external_node_path_default().join(root, 'bounded-contexts');
|
|
722
722
|
const sharedModules = findWiredModules(sharedFolder);
|
|
723
723
|
const owners = [
|
|
724
724
|
{
|
|
725
|
-
name: 'shared',
|
|
725
|
+
name: 'shared-kernel',
|
|
726
726
|
modules: sharedModules
|
|
727
727
|
},
|
|
728
728
|
...external_node_fs_default().existsSync(contextsFolder) ? external_node_fs_default().readdirSync(contextsFolder, {
|
|
@@ -771,7 +771,7 @@ const wiringViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
771
771
|
const clockViolations = (projectRoot, rootFolder)=>{
|
|
772
772
|
const root = external_node_path_default().resolve(projectRoot, rootFolder);
|
|
773
773
|
const folders = [
|
|
774
|
-
external_node_path_default().join(root, 'shared'),
|
|
774
|
+
external_node_path_default().join(root, 'shared-kernel'),
|
|
775
775
|
...external_node_fs_default().existsSync(external_node_path_default().join(root, 'bounded-contexts')) ? external_node_fs_default().readdirSync(external_node_path_default().join(root, 'bounded-contexts')).map((name)=>external_node_path_default().join(root, 'bounded-contexts', name)) : []
|
|
776
776
|
].flatMap((folder)=>[
|
|
777
777
|
external_node_path_default().join(folder, 'domain'),
|
package/dist/lint.js
CHANGED
|
@@ -72,7 +72,7 @@ const isOwnContract = (file, target)=>baseName(file).endsWith(`-${baseName(targe
|
|
|
72
72
|
const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
73
73
|
const root = node_path.resolve(projectRoot, rootFolder);
|
|
74
74
|
const contextsFolder = node_path.join(root, 'bounded-contexts');
|
|
75
|
-
const sharedFolder = node_path.join(root, 'shared');
|
|
75
|
+
const sharedFolder = node_path.join(root, 'shared-kernel');
|
|
76
76
|
const reactFolder = node_path.join(root, 'presentation', 'react');
|
|
77
77
|
const uiKitFolder = node_path.join(reactFolder, 'ui-kit');
|
|
78
78
|
const widgetsFolder = node_path.join(reactFolder, 'widgets');
|
|
@@ -91,7 +91,7 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
91
91
|
}
|
|
92
92
|
const inShared = inside(sharedFolder, file);
|
|
93
93
|
return inShared && {
|
|
94
|
-
owner: 'shared',
|
|
94
|
+
owner: 'shared-kernel',
|
|
95
95
|
segments: inShared
|
|
96
96
|
};
|
|
97
97
|
};
|
|
@@ -132,8 +132,8 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
132
132
|
if (ownContext) {
|
|
133
133
|
if (targetContext && targetContext !== ownContext) report('context-isolation', `[${ownContext}] imports another context:`, imported);
|
|
134
134
|
} else if (inside(sharedFolder, file)) {
|
|
135
|
-
const allowed = !to || 'shared' === to.owner || 'domain' === to.segments[0] && 'errors' === to.segments[1] || file === inMemoryDbFile && isDomainModel(to.segments, target);
|
|
136
|
-
if (!allowed) report('shared-
|
|
135
|
+
const allowed = !to || 'shared-kernel' === to.owner || 'domain' === to.segments[0] && 'errors' === to.segments[1] || file === inMemoryDbFile && isDomainModel(to.segments, target);
|
|
136
|
+
if (!allowed) report('shared-kernel', '[shared-kernel] imports a bounded context outside its domain/errors (and domain models for the in-memory DB):', imported);
|
|
137
137
|
} else if (inside(uiKitFolder, file) || inside(hooksFolder, file)) {
|
|
138
138
|
const [area] = inside(reactFolder, target) ?? [];
|
|
139
139
|
const forbidden = inside(uiKitFolder, file) ? [
|
|
@@ -165,12 +165,12 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
165
165
|
};
|
|
166
166
|
const wiringViolations = (projectRoot, rootFolder, rules)=>{
|
|
167
167
|
const root = node_path.resolve(projectRoot, rootFolder);
|
|
168
|
-
const sharedFolder = node_path.join(root, 'shared');
|
|
168
|
+
const sharedFolder = node_path.join(root, 'shared-kernel');
|
|
169
169
|
const contextsFolder = node_path.join(root, 'bounded-contexts');
|
|
170
170
|
const sharedModules = findWiredModules(sharedFolder);
|
|
171
171
|
const owners = [
|
|
172
172
|
{
|
|
173
|
-
name: 'shared',
|
|
173
|
+
name: 'shared-kernel',
|
|
174
174
|
modules: sharedModules
|
|
175
175
|
},
|
|
176
176
|
...node_fs.existsSync(contextsFolder) ? node_fs.readdirSync(contextsFolder, {
|
|
@@ -219,7 +219,7 @@ const wiringViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
219
219
|
const clockViolations = (projectRoot, rootFolder)=>{
|
|
220
220
|
const root = node_path.resolve(projectRoot, rootFolder);
|
|
221
221
|
const folders = [
|
|
222
|
-
node_path.join(root, 'shared'),
|
|
222
|
+
node_path.join(root, 'shared-kernel'),
|
|
223
223
|
...node_fs.existsSync(node_path.join(root, 'bounded-contexts')) ? node_fs.readdirSync(node_path.join(root, 'bounded-contexts')).map((name)=>node_path.join(root, 'bounded-contexts', name)) : []
|
|
224
224
|
].flatMap((folder)=>[
|
|
225
225
|
node_path.join(folder, 'domain'),
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export declare const codeExtension: RegExp;
|
|
2
|
+
export declare const escapeRegExp: (value: string) => string;
|
|
3
|
+
export declare const walk: (folder: string) => string[];
|
|
4
|
+
export declare const toPosix: (value: string) => string;
|
|
5
|
+
type TsconfigAlias = {
|
|
6
|
+
prefix: string;
|
|
7
|
+
target: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Code files of the project and how their import specifiers resolve:
|
|
11
|
+
* relative paths and wildcard tsconfig aliases. Package imports resolve
|
|
12
|
+
* to nothing.
|
|
13
|
+
*/
|
|
14
|
+
export declare const projectImports: (projectRoot: string) => {
|
|
15
|
+
resolve: (specifier: string, fromFile: string) => {
|
|
16
|
+
resolved: string;
|
|
17
|
+
alias: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
resolved: string;
|
|
20
|
+
alias: TsconfigAlias;
|
|
21
|
+
} | undefined;
|
|
22
|
+
specifierFor: (fromFile: string, toPath: string, alias: TsconfigAlias | undefined) => string;
|
|
23
|
+
codeFiles: Map<string, string>;
|
|
24
|
+
importsOf: (file: string) => string[];
|
|
25
|
+
};
|
|
26
|
+
export type MovePlan = {
|
|
27
|
+
/** Old path → new path of every file of the module. */
|
|
28
|
+
moves: [string, string][];
|
|
29
|
+
/** Other files with references to the module. */
|
|
30
|
+
updated: string[];
|
|
31
|
+
};
|
|
32
|
+
export type ModuleMove = {
|
|
33
|
+
projectRoot: string;
|
|
34
|
+
/** Folders emptied by the move are removed up to this one (exclusive). */
|
|
35
|
+
stopAt: string;
|
|
36
|
+
/** Old path → new path of every file of the module. */
|
|
37
|
+
moves: Map<string, string>;
|
|
38
|
+
/**
|
|
39
|
+
* Where a path of the module goes, for import resolution: files with or
|
|
40
|
+
* without extension, and folders. Undefined for other paths.
|
|
41
|
+
*/
|
|
42
|
+
movedPath: (candidate: string) => string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Renames the module's names in a file of the module or in a file that
|
|
45
|
+
* references it, directly or through a barrel.
|
|
46
|
+
*/
|
|
47
|
+
rename: (content: string, file: {
|
|
48
|
+
moved: boolean;
|
|
49
|
+
}) => string;
|
|
50
|
+
/** A change every code file gets, references or not. */
|
|
51
|
+
everyFile?: (content: string) => string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Stages the move with pending changes: files of the module, its imports
|
|
55
|
+
* of other files, and every import of it in the project.
|
|
56
|
+
*/
|
|
57
|
+
export declare const stageModuleMove: ({ projectRoot, stopAt, moves, movedPath, rename, everyFile }: ModuleMove) => MovePlan;
|
|
58
|
+
export {};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const mergeInstallCommands: (commands: string[]) => string[];
|
|
8
8
|
/**
|
|
9
|
-
* Prints the steps left after a use case: installation
|
|
10
|
-
* then additional information.
|
|
9
|
+
* Prints the steps left after a use case: one installation command to
|
|
10
|
+
* copy, then additional information.
|
|
11
11
|
*/
|
|
12
12
|
export declare const printNextSteps: (nextSteps: string[]) => void;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type MovePlan } from './module-move';
|
|
2
|
+
export type { MovePlan } from './module-move';
|
|
1
3
|
export type ReactModuleKind = 'page' | 'widget';
|
|
2
4
|
export type ReactModule = {
|
|
3
5
|
kind: ReactModuleKind;
|
|
@@ -11,12 +13,6 @@ export type ReactModule = {
|
|
|
11
13
|
};
|
|
12
14
|
export declare const findReactModules: (reactFolder: string, kind: ReactModuleKind) => ReactModule[];
|
|
13
15
|
export declare const validateMove: (reactFolder: string, module: ReactModule, rawName: string) => string | true;
|
|
14
|
-
export type MovePlan = {
|
|
15
|
-
/** Old path → new path of every file of the module. */
|
|
16
|
-
moves: [string, string][];
|
|
17
|
-
/** Other files with references to the module. */
|
|
18
|
-
updated: string[];
|
|
19
|
-
};
|
|
20
16
|
/**
|
|
21
17
|
* Stages the move with pending changes: files of the module, its imports
|
|
22
18
|
* of other files, and every import of it in the project.
|