npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nx-tool

v2.2.4

Published

Nx generator that aims to help the frontend developing process by scaffolding boilerplate for you. It works on any workspace, even not Nx projects

Downloads

38

Readme

NxTool

This package contains an Nx generator called new-component that aims to help the frontend developing process by generating and scaffolding boilerplate for you. It scaffolds a React tsx or jsx component and let you choose if setting up a story file for Storybook, as well as a .spec file for testing.

You can run it everywhere!
Meaning not only in Nx projects but also in any NodeJs frontend project.

new-component-demo

NOTE: it is still under development, at the moment of writing generated files are particularly opinionated. Feedback is appreciated.

Install and usage

First install it on your own project:

npm install -D nx-tool

To try it you only need this command:

npm run new:component

More information and alternative commands:

With optional arguments:

You can pass optional arguments too:

npm run new:component [component_name] [-- --lang js --dir hooks --dry-run]

| Option | shorthand | Description | |:----------:|:---------:|------------------------------------------------------------------------------------------------------------------------| | --test | -t | Choose between false or true (in case simply pass -t) to have a test file too. | | --style | -s | Choose between css,styled-components,none to decide which style sistem use. | | --story | --sb | Choose between false or true (then simply pass --story or --sb) to have a storybook file too | | --dir | -d | [Optional] Choose a custom directory. By default its either components or lib (if it recognizes an Nx library). | | --lang | -l | [Optional] Choose between js or ts (default) / files will be generated with .jsx or .tsx extensions. | | --dry-run | | No changes will be made, the CLI will only show you what files should be generated. |

Remember: if you use the npm scripts command prefix the options with -- .
Some examples:

# A minimal component (no styles, neither test nor storybook files too):
npm run new:component -- -s none -t false --sb false

# A component with styled-dictionary and a storybook file too
npm run new:component -- --style styled-dictionary --story

# A component with `.jsx` extension inside `src/hooks` directory
npm run new:component -- --lang js --dir hooks

Suggestion:

You can customize your script per project and minimize the questions.
Simply change the script inside your package.json > "scripts" > "new:component".
E.g.:

"new:component": "npx nx g nx-tool:new-component --lang js --style styled-components --story false"

With this in place, whenever you run npm run new:component, the script will always create a component with .jsx extension, styled-components boilerplate in place and no storybook file (it will not be asked).


Understand this generator under the hood

This tool works like any other Nx generator and follow the prompted guided proceedure.
Indeed you can run it by using the classic nx command (short version e.g.):

nx g new-component [your_component_name]

The component name is optional, in case you don't insert it it will be asked to you.
As with any other Nx generator you can pass options like --dry-run to test the commands.
An example of this with the Nx long version command:

npx nx generate nx-tool:new-component --dry-run

Troubleshooting: equip your 'package.json'

If npm run new:component does not work run this to adeguate your own package.json:

npx nx-tool equip