Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): prompt for available generators (#10463)
- Loading branch information
1 parent
affa979
commit 3bcaa18
Showing
7 changed files
with
203 additions
and
28 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
44 changes: 44 additions & 0 deletions
44
packages/nx/src/migrations/update-14-2-0/remove-default-collection.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,44 @@ | ||
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace'; | ||
import type { Tree } from '../../generators/tree'; | ||
import removeDefaultCollection from './remove-default-collection'; | ||
import { | ||
readWorkspaceConfiguration, | ||
updateWorkspaceConfiguration, | ||
} from '../../generators/utils/project-configuration'; | ||
|
||
describe('remove-default-collection', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(2); | ||
}); | ||
|
||
it('should remove default collection from nx.json', async () => { | ||
const config = readWorkspaceConfiguration(tree); | ||
config.cli = { | ||
defaultCollection: 'default-collection', | ||
defaultProjectName: 'default-project', | ||
}; | ||
updateWorkspaceConfiguration(tree, config); | ||
|
||
await removeDefaultCollection(tree); | ||
|
||
expect(readWorkspaceConfiguration(tree).cli).toEqual({ | ||
defaultProjectName: 'default-project', | ||
}); | ||
}); | ||
|
||
it('should remove cli entirely if defaultCollection was the only setting', async () => { | ||
const config = readWorkspaceConfiguration(tree); | ||
config.cli = { | ||
defaultCollection: 'default-collection', | ||
}; | ||
updateWorkspaceConfiguration(tree, config); | ||
|
||
await removeDefaultCollection(tree); | ||
|
||
expect( | ||
readWorkspaceConfiguration(tree).cli?.defaultCollection | ||
).toBeUndefined(); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/nx/src/migrations/update-14-2-0/remove-default-collection.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,19 @@ | ||
import { Tree } from '../../generators/tree'; | ||
import { | ||
readWorkspaceConfiguration, | ||
updateWorkspaceConfiguration, | ||
} from '../../generators/utils/project-configuration'; | ||
import { formatChangedFilesWithPrettierIfAvailable } from '../../generators/internal-utils/format-changed-files-with-prettier-if-available'; | ||
|
||
export default async function (tree: Tree) { | ||
const workspaceConfiguration = readWorkspaceConfiguration(tree); | ||
|
||
delete workspaceConfiguration.cli?.defaultCollection; | ||
if (Object.keys(workspaceConfiguration.cli).length === 0) { | ||
delete workspaceConfiguration.cli; | ||
} | ||
|
||
updateWorkspaceConfiguration(tree, workspaceConfiguration); | ||
|
||
await formatChangedFilesWithPrettierIfAvailable(tree); | ||
} |
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
3bcaa18
There was a problem hiding this comment.
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-five.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app