fix(misc): @nrwl/workspace:rm generator should work with standalone configs (#6348)

* fix(devkit): removeProjectConfiguration should remove path for project.json from workspace.json

When using standalone config files, removing a project's config should also remove its entry in the
workspace file.

* fix(misc): @nrwl/workspace:rm should work with standalone config files

When using standalone config files, removing a project's config should also remove its entry in
the
workspace file.
This commit is contained in:
Craigory V Coppola 2021-07-15 09:36:48 -05:00 committed by GitHub
parent 4697ce1356
commit 84b40c8b85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 6 deletions

View File

@ -119,10 +119,11 @@ describe('project configuration', () => {
);
});
it('should remove project.json file when removing projct configuration', () => {
it('should remove project.json file when removing project configuration', () => {
addProjectConfiguration(tree, 'test', baseTestProjectConfig, true);
removeProjectConfiguration(tree, 'test');
expect(readJson(tree, 'workspace.json').projects.test).toBeUndefined();
expect(tree.exists('test/project.json')).toBeFalsy();
});

View File

@ -265,13 +265,12 @@ function addProjectToWorkspaceJson(
if (configFile) {
if (mode === 'delete') {
host.delete(configFile);
delete workspaceJson.projects[projectName];
} else {
writeJson(host, configFile, project);
}
if (mode === 'create') {
workspaceJson.projects[projectName] = project.root;
writeJson(host, path, workspaceJson);
}
} else {
let workspaceConfiguration: ProjectConfiguration;
@ -279,10 +278,9 @@ function addProjectToWorkspaceJson(
const { tags, implicitDependencies, ...c } = project;
workspaceConfiguration = c;
}
workspaceJson.projects[projectName] = workspaceConfiguration;
writeJson(host, path, workspaceJson);
}
writeJson(host, path, workspaceJson);
}
function addProjectToNxJson(

View File

@ -18,8 +18,8 @@ export async function removeGenerator(tree: Tree, schema: Schema) {
await checkDependencies(tree, schema);
checkTargets(tree, schema, project);
updateJestConfig(tree, schema, project);
removeProject(tree, project);
removeProjectConfig(tree, schema);
removeProject(tree, project);
updateTsconfig(tree, schema, project);
if (!schema.skipFormat) {
await formatFiles(tree);