-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(qwik-nx): use nx e2e generators directly
- Loading branch information
1 parent
20bf202
commit 55aff9d
Showing
19 changed files
with
293 additions
and
3,181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/qwik-nx/src/generators/application/utils/add-e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { | ||
addProjectConfiguration, | ||
ensurePackage, | ||
GeneratorCallback, | ||
getPackageManagerCommand, | ||
joinPathFragments, | ||
Tree, | ||
} from '@nx/devkit'; | ||
import { getInstalledNxVersion } from '../../../utils/get-installed-nx-version'; | ||
import { NormalizedSchema } from '../schema'; | ||
import { Linter } from '@nx/linter'; | ||
|
||
export async function addE2eProject( | ||
tree: Tree, | ||
options: NormalizedSchema | ||
): Promise<GeneratorCallback> { | ||
if (options.e2eTestRunner === 'cypress') { | ||
return addCypress(tree, options); | ||
} | ||
|
||
if (options.e2eTestRunner === 'playwright') { | ||
return addPlaywright(tree, options); | ||
} | ||
|
||
return () => void 0; | ||
} | ||
|
||
async function addCypress(tree: Tree, options: NormalizedSchema) { | ||
ensurePackage('@nx/cypress', getInstalledNxVersion(tree)); | ||
const { configurationGenerator } = await import('@nx/cypress'); | ||
|
||
addProjectConfiguration(tree, options.e2eProjectName, { | ||
projectType: 'application', | ||
root: options.e2eProjectRoot, | ||
sourceRoot: joinPathFragments(options.e2eProjectRoot, 'src'), | ||
targets: {}, | ||
tags: [], | ||
implicitDependencies: [options.projectName], | ||
}); | ||
return await configurationGenerator(tree, { | ||
project: options.e2eProjectName, | ||
directory: 'src', | ||
linter: options.linter, | ||
skipFormat: true, | ||
devServerTarget: `${options.projectName}:serve:development`, | ||
}); | ||
} | ||
|
||
async function addPlaywright(tree: Tree, options: NormalizedSchema) { | ||
ensurePackage('@nx/playwright', getInstalledNxVersion(tree)); | ||
const { configurationGenerator: playwrightConfigurationGenerator } = | ||
await import('@nx/playwright'); | ||
|
||
addProjectConfiguration(tree, options.e2eProjectName, { | ||
projectType: 'application', | ||
root: options.e2eProjectRoot, | ||
sourceRoot: joinPathFragments(options.e2eProjectRoot, 'src'), | ||
targets: {}, | ||
implicitDependencies: [options.projectName], | ||
}); | ||
return await playwrightConfigurationGenerator(tree, { | ||
project: options.e2eProjectName, | ||
skipFormat: true, | ||
directory: 'src', | ||
js: false, | ||
linter: options.linter ?? Linter.EsLint, | ||
webServerCommand: `${getPackageManagerCommand().exec} nx serve ${ | ||
options.projectName | ||
}`, | ||
webServerAddress: `http://localhost:${options.devServerPort ?? 4200}`, | ||
setParserOptionsProject: true, | ||
skipPackageJson: false, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.