fix(core): keep existing name when converting project to a monorepo (#18910)
This commit is contained in:
parent
660f0a6d60
commit
ec647e7250
@ -29,7 +29,7 @@ describe('monorepo generator', () => {
|
|||||||
libsDir: 'packages',
|
libsDir: 'packages',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(readJson(tree, 'packages/my-lib/project.json')).toMatchObject({
|
expect(readProjectConfiguration(tree, 'my-lib')).toMatchObject({
|
||||||
sourceRoot: 'packages/my-lib/src',
|
sourceRoot: 'packages/my-lib/src',
|
||||||
targets: {
|
targets: {
|
||||||
build: {
|
build: {
|
||||||
@ -41,7 +41,8 @@ describe('monorepo generator', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(readJson(tree, 'packages/other-lib/project.json')).toMatchObject({
|
expect(readProjectConfiguration(tree, 'other-lib')).toMatchObject({
|
||||||
|
name: 'other-lib',
|
||||||
sourceRoot: 'packages/other-lib/src',
|
sourceRoot: 'packages/other-lib/src',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ describe('monorepo generator', () => {
|
|||||||
|
|
||||||
await monorepoGenerator(tree, {});
|
await monorepoGenerator(tree, {});
|
||||||
|
|
||||||
expect(readJson(tree, 'apps/demo/project.json')).toMatchObject({
|
expect(readProjectConfiguration(tree, 'demo')).toMatchObject({
|
||||||
sourceRoot: 'apps/demo/src',
|
sourceRoot: 'apps/demo/src',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ describe('monorepo generator', () => {
|
|||||||
|
|
||||||
await monorepoGenerator(tree, {});
|
await monorepoGenerator(tree, {});
|
||||||
|
|
||||||
expect(readJson(tree, 'apps/demo/project.json')).toMatchObject({
|
expect(readProjectConfiguration(tree, 'demo')).toMatchObject({
|
||||||
sourceRoot: 'apps/demo/src',
|
sourceRoot: 'apps/demo/src',
|
||||||
targets: {
|
targets: {
|
||||||
build: {
|
build: {
|
||||||
@ -157,11 +158,11 @@ describe('monorepo generator', () => {
|
|||||||
|
|
||||||
await monorepoGenerator(tree, {});
|
await monorepoGenerator(tree, {});
|
||||||
|
|
||||||
expect(readJson(tree, 'apps/demo/project.json')).toMatchObject({
|
expect(readProjectConfiguration(tree, 'demo')).toMatchObject({
|
||||||
sourceRoot: 'apps/demo',
|
sourceRoot: 'apps/demo',
|
||||||
});
|
});
|
||||||
expect(tree.read('apps/demo/app/page.tsx', 'utf-8')).toContain('demo');
|
expect(tree.read('apps/demo/app/page.tsx', 'utf-8')).toContain('demo');
|
||||||
expect(readJson(tree, 'libs/util/project.json')).toMatchObject({
|
expect(readProjectConfiguration(tree, 'util')).toMatchObject({
|
||||||
sourceRoot: 'libs/util/src',
|
sourceRoot: 'libs/util/src',
|
||||||
});
|
});
|
||||||
expect(tree.read('libs/util/src/lib/util.ts', 'utf-8')).toContain('util');
|
expect(tree.read('libs/util/src/lib/util.ts', 'utf-8')).toContain('util');
|
||||||
|
|||||||
@ -34,13 +34,13 @@ 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:
|
newProjectName: project.name,
|
||||||
project.projectType === 'application' || project.root === '.'
|
|
||||||
? project.name
|
|
||||||
: project.root,
|
|
||||||
destination:
|
destination:
|
||||||
project.projectType === 'application'
|
project.projectType === 'application'
|
||||||
? joinPathFragments(appsDir, project.name)
|
? joinPathFragments(
|
||||||
|
appsDir,
|
||||||
|
project.root === '.' ? project.name : project.root
|
||||||
|
)
|
||||||
: joinPathFragments(
|
: joinPathFragments(
|
||||||
libsDir,
|
libsDir,
|
||||||
project.root === '.' ? project.name : project.root
|
project.root === '.' ? project.name : project.root
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user