Leosvel Pérez Espinosa ada8be473d
fix(misc): fix misc issues in project generators for the ts solution setup (#30111)
The following are the main changes in the context of the TS solution
setup:

- Ensure `name` in `package.json` files is set to the import path for
all projects
- Set `nx.name` in `package.json` files when the user provides a name
different than the package name (import path)
- Clean up project generators so they don't set the `nx` property in
`package.json` files unless strictly needed
- Fix `@nx/vue:application` generator so it creates the Nx config in a
`package.json` file for e2e projects
- Ensure `@types/node` is installed in `vitest` generator
- Fix generated Vite config typing error (surfaced with Vite 6)
- Ensure `jsonc-eslint-parser` is installed when the
`@nx/dependency-checks` rule is added to the ESLint config
- Misc minor alignment changes

## Current Behavior

## Expected Behavior

## Related Issue(s)

Fixes #
2025-03-05 20:08:10 -05:00

53 lines
1.5 KiB
TypeScript

import { addE2e as addE2eReact } from '@nx/react/src/generators/application/lib/add-e2e';
import { GeneratorCallback, Tree, ensurePackage, names } from '@nx/devkit';
import { nxVersion } from '../../../utils/versions';
import { NormalizedSchema } from './normalize-options';
export async function addE2e(
host: Tree,
options: NormalizedSchema
): Promise<GeneratorCallback> {
switch (options.e2eTestRunner) {
case 'cypress':
return addE2eReact(host, {
...options,
e2eTestRunner: 'cypress',
style: 'none',
styledModule: null,
hasStyles: false,
unitTestRunner: 'none',
names: names(options.name),
});
case 'playwright':
return addE2eReact(host, {
...options,
e2eTestRunner: 'playwright',
style: 'none',
styledModule: null,
hasStyles: false,
unitTestRunner: 'none',
names: names(options.name),
});
case 'detox':
const { detoxApplicationGenerator } = ensurePackage<
typeof import('@nx/detox')
>('@nx/detox', nxVersion);
return detoxApplicationGenerator(host, {
...options,
e2eName: options.e2eProjectName,
e2eDirectory: options.e2eProjectRoot,
appProject: options.projectName,
appDisplayName: options.displayName,
appName: options.name,
framework: 'react-native',
setParserOptionsProject: options.setParserOptionsProject,
skipFormat: true,
});
case 'none':
default:
return () => {};
}
}