Skip to content

Commit

Permalink
fix: migration handling resilience with config updates
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanWalker committed Jul 4, 2022
1 parent a208c9f commit fc9870a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/plugin-tools/src/migrations/update-3-0-0/update-3-0-0.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatFiles, generateFiles, getProjects, getWorkspaceLayout, joinPathFragments, readJson, readProjectConfiguration, readWorkspaceConfiguration, removeProjectConfiguration, Tree, updateJson, updateProjectConfiguration } from '@nrwl/devkit';
import { formatFiles, generateFiles, getProjects, getWorkspaceLayout, joinPathFragments, readJson, readProjectConfiguration, readWorkspaceConfiguration, removeProjectConfiguration, TargetDependencyConfig, Tree, updateJson, updateProjectConfiguration } from '@nrwl/devkit';
import { convertToNxProjectGenerator } from '@nrwl/workspace';
import { relative } from 'path';

Expand Down Expand Up @@ -59,7 +59,11 @@ function updateDependencies(tree: Tree) {

function removeAllPackage(tree: Tree) {
// remove the "all" package (we are moving everyone to nx run-many)
removeProjectConfiguration(tree, 'all');
try {
removeProjectConfiguration(tree, 'all');
} catch (err) {
// may not exist
}
// update all references to the all package (mostly from the helper scripts)
let workspaceScripts = tree.read('tools/workspace-scripts.js', 'utf-8');
workspaceScripts = workspaceScripts.replace(`'nx run all:focus'`, `'nx g @nativescript/plugin-tools:focus-packages'`);
Expand Down Expand Up @@ -189,10 +193,15 @@ function updateProjectTargets(tree: Tree) {
// project.targets[target].outputs = [joinPathFragments(project.root, 'platforms')];
// }
project.targets[target].dependsOn = project.targets[target].dependsOn || [];
project.targets[target].dependsOn.push({
target: 'build.all',
projects: 'dependencies',
});
const hasBuildAll = project.targets[target].dependsOn.find((t: TargetDependencyConfig) => {
return t.target === 'build.all';
})
if (!hasBuildAll) {
project.targets[target].dependsOn.push({
target: 'build.all',
projects: 'dependencies',
});
}
const additionalDeps = [];
if (project.targets[target].executor === '@nrwl/workspace:run-commands') {
if (project.targets[target].options?.commands) {
Expand Down

0 comments on commit fc9870a

Please sign in to comment.