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

firebase-project-manager

v0.0.5

Published

Create and manage your Firebase projects from the command line or with code

Downloads

15

Readme

firebase-project-manager

Build Status Coverage Status TypeScript NPM Version License

Create and manage your Firebase projects from the command line or with code!

Example Usage

As a Command-Line Tool

$ firebase-project-manager login
$ firebase-project-manager create my-new-project

As a Node.JS Dependency

const { authenticate, createFirebaseProject } = require('firebase-project-manager');

await authenticate();
const createdProjectId = await createFirebaseProject('my-new-project');
console.log('Successfully created new Firebase project:', createdProjectId);

Installation

As a package dependency:

$ yarn add firebase-project-manager 
# OR
$ npm i firebase-project-manager

As a global binary tool:

$ yarn global add firebase-project-manager
# OR
$ npm i -g firebase-project-manager

CLI Usage

This utility can either be used in an interactive mode, or single-command/single-action mode.
To access the interactive tool, use the following command:

$ firebase-project-manager

To utilize a single function of the executable, run the following to view all options (API is subject to change):

$ firebase-project-manager --help

Note: You may need to use $ yarn firebase-project-manager if you do not have the package installed globally.

Node.JS API Usage

Embedded below are all of the functions available for import through this package currently. Since the APIs are subject to heavy change right now, official documentation will not be produced until the package is ready for an initial major release. Using exact symver numbers in your package.json recommended until then as any changes up until v1.0.0 can be considered breaking changes.

// src/index.ts

import { googleapis } from './apis';
import * as auth from './auth';
import * as firebase from './firebase';
import { EventCB } from './firebase.types';
import { noop } from './util';

export { ERRORS, EVENTS, EventCB } from './firebase.types';

/** Static OAuth client managed by `authenticate` and `deauthenticate` */
export const oauth2Client = auth.oauth2Client;

/**
 * Authenticates client with Firebase Project Manager and retains a refresh token in the
 * system's configuration store for later usage.
 * @param verbose If true, authentication status will be logged with `console.log`.
 * @return Void promise resolved upon completion
 */
export const authenticate = auth.authenticate;

/**
 * Deauthenticates the currently logged in user, revokes and deletes the currently cached
 * refresh_token stored in the system's configuration store.
 * @param verbose If true, authentication status will be logged with `console.log`.
 * @return Void promise resolved upon completion
 */
export const deauthenticate = auth.deauthenticate;

/**
 * Creates a new Firebase Project via a two step process of first creating a CGP Project
 * and then secondly adding Firebase resources to it.
 * @param name Desired display name for the underlying GCP project. If available, this name
 * will also be used as a `projectId` by replacing all non-whitespace characters with '-'
 * and making all alphabetic characters lower-case.
 * @param cb function called with progress of project creation.
 * @return Promise to the newly created project's `projectId`.
 */
export function createFirebaseProject(name: string, cb: EventCB = noop) {
	return firebase.createFirebaseProject(googleapis, name, cb);
}

/**
 * Creates a new GCP project using Google `cloudresourcemanager`.
 * @param name Desired display name for the underlying GCP project. If available, this name
 * will also be used as a `projectId` by replacing all non-whitespace characters with `-`
 * and making all alphabetic characters lower-case.
 * @param cb function called with progress of project creation.
 * @return Promise to the newly created project's `projectId`.
 */
export function createGCProject(name: string, cb: EventCB = noop) {
	return firebase.createGCProject(googleapis, name, cb);
}

/**
 * Adds Firebase resources to a GCP Project
 * @param projectId projectId of the GCP Project to add Firebase features to.
 * @param cb function called with progress of project creation.
 * @return Void promise resolved upon completion
 */
export function addFirebaseFeatures(projectId: string, cb: EventCB = noop) {
	return firebase.addFirebaseFeatures(googleapis, projectId, cb);
}

/**
 * Lists all GCP Projects with Firebase resources.
 * @param pageSize The maximum number of Projects to return
 * @param pageToken Token returned from a previous call indicating where in the
 * set of Projects to resume listing.
 * @return Promise to an array of Firebase Projects
 */
export function listFirebaseProjects(pageSize?: number, pageToken?: string) {
	return firebase.listFirebaseProjects(googleapis, pageSize, pageToken);
}
/**
 * Lists all GCP Projects lacking Firebase resources, but that are available to become Firebase
 * projects.
 * @param pageSize The maximum number of Projects to return
 * @param pageToken Token returned from a previous call indicating where in the
 * set of Projects to resume listing.
 * @return Promise to an array of GCP Projects
 */
export function listAvailableProjects(pageSize?: number, pageToken?: string) {
	return firebase.listAvailableProjects(googleapis, pageSize, pageToken);
}

/**
 * Retrieves information for a given Firebase project.
 * @param projectId projectId of the Firebase project to retrieve
 * @return Promise to a Firebase Project
 */
export function getFirebaseProject(projectId: string) {
	return firebase.getFirebaseProject(googleapis, projectId);
}

/**
 * Lists all applications associated with a Firebase Project.
 * @param projectId projectId of the Firebase project to retrieve apps of
 * @param pageSize The maximum number of Apps to return
 * @param pageToken Token returned from a previous call indicating where in the
 * set of Apps to resume listing.
 */
export function listFirebaseProjectApps(projectId: string, pageSize?: number, pageToken?: string) {
	return firebase.listFirebaseProjectApps(googleapis, projectId, pageSize, pageToken);
}

/**
 * Creates a new web application under a given Firebase Project.
 * @param projectId projectId of the parent Firebase project to create an application for
 * @param displayName User-assigned display name of the App.
 * @param appUrls Fully qualified URLs where the App is hosted.
 */
export function createFirebaseWebapp(projectId: string, displayName?: string, appUrls?: string[]) {
	return firebase.createFirebaseWebapp(googleapis, projectId, displayName, appUrls);
}

/**
 * Retrieves information for a given Firebase Project's app.
 * @param name Fully qualified identifier for the webapp (Eg: `/projects/.../webApp/...`)
 */
export function getFirebaseWebapp(name: string): ReturnType<typeof firebase.getFirebaseWebapp>;
/**
 * Retrieves information for a given Firebase Project's app.
 * @param projectId projectId of the parent Firebase project
 * @param appId The webapp's ID.
 */
export function getFirebaseWebapp(projectId: string, appId?: string): ReturnType<typeof firebase.getFirebaseWebapp>;
export function getFirebaseWebapp(projectId: string, appId?: string) {
	return firebase.getFirebaseWebapp(googleapis, projectId, appId);
}

/**
 * Retrieves configuration information for a given Firebase Project's app.
 * @param name Fully qualified identifier for the webapp (Eg: `/projects/.../webApp/...`)
 */
export function getFirebaseWebappConfig(name: string): ReturnType<typeof firebase.getFirebaseWebappConfig>;
/**
 * Retrieves configuration information for a given Firebase Project's app.
 * @param projectId projectId of the parent Firebase project
 * @param appId The webapp's ID.
 */
export function getFirebaseWebappConfig(
	projectId: string,
	appId?: string
): ReturnType<typeof firebase.getFirebaseWebappConfig>;
export function getFirebaseWebappConfig(projectId: string, appId?: string) {
	return firebase.getFirebaseWebappConfig(googleapis, projectId, appId);
}