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

@2bttns/2bttns-cli

v1.0.3-beta

Published

The 2bttns command line interface.

Downloads

30

Readme

@2bttns/2bttns-cli

The 2bttns command line interface.

Features

  • Get up-and-running with a 2bttns installation using 2bttns-cli new
  • Apply the necessary 2bttns migrations to the database you intend to use with 2bttns (2bttns-cli db migrate)
  • Apply example data to the database you intend to use with 2bttns (2bttns-cli db seed)
  • Interactive command to create 2bttns console administrators (2bttns-cli admin create), with command-line-only alternatives (2bttns-cli admin create credentials, 2bttns-cli admin create oauth-allow)
  • Set configuration values via the command line (e.g. 2bttns-cli config set db.url <value>) to avoid having to specify them every time you run a command

Install

# You can install the 2bttns CLI globally via npm:
npm i -g @2bttns/2bttns-cli

# Alternatively, you can call it via npx without installing it globally.
npx @2bttns/2bttns-cli <command>

Usage

Get Started

# If installed globally:
2bttns-cli --help


# If calling it via npx:
npx @2bttns/2bttns-cli --help

i. Automated 2bttns Setup via 2bttns-cli new

The 2bttns-cli new command will ask you for a few configuration values, create a 2bttns-ready Docker Compose file, and start it so you can quickly get your own applications integrated with 2bttns.

2bttns-cli new

DB Migrations & Seeding

# Apply migrations
## Migrate the specified database using the -d flag
2bttns-cli db migrate -d <database-url>

# Create example seed data (Games, Tags, GameObjects, and an example App Secret) in your database
## Seed the specified database using the -d flag
## IMPORTANT: The database must be migrated via `2bttns-cli db migrate` before seeding, or else the seed will fail.
2bttns-cli db seed -d <database-url>

## If you have set the db.url config value, you can omit the -d flag
2bttns-cli db migrate
2bttns-cli db seed

Create 2bttns Console Administrators

# Create a new 2bttns console administrator:
## Create an administrator via interactive prompts
2bttns-cli admin create -d <database-url> -s <nextauth-secret>

## Create an administrator via command line arguments
2bttns-cli admin create credentials -u <username> -p <password> -d <database-url> -s <nextauth-secret>
2bttns-cli admin create oauth-allow -e <email> -d <database-url> -s <nextauth-secret>

## If you have set the db.url and nextAuthSecret config values or have the proper environment variables set, you can omit the -d and -s flags
2bttns-cli admin create
2bttns-cli admin create credentials -u <username> -p <password>
2bttns-cli admin create oauth-allow -e <email>

Configuration Values

Set configuration values via the CLI using the config command. Values set this way will be used by the CLI when running commands, so you don't have to specify them every time using flags.

Commands

# Set a configuration value
2bttns-cli config set <key> <value>

# Get the current value of a configuration value
2bttns-cli config get <key>

# Clear a configuration value
2bttns-cli config clear <key>

Available Configuration Values

| Key | Description | Default Value | Example Value | Flag(s) | Environment Variable | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ---------------------------------------------------- | ---------------- | -------------------- | | db.url | The connection URL of the database you want to use with 2bttns. | null | postgresql://username:password@db-hostname:port/db | -d, --db-url | DATABASE_URL | | nextAuthSecret | The NEXTAUTH_SECRET used by your 2bttns admin console. This value is reused for hashing admin credential passwords, and is only required when creating a new admin user using credentials. | null | placeholder-secret-remember-to-change | -s, --secret | NEXTAUTH_SECRET |

Configuration Value Precedence

The CLI takes configuration values from the following sources, in order of precedence:

  1. Command line arguments (The --db-url flag, for example)

  2. Config file (Set these via 2bttns config set <key> <value>)

    ⚠️ An exception to this is if you set the --ignore-config flag, which in this case the CLI will ignore config values. This is useful if you want to use environment variables instead of the existing config.

       # Example:
       # In this case, the CLI will use the necessary environment variables (DATABASE_URL, NEXTAUTH_SECRET) instead of the config file (if they exist)
       # If you do not know which environment variables to use for certain commands, the command will warn you if you are missing any.
       2bttns-cli admin create --ignore-config
  3. Environment variables (DATABASE_URL, NEXTAUTH_SECRET)