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

code-push-v2

v0.0.25

Published

Management SDK for the CodePush service

Downloads

4

Readme

CodePush Management SDK (Node.js)

A JavaScript library for programmatically managing your CodePush account (e.g. creating apps, promoting releases), which allows authoring Node.js-based build and/or deployment scripts, without needing to shell out to the CLI.

Getting Started

  1. Create an access key to authenticate with the CodePush server using the following CodePush CLI command:

    code-push access-key add "DESCRIPTION_OF_THE_KEY"

    If you already created a key that you want to use here, then you can retrieve it by running code-push access-key ls and using the value of the Key column for the key you wish to use.

  2. Install the management SDK by running npm install code-push --save

  3. Import it using the following statement (using ES6 syntax as applicable):

    var CodePush = require("code-push-v2");    
  4. Create an instance of the CodePush class, passing it the access key you created or retrieved in step #1:

    var codePush = new CodePush("YOUR_ACCESS_KEY");
  5. Begin automating the management of your account! For more details on what you can do with this codePush object, refer to the API reference section below.

API Reference

The code-push module exports a single class (typically referred to as CodePush), which represents a proxy to the CodePush account management REST API. This class has a single constructor for authenticating with the CodePush service, and a collection of instance methods that correspond to the commands in the management CLI, which allow you to programmatically control every aspect of your CodePush account.

Constructors

  • CodePush(accessKey: string) - Creates a new instance of the CodePush management SDK, using the specified access key to authenticated with the server.

Methods

  • addAccessKey(description: string): Promise<AccessKey> - Creates a new access key with the specified description (e.g. "VSTS CI").

  • addApp(name: string, os: string, platform: string, manuallyProvisionDeployments: boolean = false): Promise<App> - Creates a new CodePush app with the specified name, os, and platform. If the default deployments of "Staging" and "Production" are not desired, pass a value of true for the manuallyProvisionDesployments parameter.

  • addCollaborator(appName: string, email: string): Promise<void> - Adds the specified CodePush user as a collaborator to the specified CodePush app.

  • addDeployment(appName: string, deploymentName: string): Promise<Deployment> - Creates a new deployment with the specified name, and associated with the specified app.

  • clearDeploymentHistory(appName: string, deploymentName: string): Promise<void> - Clears the release history associated with the specified app deployment.

  • getAccessKey(accessKey: string): Promise<AccessKey> - Retrieves the metadata about the specific access key.

  • getAccessKeys(): Promise<AccessKey[]> - Retrieves the list of access keys associated with your CodePush account.

  • getApp(appName: string): Promise<App> - Retrieves the metadata about the specified app.

  • getApps(): Promise<App[]> - Retrieves the list of apps associated with your CodePush account.

  • getCollaborators(appName: string): Promise<CollaboratorMap> - Retrieves the list of collaborators associated with the specified app.

  • getDeployment(appName: string, deploymentName: string): Promise<Deployment> - Retrieves the metadata for the specified app deployment.

  • getDeploymentHistory(appName: string, deploymentName: string): Promise<Package[]> - Retrieves the list of releases that have been made to the specified app deployment.

  • getDeploymentMetrics(appName: string, deploymentName: string): Promise<DeploymentMetrics> - Retrieves the installation metrics for the specified app deployment.

  • getDeployments(appName: string): Promose<Deployment[]> - Retrieves the list of deployments associated with the specified app.

  • patchRelease(appName: string, deploymentName: string, label: string, updateMetadata: PackageInfo): Promise<void> - Updates the specified release's metadata with the given information.

  • promote(appName: string, sourceDeploymentName: string, destinationDeploymentName: string, updateMetadata: PackageInfo): Promise<Package> - Promotes the latest release from one deployment to another for the specified app and updates the release with the given metadata.

  • release(appName: string, deploymentName: string, updateContentsPath: string, targetBinaryVersion: string, updateMetadata: PackageInfo): Promise<Package> - Releases a new update to the specified deployment with the given metadata.

  • removeAccessKey(accessKey: string): Promise<void> - Removes the specified access key from your CodePush account.

  • removeApp(appName: string): Promise<void> - Deletes the specified CodePush app from your account.

  • removeCollaborator(appName: string, email: string): Promise<void> - Removes the specified account as a collaborator from the specified app.

  • removeDeployment(appName: string, deploymentName: string): Promise<void> - Removes the specified deployment from the specified app.

  • renameApp(oldAppName: string, newAppName: string): Promise<void> - Renames an existing app.

  • renameDeployment(appName: string, oldDeploymentName: string, newDeploymentName: string): Promise<void> - Renames an existing deployment within the specified app.

  • rollback(appName: string, deploymentName: string, targetRelease?: string): Promise<void> - Rolls back the latest release within the specified deployment. Optionally allows you to target a specific release in the deployment's history, as opposed to rolling to the previous release.

  • transferApp(appName: string, email: string): Promise<void> - Transfers the ownership of the specified app to the specified account.

Error Handling

When an error occurs in any of the methods, the promise will be rejected with a CodePushError object with the following properties:

  • message: A user-friendly message that describes the error.
  • statusCode: An HTTP response code that identifies the category of error:
    • CodePush.ERROR_GATEWAY_TIMEOUT: A network error prevented you from connecting to the CodePush server.
    • CodePush.ERROR_INTERNAL_SERVER: An error occurred internally on the CodePush server.
    • CodePush.ERROR_NOT_FOUND: The resource you are attempting to retrieve does not exist.
    • CodePush.ERROR_CONFLICT: The resource you are attempting to create already exists.
    • CodePush.ERROR_UNAUTHORIZED: The access key you configured is invalid or expired.