# kubozer

> Contactlab build utility

Latest version **1.2.1** (published 2018-04-16) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install kubozer
pnpm add kubozer
yarn add kubozer
bun add kubozer
```

Provides the command `kubozer`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2018-04-16 |
| First published | 2017-01-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 15 |
| Unpacked size | 344.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Contactlab Product Team |
| Maintainers | arual, contactlab-developer, equinusocio, giotramu, psantori, stefano_magrassi |
| Keywords | build, minify, vulcanize, webpack, kubozer, es6, projects, polymer |

## Links

- npm: https://www.npmjs.com/package/kubozer
- Repository: https://github.com/contactlab/kubozer
- Homepage: https://github.com/contactlab/kubozer#readme
- Issues: https://github.com/contactlab/kubozer/issues
- npm.io page: https://npm.io/package/kubozer

## Dependencies (15)

- [ora](https://npm.io/package/ora.md) 1.2.0
- [meow](https://npm.io/package/meow.md) 3.7.0
- [pify](https://npm.io/package/pify.md) 2.3.0
- [ramda](https://npm.io/package/ramda.md) 0.23.0
- [semver](https://npm.io/package/semver.md) 5.3.0
- [webpack](https://npm.io/package/webpack.md) 2.5.1
- [fs-extra](https://npm.io/package/fs-extra.md) 3.0.1
- [has-flag](https://npm.io/package/has-flag.md) 2.0.0
- [hashmark](https://npm.io/package/hashmark.md) 4.1.0
- [vulcanize](https://npm.io/package/vulcanize.md) 1.15.4
- [node-minify](https://npm.io/package/node-minify.md) 2.1.0
- [babel-loader](https://npm.io/package/babel-loader.md) 7.0.0
- [onesky-utils](https://npm.io/package/onesky-utils.md) 1.1.0
- [replace-in-file](https://npm.io/package/replace-in-file.md) 2.5.0
- [webpack-notifier](https://npm.io/package/webpack-notifier.md) 1.5.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2018-04-16
- 1.2.0 — 2017-05-23
- 1.1.0 — 2017-02-22
- 1.0.0 — 2017-02-20
- 0.2.2 — 2017-02-03
- 0.2.1 — 2017-02-03
- 0.1.2 — 2017-01-26
- 0.1.1 — 2017-01-19
- 0.1.0 — 2017-01-19

## README

# :warning: Deprecated

<p align="center">
    <img src="https://raw.githubusercontent.com/contactlab/kubozer/master/Kubozer.png" alt="Kubozer"/>
</p>

---

> The best tool for Contactlab projects builds :rocket:

[![GitHub tag](https://img.shields.io/github/release/contactlab/kubozer.svg?style=flat-square)](https://github.com/contactlab/kubozer)
[![Build Status](https://travis-ci.org/contactlab/kubozer.svg?branch=master)](https://travis-ci.org/contactlab/kubozer)
[![Coverage Status](https://coveralls.io/repos/github/contactlab/kubozer/badge.svg?branch=master)](https://coveralls.io/github/contactlab/kubozer?branch=master)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/contactlab/kubozer)
[![npm](https://img.shields.io/npm/dt/kubozer.svg?style=flat-square)](https://github.com/contactlab/kubozer)
[![Package Quality](http://npm.packagequality.com/shield/kubozer.png?style=flat-square)](http://packagequality.com/#?package=kubozer)

Kubozer is a wrapper of some tools for building production (and development) application written in Polymer 1.x. and ***ESnext*** syntax.

## Features
- **Copy** whatever files you need into your `build` directory
- **Replace** part of the `html` files where needed (like change the link within the index.html to your production-ready script) with [replace-in-file]()
- **Build** both `js` with [Webpack](https://github.com/webpack/webpack) and `html` (Polymer) with [Vulcanize](https://www.npmjs.com/package/vulcanize)
- **Minify** minify `CSS` with [node-minify](https://www.npmjs.com/package/node-minify) and `JS` with the Uglify Webpack plugin (only with `PRODUCTION` build)
- **Add a hash** to the built `js` and `css` files names in order to invalidate browser cache on every release (only with `PRODUCTION` build)

Other commands are included in the bundle of Kubozer:
- **Bump** for bump the version of your project
- **Translate** with [OneSkyApp](https://www.oneskyapp.com/)

## Install

    $ yarn add kubozer

## Usage

```bash
Usage
    $ [NODE_ENV=env_name] kubozer [option]

Options
    --build          Run the build task
    --bump           Semver label for version bump: patch, minor, major, prepatch, preminor, premajor, prerelease
    --config         Load specified Kubozer configuration file
    --webpack-config Load specified Webpack configuration file
    --i18n           Use I18N capabilities
    --upload         Use ONLY with --i18n option: upload a translation file
    --download       Use ONLY with --i18n option: download a translation file

Examples
    $ NODE_ENV=production kubozer --build
    $ kubozer --build --config=../../kubozer.conf.js --webpack-config=another-webpack.config.js
    $ kubozer --bump minor
    $ kubozer --i18n --upload en
    $ kubozer --i18n --download it
```

## Enviroment typed-build

The `PRODUCTION` build `(NODE_ENV=production)` will add the **minify** step to the process.  The **default** build will not produce a minified **JS** and also **CSS**.

If you want to handle a dynamic configuration, you can simply check the `process.env.NODE_ENV` within the `kubozer.conf.js` (or also `webpack.config.js`) and change the ***exported*** configuration in relation to the NODE_ENV.

## Configuration

Kubozer will search for two configurations file: `kubozer.conf.js` and `webpack.config.js` (standard Webpack configuration file)

### Kubozer
Example configuration.  **Kubozer will not assume nothing as default**.
```javascript
// kubozer.conf.js
module.exports = {
    workspace: './test/workspace',
    sourceFolder: './test/src-test',
    buildFolder: './test/build',
    // Relative to you workspace
    assetsFolder: 'assets',
    sourceCssFiles: ['/test.css'],
    buildCssFile: 'style.min.css',
    manifest: true,
    stripConsole: true,
    bump: {
        files: [
            './test/src-test/package.json',
            './test/src-test/manifest.json'
        ]
    },
    copy: [
        {
            baseFolder: 'assets',
            items: [
                'imgs-others'
            ]
        }, {
            baseFolder: 'bundles',
            items: [
                ''
            ]
        }
    ],
    replace: {
        css: {
            files: 'index.html',
            commentRegex: ['<!--styles!-->((.|\n)*)<!--styles!-->'],
            with: ['assets/style.min.css']
        },
        js: {
            files: 'index.html',
            commentRegex: ['<!--js!-->((.|\n)*)<!--js!-->'],
            with: ['bundle.js']
        }
    }
    vulcanize: {
        srcTarget: 'index.html',
        buildTarget: 'index.html',
        conf: {
            stripComments: true,
            inlineScripts: true,
            inlineStyles: true,
            excludes: ['bundle.js']
        }
    },
    i18n: {
        secret: 'thisisyoursecret',
        apiKey: 'heregoesyourapikey',
        projectId: 'heyaprojectid',
        defaultLanguage: 'en',
        format: 'HIERARCHICAL_JSON'
        languagesPath: './app/bundles'
    }
};
```

### Webpack
```javascript
// webpack.config.js
module.exports = {
    entry: {
        main: './src/index.js',
        // Other modules
        vendors: ['fetch', 'array-from']
    }
    output: {
        // Make sure this path is the same of the `buildFolder` of `kubozer.conf.js` if you want to build everithing in the same directory
        path: './test/build',
        // Make sure to use [name] or [id] in output.filename
        //  when using multiple entry points
        filename: '[name].bundle.js'
    },
    devtool: 'source-map',
    module: {
        loaders: [{
            test: /\.js?$/,
            // exclude: /(node_modules|bower_components)/,
            exclude: ['node_modules', 'bundle.js', 'build'],
            loader: 'babel-loader',
            query: {
                presets: ['es2015'],
                plugins: ['transform-es2015-spread', 'syntax-object-rest-spread', 'transform-object-rest-spread']
            }
        }]
    }
};
```

## Programmatic usage
```javascript
const Kubozer = require('kubozer');
const config = {...};
const webpackConfig = {...};

const isProd = process.env.NODE_ENV === 'production';

// Initialize (check for required config and init workspace folder)
const k = new Kubozer(config, webpackConfig);

// Sync operation
k.deletePrevBuild();

k.copy()
    .then(() => k.replace())
    .then(() => k.build(isProd))
    .then(res => {
        console.log(res);
    })
    .catch(err => {
        console.error(err);
    });
```

## API

### deletePrevBuild()
Simply delete the previous build in the "workspace" directory.

### copy()
Copy every elements within the object `copy`.

#### return `Promise`

### replace()
HTML replace in file. Set a placeholder in your HTML and remove/replace the inner elements during the build.

#### return `Promise`

### build([minify])
`Webpack` and `Vulcanize` following the configuration.

#### minify: boolean
Choose if minify the content of js files with [UglifyJS](https://github.com/mishoo/UglifyJS2) and css files with [clean-css](https://github.com/jakubpawlowicz/clean-css).
#### return `Promise`

### bump(type)
Bump to new version every file following the configuration.

#### type: string
Allowed values: patch | minor | major | prepatch | preminor | premajor | prerelease
#### return `Promise`

## Development

    $ git clone https://github.com/contactlab/kubozer.git#development
    $ yarn

### Build

    $ yarn run build

### Testing
> XO as linter and AVA for units.

    $ yarn test


### Git branching policies
Any feature/bug fixing/refactor must be developed on a **feature branch** derived from the **develop** branch and integrate the changes through a **pull request** to have a code review.

### License
Released under the [Apache 2.0](https://github.com/contactlab/kubozer/blob/master/LICENSE) license.

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