Skip to content

Commit 3dd89f0

Browse files
committed
preparing version 1.3
1 parent d832f17 commit 3dd89f0

File tree

17 files changed

+128
-110
lines changed

17 files changed

+128
-110
lines changed

libs/ddd/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ ng g @angular-architects/ddd:feature manage --domain boarding
4141
For NGRX support, just add the `--ngrx` switch:
4242

4343
```
44-
ng g @angular-architects/ddd:domain booking --addApp --ngrx
45-
ng g @angular-architects/ddd:feature search --domain booking --entity flight --ngrx
44+
ng g @angular-architects/ddd:domain luggage --addApp --ngrx
45+
ng g @angular-architects/ddd:feature checkin --domain luggage --entity luggage-list --ngrx
4646
[...]
4747
```
4848

libs/ddd/collection.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
"version": "0.0.1",
55
"schematics": {
66
"ng-add": {
7-
"factory": "./src/schematics/ng-add/index",
7+
"factory": "./libs/ddd/src/schematics/ng-add/index",
88
"description": "adds initial access restrictions to linting rules"
99
},
1010
"domain": {
11-
"factory": "./src/schematics/domain/index",
12-
"schema": "./src/schematics/domain/schema.json",
11+
"factory": "./libs/ddd/src/schematics/domain/index",
12+
"schema": "./libs/ddd/src/schematics/domain/schema.json",
1313
"description": "adds a domain including a domain folder, domain lib, entries in nx.json, and linting rules in tslint.json"
1414
},
1515
"feature": {
16-
"factory": "./src/schematics/feature/index",
17-
"schema": "./src/schematics/feature/schema.json",
16+
"factory": "./libs/ddd/src/schematics/feature/index",
17+
"schema": "./libs/ddd/src/schematics/feature/schema.json",
1818
"description": "adds a feature lib to a domain"
1919
},
2020
"ui": {
21-
"factory": "./src/schematics/ui/ui",
22-
"schema": "./src/schematics/ui/schema.json",
21+
"factory": "./libs/ddd/src/schematics/ui/ui",
22+
"schema": "./libs/ddd/src/schematics/ui/schema.json",
2323
"description": "adds a UI library to a domain or as a shared library"
2424
},
2525
"util": {
26-
"factory": "./src/schematics/util/util",
27-
"schema": "./src/schematics/util/schema.json",
26+
"factory": "./libs/ddd/src/schematics/util/util",
27+
"schema": "./libs/ddd/src/schematics/util/schema.json",
2828
"description": "adds a utility library to a domain or as a shared library"
2929
}
3030
}

libs/ddd/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"name": "@angular-architects/ddd",
3-
"version": "1.2.2",
3+
"version": "1.3.0",
44
"license": "MIT",
55
"author": "Manfred Steyer",
66
"description": "Nx plugin for structuring a monorepo with domains and layers",
77
"repository": {
88
"type": "github",
99
"url": "https://github.com/angular-architects/nx-ddd-plugin"
1010
},
11+
"dependencies": {
12+
"@ngrx/schematics":"^11.0.1"
13+
},
1114
"main": "src/index.js",
1215
"schematics": "./collection.json"
1316
}

libs/ddd/src/schematics/domain/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export default function (options: DomainOptions): Rule {
6262
prefix: libName,
6363
publishable: options.type === 'publishable',
6464
buildable: options.type === 'buildable',
65+
importPath: options.importPath
6566
}),
6667
addDomainToLintingRules(libName),
6768
mergeWith(templateSource),

libs/ddd/src/schematics/domain/schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
"enum": ["internal", "buildable", "publishable"],
3737
"description": "A type to determine if and how to build the library.",
3838
"default": "buildable"
39-
}
39+
},
40+
"importPath": {
41+
"type": "string",
42+
"description": "For publishable libs: Official package name used in import statements"
43+
}
4044
},
4145
"required": ["name"]
4246
}

libs/ddd/src/schematics/domain/schema.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export interface DomainOptions {
1010
* Grouping name for the Domain
1111
*/
1212
name: string;
13+
/**
14+
* Grouping folder within the apps directory
15+
*/
16+
appDirectory?: string;
1317
/**
1418
* Subpath of the domain within libs directory
1519
*/
@@ -18,17 +22,17 @@ export interface DomainOptions {
1822
* Add an app for the domain?
1923
*/
2024
addApp?: boolean;
21-
/**
22-
* Subpath of the domain within apps directory
23-
*/
24-
appDirectory?: string;
2525
/**
2626
* Add ngrx for the associated app (addApp required)
2727
*/
2828
ngrx?: boolean;
2929
/**
3030
* A type to determine if and how to build the library.
3131
*/
32-
type?: 'internal' | 'buildable' | 'publishable';
32+
type?: "internal" | "buildable" | "publishable";
33+
/**
34+
* For publishable libs: Official package name used in import statements
35+
*/
36+
importPath?: string;
3337
[k: string]: any;
3438
}

libs/ddd/src/schematics/feature/index.ts

Lines changed: 53 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import { readWorkspaceName } from '../utils';
2525

2626
export default function (options: FeatureOptions): Rule {
2727
return (host: Tree) => {
28+
29+
if (!options.app) {
30+
options.app = options.domain;
31+
}
32+
2833
const workspaceName = readWorkspaceName(host);
2934
const featureName = strings.dasherize(options.name)
3035
? strings.dasherize(options.name)
@@ -48,8 +53,8 @@ export default function (options: FeatureOptions): Rule {
4853
.split('/')
4954
.join('-');
5055
const domainNameAndDirectory = domainDirectory
51-
? `${domainName}/${domainDirectory}`
52-
: `${domainName}`;
56+
? `${domainName}/${domainDirectory}`
57+
: `${domainName}`;
5358
const domainNameAndDirectoryDasherized = `${domainNameAndDirectory}`
5459
.split('/')
5560
.join('-');
@@ -90,37 +95,12 @@ export default function (options: FeatureOptions): Rule {
9095
`${featureDirectoryAndNameDasherized}Component`
9196
);
9297
const appModulePath = `apps/${appDirectoryAndName}/src/app/app.module.ts`;
93-
/*
94-
console.log("featureDirectoryAndName", featureDirectoryAndName);
95-
console.log("featureDirectoryAndNameDasherized", featureDirectoryAndNameDasherized);
96-
console.log("domainNameAndDirectory", domainNameAndDirectory);
97-
console.log("domainNameAndDirectoryDasherized", domainNameAndDirectoryDasherized);
98-
console.log("appDirectoryAndName", appDirectoryAndName);
99-
console.log("domainNameAndDirectoryPath", domainNameAndDirectoryPath);
100-
console.log("domainFolderPath", domainFolderPath);
101-
console.log("domainLibFolderPath", domainLibFolderPath);
102-
console.log("domainModuleFilepath", domainModuleFilepath);
103-
console.log("domainModuleClassName", domainModuleClassName);
104-
console.log("domainImportPath", domainImportPath);
105-
console.log("domainIndexPath", domainIndexPath);
106-
console.log("featureFolderName", featureFolderName);
107-
console.log("featureDirectoryAndFolderName", featureDirectoryAndFolderName);
108-
console.log("featureLibFolderPath", featureLibFolderPath);
109-
console.log("featureModuleFilepath", featureModuleFilepath);
110-
console.log("featureModuleClassName", featureModuleClassName);
111-
console.log("featureImportPath", featureImportPath);
112-
console.log("featureIndexPath", featureIndexPath);
113-
console.log("entityName", entityName);
114-
console.log("featureComponentImportPath", featureComponentImportPath);
115-
console.log("featureComponentClassName", featureComponentClassName);
116-
*/
117-
if (options.app) {
118-
const requiredAppModulePath = `apps/${appDirectoryAndName}/src/app/app.module.ts`;
119-
if (!host.exists(requiredAppModulePath)) {
120-
throw new Error(
121-
`Specified app ${options.app} does not exist: ${requiredAppModulePath} expected!`
122-
);
123-
}
98+
99+
const requiredAppModulePath = `apps/${appDirectoryAndName}/src/app/app.module.ts`;
100+
if (!host.exists(requiredAppModulePath)) {
101+
throw new Error(
102+
`Specified app ${options.app} does not exist: ${requiredAppModulePath} expected!`
103+
);
124104
}
125105

126106
if (options.ngrx && !entityName) {
@@ -129,33 +109,33 @@ export default function (options: FeatureOptions): Rule {
129109
);
130110
}
131111

132-
let updatedEntityNameOptions = Object.assign({},options);
133-
updatedEntityNameOptions.entity = featureDirectoryAndNameDasherized;
112+
let updatedEntityNameOptions = Object.assign({}, options);
113+
// updatedEntityNameOptions.entity = featureDirectoryAndNameDasherized;
134114

135115
const domainTemplates =
136116
options.ngrx && entityName
137117
? apply(url('./files/forDomainWithNgrx'), [
138-
filterTemplates(updatedEntityNameOptions),
139-
template({ ...strings, ...updatedEntityNameOptions, workspaceName }),
140-
move(domainLibFolderPath),
141-
])
118+
filterTemplates(updatedEntityNameOptions),
119+
template({ ...strings, ...updatedEntityNameOptions, workspaceName }),
120+
move(domainLibFolderPath),
121+
])
142122
: apply(url('./files/forDomain'), [
143-
filterTemplates(options),
144-
template({ ...strings, ...options, workspaceName }),
145-
move(domainLibFolderPath),
146-
]);
123+
filterTemplates(options),
124+
template({ ...strings, ...options, workspaceName }),
125+
move(domainLibFolderPath),
126+
]);
147127

148128
const featureTemplates =
149129
options.ngrx && entityName
150130
? apply(url('./files/forFeatureWithNgrx'), [
151-
filterTemplates(options),
152-
template({ ...strings, ...options, workspaceName }),
153-
move(featureLibFolderPath),
154-
])
131+
filterTemplates(options),
132+
template({ ...strings, ...options, workspaceName }),
133+
move(featureLibFolderPath),
134+
])
155135
: apply(url('./files/forFeature'), [
156-
template({ ...strings, ...options, workspaceName }),
157-
move(featureLibFolderPath),
158-
]);
136+
template({ ...strings, ...options, workspaceName }),
137+
move(featureLibFolderPath),
138+
]);
159139

160140
return chain([
161141
externalSchematic('@nrwl/angular', 'lib', {
@@ -168,39 +148,40 @@ export default function (options: FeatureOptions): Rule {
168148
prefix: domainNameAndDirectoryDasherized,
169149
publishable: options.type === 'publishable',
170150
buildable: options.type === 'buildable',
151+
importPath: options.importPath
171152
}),
172153
addImport(featureModuleFilepath, domainImportPath, domainModuleClassName),
173154
!options.lazy && host.exists(appModulePath)
174155
? chain([
175-
addImport(
176-
appModulePath,
177-
featureImportPath,
178-
featureModuleClassName,
179-
true
180-
),
181-
addImport(
182-
appModulePath,
183-
'@angular/common/http',
184-
'HttpClientModule',
185-
true
186-
),
187-
])
156+
addImport(
157+
appModulePath,
158+
featureImportPath,
159+
featureModuleClassName,
160+
true
161+
),
162+
addImport(
163+
appModulePath,
164+
'@angular/common/http',
165+
'HttpClientModule',
166+
true
167+
),
168+
])
188169
: noop(),
189170
mergeWith(domainTemplates),
190171
entityName
191172
? addTsExport(domainIndexPath, [
192-
`./lib/entities/${featureDirectoryAndNameDasherized}`,
193-
`./lib/infrastructure/${featureDirectoryAndNameDasherized}.data.service`,
194-
])
173+
`./lib/entities/${entityName}`,
174+
`./lib/infrastructure/${entityName}.data.service`,
175+
])
195176
: noop(),
196177
options.ngrx && entityName && host.exists(domainModuleFilepath)
197178
? chain([
198-
addNgRxToPackageJson(),
199-
addNgrxImportsToDomain(domainModuleFilepath, featureDirectoryAndNameDasherized),
200-
addTsExport(domainIndexPath, [
201-
`./lib/+state/${featureDirectoryAndNameDasherized}/${featureDirectoryAndNameDasherized}.actions`,
202-
]),
203-
])
179+
addNgRxToPackageJson(),
180+
addNgrxImportsToDomain(domainModuleFilepath, entityName),
181+
addTsExport(domainIndexPath, [
182+
`./lib/+state/${entityName}/${entityName}.actions`,
183+
]),
184+
])
204185
: noop(),
205186
addTsExport(domainIndexPath, [
206187
`./lib/application/${featureDirectoryAndNameDasherized}.facade`, //featureDirectoryAndNameDasherized

libs/ddd/src/schematics/feature/schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
},
2929
"domainDirectory": {
3030
"type": "string",
31-
"x-prompt": "Subpath within domain directory",
3231
"description": "Domain name"
3332
},
3433
"app": {
@@ -54,6 +53,10 @@
5453
"description": "A type to determine if and how to build the library.",
5554
"default": "buildable"
5655
},
56+
"importPath": {
57+
"type": "string",
58+
"description": "For publishable libs: Official package name used in import statements"
59+
},
5760
"ngrx": {
5861
"type": "boolean",
5962
"default": false,

libs/ddd/src/schematics/feature/schema.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ export interface FeatureOptions {
2323
*/
2424
domain: string;
2525
/**
26-
* Subpath within apps directory
26+
* Domain name
2727
*/
2828
domainDirectory?: string;
2929
/**
3030
* app name
3131
*/
3232
app?: string;
3333
/**
34-
* Subpath within apps directory
34+
* Subpath within app directory
3535
*/
3636
appDirectory?: string;
3737
/**
@@ -45,7 +45,11 @@ export interface FeatureOptions {
4545
/**
4646
* A type to determine if and how to build the library.
4747
*/
48-
type?: 'internal' | 'buildable' | 'publishable';
48+
type?: "internal" | "buildable" | "publishable";
49+
/**
50+
* For publishable libs: Official package name used in import statements
51+
*/
52+
importPath?: string;
4953
/**
5054
* Add ngrx for the domain (entity required)
5155
*/

libs/ddd/src/schematics/ng-add/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import { NGRX_VERSION } from '../utils';
1010
export default function(): Rule {
1111
return chain([
1212
initLintingRules(),
13-
addDepsToPackageJson({
14-
'@ngrx/schematics': NGRX_VERSION
15-
})
13+
// This is now a dependency in package.json
14+
// This prevents issues when installing this lib
15+
// and makes installing faster
16+
// addDepsToPackageJson({}, {
17+
// '@ngrx/schematics': NGRX_VERSION
18+
// })
1619
]);
1720
}

0 commit comments

Comments
 (0)