Skip to content

Commit

Permalink
fix(core): check for nx.json before applying migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj authored and vsavkin committed Jan 13, 2023
1 parent 6f253b0 commit 6e6ca5f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace';
import type { Tree } from '../../generators/tree';
import removeDefaultCollection from './remove-default-collection';
import {
readNxJson,
updateNxJson,
} from '../../generators/utils/project-configuration';
import removeDefaultCollection from './remove-default-collection';

describe('remove-default-collection', () => {
let tree: Tree;
Expand Down Expand Up @@ -47,4 +47,9 @@ describe('remove-default-collection', () => {

await expect(removeDefaultCollection(tree)).resolves.not.toThrow();
});

it('should not error when nxJson does not exist', async () => {
tree.delete('nx.json');
await expect(removeDefaultCollection(tree)).resolves.not.toThrow();
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { formatChangedFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available';
import { Tree } from '../../generators/tree';
import {
readNxJson,
updateNxJson,
} from '../../generators/utils/project-configuration';
import { formatChangedFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available';

export default async function (tree: Tree) {
// If the workspace doesn't have a nx.json, don't make any changes
if (!tree.exists('nx.json')) {
return;
}

const nxJson = readNxJson(tree);

delete nxJson.cli?.defaultCollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ describe('createTargetDefaults', () => {
});
expect(updated.targetDependencies).toBeUndefined();
});

it('should not error when nxJson does not exist', async () => {
tree.delete('nx.json');
await expect(createTargetDefaults(tree)).resolves.not.toThrow();
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { formatChangedFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available';
import { Tree } from '../../generators/tree';
import {
readNxJson,
updateNxJson,
} from '../../generators/utils/project-configuration';
import { formatChangedFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available';

export default async function (tree: Tree) {
// If the workspace doesn't have a nx.json, don't make any changes
if (!tree.exists('nx.json')) {
return;
}

const nxJson = readNxJson(tree);

if (nxJson.targetDependencies) {
Expand Down

1 comment on commit 6e6ca5f

@vercel
Copy link

@vercel vercel bot commented on 6e6ca5f Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app

Please sign in to comment.