Skip to content

Latest commit

 

History

History
140 lines (108 loc) · 4.66 KB

README.md

File metadata and controls

140 lines (108 loc) · 4.66 KB

Qilin package manager

Greenkeeper badge Build Status License npm version npm downloads

qilin-manager is a simple and minimal package manager which allows you to install plugins and themes for Qilin. Packages are downloaded and prepared from GitHub.

Installation

$ npm install qilin-manager

Usage

import QilinManager from "qilin-manager";

const qpm = new QilinManager();

qpm.install(package: string, namespace?: string): Promise

Asynchronously installs a specified package from GitHub. Once downloaded, the package is extracted in dest directory and properly prepared: its dependencies are downloaded by NPM and build scripts are launched.

Example:

Promise.all([
  qpm.install("userA/repo"),
  qpm.install("userB/repo", "namespaceB"),
  qpm.install("userC/repo", "namespaceC")
]).then(() => {
  console.log("Done!");
});

qpm.list(namespace?: string): Promise

Asynchronously returns a list of installed packages in dest directory under a given namespace. The returned list is an object whose keys correspond to packages names and values are objects containing:

  • namespace: plugin namespace;
  • directory: plugin parent directory;
  • version: same as in package.json;
  • package : full path to package.json;

Example:

const all = await qpm.list();
const themes = await qpm.list("themes");
const plugins = await qpm.list("plugins");

Example output:

{
    "packageA": {
        "namespace": "namespaceA",
        "directory": "packageA-master",
        "version": "x.x.x",
        "package": "[…]/namespaceA/packageA-master/package.json"
    },
    "packageB": {
        "namespace": "namespaceB",
        "directory": "packageB-master",
        "version": "x.x.x",
        "package": "[…]/namespaceB/packageB-master/package.json"
    }
}

qpm.update(namespace?: string): Promise

Asynchronously checks if locally installed packages under a certain namespace are up-to-date. If no, they are downloaded again.

Example:

qpm.update().then(/* … */);
qpm.update("themes").then(/* … */);
qpm.update("plugins").then(/* … */);

qpm.load(package: string, namespace?: string): Promise

Asynchronously loads then executes a script in a virtual machine (V8 sandbox) and returns it's module.exports back to the client. All the dependencies are resolved automatically.

Example:

const MyPlugin = await qpm.load("user/repo", "plugins");
const instance = new MyPlugin();

qpm.search(organization: string, filter?: string): Promise

Asynchronously searches a GitHub organization for repositories matching a specified filter.

Example:

const plugins = await qpm.search("organization", "project-plugin-");
const themes = await qpm.search("organization", "project-theme-");

Example output:

Refer to GitHub API.

Note: packages are built automatically once installed using qpm.install.

Installs dependencies for a given package and executes several NPM scripts in order to build the plugin. Scripts are executes in the order below:

  1. preinstall;
  2. install;
  3. postinstall;
  4. prepare;

Example:

qpm.build("full/path/to/package_A").then(/* … */);
qpm.build("full/path/to/package_B").then(/* … */);

Configuration

You can configure qilin-manager using environment variables.

Variable Description Default
DEBUG=qilin:* Outputs debug informations in terminal undefined
QPM_HOME Destination path for downloaded packages HOME/.qpm/
QPM_PROXY Custom proxy settings undefined