Skip to content

Commit

Permalink
fix(core): keep existing name when converting project to a monorepo (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Aug 30, 2023
1 parent 660f0a6 commit ec647e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('monorepo generator', () => {
libsDir: 'packages',
});

expect(readJson(tree, 'packages/my-lib/project.json')).toMatchObject({
expect(readProjectConfiguration(tree, 'my-lib')).toMatchObject({
sourceRoot: 'packages/my-lib/src',
targets: {
build: {
Expand All @@ -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',
});

Expand All @@ -67,7 +68,7 @@ describe('monorepo generator', () => {

await monorepoGenerator(tree, {});

expect(readJson(tree, 'apps/demo/project.json')).toMatchObject({
expect(readProjectConfiguration(tree, 'demo')).toMatchObject({
sourceRoot: 'apps/demo/src',
});

Expand Down Expand Up @@ -117,7 +118,7 @@ describe('monorepo generator', () => {

await monorepoGenerator(tree, {});

expect(readJson(tree, 'apps/demo/project.json')).toMatchObject({
expect(readProjectConfiguration(tree, 'demo')).toMatchObject({
sourceRoot: 'apps/demo/src',
targets: {
build: {
Expand Down Expand Up @@ -157,11 +158,11 @@ describe('monorepo generator', () => {

await monorepoGenerator(tree, {});

expect(readJson(tree, 'apps/demo/project.json')).toMatchObject({
expect(readProjectConfiguration(tree, 'demo')).toMatchObject({
sourceRoot: 'apps/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',
});
expect(tree.read('libs/util/src/lib/util.ts', 'utf-8')).toContain('util');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export async function monorepoGenerator(tree: Tree, options: {}) {
for (const project of projectsToMove) {
await moveGenerator(tree, {
projectName: project.name,
newProjectName:
project.projectType === 'application' || project.root === '.'
? project.name
: project.root,
newProjectName: project.name,
destination:
project.projectType === 'application'
? joinPathFragments(appsDir, project.name)
? joinPathFragments(
appsDir,
project.root === '.' ? project.name : project.root
)
: joinPathFragments(
libsDir,
project.root === '.' ? project.name : project.root
Expand Down

0 comments on commit ec647e7

Please sign in to comment.