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

fcm-cli

v0.2.1

Published

FCM(Firebase Cloud Messaging Client) for CLI

Downloads

16

Readme

fcm-cli Build Status

FCM(Firebase Cloud Messaging Client) Development tool working on CLI to avoid a troublesome testing of Push Notification on the terminal

Install

$ yarn global add fcm-cli <or> npm install -g fcm-cli

Help

$ fcm --help

Usase

$ fcm [command] <sources> <params> <configs...>

Commands and Mandatory Configs

  • send: Sending push message only. It requires:

    • server_key: You can get from Firebase Dashboard. Setting > Cloud Messaging > Server Key
    • to: You will get from a peer, client after they subscribed to push messaging service of FCM
    • notification / data: You should offer either of them at least. title and body should be exist if you'd use notification property. It's built on top of fcm-node, Please refer to get mode information.
  • watch: Watching changes on database url and send push notification message. It requires:

    • server_key, to, notification is same with mentioned above
    • api_key: You can get from Firebase Dashboard Overview
    • credential: We use firebase-admin which requires Service Account Credential. You can get the credential file from Firebase Admin Setup )

Use Case

# sending FCM push message by passed configs
$ fcm send --server-key $SERVER_KEY --to $TOKEN \
           --notification.title hi \
           --notification.body message

# save configs in global named by 'pwa-app1' after sending message
$ fcm send pwa-app1 --server-key $SERVER_KEY --to $TOKEN \
                    --notification.title hi \
                    --notification.body message

# loading configs by 'pwa-app1 and then sending message
$ fcm send pwa-app1 --notification.title hi --notification.body message

# loading configs by 'pwa-app1' and sending message to multiple peers
$ fcm send pwa-app1 --to $PEER1_TOKEN --to $PEER2_TOKEN \
                    --notification.title hi \
                    --notification.body message

# loading configs from firebaseConfig properties at firebase.json
$ fcm send firebase.json firebaseConfig \
                    --notification.title hi \
                    --notification.body message

# loading configs from .env file and strip out FIREBASE_ prefix in keys
$ fcm send .env FIREBASE_ --notification.title hi --notification.body message

# watch Firebase database and sending push when it's changed
fcm watch test1 --credential $PRJECT/conf/credential.json \
                --database-url https://yourapp-id.firebaseio.com/

What is benefits in terms of testing with FCM

It's working in a similar way of other tools, are supporting RESTful APIs of Firebase, are working on terminal, like curl. However, those of another tools and commands is so hard and not handy to use while test as we frequently modify configurations on terminal. This package supports saving and loading pre-configuration by alias, loading from json with specific property and also .env which have simple key and value format. So, we don't need to pass all of configuration everytime. We can just put in simple updatable messages with alias

Workflow

Testing with Alias

# first time, sending FCM push message with all of configs and alias for saving
$ fcm send test1 --server-key $SERVER_KEY --to $TOKEN \
                 --notification.title hi \
                 --notification.body message

# second time, we don't need to pass keys configuration its already saved before named by test1
$ fcm send test1 --notification.title hi --notification.body message2

# the next time or next day, we can just call alias to test
$ fcm send test1

Testing with pre-configured file .json and .env

# if you have json or env file having Firebase configurations, just pass its path to
$ fcm send .env --notification.title hi --notification.body message2
$ fcm send firebase.json --notification.title hi --notification.body message2

# may your configurations have parent property or prefix to distingush from other values. Just pass
# third param with .env or json files. It will works, remove prefix or find property depends on files type
$ fcm send .env FIREBASE_ --notification.title hi --notification.body message2
$ fcm send firebase.json firebaseConfig --notification.title hi --notification.body message2

Testing with watch mode

fcm watch test1 --credential $PRJECT/conf/credential.json \
                --database-url https://react-pwa-hello-world.firebaseio.com/

FAQ

  • Where is the location for saving alias and configurations?: We use configstore to save configs. It usally use for that location at ~/.config/configstore/, with package name, fcm-cli. You can have a look what is saved.
cat ~/.config/configstore/fcm-cli.json
{
	"test1": {
		"serverKey": "SERVER-KEY",
		"to": "LAST-SENT-TO-TOKEN",
		"notification": {
			"title": "hi",
			"body": "Welcome Push World"
		},
		"credential": "/Users/ragingwind/Downloads/credential.json",
		"apiKey": "-LADPTQtqD54TWdMzmZk",
		"databaseURL": "https://react-pwa-hello-world.firebaseio.com/"
	}
}

License

MIT © Jimmy Moon