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

codesnippets-cli

v1.2.0

Published

A CLI tool for importing and exporting code snippets via https://codesnippets.dev

Downloads

20

Readme

CodeSnippets.dev CLI (BETA)

CodeSnippets.dev is a service that allows you to publish code snippets for easy reuse across projects and teams. Gone are the days of hunting through folders and projects looking for that one snippet of code to copy and paste.

Basic Example

Imagine you created a nice little utility function, getQueryStringParam.js inside of ProjectA. You can do "future you" a favor and export it as code snippet.

snippets export src/utils/getQueryStringParam.js

Then two months later, when the same need arises while working on ProjectB, you can quickly import it.

snippets import getQueryStringParam.js --out src/shared

Getting Started

Install the CLI via NPM

npm install -g codesnippets-cli

Then login:

snippets login

Available Commands

  • list - Display a list of your (or a specified user's) code snippets
  • export <filepath> - Export a local file to create a new CodeSnippet
  • import <snippetPath> - Import a remote CodeSnippet to be saved as a local file.
  • remove <snippetPath> - Remove a CodeSnippet you have created
  • settings - Display your CodeSnippets.dev CLI settings
  • login - Log into the CodeSnippets.dev CLI
  • logout - Log out of the CodeSnippets.dev CLI

List

Display the available code snippets. By default your own, but you can specify a CodeSnippets.dev user.

snippets list [--user <value>] [--collection <value>]

List Examples

Show all of your own snippets

snippets list

Show all your snippets from a specified collection

snippets list --collection utils

Show all of another user's snippets

snippets list --user droopytersen

Export

Export a local file to be available as a CodeSnippets.dev snippet.

snippets export <filepath> [--title <value>] [--collection <value>] [--details <value>] [--overwrite]
  • If already have a snippet with a matching filename and collection, you must pass the --overwrite flag.
  • When you run the export command without any options you will be prompted for the required parmeters.

Export Examples

Export a file

snippets export src/components/Slider.jsx

Export a file to a specific collection

snippets export src/components/Slider.jsx --collection components

Import

Save available CodeSnippets.dev snippets as local files.

snippets import <snippet> [--path <value>] [--overwrite]
  • If a local file already exists, you will need to pass the --overwrite flag
  • If the given --path doesn't exist, you will receive an error

Import Examples

Import a snippet file to the current folder

Get your snippet that has a filename of Slider.tsx and save it locally to the current directory

snippets import Slider.tsx

Import a snippet file to a specific folder

If the destination folder doesn't exist, it will automatically be created

Get your snippet that has a filename of Slider.tsx and save it locally to src/components/Slider

snippets import Slider.tsx --out src/components/Slider

Import a snippet to a specific folder with a different filename

If you include a filename in the --out path, then that filename will be used instead of the Snippet's filename.

snippets import Slider.tsx --out src/components/AnimatedSlider/AnimatedSlider.tsx

Import a snippet file from a specific collection

Look in your utils collection for a snippet named debounce.js and save it to the current folder

snippets import utils/debounce.js

Import an entire collection

You can import an entire collection with the COLLECTION/ syntax

Import every snippet file that exists in your utils collection and save them locally in the src/utils folder.

snippets import utils/ --out src/utils

Import another user's entire collection

You can import an entire collection of another user with the USERNAME/COLLECTION/ syntax

Import every snippet file that exists in DroopyTersen's utils collection and save them locally in the src/utils folder.

snippets import droopytersen/utils/ --out src/utils

Login / Logout

Log in and out of the CodeSnippets.dev CLI

snippets login
snippets logout

Settings

For development only. Allows you to see your env configuration as well as switch from local to dev to prod.

snippets settings [--env <value>]

Display current environment settings

snippets settings

Switch to a different environment

Switch to the dev environment. You might have to login again if it is your first time using the targeted env.

snippets settings --env dev