Giter VIP home page Giter VIP logo

cocoon-cloud-sdk's Introduction

Cocoon Cloud SDK Travis Build Status NPM Version Docs: API

bitHound Overall Score bitHound Dependencies bitHound Dev Dependencies bitHound Code

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_9.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_7.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

cocoon-cloud-sdk's People

Contributors

alebles avatar andonimartin avatar bluesialia avatar mortimergoro avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.