# node-kpc

> build KISSY packages

Latest version **0.5.0** (published 2014-12-09) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install node-kpc
pnpm add node-kpc
yarn add node-kpc
bun add node-kpc
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2014-12-09 |
| First published | 2013-11-18 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+9 in 2 direct dependencies) |
| Install scripts | no |
| Author | maxbbn |
| Maintainers | abc-team, maxbbn |
| Keywords | KISSY, abc |

## Links

- npm: https://www.npmjs.com/package/node-kpc
- Repository: https://github.com/abc-team/node-kpc
- Issues: https://github.com/abc-team/node-kpc/issues
- npm.io page: https://npm.io/package/node-kpc

## Dependencies (7)

- [glob](https://npm.io/package/glob.md) ~3.2.7
- [lodash](https://npm.io/package/lodash.md) ~2.4.1
- [mkdirp](https://npm.io/package/mkdirp.md) ~0.3.5
- [esprima](https://npm.io/package/esprima.md) ~1.0.4
- [eswalker](https://npm.io/package/eswalker.md) ~0.1.2
- [escodegen](https://npm.io/package/escodegen.md) 0.0.28
- [minimatch](https://npm.io/package/minimatch.md) ~0.2.14

## Recent versions

- 0.5.0 (latest) — 2014-12-09
- 0.4.0 — 2014-08-11
- 0.3.12 — 2014-06-11
- 0.3.11 — 2014-06-11
- 0.3.10 — 2014-05-14
- 0.3.9 — 2014-03-28
- 0.3.7 — 2014-03-27
- 0.3.6 — 2014-03-26
- 0.3.5 — 2014-03-18
- 0.3.3 — 2014-03-07
- 0.3.2 — 2014-01-26
- 0.3.1 — 2014-01-26
- 0.3.0 — 2013-12-19
- 0.2.0 — 2013-12-16
- 0.1.3 — 2013-12-13
- … 5 more at https://npm.io/package/node-kpc/versions

## README

# KPC

Build a KISSY package, for KISSY 1.3+.

[![build status](https://secure.travis-ci.org/abc-team/node-kpc.png)](http://travis-ci.org/abc-team/node-kpc)

## Features

- Simple
- KISSY 1.3+
- Online combo only
- Support CJS Style
- Support Module Name Flatten
- Support KISSY.add auto generate for no-kissy module

## Installation

This module is installed via npm:

``` bash
$ npm install node-kpc
```

## API

### kpc.build(options[, files])
- options.name, String, Name of package, required
- options.path, String, Path of package, required
- options.flatten, Boolean, false, 是否压缩模块名, optional
- files Array|String, Files to compile, optional


### kpc.compile(options[, files])

- options.name, String, Name of package, required
- options.path, String, Path of package, required
- options.flatten, Boolean, false, 是否压缩模块名, optional
- files Array|String, Files to compile, optional
- Return Object

### kpc.generateDepFile(modules);

- modules Object, the module object compiled
- return String


## Example Usage

#### Case1. Build all file in a Package

``` js
var kpc = require('node-kpc');

// build a package
kpc.build({
    pkg: {
        name: 'xcake',
        path: 'sample/src'
    },
    dest: 'sample/build', // where the package is build to
    depFile: 'sample/build/map.js'
});

```


<table>
    <thead>
        <tr>
            <th>Before</th>
            <th>After</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
<pre>
sample/src
├── app
│   ├── cjs-full.js
│   ├── cjs.js
│   ├── fac-config.js
│   ├── name-fac-config.js
│   ├── no-kissy.js
│   ├── object.js
│   └── string.js
└── pages
    └── home
        ├── index.js
        └── mod.js
</pre>
            </td>
            <td>
<pre>
sample/build
├── app
│   ├── cjs-full.js
│   ├── cjs.js
│   ├── fac-config.js
│   ├── name-fac-config.js
│   ├── no-kissy.js
│   ├── object.js
│   └── string.js
├── map.js
└── pages
    └── home
        ├── index.js
        └── mod.js
</pre>
            </td>
        </tr>
    </tbody>
</table>

#### Case2. Specify Files to build

``` js
var kpc = require('node-kpc');

// build a package
kpc.build({
    pkg: {
        name: 'xcake',
        path: 'sample/src'
    },
    dest: 'sample/build', // where the package is build to
    depFile: 'sample/build/map.js' //
}, ['sample/src/app/*.js']);

```
After build:
<table>
    <thead>
        <tr>
            <th>src</th>
            <th>dest</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
<pre>
sample/src
├── app
│   ├── cjs-full.js
│   ├── cjs.js
│   ├── fac-config.js
│   ├── name-fac-config.js
│   ├── no-kissy.js
│   ├── object.js
│   └── string.js
└── pages
    └── home
        ├── index.js
        └── mod.js
</pre>
            </td>
            <td>
<pre>
sample/build
├── app
│   ├── cjs-full.js
│   ├── cjs.js
│   ├── fac-config.js
│   ├── name-fac-config.js
│   ├── no-kissy.js
│   ├── object.js
│   └── string.js
└─ map.js

</pre>
            </td>
        </tr>
    </tbody>
</table>



#### Case3. Compile a package (all file in package path)

````js
var kpc = require('node-kpc');

var pkg = kpc.compile({
    name: 'xcake',
    path: 'sample/src'
});

console.log(pkg);

```

the pkg look like this

```json
{
    "files": [
        {
            "srcCode": "/**\n * @fi...",
            "isKISSY": true,
            "modules": [
                {
                    "name": "xcake/app/cjs",
                    "requires": [
                        "node",
                        "../components/header/",
                        "./mod/",
                        "./example.css"
                    ]
                }
            ],
            "genCode": "/**\n * @fi...",
            "filename": "app/cjs.js",
            "srcFile": "sample/src/app/cjs.js"
        }
    ],
    "ignoredFiles": [],
    "modules": {
        "xcake/app/cjs": {
            "requires": [
                "node",
                "../components/header/",
                "./mod/",
                "./example.css"
            ]
        }
    }
}
```

#### Case5. Specify files to compile

````js
var kpc = require('node-kpc');

var pkg = kpc.compile({
    name: 'xcake',
    path: 'sample/src'
}, ['sample/src/app/*']);

console.log(pkg);

```

---
_Source: https://npm.io/package/node-kpc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
