Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): flatten default base config to base
- Loading branch information
1 parent
8ec589d
commit 478e5e6
Showing
17 changed files
with
135 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/nx/src/migrations/update-17-1-0/move-default-base.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { createTreeWithEmptyWorkspace } from 'nx/src/generators/testing-utils/create-tree-with-empty-workspace'; | ||
import update from './move-default-base'; | ||
import { Tree } from 'nx/src/generators/tree'; | ||
import { readNxJson, updateNxJson } from 'nx/src/generators/utils/nx-json'; | ||
|
||
describe('update-17.1.0 migration', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); | ||
}); | ||
|
||
it("shouldn't do anything if affected.defaultBase is not set", () => { | ||
tree.write('nx.json', JSON.stringify({})); | ||
update(tree); | ||
expect(readNxJson(tree)).toEqual({}); | ||
}); | ||
|
||
it("shouldn't remove affected if other keys present", () => { | ||
updateNxJson(tree, { | ||
affected: { | ||
defaultBase: 'master', | ||
otherKey: 'otherValue', | ||
} as any, | ||
}); | ||
update(tree); | ||
expect(readNxJson(tree)).toEqual({ | ||
affected: { | ||
otherKey: 'otherValue', | ||
}, | ||
base: 'master', | ||
}); | ||
}); | ||
|
||
it('should remove affected if no other keys present', () => { | ||
updateNxJson(tree, { | ||
affected: { | ||
defaultBase: 'master', | ||
} as any, | ||
}); | ||
update(tree); | ||
expect(readNxJson(tree)).toEqual({ | ||
base: 'master', | ||
}); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/nx/src/migrations/update-17-1-0/move-default-base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { readNxJson, updateNxJson } from '../../generators/utils/nx-json'; | ||
import { Tree } from '../../generators/tree'; | ||
|
||
/** | ||
* Updates existing workspaces to move nx.json's affected.defaultBase to nx.json's base. | ||
*/ | ||
export default function update(host: Tree) { | ||
const nxJson = readNxJson(host); | ||
if (nxJson.affected?.defaultBase) { | ||
nxJson.base = nxJson.affected.defaultBase; | ||
delete nxJson.affected.defaultBase; | ||
if (Object.keys(nxJson.affected).length === 0) { | ||
delete nxJson.affected; | ||
} | ||
updateNxJson(host, nxJson); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters