@canner/canner-tools

canner tools

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@canner/canner-tools
0.3.187 years ago7 years agoMinified + gzip package size for @canner/canner-tools in KB

Readme

canner-tools
These are the Canner Command Line Interface (CLI) Tools

Administrative Commands App Commands Schema Commands Data Commands Statics Commands .cannerrc canner.schema.js canner.data.js

Installation

$ npm install -g canner-tools

Usage

canner --help

Get Started

example

Commands

The command canner --help lists the available commands and canner <command> --help shows more details for and individual command.
Remeber to login first before you start to use these commands.

Administrative Commands

<td>Command</td>
<td>Description</td>
<td>login</td>
<td>
  Log in to canner. Required before using other commands
</td>
<td>logout</td>
<td>Log out from canner.</td>
<td>init</td>
<td>Create <a href="#.cannerrc"><code>.cannerrc</code></a> configureation file in your current directory. Also you can use this to change the configureation if you want.</td>

App Commands

<td>Command</td>
<td>Description</td>
<td>app:list</td>
<td>List all your apps their infos.</td>

Schema Commands

<td>Command</td>
<td>Description</td>
<td>schema:deploy</td>
<td>
  Deploy your <a href="#cannerschemajs"><code>canner.schema.js</code></a> to the default app url which setted in <code>.cannerrc</code>, or you can use option <code>-u <url>, --url <url></code> to deploy schema to the specific app.
</td>

Data Commands

<td>Command</td>
<td>Description</td>
<td>Options</td>
<td>data:import</td>
<td>
  Import your <a href="#cannerdatajs"><code>canner.data.js</code></a>  to the default app url which setted in <code>.cannerrc</code>.
  在 Canner 與 Firebase 上的表現有些許差異。
  <li>在 Canner 上如果是 <code>object</code> 會直接覆蓋資料,如果是 <code>array</code> 會 append 在原本資料後面。 </li>
  <li>在 Firebase 上只要有相同 key 的資料,就無法 import。 必須使用 <code>-d, --drop-first</code> </li>
</td>
<td>
  <li><code>-u <url<, --url <url></code> to import data to the specific app.</li>
  <li><code>-d, --drop-first</code> to drop the data before import. Be careful to use this option</li>
</td>

Statics Commands

You can use Canner to host your statics files, like html, css, js, image and etc. Just upload them to the app.
html files have to be placed in pages, and others in statics
  • pages
index.html other.html otherFolder
* other1.html
  • statics
anyfiles
<td>Command</td>
<td>Description</td>
<td>serve</td>
<td>
  This will serve the current folder.
  Before you upload statics files to app, you could use this command to confirm the result is correct.
</td>
<td>statics:upload</td>
<td>
  Upload the directories, <code>pages</code> and <code>statics</code> to the default app url which setted in <code>.cannerrc</code>, or you can use option <code>-u <url<, --url <url></code> to upload statics files to the specific app.
</td>

Files

.cannerrc

The file created when you use command canner init. You can also create this manually.
{
  "app": {
    "default": "<your app url>"
  }
}

canner.schema.js

This file declares the data info, and would be deploy when you use command canner schema:deploy. It's written with CannerTypes. To know more, you could read Canner Handbook
// canner.schema.js
/* global CannerTypes */
module.exports = {
  home: CannerTypes.object({
    intro: CannerTypes.string().description('介紹')
  }).description('首頁');
}

canner.data.js

This js file is the data you want to import to your app, would be imported when you use command canner data:import. To know more, you could read Canner Handbook
// canner.data.js
module.exports = {
  home: {
    intro: 'canner.data.js exports the data'
  }
}

You can use ImageService to uplaod image.
// canner.data.js
/* global ImageService */
module.exports = {
  home: {
    backgroundImg: ImageService.image('relative/path/to/img')
  }
}

.canner-image-uploaded.json

If you use feature auto upload image in canner.data.js. This json file saves the checksum and url of the uploaded images to prevent from uploading the duplicated images.

.canner-statics-uploaded.json

This json file saves the checksum of the statics file to prevent from uploading the duplicated files.