jscutlery / nx-completion Goto Github PK
View Code? Open in Web Editor NEWNx workspace completion plugin for Zsh.
License: MIT License
Nx workspace completion plugin for Zsh.
License: MIT License
Actually, the plugin statically describes commands and their arguments. It might break on different workspaces as they may use another type of executor than the one described in the plugin.
To fix this issue we could dynamically grab the target definition and build the completion out of it.
To avoid heavy computation we need to cache all sub commands as nx generate
.
When running nx
in pnpm
managed repo, I get the following warning (which sometimes even results in not working command)
> NX Running global Nx CLI with PNPM may have issues.
Prefer to use "pnpm" (https://pnpm.io/cli/exec) to execute commands in this workspace.
TIP create a shortcut such as: alias pnx="pnpm nx --"
Using the alias from the TIP would break this autocompletion, so would be really great if the plugin could work with PNPM natively and run pnpm nx
whenever nx
is used.
Here is what I came up with as a solution for me:
In .zrhrc
function pnpm-nx() {
local cmd=$BUFFER
if [[ "$cmd" =~ ^nx ]]; then
local new_cmd=$(echo $cmd | sed -E 's/^nx /pnpm nx /g')
BUFFER="$new_cmd"
fi
zle accept-line
}
zle -N pnpm-nx
bindkey "^M" pnpm-nx
So, now whenever I type nx {command}
it gets replaced by pnpm nx {command}
automatically on Enter
. This also doesn't break this autocompletion plugin
Thanks for writing this :)
Probably not worth including in the readme, but felt like sharing.
I was able to get this added to my zsh-snap based config with a one-liner:
znap eval nx "curl -fsSL https://raw.githubusercontent.com/zdog234/nx-completion/main/nx-completion.plugin.zsh"
(pointed at a fork because paranoia)
random aside:
I'm surprised nx
doesn't include completion out of the box -- it seems like the JS ecosystem is a bit lacking w.r.t. CLI libaries compared to other languages I've worked in
All arguments should be formatted in camel-case, eg: --i18nLocale
instead of --i18n-locale
.
Hi,
This is such a nice plugin that I don't realize I want. However, like many people, I don't usually have Nx CLI
installed globally and use yarn nx
(or npx nx
) to invoke the locally installed nx
instead.
That said, would it be possible to support yarn nx
as well?
Thanks
--deleteOutputPath
for nx build
.Hi!
Completions work quite nicely, but I can't get "nx generate" to complete anything. I've seen that in the code you call nx g
which in my case returns Specify the generator name (e.g., nx generate @nrwl/workspace:library)
on stderr. My nx --version
is 13.9.2.
Regards
Adam
The plugin should support the v2 definition format, more info here on the changes.
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/globalias is a plugin that exapnds aliases when you press space.
Having this plugin loaded breaks the functionality of that.
Interestingly, when in a nix-shell it starts to work again.
I use nx
with npx
because I don't want to deal with update my global install and I can use the version installed on each project, not the global one.
There is a way to use your plugin to have compatibility with npx
and other ways to use nx
without having it installed globally (like yarn
and npm
)?
Hi all,
In a NX-angular project I cannot use the nx-completion plugin. It gives two errors when using it:
nx g Plugin listed in nx.json
not found: devextreme-schematics
Plugin listed in nx.json
not found: ng-extract-i18n-merge
These are npm installed packages, I'm not aware that they are listed in nx.json or elsewhere.
Thanks in advance
When running the latest version I got this error command not found: md5sum
. That's probably because I needed to install it on MacOS with brew install md5sha1sum
. After that it works fine. So maybe this should be mentioned in the readme.
The plugin should support standalone project definition.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.