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

cocoon-cloud-sdk

v3.0.0

Published

Cocoon.io is a cloud service that allows any web developer to build performant mobile native apps/games based on their HTML5 content.

Downloads

21

Readme

Cocoon Cloud SDK Travis Build Status NPM Version Docs: API

Dependencies devDependencies Maintainability Test Coverage


The Cocoon Cloud SDK is the easiest way to integrate the Cocoon.io cloud compiler in any service or app. With this simple API, anyone can authenticate with their Cocoon.io account and create, update and compile HTML5 projects in the cloud programmatically.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

First things first. In order to access the Cocoon.io API you will need a ClientID credential (a ClientSecret too if your code runs in a server). You can contact us at [email protected] to request it.

Other than that, you only need to have NodeJS and NPM installed in your system.

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install -y nodejs

Installing

Clone the repository.

git clone https://github.com/CocoonIO/cocoon-cloud-sdk.git

And install its dependencies

npm install

The transpiled code should be in the out folder.

Running the tests

The tests are found in spec/tests.

npm test

Coding style tests

To inspect the code style of the source code:

npm run inspect-src

To inspect the code style of the tests:

npm run inspect-spec

Deployment

To use this repo as a NPM module in your project follow these instructions.

As mentioned previously: to access the Cocoon.io API you will need a ClientID credential (a ClientSecret too if your code runs in a server). You can contact us at [email protected] to request it.

Install NodeJS and NPM in your system.

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install -y nodejs

Install the module from NPM.

npm install cocoon-cloud-sdk  --save

You must use a module bundler like Webpack to use it in a browser. Make sure the node definitions are included if you use typescript

{
   "compilerOptions": {
       "typeRoots" : ["node_modules/@types"],
       "types" : ["node"]
   }
}

And import it in your NodeJS or Web project.

import * as cocoonSDK from "cocoon-cloud-sdk";

Documentation

You can read the documentation at CocoonIO.github.io/cocoon-cloud-sdk.

Example

You can see an example of the usage in sample.

Usage

Log In into Cocoon.

const oAuth = new cocoonSDK.OAuth(grantType.Password, CLIENT_ID, CLIENT_SECRET);
oAuth.tokenExchangePassword("[email protected]", "12345678")
.then((response) => {
	cocoonSDK.CocoonAPI.setupAPIAccess(response.access_token, response.refresh_token, response.expires_in);
});

Some API Examples. The SDK mimics the Cocoon.io REST API.

The Project API:

//List all projects
cocoonSDK.ProjectAPI.list()
.then((projects) => {
	doSomething();
})
.catch((error) => {
	fixSomething();
});

//Create a new project by uploading a zip file
cocoonSDK.ProjectAPI.createFromZipUpload(file)
.then((project) => {
	doSomething();
})
.catch((error) => {
	fixSomething();
});

//Create a new project from a url
cocoonSDK.ProjectAPI.createFromURL("MY_URL")
.then((project) => {
	doSomething();
})
.catch((error) => {
	fixSomething();
});

//Create a new project from a repository
cocoonSDK.ProjectAPI.createFromRepository({url:"MY_GITHUB_URL", branch:"MY_BRANCH"})
.then((project) => {
	doSomething();
})
.catch((error) => {
	fixSomething();
});

For Signing Keys:

//List all signing keys
cocoonSDK.SigningKeyAPI.list()
.then((signingKeys) => {
	doSomething();
})
.catch((error) => {
	fixSomething();
});

//Create a new Android signing key
cocoonSDK.SigningKeyAPI.createAndroid(name, alias, keystore, keystorePassword, certificatePassword)
.then((signingKey) => {
	doSomething();
})
.catch((error) => {
	fixSomething();
});

The objects returned by the API have their own methods to ease commonly performed tasks.

//Working with a Project object
cocoonSDK.ProjectAPI.get("PROJECT_ID")
.then((project) => {
	//project.isCompiling();
	//project.updateZip(zipFile);
	//project.delete();
	//project.assignSigningKey(signingKey);
	//...
})
.catch((error) => {
	fixSomething();
});

//Working with a Signing Key object
cocoonSDK.SigningKeyAPI.get("SIGNING_KEY_ID")
.then((signingKey) => {
	//signingKey.delete();
})
.catch((error) => {
	fixSomething();
});

Built With

  • Typescript - Language
  • NPM - Dependency Management
  • Jasmine - Testing Framework
  • Popsicle - Simple HTTP requests library for node and the browser
  • XMLSugar - Helper functions to work with the config.xml

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details