<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> Angular v18.1.0 is not supported. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Angular v18.1.0 should be supported. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
import {
|
|
generateFiles,
|
|
joinPathFragments,
|
|
readProjectConfiguration,
|
|
type Tree,
|
|
} from '@nx/devkit';
|
|
import { addRoute } from '../../../utils/nx-devkit/route-utils';
|
|
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
|
|
import type { Schema } from '../schema';
|
|
|
|
export function updateHostAppRoutes(tree: Tree, options: Schema) {
|
|
const { sourceRoot } = readProjectConfiguration(tree, options.appName);
|
|
|
|
tree.write(
|
|
joinPathFragments(sourceRoot, 'app/app.component.html'),
|
|
`<ul class="remote-menu">
|
|
<li><a routerLink="/">Home</a></li>
|
|
</ul>
|
|
<router-outlet></router-outlet>
|
|
`
|
|
);
|
|
|
|
let pathToHostRootRoutingFile = joinPathFragments(
|
|
sourceRoot,
|
|
'app/app.routes.ts'
|
|
);
|
|
|
|
let hostRootRoutingFile = tree.read(pathToHostRootRoutingFile, 'utf-8');
|
|
|
|
if (!hostRootRoutingFile) {
|
|
pathToHostRootRoutingFile = joinPathFragments(
|
|
sourceRoot,
|
|
'app/app-routing.module.ts'
|
|
);
|
|
hostRootRoutingFile = tree.read(pathToHostRootRoutingFile, 'utf-8');
|
|
}
|
|
|
|
addRoute(
|
|
tree,
|
|
pathToHostRootRoutingFile,
|
|
`{
|
|
path: '',
|
|
component: NxWelcomeComponent
|
|
}`
|
|
);
|
|
|
|
tree.write(
|
|
pathToHostRootRoutingFile,
|
|
`import { NxWelcomeComponent } from './nx-welcome.component';
|
|
${tree.read(pathToHostRootRoutingFile, 'utf-8')}`
|
|
);
|
|
|
|
const { major: angularMajorVersion } = getInstalledAngularVersionInfo(tree);
|
|
generateFiles(
|
|
tree,
|
|
joinPathFragments(__dirname, '../files/host-files'),
|
|
joinPathFragments(sourceRoot, 'app'),
|
|
{
|
|
appName: options.appName,
|
|
standalone: options.standalone,
|
|
useRouterTestingModule: angularMajorVersion < 18,
|
|
tmpl: '',
|
|
}
|
|
);
|
|
}
|