@nx/angular 19.6.0-canary.20240809-d3747e0 → 19.6.0-canary.20240814-6d83ae2
Sign up to get free protection for your applications and to get access to all the features.
- package/esm2022/src/runtime/nx/data-persistence.mjs +9 -4
- package/esm2022/testing/src/testing-utils.mjs +5 -3
- package/fesm2022/nx-angular-testing.mjs +4 -2
- package/fesm2022/nx-angular-testing.mjs.map +1 -1
- package/fesm2022/nx-angular.mjs +8 -3
- package/fesm2022/nx-angular.mjs.map +1 -1
- package/package.json +8 -8
- package/src/executors/module-federation-dev-server/lib/normalize-options.js +4 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +6 -1
- package/src/generators/application/files/nx-welcome/claimed/ng-module/src/app/nx-welcome.component.ts__tpl__ +808 -0
- package/src/generators/application/files/nx-welcome/claimed/standalone/src/app/nx-welcome.component.ts__tpl__ +811 -0
- package/src/generators/application/files/{ng-module → nx-welcome/not-configured/ng-module}/src/app/nx-welcome.component.ts__tpl__ +37 -66
- package/src/generators/application/files/{standalone-components → nx-welcome/not-configured/standalone}/src/app/nx-welcome.component.ts__tpl__ +39 -68
- package/src/generators/application/files/nx-welcome/unclaimed/ng-module/src/app/nx-welcome.component.ts__tpl__ +810 -0
- package/src/generators/application/files/nx-welcome/unclaimed/standalone/src/app/nx-welcome.component.ts__tpl__ +813 -0
- package/src/generators/application/lib/create-files.js +10 -0
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/ng-add/migrators/projects/e2e.migrator.js +1 -1
- package/src/generators/ng-add/migrators/projects/project.migrator.d.ts +2 -0
- package/src/generators/ng-add/migrators/projects/project.migrator.js +38 -1
- package/src/runtime/nx/data-persistence.d.ts +8 -3
- package/testing/src/testing-utils.d.ts +4 -2
@@ -8,6 +8,7 @@ const test_runners_1 = require("../../../utils/test-runners");
|
|
8
8
|
const selector_1 = require("../../utils/selector");
|
9
9
|
const update_project_root_tsconfig_1 = require("../../utils/update-project-root-tsconfig");
|
10
10
|
const version_utils_1 = require("../../utils/version-utils");
|
11
|
+
const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
|
11
12
|
async function createFiles(tree, options, rootOffset) {
|
12
13
|
const { major: angularMajorVersion, version: angularVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
13
14
|
const isUsingApplicationBuilder = angularMajorVersion >= 17 && options.bundler === 'esbuild';
|
@@ -16,6 +17,9 @@ async function createFiles(tree, options, rootOffset) {
|
|
16
17
|
(0, selector_1.validateHtmlSelector)(rootSelector);
|
17
18
|
const nxWelcomeSelector = `${options.prefix}-nx-welcome`;
|
18
19
|
(0, selector_1.validateHtmlSelector)(nxWelcomeSelector);
|
20
|
+
const onBoardingStatus = await (0, onboarding_1.createNxCloudOnboardingURLForWelcomeApp)(tree, options.nxCloudToken);
|
21
|
+
const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
|
22
|
+
(await (0, onboarding_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
|
19
23
|
const substitutions = {
|
20
24
|
rootSelector,
|
21
25
|
appName: options.name,
|
@@ -34,8 +38,13 @@ async function createFiles(tree, options, rootOffset) {
|
|
34
38
|
disableModernClassFieldsBehavior,
|
35
39
|
useEventCoalescing: angularMajorVersion >= 18,
|
36
40
|
useRouterTestingModule: angularMajorVersion < 18,
|
41
|
+
connectCloudUrl,
|
42
|
+
tutorialUrl: options.standalone
|
43
|
+
? 'https://nx.dev/getting-started/tutorials/angular-standalone-tutorial?utm_source=nx-project'
|
44
|
+
: 'https://nx.dev/getting-started/tutorials/angular-monorepo-tutorial?utm_source=nx-project',
|
37
45
|
tpl: '',
|
38
46
|
};
|
47
|
+
const angularAppType = options.standalone ? 'standalone' : 'ng-module';
|
39
48
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/base'), options.appProjectRoot, substitutions);
|
40
49
|
if (angularMajorVersion >= 18) {
|
41
50
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/base-18+'), options.appProjectRoot, substitutions);
|
@@ -49,6 +58,7 @@ async function createFiles(tree, options, rootOffset) {
|
|
49
58
|
else {
|
50
59
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/ng-module'), options.appProjectRoot, substitutions);
|
51
60
|
}
|
61
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/nx-welcome', onBoardingStatus, angularAppType), options.appProjectRoot, substitutions);
|
52
62
|
(0, update_project_root_tsconfig_1.updateProjectRootTsConfig)(tree, options.appProjectRoot, (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot), options.rootProject);
|
53
63
|
if (!options.routing) {
|
54
64
|
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, '/src/app/app.routes.ts'));
|
@@ -254,7 +254,7 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
254
254
|
this.tree.delete(newTsConfigPath);
|
255
255
|
this.moveFile((0, devkit_1.joinPathFragments)(this.project.oldSourceRoot, 'tsconfig.json'), newTsConfigPath);
|
256
256
|
// replace the generated source with the project source
|
257
|
-
|
257
|
+
this.visitFiles(this.project.newSourceRoot, (filePath) => {
|
258
258
|
this.tree.delete(filePath);
|
259
259
|
});
|
260
260
|
this.moveDir(this.project.oldSourceRoot, (0, devkit_1.joinPathFragments)(this.project.newSourceRoot));
|
@@ -18,6 +18,8 @@ export declare class ProjectMigrator<TargetType extends string = string> extends
|
|
18
18
|
protected convertPath(originalPath: string): string;
|
19
19
|
protected moveDir(from: string, to: string): void;
|
20
20
|
protected shouldSkipTargetTypeMigration(targetType: TargetType): boolean;
|
21
|
+
protected visitFiles(dirPath: string, visitor: (path: string) => void): void;
|
22
|
+
private updateGitAndPrettierIgnore;
|
21
23
|
private collectTargetNames;
|
22
24
|
private createBuilderMigrators;
|
23
25
|
private skipProjectMigration;
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ProjectMigrator = void 0;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
+
const node_path_1 = require("node:path");
|
5
6
|
const utilities_1 = require("../../utilities");
|
6
7
|
const migrator_1 = require("../migrator");
|
7
8
|
class ProjectMigrator extends migrator_1.Migrator {
|
@@ -42,6 +43,7 @@ class ProjectMigrator extends migrator_1.Migrator {
|
|
42
43
|
migrate() {
|
43
44
|
const validationResult = this.validate();
|
44
45
|
if (!validationResult) {
|
46
|
+
this.updateGitAndPrettierIgnore();
|
45
47
|
return;
|
46
48
|
}
|
47
49
|
this.logger.warn((0, utilities_1.getProjectValidationResultMessage)(validationResult));
|
@@ -138,7 +140,7 @@ class ProjectMigrator extends migrator_1.Migrator {
|
|
138
140
|
return originalPath;
|
139
141
|
}
|
140
142
|
moveDir(from, to) {
|
141
|
-
|
143
|
+
this.visitFiles(from, (file) => {
|
142
144
|
this.moveFile(file, (0, devkit_1.normalizePath)(file).replace(from, to), true);
|
143
145
|
});
|
144
146
|
}
|
@@ -146,6 +148,41 @@ class ProjectMigrator extends migrator_1.Migrator {
|
|
146
148
|
return (Array.isArray(this.skipMigration) &&
|
147
149
|
this.skipMigration.includes(targetType));
|
148
150
|
}
|
151
|
+
visitFiles(dirPath, visitor) {
|
152
|
+
dirPath = (0, devkit_1.normalizePath)((0, node_path_1.relative)(this.tree.root, (0, devkit_1.joinPathFragments)(this.tree.root, dirPath)));
|
153
|
+
for (const child of this.tree.children(dirPath)) {
|
154
|
+
const fullPath = (0, devkit_1.joinPathFragments)(dirPath, child);
|
155
|
+
if (this.tree.isFile(fullPath)) {
|
156
|
+
visitor(fullPath);
|
157
|
+
}
|
158
|
+
else {
|
159
|
+
this.visitFiles(fullPath, visitor);
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
updateGitAndPrettierIgnore() {
|
164
|
+
if (!this.tree.exists('.prettierignore') &&
|
165
|
+
!this.tree.exists('.gitignore')) {
|
166
|
+
return;
|
167
|
+
}
|
168
|
+
let from = this.project.oldRoot;
|
169
|
+
let to = this.project.newRoot;
|
170
|
+
if (this.project.oldRoot === '') {
|
171
|
+
from = this.project.oldSourceRoot;
|
172
|
+
to = this.project.newSourceRoot;
|
173
|
+
}
|
174
|
+
const regex = new RegExp(`(^!?\\/?)(${from})(\\/|$)`, 'gm');
|
175
|
+
if (this.tree.exists('.gitignore')) {
|
176
|
+
const gitignore = this.tree.read('.gitignore', 'utf-8');
|
177
|
+
const content = gitignore.replace(regex, `$1${to}$3`);
|
178
|
+
this.tree.write('.gitignore', content);
|
179
|
+
}
|
180
|
+
if (this.tree.exists('.prettierignore')) {
|
181
|
+
const prettierIgnore = this.tree.read('.prettierignore', 'utf-8');
|
182
|
+
const content = prettierIgnore.replace(regex, `$1${to}$3`);
|
183
|
+
this.tree.write('.prettierignore', content);
|
184
|
+
}
|
185
|
+
}
|
149
186
|
collectTargetNames() {
|
150
187
|
const targetTypes = Object.keys(this.targets);
|
151
188
|
Object.entries(this.projectConfig.targets ?? {}).forEach(([targetName, target]) => {
|
@@ -24,7 +24,6 @@ export type ActionOrActionWithState<T, A> = ActionOrActionWithStates<[T], A>;
|
|
24
24
|
export type ActionStatesStream<T extends Array<unknown>, A> = Observable<ActionOrActionWithStates<T, A>>;
|
25
25
|
export type ActionStateStream<T, A> = Observable<ActionOrActionWithStates<[T], A>>;
|
26
26
|
/**
|
27
|
-
*
|
28
27
|
* @whatItDoes Handles pessimistic updates (updating the server first).
|
29
28
|
*
|
30
29
|
* Updating the server, when implemented naively, suffers from race conditions and poor error handling.
|
@@ -79,10 +78,11 @@ export type ActionStateStream<T, A> = Observable<ActionOrActionWithStates<[T], A
|
|
79
78
|
* ```
|
80
79
|
*
|
81
80
|
* @param opts
|
81
|
+
*
|
82
|
+
* @deprecated This will be removed in Nx v21. Import `pessimisticUpdate` from `@ngrx/router-store/data-persistence` instead.
|
82
83
|
*/
|
83
84
|
export declare function pessimisticUpdate<T extends Array<unknown>, A extends Action>(opts: PessimisticUpdateOpts<T, A>): (source: ActionStatesStream<T, A>) => Observable<Action>;
|
84
85
|
/**
|
85
|
-
*
|
86
86
|
* @whatItDoes Handles optimistic updates (updating the client first).
|
87
87
|
*
|
88
88
|
* It runs all fetches in order, which removes race conditions and forces the developer to handle errors.
|
@@ -138,10 +138,11 @@ export declare function pessimisticUpdate<T extends Array<unknown>, A extends Ac
|
|
138
138
|
* ```
|
139
139
|
*
|
140
140
|
* @param opts
|
141
|
+
*
|
142
|
+
* @deprecated This will be removed in Nx v21. Import `optimisticUpdate` from `@ngrx/router-store/data-persistence` instead.
|
141
143
|
*/
|
142
144
|
export declare function optimisticUpdate<T extends Array<unknown>, A extends Action>(opts: OptimisticUpdateOpts<T, A>): (source: ActionStatesStream<T, A>) => Observable<Action>;
|
143
145
|
/**
|
144
|
-
*
|
145
146
|
* @whatItDoes Handles data fetching.
|
146
147
|
*
|
147
148
|
* Data fetching implemented naively suffers from race conditions and poor error handling.
|
@@ -217,6 +218,8 @@ export declare function optimisticUpdate<T extends Array<unknown>, A extends Act
|
|
217
218
|
* In addition, if there are multiple requests for Todo 1 scheduled, it will only run the last one.
|
218
219
|
*
|
219
220
|
* @param opts
|
221
|
+
*
|
222
|
+
* @deprecated This will be removed in Nx v21. Import `fetch` from `@ngrx/router-store/data-persistence` instead.
|
220
223
|
*/
|
221
224
|
export declare function fetch<T extends Array<unknown>, A extends Action>(opts: FetchOpts<T, A>): (source: ActionStatesStream<T, A>) => Observable<Action>;
|
222
225
|
/**
|
@@ -267,5 +270,7 @@ export declare function fetch<T extends Array<unknown>, A extends Action>(opts:
|
|
267
270
|
*
|
268
271
|
* @param component
|
269
272
|
* @param opts
|
273
|
+
*
|
274
|
+
* @deprecated This will be removed in Nx v21. Import `navigation` from `@ngrx/router-store/data-persistence` instead.
|
270
275
|
*/
|
271
276
|
export declare function navigation<T extends Array<unknown>, A extends Action>(component: Type<any>, opts: HandleNavigationOpts<T>): (source: ActionStatesStream<T, A>) => Observable<Action<string>>;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { Observable } from 'rxjs';
|
2
2
|
/**
|
3
|
-
* @deprecated This will be removed in
|
3
|
+
* @deprecated This will be removed in Nx v21. If using RxJS 7, use `firstValueFrom(obs$.pipe(toArray()))`
|
4
|
+
* or `lastValueFrom(obs$.pipe(toArray()))`. If using RxJS 6, use `obs$.pipe(toArray()).toPromise()`.
|
4
5
|
*
|
5
6
|
* @whatItDoes reads all the values from an observable and returns a promise
|
6
7
|
* with an array of all values. This should be used in combination with async/await.
|
@@ -15,7 +16,8 @@ import type { Observable } from 'rxjs';
|
|
15
16
|
*/
|
16
17
|
export declare function readAll<T>(o: Observable<T>): Promise<T[]>;
|
17
18
|
/**
|
18
|
-
* @deprecated This will be removed in
|
19
|
+
* @deprecated This will be removed in Nx v21. Since RxJS 7, use `firstValueFrom(obs$)`. If using RxJS 6,
|
20
|
+
* use `obs$.pipe(first()).toPromise()`.
|
19
21
|
*
|
20
22
|
* @whatItDoes reads the first value from an observable and returns a promise
|
21
23
|
* with it. This should be used in combination with async/await.
|