Colum Ferry b076f0380a
fix(angular): ngrx attaching to route and non-standalone apis for 14 (#14489)
Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
2023-01-20 12:50:06 +00:00

66 lines
1.9 KiB
TypeScript

import type { Tree } from '@nrwl/devkit';
import { formatFiles, readProjectConfiguration } from '@nrwl/devkit';
import type { Schema } from './schema';
import {
addCypressOnErrorWorkaround,
addRemoteEntry,
addRemoteToHost,
changeBuildTarget,
fixBootstrap,
generateWebpackConfig,
getRemotesWithPorts,
removeDeadCodeFromRemote,
setupHostIfDynamic,
setupServeTarget,
updateHostAppRoutes,
updateTsConfigTarget,
} from './lib';
import { getInstalledAngularVersionInfo } from '../utils/version-utils';
import { lt } from 'semver';
export async function setupMf(tree: Tree, options: Schema) {
const installedAngularInfo = getInstalledAngularVersionInfo(tree);
if (lt(installedAngularInfo.version, '14.1.0') && options.standalone) {
throw new Error(
`The --standalone flag is not supported in your current version of Angular (${installedAngularInfo.version}). Please update to a version of Angular that supports Standalone Components (>= 14.1.0).`
);
}
const projectConfig = readProjectConfiguration(tree, options.appName);
options.federationType = options.federationType ?? 'static';
if (options.mfType === 'host') {
setupHostIfDynamic(tree, options);
updateHostAppRoutes(tree, options);
}
if (options.mfType === 'remote') {
addRemoteToHost(tree, options);
addRemoteEntry(tree, options, projectConfig.root);
removeDeadCodeFromRemote(tree, options);
}
const remotesWithPorts = getRemotesWithPorts(tree, options);
generateWebpackConfig(tree, options, projectConfig.root, remotesWithPorts);
changeBuildTarget(tree, options);
updateTsConfigTarget(tree, options);
setupServeTarget(tree, options);
fixBootstrap(tree, projectConfig.root, options);
if (!options.skipE2E) {
addCypressOnErrorWorkaround(tree, options);
}
// format files
if (!options.skipFormat) {
await formatFiles(tree);
}
}
export default setupMf;