fix(core): convert to monorepo generator should respect nested libs (#18795)

This commit is contained in:
Nicholas Cunningham 2023-08-25 10:25:06 -06:00 committed by GitHub
parent e3b513b6c0
commit 413e57f99a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 2 deletions

View File

@ -76,6 +76,34 @@ describe('monorepo generator', () => {
expect(tree.exists('.eslintrc.base.json')).toBeTruthy(); expect(tree.exists('.eslintrc.base.json')).toBeTruthy();
}); });
it('should respect nested libraries', async () => {
await reactAppGenerator(tree, {
name: 'demo',
style: 'css',
bundler: 'vite',
unitTestRunner: 'vitest',
e2eTestRunner: 'none',
linter: 'eslint',
rootProject: true,
});
await libraryGenerator(tree, {
name: 'my-lib',
directory: 'inner',
style: 'css',
bundler: 'vite',
unitTestRunner: 'none',
e2eTestRunner: 'none',
linter: 'eslint',
rootProject: true,
});
await monorepoGenerator(tree, {});
expect(tree.exists('libs/inner/my-lib/tsconfig.json')).toBeTruthy();
expect(tree.exists('libs/inner/my-lib/src/index.ts')).toBeTruthy();
});
it('should convert root React app (Webpack, Jest)', async () => { it('should convert root React app (Webpack, Jest)', async () => {
await reactAppGenerator(tree, { await reactAppGenerator(tree, {
name: 'demo', name: 'demo',

View File

@ -34,11 +34,15 @@ export async function monorepoGenerator(tree: Tree, options: {}) {
for (const project of projectsToMove) { for (const project of projectsToMove) {
await moveGenerator(tree, { await moveGenerator(tree, {
projectName: project.name, projectName: project.name,
newProjectName: project.name, newProjectName:
project.projectType === 'application' ? project.name : project.root,
destination: destination:
project.projectType === 'application' project.projectType === 'application'
? joinPathFragments(appsDir, project.name) ? joinPathFragments(appsDir, project.name)
: joinPathFragments(libsDir, project.name), : joinPathFragments(
libsDir,
project.root === '.' ? project.name : project.root
),
destinationRelativeToRoot: true, destinationRelativeToRoot: true,
updateImportPath: project.projectType === 'library', updateImportPath: project.projectType === 'library',
}); });