Leosvel Pérez Espinosa 3ec539065d
feat(angular): add support for angular v19 (#28847)
## Third-party deps support for Angular v19

- [x] `jest-preset-angular`
  - [x] PRs:
    - [x] https://github.com/thymikee/jest-preset-angular/pull/2835
  - [x] Released:
- [x] RC:
https://github.com/thymikee/jest-preset-angular/releases/tag/v14.4.0-rc.0
- [x] Stable:
https://github.com/thymikee/jest-preset-angular/releases/tag/v14.4.0
- [x] Angular ESLint
  - [x] PRs:
    - [x] https://github.com/angular-eslint/angular-eslint/pull/2109
  - [x] Released:
- [x]
https://github.com/angular-eslint/angular-eslint/releases/tag/v19.0.0
- [x] Storybook
  - [x] PRs:
    - [x] https://github.com/storybookjs/storybook/pull/29659
    - [x] https://github.com/storybookjs/storybook/pull/29677
  - [x] Released:
    - [x] https://github.com/storybookjs/storybook/pull/29679
- [ ] NgRx
  - [x] PRs:
    - [x] https://github.com/ngrx/platform/pull/4602
  - [ ] Released:
- [x] Beta:
https://github.com/ngrx/platform/blob/main/CHANGELOG.md#1900-beta0-2024-11-20
    - [ ] Stable:
- [ ] Analog
  - [x] PRs:
    - [x] https://github.com/analogjs/analog/pull/1447
    - [x] https://github.com/analogjs/analog/pull/1451
  - [ ] Released:
- [x] Beta:
https://github.com/analogjs/analog/releases/tag/v1.10.0-beta.6
    - [ ] Stable:

<!-- 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` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

Angular v19 is not supported.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

Angular v19 should be supported.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->
 
Fixes #29028
2024-12-02 11:43:24 -05:00

116 lines
2.9 KiB
TypeScript

import {
formatFiles,
GeneratorCallback,
installPackagesTask,
offsetFromRoot,
readNxJson,
Tree,
updateNxJson,
} from '@nx/devkit';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';
import { initGenerator as jsInitGenerator } from '@nx/js';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
import { angularInitGenerator } from '../init/init';
import { setupSsr } from '../setup-ssr/setup-ssr';
import { setupTailwindGenerator } from '../setup-tailwind/setup-tailwind';
import { ensureAngularDependencies } from '../utils/ensure-angular-dependencies';
import {
addE2e,
addLinting,
addProxyConfig,
addServeStaticTarget,
addUnitTestRunner,
createFiles,
createProject,
enableStrictTypeChecking,
normalizeOptions,
setApplicationStrictDefault,
setGeneratorDefaults,
updateEditorTsConfig,
} from './lib';
import type { Schema } from './schema';
export async function applicationGenerator(
tree: Tree,
schema: Partial<Schema>
): Promise<GeneratorCallback> {
assertNotUsingTsSolutionSetup(tree, 'angular', 'application');
const options = await normalizeOptions(tree, schema);
const rootOffset = offsetFromRoot(options.appProjectRoot);
await jsInitGenerator(tree, {
...options,
tsConfigName: options.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
js: false,
skipFormat: true,
});
await angularInitGenerator(tree, {
...options,
skipFormat: true,
});
if (!options.skipPackageJson) {
ensureAngularDependencies(tree);
}
createProject(tree, options);
await createFiles(tree, options, rootOffset);
if (options.addTailwind) {
await setupTailwindGenerator(tree, {
project: options.name,
skipFormat: true,
skipPackageJson: options.skipPackageJson,
});
}
await addLinting(tree, options);
await addUnitTestRunner(tree, options);
const e2ePort = await addE2e(tree, options);
addServeStaticTarget(
tree,
options,
options.e2eTestRunner !== 'none' ? e2ePort : options.port
);
updateEditorTsConfig(tree, options);
setGeneratorDefaults(tree, options);
if (options.rootProject) {
const nxJson = readNxJson(tree);
nxJson.defaultProject = options.name;
updateNxJson(tree, nxJson);
}
if (options.backendProject) {
addProxyConfig(tree, options);
}
if (options.strict) {
enableStrictTypeChecking(tree, options);
} else {
setApplicationStrictDefault(tree, false);
}
if (options.ssr) {
await setupSsr(tree, {
project: options.name,
standalone: options.standalone,
skipPackageJson: options.skipPackageJson,
serverRouting: options.serverRouting,
});
}
if (!options.skipFormat) {
await formatFiles(tree);
}
return () => {
installPackagesTask(tree);
logShowProjectCommand(options.name);
};
}
export default applicationGenerator;