@nx/angular 18.0.0-beta.0 → 18.0.0-beta.2
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/executors.d.ts +1 -1
- package/generators.d.ts +1 -1
- package/generators.js +3 -1
- package/generators.json +7 -2
- package/migrations.json +6 -0
- package/package.json +11 -11
- package/plugins/component-testing.d.ts +1 -26
- package/plugins/component-testing.js +11 -1
- package/src/builders/dev-server/dev-server.impl.js +1 -1
- package/src/builders/dev-server/schema.json +1 -1
- package/src/executors/module-federation-dev-server/schema.json +1 -1
- package/src/executors/ng-packagr-lite/schema.json +1 -1
- package/src/executors/package/schema.json +1 -1
- package/src/generators/add-linting/add-linting.js +1 -0
- package/src/generators/add-linting/schema.d.ts +1 -0
- package/src/generators/add-linting/schema.json +1 -1
- package/src/generators/application/application.js +3 -0
- package/src/generators/application/files/ng-module/src/app/nx-welcome.component.ts__tpl__ +19 -0
- package/src/generators/application/files/standalone-components/src/app/nx-welcome.component.ts__tpl__ +19 -0
- package/src/generators/application/lib/add-e2e.js +2 -0
- package/src/generators/application/lib/add-linting.js +1 -0
- package/src/generators/application/lib/add-unit-test-runner.js +1 -0
- package/src/generators/application/lib/normalize-options.js +1 -0
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +4 -4
- package/src/generators/component/schema.d.ts +3 -3
- package/src/generators/component/schema.json +2 -2
- package/src/generators/component-cypress-spec/schema.json +1 -1
- package/src/generators/component-test/schema.json +1 -1
- package/src/generators/convert-to-application-executor/convert-to-application-executor.d.ts +4 -0
- package/src/generators/convert-to-application-executor/convert-to-application-executor.js +240 -0
- package/src/generators/convert-to-application-executor/schema.d.ts +4 -0
- package/src/generators/convert-to-application-executor/schema.json +26 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +2 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +30 -14
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- package/src/generators/directive/schema.d.ts +3 -3
- package/src/generators/directive/schema.json +2 -2
- package/src/generators/federate-module/schema.json +1 -1
- package/src/generators/host/host.js +2 -0
- package/src/generators/host/schema.json +4 -4
- package/src/generators/init/schema.json +1 -1
- package/src/generators/library/lib/add-project.js +6 -3
- package/src/generators/library/library.js +2 -0
- package/src/generators/library/schema.json +1 -1
- package/src/generators/library-secondary-entry-point/schema.json +1 -1
- package/src/generators/move/schema.json +1 -1
- package/src/generators/ng-add/migrators/projects/e2e.migrator.js +1 -0
- package/src/generators/ng-add/schema.json +1 -1
- package/src/generators/ng-add/utilities/workspace.js +3 -1
- package/src/generators/ngrx/schema.json +1 -1
- package/src/generators/ngrx-feature-store/schema.json +1 -1
- package/src/generators/ngrx-root-store/schema.json +1 -1
- package/src/generators/pipe/schema.d.ts +3 -3
- package/src/generators/pipe/schema.json +2 -2
- package/src/generators/remote/remote.js +2 -0
- package/src/generators/remote/schema.json +4 -4
- package/src/generators/scam/schema.d.ts +3 -3
- package/src/generators/scam/schema.json +2 -2
- package/src/generators/scam-directive/schema.d.ts +3 -3
- package/src/generators/scam-directive/schema.json +2 -2
- package/src/generators/scam-pipe/schema.d.ts +3 -3
- package/src/generators/scam-pipe/schema.json +2 -2
- package/src/generators/scam-to-standalone/schema.json +1 -1
- package/src/generators/setup-mf/schema.json +1 -1
- package/src/generators/setup-ssr/lib/add-hydration.js +11 -5
- package/src/generators/setup-ssr/lib/update-project-config.js +3 -1
- package/src/generators/setup-ssr/schema.json +1 -1
- package/src/generators/setup-ssr/setup-ssr.js +2 -1
- package/src/generators/setup-tailwind/schema.json +1 -1
- package/src/generators/stories/schema.json +1 -1
- package/src/generators/storybook-configuration/schema.json +4 -4
- package/src/generators/storybook-configuration/storybook-configuration.js +1 -1
- package/src/generators/utils/add-jest.d.ts +1 -0
- package/src/generators/utils/add-jest.js +1 -0
- package/src/generators/utils/add-mf-env-to-inputs.d.ts +2 -0
- package/src/generators/utils/add-mf-env-to-inputs.js +24 -0
- package/src/migrations/update-17-1-0/replace-nguniversal-engines.js +2 -14
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +2 -0
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +26 -0
- package/src/utils/targets.d.ts +2 -0
- package/src/utils/targets.js +17 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToApplicationExecutor = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const posix_1 = require("node:path/posix");
|
|
6
|
+
const semver_1 = require("semver");
|
|
7
|
+
const targets_1 = require("../../utils/targets");
|
|
8
|
+
const setup_ssr_1 = require("../setup-ssr/setup-ssr");
|
|
9
|
+
const validations_1 = require("../utils/validations");
|
|
10
|
+
const version_utils_1 = require("../utils/version-utils");
|
|
11
|
+
const executorsToConvert = new Set([
|
|
12
|
+
'@angular-devkit/build-angular:browser',
|
|
13
|
+
'@angular-devkit/build-angular:browser-esbuild',
|
|
14
|
+
'@nx/angular:webpack-browser',
|
|
15
|
+
'@nx/angular:browser-esbuild',
|
|
16
|
+
]);
|
|
17
|
+
const serverTargetExecutors = new Set([
|
|
18
|
+
'@angular-devkit/build-angular:server',
|
|
19
|
+
'@nx/angular:webpack-server',
|
|
20
|
+
]);
|
|
21
|
+
const redundantExecutors = new Set([
|
|
22
|
+
'@angular-devkit/build-angular:server',
|
|
23
|
+
'@angular-devkit/build-angular:prerender',
|
|
24
|
+
'@angular-devkit/build-angular:app-shell',
|
|
25
|
+
'@angular-devkit/build-angular:ssr-dev-server',
|
|
26
|
+
'@nx/angular:webpack-server',
|
|
27
|
+
]);
|
|
28
|
+
async function convertToApplicationExecutor(tree, options) {
|
|
29
|
+
const { major: angularMajorVersion, version: angularVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
30
|
+
if (angularMajorVersion < 17) {
|
|
31
|
+
throw new Error(`The "convert-to-application-executor" generator is only supported in Angular >= 17.0.0. You are currently using "${angularVersion}".`);
|
|
32
|
+
}
|
|
33
|
+
let didAnySucceed = false;
|
|
34
|
+
if (options.project) {
|
|
35
|
+
(0, validations_1.validateProject)(tree, options.project);
|
|
36
|
+
didAnySucceed = await convertProjectTargets(tree, options.project, angularVersion, true);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
40
|
+
for (const [projectName] of projects) {
|
|
41
|
+
devkit_1.logger.info(`Converting project "${projectName}"...`);
|
|
42
|
+
const success = await convertProjectTargets(tree, projectName, angularVersion);
|
|
43
|
+
if (success) {
|
|
44
|
+
devkit_1.logger.info(`Project "${projectName}" converted successfully.`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
devkit_1.logger.info(`Project "${projectName}" could not be converted. See above for more information.`);
|
|
48
|
+
}
|
|
49
|
+
devkit_1.logger.info('');
|
|
50
|
+
didAnySucceed = didAnySucceed || success;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!options.skipFormat) {
|
|
54
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
55
|
+
}
|
|
56
|
+
return didAnySucceed ? () => (0, devkit_1.installPackagesTask)(tree) : () => { };
|
|
57
|
+
}
|
|
58
|
+
exports.convertToApplicationExecutor = convertToApplicationExecutor;
|
|
59
|
+
async function convertProjectTargets(tree, projectName, angularVersion, isProvidedProject = false) {
|
|
60
|
+
function warnIfProvided(message) {
|
|
61
|
+
if (isProvidedProject) {
|
|
62
|
+
devkit_1.logger.warn(message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
66
|
+
if (project.projectType !== 'application') {
|
|
67
|
+
warnIfProvided(`The provided project "${projectName}" is not an application. Skipping conversion.`);
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const { buildTargetName, serverTargetName } = getTargetsToConvert(project.targets);
|
|
71
|
+
if (!buildTargetName) {
|
|
72
|
+
warnIfProvided(`The provided project "${projectName}" does not have any targets using on of the ` +
|
|
73
|
+
`'@angular-devkit/build-angular:browser', '@angular-devkit/build-angular:browser-esbuild', ` +
|
|
74
|
+
`'@nx/angular:browser' and '@nx/angular:browser-esbuild' executors. Skipping conversion.`);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const useNxExecutor = project.targets[buildTargetName].executor.startsWith('@nx/angular:');
|
|
78
|
+
const newExecutor = useNxExecutor
|
|
79
|
+
? '@nx/angular:application'
|
|
80
|
+
: '@angular-devkit/build-angular:application';
|
|
81
|
+
const buildTarget = project.targets[buildTargetName];
|
|
82
|
+
buildTarget.executor = newExecutor;
|
|
83
|
+
if ((0, semver_1.gte)(angularVersion, '17.1.0') && buildTarget.outputs) {
|
|
84
|
+
buildTarget.outputs = buildTarget.outputs.map((output) => output === '{options.outputPath}' ? '{options.outputPath.base}' : output);
|
|
85
|
+
}
|
|
86
|
+
for (const [, options] of (0, targets_1.allTargetOptions)(buildTarget)) {
|
|
87
|
+
if (options['index'] === '') {
|
|
88
|
+
options['index'] = false;
|
|
89
|
+
}
|
|
90
|
+
// Rename and transform options
|
|
91
|
+
options['browser'] = options['main'];
|
|
92
|
+
if (serverTargetName && typeof options['browser'] === 'string') {
|
|
93
|
+
options['server'] = (0, posix_1.dirname)(options['browser']) + '/main.server.ts';
|
|
94
|
+
}
|
|
95
|
+
options['serviceWorker'] =
|
|
96
|
+
options['ngswConfigPath'] ?? options['serviceWorker'];
|
|
97
|
+
if (typeof options['polyfills'] === 'string') {
|
|
98
|
+
options['polyfills'] = [options['polyfills']];
|
|
99
|
+
}
|
|
100
|
+
let outputPath = options['outputPath'];
|
|
101
|
+
if ((0, semver_1.lt)(angularVersion, '17.1.0')) {
|
|
102
|
+
options['outputPath'] = outputPath?.replace(/\/browser\/?$/, '');
|
|
103
|
+
}
|
|
104
|
+
else if (typeof outputPath === 'string') {
|
|
105
|
+
if (!/\/browser\/?$/.test(outputPath)) {
|
|
106
|
+
devkit_1.logger.warn(`The output location of the browser build has been updated from "${outputPath}" to ` +
|
|
107
|
+
`"${(0, posix_1.join)(outputPath, 'browser')}". ` +
|
|
108
|
+
'You might need to adjust your deployment pipeline or, as an alternative, ' +
|
|
109
|
+
'set outputPath.browser to "" in order to maintain the previous functionality.');
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
outputPath = outputPath.replace(/\/browser\/?$/, '');
|
|
113
|
+
}
|
|
114
|
+
options['outputPath'] = {
|
|
115
|
+
base: outputPath,
|
|
116
|
+
};
|
|
117
|
+
if (typeof options['resourcesOutputPath'] === 'string') {
|
|
118
|
+
const media = options['resourcesOutputPath'].replaceAll('/', '');
|
|
119
|
+
if (media && media !== 'media') {
|
|
120
|
+
options['outputPath'] = {
|
|
121
|
+
base: outputPath,
|
|
122
|
+
media: media,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Delete removed options
|
|
128
|
+
delete options['deployUrl'];
|
|
129
|
+
delete options['vendorChunk'];
|
|
130
|
+
delete options['commonChunk'];
|
|
131
|
+
delete options['resourcesOutputPath'];
|
|
132
|
+
delete options['buildOptimizer'];
|
|
133
|
+
delete options['main'];
|
|
134
|
+
delete options['ngswConfigPath'];
|
|
135
|
+
}
|
|
136
|
+
// Merge browser and server tsconfig
|
|
137
|
+
if (serverTargetName) {
|
|
138
|
+
const browserTsConfigPath = buildTarget?.options?.tsConfig;
|
|
139
|
+
const serverTsConfigPath = project.targets['server']?.options?.tsConfig;
|
|
140
|
+
if (typeof browserTsConfigPath !== 'string') {
|
|
141
|
+
devkit_1.logger.warn(`Cannot update project "${projectName}" to use the application executor ` +
|
|
142
|
+
`as the browser tsconfig cannot be located.`);
|
|
143
|
+
}
|
|
144
|
+
if (typeof serverTsConfigPath !== 'string') {
|
|
145
|
+
devkit_1.logger.warn(`Cannot update project "${projectName}" to use the application executor ` +
|
|
146
|
+
`as the server tsconfig cannot be located.`);
|
|
147
|
+
}
|
|
148
|
+
const browserTsConfigJson = (0, devkit_1.readJson)(tree, browserTsConfigPath);
|
|
149
|
+
const serverTsConfigJson = (0, devkit_1.readJson)(tree, serverTsConfigPath);
|
|
150
|
+
const files = new Set([
|
|
151
|
+
...(browserTsConfigJson.files ?? []),
|
|
152
|
+
...(serverTsConfigJson.files ?? []),
|
|
153
|
+
]);
|
|
154
|
+
// Server file will be added later by the setup-ssr generator
|
|
155
|
+
files.delete('server.ts');
|
|
156
|
+
browserTsConfigJson.files = Array.from(files);
|
|
157
|
+
browserTsConfigJson.compilerOptions ?? {};
|
|
158
|
+
browserTsConfigJson.compilerOptions.types = Array.from(new Set([
|
|
159
|
+
...(browserTsConfigJson.compilerOptions.types ?? []),
|
|
160
|
+
...(serverTsConfigJson.compilerOptions?.types ?? []),
|
|
161
|
+
]));
|
|
162
|
+
// Delete server tsconfig
|
|
163
|
+
tree.delete(serverTsConfigPath);
|
|
164
|
+
}
|
|
165
|
+
// Update project main tsconfig
|
|
166
|
+
const projectRootTsConfigPath = (0, posix_1.join)(project.root, 'tsconfig.json');
|
|
167
|
+
if (tree.exists(projectRootTsConfigPath)) {
|
|
168
|
+
const rootTsConfigJson = (0, devkit_1.readJson)(tree, projectRootTsConfigPath);
|
|
169
|
+
rootTsConfigJson.compilerOptions ?? {};
|
|
170
|
+
rootTsConfigJson.compilerOptions.esModuleInterop = true;
|
|
171
|
+
rootTsConfigJson.compilerOptions.downlevelIteration = undefined;
|
|
172
|
+
rootTsConfigJson.compilerOptions.allowSyntheticDefaultImports = undefined;
|
|
173
|
+
(0, devkit_1.writeJson)(tree, projectRootTsConfigPath, rootTsConfigJson);
|
|
174
|
+
}
|
|
175
|
+
// Update server file
|
|
176
|
+
const ssrMainFile = project.targets['server']?.options?.['main'];
|
|
177
|
+
if (typeof ssrMainFile === 'string') {
|
|
178
|
+
tree.delete(ssrMainFile);
|
|
179
|
+
// apply changes so the setup-ssr generator can access the updated project
|
|
180
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
181
|
+
await (0, setup_ssr_1.setupSsr)(tree, { project: projectName, skipFormat: true });
|
|
182
|
+
// re-read project configuration as it might have changed
|
|
183
|
+
project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
184
|
+
}
|
|
185
|
+
// Delete all redundant targets
|
|
186
|
+
for (const [targetName, target] of Object.entries(project.targets)) {
|
|
187
|
+
if (redundantExecutors.has(target.executor)) {
|
|
188
|
+
delete project.targets[targetName];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
function getTargetsToConvert(targets) {
|
|
195
|
+
let buildTargetName;
|
|
196
|
+
let serverTargetName;
|
|
197
|
+
for (const target of Object.keys(targets)) {
|
|
198
|
+
if (targets[target].executor === '@nx/angular:application' ||
|
|
199
|
+
targets[target].executor === '@angular-devkit/build-angular:application') {
|
|
200
|
+
devkit_1.logger.warn('The project is already using the application builder. Skipping conversion.');
|
|
201
|
+
return {};
|
|
202
|
+
}
|
|
203
|
+
// build target
|
|
204
|
+
if (executorsToConvert.has(targets[target].executor)) {
|
|
205
|
+
for (const [, options] of (0, targets_1.allTargetOptions)(targets[target])) {
|
|
206
|
+
if (options.deployUrl) {
|
|
207
|
+
devkit_1.logger.warn(`The project is using the "deployUrl" option which is not available in the application builder. Skipping conversion.`);
|
|
208
|
+
return {};
|
|
209
|
+
}
|
|
210
|
+
if (options.customWebpackConfig) {
|
|
211
|
+
devkit_1.logger.warn(`The project is using a custom webpack configuration which is not supported by the esbuild-based application executor. Skipping conversion.`);
|
|
212
|
+
return {};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (buildTargetName) {
|
|
216
|
+
devkit_1.logger.warn('The project has more than one build target. Skipping conversion.');
|
|
217
|
+
return {};
|
|
218
|
+
}
|
|
219
|
+
buildTargetName = target;
|
|
220
|
+
}
|
|
221
|
+
// server target
|
|
222
|
+
if (serverTargetExecutors.has(targets[target].executor)) {
|
|
223
|
+
if (targets[target].executor === '@nx/angular:webpack-server') {
|
|
224
|
+
for (const [, options] of (0, targets_1.allTargetOptions)(targets[target])) {
|
|
225
|
+
if (options.customWebpackConfig) {
|
|
226
|
+
devkit_1.logger.warn(`The project is using a custom webpack configuration which is not supported by the esbuild-based application executor. Skipping conversion.`);
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (serverTargetName) {
|
|
232
|
+
devkit_1.logger.warn('The project has more than one server target. Skipping conversion.');
|
|
233
|
+
return {};
|
|
234
|
+
}
|
|
235
|
+
serverTargetName = target;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return { buildTargetName, serverTargetName };
|
|
239
|
+
}
|
|
240
|
+
exports.default = convertToApplicationExecutor;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NxAngularConvertToApplicationExecutorGenerator",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"title": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. _Note: this is only supported in Angular versions >= 17.0.0_.",
|
|
6
|
+
"description": "Converts a project or all projects using one of the `@angular-devkit/build-angular:browser`, `@angular-devkit/build-angular:browser-esbuild`, `@nx/angular:browser` and `@nx/angular:browser-esbuild` executors to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder. If the converted target is using one of the `@nx/angular` executors, the `@nx/angular:application` executor will be used. Otherwise, the `@angular-devkit/build-angular:application` builder will be used.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Name of the Angular application project to convert. It has to contain a target using one of the `@angular-devkit/build-angular:browser`, `@angular-devkit/build-angular:browser-esbuild`, `@nx/angular:browser` and `@nx/angular:browser-esbuild` executors. If not specified, all projects with such targets will be converted.",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-priority": "important"
|
|
17
|
+
},
|
|
18
|
+
"skipFormat": {
|
|
19
|
+
"description": "Skip formatting files.",
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"default": false,
|
|
22
|
+
"x-priority": "internal"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"additionalProperties": false
|
|
26
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { CypressComponentConfigSchema } from './schema';
|
|
3
|
+
export declare function cypressComponentConfiguration(tree: Tree, options: CypressComponentConfigSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
3
4
|
/**
|
|
4
5
|
* This is for cypress built in component testing, if you want to test with
|
|
5
6
|
* storybook + cypress then use the componentCypressGenerator instead.
|
|
6
7
|
*/
|
|
7
|
-
export declare function
|
|
8
|
+
export declare function cypressComponentConfigurationInternal(tree: Tree, options: CypressComponentConfigSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
8
9
|
export default cypressComponentConfiguration;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cypressComponentConfiguration = void 0;
|
|
3
|
+
exports.cypressComponentConfigurationInternal = exports.cypressComponentConfiguration = void 0;
|
|
4
4
|
const cypress_1 = require("@nx/cypress");
|
|
5
5
|
const config_1 = require("@nx/cypress/src/utils/config");
|
|
6
6
|
const find_target_options_1 = require("@nx/cypress/src/utils/find-target-options");
|
|
@@ -10,28 +10,34 @@ const component_test_1 = require("../component-test/component-test");
|
|
|
10
10
|
const component_info_1 = require("../utils/storybook-ast/component-info");
|
|
11
11
|
const entry_point_1 = require("../utils/storybook-ast/entry-point");
|
|
12
12
|
const module_info_1 = require("../utils/storybook-ast/module-info");
|
|
13
|
+
function cypressComponentConfiguration(tree, options) {
|
|
14
|
+
return cypressComponentConfigurationInternal(tree, {
|
|
15
|
+
addPlugin: false,
|
|
16
|
+
...options,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.cypressComponentConfiguration = cypressComponentConfiguration;
|
|
13
20
|
/**
|
|
14
21
|
* This is for cypress built in component testing, if you want to test with
|
|
15
22
|
* storybook + cypress then use the componentCypressGenerator instead.
|
|
16
23
|
*/
|
|
17
|
-
async function
|
|
24
|
+
async function cypressComponentConfigurationInternal(tree, options) {
|
|
25
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
18
26
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
19
27
|
const installTask = await (0, cypress_1.componentConfigurationGenerator)(tree, {
|
|
20
28
|
project: options.project,
|
|
21
29
|
skipFormat: true,
|
|
30
|
+
addPlugin: options.addPlugin,
|
|
22
31
|
});
|
|
23
|
-
await
|
|
32
|
+
await configureCypressCT(tree, options);
|
|
24
33
|
await addFiles(tree, projectConfig, options);
|
|
25
34
|
if (!options.skipFormat) {
|
|
26
35
|
await (0, devkit_1.formatFiles)(tree);
|
|
27
36
|
}
|
|
28
37
|
return installTask;
|
|
29
38
|
}
|
|
30
|
-
exports.
|
|
39
|
+
exports.cypressComponentConfigurationInternal = cypressComponentConfigurationInternal;
|
|
31
40
|
async function addFiles(tree, projectConfig, options) {
|
|
32
|
-
const cyConfigFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
|
|
33
|
-
const updatedCyConfig = await (0, config_1.addDefaultCTConfig)(tree.read(cyConfigFile, 'utf-8'));
|
|
34
|
-
tree.write(cyConfigFile, `import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';\n${updatedCyConfig}`);
|
|
35
41
|
const componentFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
|
|
36
42
|
const updatedCmpContents = await (0, config_1.addMountDefinition)(tree.read(componentFile, 'utf-8'));
|
|
37
43
|
tree.write(componentFile, `import { mount } from 'cypress/angular';\n${updatedCmpContents}`);
|
|
@@ -57,7 +63,7 @@ async function addFiles(tree, projectConfig, options) {
|
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
|
-
async function
|
|
66
|
+
async function configureCypressCT(tree, options) {
|
|
61
67
|
let found = { target: options.buildTarget, config: undefined };
|
|
62
68
|
if (!options.buildTarget) {
|
|
63
69
|
found = await (0, find_target_options_1.findBuildConfig)(tree, {
|
|
@@ -71,13 +77,23 @@ async function updateProjectConfig(tree, options) {
|
|
|
71
77
|
});
|
|
72
78
|
assertValidConfig(found?.config);
|
|
73
79
|
}
|
|
80
|
+
const ctConfigOptions = {};
|
|
74
81
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
75
|
-
projectConfig.targets['component-test']
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
if (projectConfig.targets?.['component-test']?.executor ===
|
|
83
|
+
'@nx/cypress:cypress') {
|
|
84
|
+
projectConfig.targets['component-test'].options = {
|
|
85
|
+
...projectConfig.targets['component-test'].options,
|
|
86
|
+
skipServe: true,
|
|
87
|
+
devServerTarget: found.target,
|
|
88
|
+
};
|
|
89
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
ctConfigOptions.buildTarget = found.target;
|
|
93
|
+
}
|
|
94
|
+
const cypressConfigPath = (0, config_1.getProjectCypressConfigPath)(tree, projectConfig.root);
|
|
95
|
+
const updatedCyConfig = await (0, config_1.addDefaultCTConfig)(tree.read(cypressConfigPath, 'utf-8'), ctConfigOptions);
|
|
96
|
+
tree.write(cypressConfigPath, `import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';\n${updatedCyConfig}`);
|
|
81
97
|
}
|
|
82
98
|
function assertValidConfig(config) {
|
|
83
99
|
if (!config) {
|
|
@@ -13,15 +13,15 @@ export interface Schema {
|
|
|
13
13
|
export?: boolean;
|
|
14
14
|
skipFormat?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
16
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
|
|
17
17
|
*/
|
|
18
18
|
flat?: boolean;
|
|
19
19
|
/**
|
|
20
|
-
* @deprecated Provide the `directory` option instead. It will be removed in Nx
|
|
20
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v19.
|
|
21
21
|
*/
|
|
22
22
|
path?: string;
|
|
23
23
|
/**
|
|
24
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
24
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
25
25
|
*/
|
|
26
26
|
project?: string;
|
|
27
27
|
}
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"$source": "projectName"
|
|
35
35
|
},
|
|
36
36
|
"x-dropdown": "projects",
|
|
37
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
37
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
38
38
|
},
|
|
39
39
|
"prefix": {
|
|
40
40
|
"type": "string",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"type": "boolean",
|
|
75
75
|
"description": "When true (the default), creates the new files at the top level of the current project.",
|
|
76
76
|
"default": true,
|
|
77
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
77
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
78
78
|
},
|
|
79
79
|
"module": {
|
|
80
80
|
"type": "string",
|
|
@@ -8,6 +8,7 @@ const application_1 = require("../application/application");
|
|
|
8
8
|
const remote_1 = require("../remote/remote");
|
|
9
9
|
const setup_mf_1 = require("../setup-mf/setup-mf");
|
|
10
10
|
const lib_1 = require("./lib");
|
|
11
|
+
const add_mf_env_to_inputs_1 = require("../utils/add-mf-env-to-inputs");
|
|
11
12
|
async function host(tree, options) {
|
|
12
13
|
return await hostInternal(tree, {
|
|
13
14
|
projectNameAndRootFormat: 'derived',
|
|
@@ -90,6 +91,7 @@ async function hostInternal(tree, schema) {
|
|
|
90
91
|
typescriptConfiguration,
|
|
91
92
|
});
|
|
92
93
|
}
|
|
94
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
|
|
93
95
|
if (!options.skipFormat) {
|
|
94
96
|
await (0, devkit_1.formatFiles)(tree);
|
|
95
97
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxMFHost",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"title": "Nx Module Federation Host Application",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
"value": "scss",
|
|
58
|
-
"label": "SASS(.scss) [
|
|
58
|
+
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
"value": "sass",
|
|
62
|
-
"label": "SASS(.sass) [
|
|
62
|
+
"label": "SASS(.sass) [ https://sass-lang.com ]"
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"value": "less",
|
|
66
|
-
"label": "LESS [
|
|
66
|
+
"label": "LESS [ https://lesscss.org ]"
|
|
67
67
|
}
|
|
68
68
|
]
|
|
69
69
|
}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addProject = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
|
|
5
6
|
function addProject(tree, libraryOptions) {
|
|
7
|
+
const executor = libraryOptions.publishable
|
|
8
|
+
? '@nx/angular:package'
|
|
9
|
+
: '@nx/angular:ng-packagr-lite';
|
|
10
|
+
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, executor);
|
|
6
11
|
const project = {
|
|
7
12
|
name: libraryOptions.name,
|
|
8
13
|
root: libraryOptions.projectRoot,
|
|
@@ -13,9 +18,7 @@ function addProject(tree, libraryOptions) {
|
|
|
13
18
|
targets: {
|
|
14
19
|
build: libraryOptions.buildable || libraryOptions.publishable
|
|
15
20
|
? {
|
|
16
|
-
executor
|
|
17
|
-
? '@nx/angular:package'
|
|
18
|
-
: '@nx/angular:ng-packagr-lite',
|
|
21
|
+
executor,
|
|
19
22
|
outputs: ['{workspaceRoot}/dist/{projectRoot}'],
|
|
20
23
|
options: {
|
|
21
24
|
project: `${libraryOptions.projectRoot}/ng-package.json`,
|
|
@@ -20,6 +20,7 @@ const add_project_1 = require("./lib/add-project");
|
|
|
20
20
|
const add_jest_1 = require("../utils/add-jest");
|
|
21
21
|
const set_generator_defaults_1 = require("./lib/set-generator-defaults");
|
|
22
22
|
const ensure_angular_dependencies_1 = require("../utils/ensure-angular-dependencies");
|
|
23
|
+
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
23
24
|
async function libraryGenerator(tree, schema) {
|
|
24
25
|
return await libraryGeneratorInternal(tree, {
|
|
25
26
|
// provide a default projectNameAndRootFormat to avoid breaking changes
|
|
@@ -80,6 +81,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
80
81
|
}
|
|
81
82
|
return () => {
|
|
82
83
|
(0, devkit_1.installPackagesTask)(tree);
|
|
84
|
+
(0, log_show_project_command_1.logShowProjectCommand)(libraryOptions.name);
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
87
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "NxAngularLibrarySecondaryEntryPoint",
|
|
4
4
|
"title": "Creates a secondary entry point for a library",
|
|
5
5
|
"description": "Creates a secondary entry point for an Angular publishable library.",
|
|
@@ -242,6 +242,7 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
|
242
242
|
// any target would do, we replace it later with the target existing in the project being migrated
|
|
243
243
|
devServerTarget: `${this.appName}:serve`,
|
|
244
244
|
baseUrl: 'http://localhost:4200',
|
|
245
|
+
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
|
245
246
|
});
|
|
246
247
|
const cypressConfigFilePath = this.updateOrCreateCypressConfigFile(oldCypressConfigFilePath);
|
|
247
248
|
this.updateCypressProjectConfiguration(cypressConfigFilePath);
|
|
@@ -150,7 +150,9 @@ function updatePackageJson(tree) {
|
|
|
150
150
|
}
|
|
151
151
|
exports.updatePackageJson = updatePackageJson;
|
|
152
152
|
async function updateRootEsLintConfig(tree, existingEsLintConfig, unitTestRunner) {
|
|
153
|
-
await (0, eslint_1.lintInitGenerator)(tree, {
|
|
153
|
+
await (0, eslint_1.lintInitGenerator)(tree, {
|
|
154
|
+
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
|
155
|
+
});
|
|
154
156
|
if (!existingEsLintConfig) {
|
|
155
157
|
// There was no eslint config in the root, so we set it up and use it as-is
|
|
156
158
|
(0, setup_root_eslint_1.setupRootEsLint)(tree, { unitTestRunner });
|
|
@@ -11,15 +11,15 @@ export interface Schema {
|
|
|
11
11
|
export?: boolean;
|
|
12
12
|
skipFormat?: boolean;
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
14
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
|
|
15
15
|
*/
|
|
16
16
|
flat?: boolean;
|
|
17
17
|
/**
|
|
18
|
-
* @deprecated Provide the `directory` option instead. It will be removed in Nx
|
|
18
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v19.
|
|
19
19
|
*/
|
|
20
20
|
path?: string;
|
|
21
21
|
/**
|
|
22
|
-
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx
|
|
22
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
23
23
|
*/
|
|
24
24
|
project?: string;
|
|
25
25
|
}
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"$source": "projectName"
|
|
35
35
|
},
|
|
36
36
|
"x-dropdown": "projects",
|
|
37
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
37
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
38
38
|
},
|
|
39
39
|
"flat": {
|
|
40
40
|
"type": "boolean",
|
|
41
41
|
"default": true,
|
|
42
42
|
"description": "When true (the default) creates files at the top level of the project.",
|
|
43
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
43
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
44
44
|
},
|
|
45
45
|
"skipTests": {
|
|
46
46
|
"type": "boolean",
|