-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Nx Move and Remove Project in Context Menu #1256
Changes from 2 commits
62028f2
c00c16d
5736239
c591644
e89a9e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,4 +1,12 @@ | ||||
import { commands, ExtensionContext, window, Uri } from 'vscode'; | ||||
import { | ||||
commands, | ||||
ExtensionContext, | ||||
window, | ||||
Uri, | ||||
Task, | ||||
TaskScope, | ||||
tasks, | ||||
} from 'vscode'; | ||||
|
||||
import { verifyWorkspace } from '@nx-console/vscode/nx-workspace'; | ||||
import { verifyBuilderDefinition } from '@nx-console/vscode/verify'; | ||||
|
@@ -67,6 +75,20 @@ export function registerCliTaskCommands( | |||
selectCliCommandAndPromptForFlags('run', await getCliProjectFromUri(uri)) | ||||
); | ||||
|
||||
commands.registerCommand(`${cli}.move.fileexplorer`, async (uri: Uri) => { | ||||
const getCorrectMoveGenerator = (uri: Uri) => '@nrwl/workspace:move'; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could probably find out the minimum version of Nx that introduced this generator and have that logic here. We have this function here that could be exported and used outside that project:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oooh, hadn't considered that. Good point. For versions younger than we had the move/remove generators, we should probably remove this option from the context menu, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar note: for when the user right-clicks on a node in the root, my solution would open the webview for the I think this is problematic, since we should be using the |
||||
// ^ needs to determine if the @nrwl/angular:move is in the list of | ||||
// generators for the cli and use it instead if present. | ||||
const generator = getCorrectMoveGenerator(uri); | ||||
selectCliCommandAndShowUi( | ||||
'generate', | ||||
context.extensionPath, | ||||
uri, | ||||
GeneratorType.Other, | ||||
generator | ||||
); | ||||
}); | ||||
|
||||
commands.registerCommand(`${cli}.generate`, () => | ||||
selectGeneratorAndPromptForFlags() | ||||
); | ||||
|
@@ -137,7 +159,8 @@ async function selectCliCommandAndShowUi( | |||
command: string, | ||||
extensionPath: string, | ||||
uri?: Uri, | ||||
generatorType?: GeneratorType | ||||
generatorType?: GeneratorType, | ||||
generator?: string | ||||
) { | ||||
const workspacePath = cliTaskProvider.getWorkspacePath(); | ||||
if (!workspacePath) { | ||||
|
@@ -153,9 +176,10 @@ async function selectCliCommandAndShowUi( | |||
} | ||||
const workspaceTreeItem = new RunTargetTreeItem( | ||||
configurationFilePath, | ||||
`${command[0].toUpperCase()}${command.slice(1)}`, | ||||
command, | ||||
extensionPath, | ||||
generatorType | ||||
generatorType, | ||||
generator | ||||
); | ||||
|
||||
commands.executeCommand( | ||||
|
@@ -319,7 +343,7 @@ export async function selectCliProject( | |||
|
||||
if (!items.length) { | ||||
window.showInformationMessage( | ||||
`No projects have an target command for ${command}` | ||||
`No projects have a target command for ${command}` | ||||
); | ||||
|
||||
return; | ||||
|
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.
I think it's better to use
isAngularWorkspace
here.