-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): automatically add root to the project.json projects
- Loading branch information
1 parent
8c38b86
commit 7bc5a2c
Showing
15 changed files
with
118 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
{ | ||
"migrations": {} | ||
"migrations": { | ||
"remove-root": { | ||
"cli": "nx", | ||
"version": "14.1.0-beta.0", | ||
"description": "Removes unnecessary root property from project.json files", | ||
"factory": "./src/migrations/update-14-0-4/" | ||
} | ||
} | ||
} |
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
59 changes: 59 additions & 0 deletions
59
packages/nx/src/migrations/update-14-1-0/remove-root.spec.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,59 @@ | ||
import { | ||
addProjectConfiguration, | ||
readJson, | ||
Tree, | ||
updateJson, | ||
} from '@nrwl/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import removeRoot from './remove-root'; | ||
|
||
describe('remove-root', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(2); | ||
}); | ||
|
||
describe('project.json projects', () => { | ||
it('should have their root removed', async () => { | ||
addProjectConfiguration( | ||
tree, | ||
'proj1', | ||
{ | ||
root: 'proj1', | ||
targets: {}, | ||
}, | ||
true | ||
); | ||
|
||
updateJson(tree, './proj1/project.json', (json) => ({ | ||
...json, | ||
root: 'proj1', | ||
})); | ||
|
||
await removeRoot(tree); | ||
|
||
expect(readJson(tree, './proj1/project.json').root).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('workspace.json projects', () => { | ||
it('should not have their root removed', async () => { | ||
addProjectConfiguration( | ||
tree, | ||
'proj1', | ||
{ | ||
root: 'proj1', | ||
targets: {}, | ||
}, | ||
false | ||
); | ||
|
||
await removeRoot(tree); | ||
|
||
expect( | ||
readJson(tree, './workspace.json').projects.proj1.root | ||
).toBeDefined(); | ||
}); | ||
}); | ||
}); |
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,14 @@ | ||
import { | ||
formatFiles, | ||
getProjects, | ||
Tree, | ||
updateProjectConfiguration, | ||
} from '@nrwl/devkit'; | ||
|
||
export default async function (tree: Tree) { | ||
for (const [projName, projConfig] of getProjects(tree)) { | ||
updateProjectConfiguration(tree, projName, projConfig); | ||
} | ||
|
||
await formatFiles(tree); | ||
} |
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