Skip to content

Commit c9cf238

Browse files
committed
feat: update templates for nx18 and new ngrx apis
1 parent 515a67e commit c9cf238

27 files changed

+133
-182
lines changed

libs/ddd/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/ddd",
3-
"version": "17.0.3",
3+
"version": "19.0.0-beta.11",
44
"license": "MIT",
55
"author": "Manfred Steyer",
66
"description": "Nx plugin for structuring a monorepo with domains and layers",
@@ -9,10 +9,10 @@
99
"url": "https://github.com/angular-architects/nx-ddd-plugin"
1010
},
1111
"dependencies": {
12-
"@ngrx/schematics": "^16.0.0"
12+
"@ngrx/schematics": "^18.0.0"
1313
},
1414
"peerDependencies": {
15-
"@nx/angular": "^17.0.0"
15+
"@nx/angular": "^19.0.0"
1616
},
1717
"main": "src/index.js",
1818
"schematics": "./collection.json",

libs/ddd/src/generators/api/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ export default async function (tree: Tree, options: ApiOptions) {
1919
const isPublishableLib = options.type === 'publishable';
2020

2121
await libraryGenerator(tree, {
22-
name: libName,
22+
name: `libs/${libDirectory}/${libName}`,
2323
tags: `domain:${domain},domain:${domain}/${libName},type:api`,
2424
prefix: options.name,
2525
publishable: isPublishableLib,
2626
buildable: options.type === 'buildable',
27-
directory: libDirectory,
27+
// directory: libDirectory,
2828
importPath: options.importPath,
2929
standalone: options.standalone,
3030
});

libs/ddd/src/generators/api/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"standalone": {
4242
"type": "boolean",
43-
"default": false,
43+
"default": true,
4444
"description": "Use standalone components?"
4545
}
4646
}

libs/ddd/src/generators/domain/files/standalone-app/app/app.component.ts__tmpl__

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Component } from '@angular/core';
66
imports: [
77
CommonModule
88
],
9-
selector: '<%=npmScope%>-root',
9+
selector: 'app-root',
1010
templateUrl: './app.component.html',
1111
styleUrls: ['./app.component.scss']
1212
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
2+
import { provideRouter } from '@angular/router';
3+
import { provideHttpClient } from '@angular/common/http';
4+
<% if (ngrx) { %>
5+
import { isDevMode } from '@angular/core';
6+
import { provideEffects } from '@ngrx/effects';
7+
import { provideStore } from '@ngrx/store';
8+
import { provideStoreDevtools } from '@ngrx/store-devtools';
9+
import { provide<%=className%>Domain } from '<%=npmScope%>/<%=fileName%>/domain';
10+
<% } %>
11+
import { appRoutes } from './app.routes';
12+
13+
export const appConfig: ApplicationConfig = {
14+
providers: [
15+
provideZoneChangeDetection({ eventCoalescing: true }),
16+
provideRouter(appRoutes),
17+
provideHttpClient(), <% if (ngrx) { %>
18+
provideStore(),
19+
provideEffects([]),
20+
... (isDevMode()) ? [provideStoreDevtools()] : [],
21+
provide<%=className%>Domain() <% } %>
22+
],
23+
};

libs/ddd/src/generators/domain/files/standalone-app/main.ts__tmpl__

Lines changed: 0 additions & 20 deletions
This file was deleted.

libs/ddd/src/generators/domain/files/standalone-lib/lib/providers.ts__tmpl__

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { provideEffects } from '@ngrx/effects';
22
import { provideState } from '@ngrx/store';
33

44
export function provide<%=className%>Domain() {
5+
// prettier-ignore
56
return [
67
];
78
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import {
99
readNxJson,
1010
} from '@nx/devkit';
1111

12-
import { readPackageJson } from '@nx/workspace'
13-
1412
import { libraryGenerator, applicationGenerator } from '@nx/angular/generators';
1513
import { strings } from '@angular-devkit/core';
1614
import { DomainOptions } from './schema';
@@ -86,8 +84,8 @@ export default async function (tree: Tree, options: DomainOptions) {
8684
// }
8785

8886
await libraryGenerator(tree, {
89-
name: 'domain',
90-
directory: libNameAndDirectory,
87+
name: `libs/${libNameAndDirectory}/domain`,
88+
// directory: libNameAndDirectory,
9189
tags: `domain:${libName},type:domain-logic`,
9290
prefix: libName,
9391
publishable: options.type === 'publishable',
@@ -116,8 +114,8 @@ export default async function (tree: Tree, options: DomainOptions) {
116114

117115
if (options.addApp) {
118116
await applicationGenerator(tree, {
119-
name: appName,
120-
directory: options.appDirectory,
117+
name: options.appDirectory ? `apps/${options.appDirectory}/${appName}` : `apps/${appName}`,
118+
// directory: options.appDirectory,
121119
tags: `domain:${appName},type:app`,
122120
style: 'scss',
123121
standalone: options.standalone
@@ -167,15 +165,17 @@ export default async function (tree: Tree, options: DomainOptions) {
167165
...options,
168166
...names(options.name),
169167
tmpl: '',
170-
}
168+
},
171169
);
170+
172171
}
173172

174173
deleteDefaultComponent(
175174
tree,
176175
libNameAndDirectory,
177176
'domain',
178-
libName
177+
libName,
178+
!options.ngrx
179179
);
180180

181181
await formatFiles(tree);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
"standalone": {
4949
"type": "boolean",
50-
"default": false,
50+
"default": true,
5151
"description": "Use standalone components?"
5252
}
5353
},

libs/ddd/src/generators/feature/files/forDomain/infrastructure/__entity@dasherize__.data.service.ts__tmpl__

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import {Injectable} from '@angular/core';
1+
import {Injectable, inject} from '@angular/core';
22
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
33
import {Observable, of} from 'rxjs';
44
import {<%=classify(entity)%>} from '../entities/<%=dasherize(entity)%>';
55

66
@Injectable({ providedIn: 'root' })
77
export class <%=classify(entity)%>DataService {
88

9-
constructor(private http: HttpClient) {
10-
}
9+
private http = inject(HttpClient);
1110

1211
load(): Observable<<%=classify(entity)%>[]> {
1312

0 commit comments

Comments
 (0)