Skip to content

Commit

Permalink
fix(core): remove generator should work w/o workspace.json (#8077)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Dec 9, 2021
1 parent ec24422 commit ea26751
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 2 additions & 3 deletions packages/devkit/src/generators/project-configuration.ts
Expand Up @@ -461,11 +461,10 @@ function readRawWorkspaceJson(tree: Tree): RawWorkspaceJsonConfiguration {
const projects = { ...staticFSWorkspace.projects, ...createdProjects };
findDeletedProjects(tree).forEach((file) => {
const matchingStaticProject = Object.entries(projects).find(
([, config]) => {
([, config]) =>
typeof config === 'string'
? config === dirname(file.path)
: config.root === dirname(file.path);
}
: config.root === dirname(file.path)
);

if (matchingStaticProject) {
Expand Down
23 changes: 14 additions & 9 deletions packages/workspace/src/generators/move/lib/update-build-targets.ts
@@ -1,18 +1,23 @@
import { getWorkspacePath, Tree, updateJson } from '@nrwl/devkit';
import { getProjects, Tree, updateProjectConfiguration } from '@nrwl/devkit';
import { NormalizedSchema } from '../schema';

/**
* Update other references to the source project's targets
*/
export function updateBuildTargets(tree: Tree, schema: NormalizedSchema) {
updateJson(tree, getWorkspacePath(tree), (json) => {
const strWorkspace = JSON.stringify(json);
json = JSON.parse(
strWorkspace.replace(
new RegExp(`${schema.projectName}:`, 'g'),
`${schema.newProjectName}:`
)
getProjects(tree).forEach((projectConfig, project) => {
Object.entries(projectConfig.targets || {}).forEach(
([target, targetConfig]) => {
const configString = JSON.stringify(targetConfig);
const updated = JSON.parse(
configString.replace(
new RegExp(`${schema.projectName}:`, 'g'),
`${schema.newProjectName}:`
)
);
projectConfig.targets[target] = updated;
}
);
return json;
updateProjectConfiguration(tree, project, projectConfig);
});
}

0 comments on commit ea26751

Please sign in to comment.