Skip to content

Commit 40d37b3

Browse files
authored
fix(core): set project names using a blog instead of project graph (#13202)
1 parent 45cba68 commit 40d37b3

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

packages/nx/src/migrations/update-15-1-0/set-project-names.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
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';
76
import { formatChangedFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available';
8-
import { join } from 'path';
97

108
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);
1818
}
1919
}
20-
2120
await formatChangedFilesWithPrettierIfAvailable(tree);
2221
}
2322

0 commit comments

Comments
 (0)