Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): set project names using a blog instead of project graph #13202

Merged
merged 1 commit into from Nov 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 13 additions & 14 deletions packages/nx/src/migrations/update-15-1-0/set-project-names.ts
@@ -1,23 +1,22 @@
import { Tree } from '../../generators/tree';
import {
getProjects,
readNxJson,
updateProjectConfiguration,
} from '../../generators/utils/project-configuration';
import { readNxJson } from '../../generators/utils/project-configuration';
import { globForProjectFiles } from '../../config/workspaces';
import { dirname } from 'path';
import { readJson, writeJson } from '../../generators/utils/json';
import { formatChangedFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available';
import { join } from 'path';

export default async function (tree: Tree) {
// 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
for (const [projName, projConfig] of getProjects(tree)) {
if (tree.exists(join(projConfig.root, 'project.json'))) {
if (!projConfig.name) {
projConfig.name = toProjectName(projConfig.root, readNxJson(tree));
}
updateProjectConfiguration(tree, projName, projConfig);
const nxJson = readNxJson(tree);
const projectFiles = globForProjectFiles(tree.root, nxJson);
const projectJsons = projectFiles.filter((f) => f.endsWith('project.json'));

for (let f of projectJsons) {
const projectJson = readJson(tree, f);
if (!projectJson.name) {
projectJson.name = toProjectName(dirname(f), nxJson);
writeJson(tree, f, projectJson);
}
}

await formatChangedFilesWithPrettierIfAvailable(tree);
}

Expand Down