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:
parent
4697ce1356
commit
84b40c8b85
@ -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);
|
addProjectConfiguration(tree, 'test', baseTestProjectConfig, true);
|
||||||
removeProjectConfiguration(tree, 'test');
|
removeProjectConfiguration(tree, 'test');
|
||||||
|
|
||||||
|
expect(readJson(tree, 'workspace.json').projects.test).toBeUndefined();
|
||||||
expect(tree.exists('test/project.json')).toBeFalsy();
|
expect(tree.exists('test/project.json')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -265,13 +265,12 @@ function addProjectToWorkspaceJson(
|
|||||||
if (configFile) {
|
if (configFile) {
|
||||||
if (mode === 'delete') {
|
if (mode === 'delete') {
|
||||||
host.delete(configFile);
|
host.delete(configFile);
|
||||||
|
delete workspaceJson.projects[projectName];
|
||||||
} else {
|
} else {
|
||||||
writeJson(host, configFile, project);
|
writeJson(host, configFile, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === 'create') {
|
if (mode === 'create') {
|
||||||
workspaceJson.projects[projectName] = project.root;
|
workspaceJson.projects[projectName] = project.root;
|
||||||
writeJson(host, path, workspaceJson);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let workspaceConfiguration: ProjectConfiguration;
|
let workspaceConfiguration: ProjectConfiguration;
|
||||||
@ -279,10 +278,9 @@ function addProjectToWorkspaceJson(
|
|||||||
const { tags, implicitDependencies, ...c } = project;
|
const { tags, implicitDependencies, ...c } = project;
|
||||||
workspaceConfiguration = c;
|
workspaceConfiguration = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
workspaceJson.projects[projectName] = workspaceConfiguration;
|
workspaceJson.projects[projectName] = workspaceConfiguration;
|
||||||
writeJson(host, path, workspaceJson);
|
|
||||||
}
|
}
|
||||||
|
writeJson(host, path, workspaceJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addProjectToNxJson(
|
function addProjectToNxJson(
|
||||||
|
|||||||
@ -18,8 +18,8 @@ export async function removeGenerator(tree: Tree, schema: Schema) {
|
|||||||
await checkDependencies(tree, schema);
|
await checkDependencies(tree, schema);
|
||||||
checkTargets(tree, schema, project);
|
checkTargets(tree, schema, project);
|
||||||
updateJestConfig(tree, schema, project);
|
updateJestConfig(tree, schema, project);
|
||||||
removeProject(tree, project);
|
|
||||||
removeProjectConfig(tree, schema);
|
removeProjectConfig(tree, schema);
|
||||||
|
removeProject(tree, project);
|
||||||
updateTsconfig(tree, schema, project);
|
updateTsconfig(tree, schema, project);
|
||||||
if (!schema.skipFormat) {
|
if (!schema.skipFormat) {
|
||||||
await formatFiles(tree);
|
await formatFiles(tree);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user