|
1 | 1 | import { Tree } from '../../generators/tree'; |
2 | | -import { |
3 | | - getProjects, |
4 | | - readNxJson, |
5 | | - updateProjectConfiguration, |
6 | | -} from '../../generators/utils/project-configuration'; |
| 2 | +import { readNxJson } from '../../generators/utils/project-configuration'; |
| 3 | +import { globForProjectFiles } from '../../config/workspaces'; |
| 4 | +import { dirname } from 'path'; |
| 5 | +import { readJson, writeJson } from '../../generators/utils/json'; |
7 | 6 | import { formatChangedFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available'; |
8 | | -import { join } from 'path'; |
9 | 7 |
|
10 | 8 | export default async function (tree: Tree) { |
11 | | - // This looks like it does nothing, but this will actually effectively migrate over all the configs that need to be moved over, but won't touch configs that don't need to be moved |
12 | | - for (const [projName, projConfig] of getProjects(tree)) { |
13 | | - if (tree.exists(join(projConfig.root, 'project.json'))) { |
14 | | - if (!projConfig.name) { |
15 | | - projConfig.name = toProjectName(projConfig.root, readNxJson(tree)); |
16 | | - } |
17 | | - updateProjectConfiguration(tree, projName, projConfig); |
| 9 | + const nxJson = readNxJson(tree); |
| 10 | + const projectFiles = globForProjectFiles(tree.root, nxJson); |
| 11 | + const projectJsons = projectFiles.filter((f) => f.endsWith('project.json')); |
| 12 | + |
| 13 | + for (let f of projectJsons) { |
| 14 | + const projectJson = readJson(tree, f); |
| 15 | + if (!projectJson.name) { |
| 16 | + projectJson.name = toProjectName(dirname(f), nxJson); |
| 17 | + writeJson(tree, f, projectJson); |
18 | 18 | } |
19 | 19 | } |
20 | | - |
21 | 20 | await formatChangedFilesWithPrettierIfAvailable(tree); |
22 | 21 | } |
23 | 22 |
|
|
0 commit comments