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

@gibsonmurray/ghooks-cli

v1.0.8

Published

A CLI for managing React hooks in your project

Downloads

456

Readme

GHooks

GHooks is a command-line tool and React hooks library that allows you to easily add pre-built React hooks to your project.

Table of Contents

Installation

Install GHooks globally using your preferred package manager:

npm install -g @gibsonmurray/ghooks-cli

Command-Line Usage

After installation, you can use the ghooks command in your terminal:

Add Hooks

To add hooks interactively:

ghooks add

To add a specific hook by name:

ghooks add <hook-name>

List Available Hooks

To list all available hooks:

ghooks list

Update Library & CLI

To update the hooks in the project:

ghooks update

To upgrade the CLI to the latest version:

ghooks upgrade

Hooks Library

The GHooks library provides the following hooks:

  • useArray
  • useAsync
  • useClickOutside
  • useClipboard
  • useCookie
  • useDarkMode
  • useDebounce
  • useDebug
  • useDeepEffect
  • useDocumentTitle
  • useDragDrop
  • useEventListener
  • useFetch
  • useFlipGSAP
  • useForm
  • useGeolocation
  • useGlobalState
  • useHover
  • useIdle
  • useImageLoad
  • useKeyPress
  • useLockScroll
  • useLongPress
  • useMediaDevices
  • useMediaQuery
  • useMounted
  • useMouse
  • useOnlineStatus
  • useOnScreen
  • useOrientation
  • usePermission
  • usePrevious
  • useRenderCount
  • useScript
  • useSize
  • useStateHistory
  • useStateValidation
  • useLocalStorage
  • useSessionStorage
  • useTimeout
  • useToggle
  • useUnmounted
  • useUpdated
  • useWindowSize

Library Usage

You can also use the hooks directly in your React projects:

  1. Install the library:
npm install @gibsonmurray/react-hooks
  1. Import the hook you need:
import { useDebounce } from "@gibsonmurray/react-hooks"
const MyComponent = () => {
    const [value, setValue] = useState("")
    const debouncedValue = useDebounce(value, 500)
    // ... rest of your component
}

CLI Implementation

The GHooks CLI is implemented in the index.ts file, which provides the following functionality:

  • Adding Hooks: Users can add hooks interactively or by specifying a hook name.
  • Listing Hooks: Displays all available hooks from the repository.
  • Updating Hooks: Updates existing hooks in the project to their latest versions.
  • Upgrading CLI: Upgrades the GHooks CLI to the latest version.
  • Version Information: Displays the current version of the CLI.

The CLI uses several dependencies:

  • commander: For parsing command-line arguments and defining commands.
  • inquirer: For interactive command-line user interfaces.
  • axios: For making HTTP requests to fetch hook data.
  • chalk: For colorful console output.
  • semver: For semantic versioning comparisons.

The main commands implemented in index.ts are:

  1. ghooks add [hookName]: Adds one or more hooks to the project.
  2. ghooks list: Lists all available hooks.
  3. ghooks update: Updates existing hooks in the project.
  4. ghooks upgrade: Upgrades the GHooks CLI to the latest version.
  5. ghooks version: Displays the current version of the CLI.

The CLI fetches hook data from the GitHub repository, ensuring that users always have access to the latest versions of the hooks.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.