# burj

> Customizable project structure generator. 🏗👷

Latest version **1.3.0** (published 2019-02-28) · MIT license · 0 weekly downloads

## Install

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

Provides the command `burj`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2019-02-28 |
| First published | 2018-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.10.0 |
| Dependencies | 4 |
| Unpacked size | 191.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Michał Wilk |
| Maintainers | whereiswolf |
| Keywords | customizable, project, structure, generator, hierarchy, scripts, templates, folders, file, files, custom |

## Links

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

## Dependencies (4)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [optionator](https://npm.io/package/optionator.md) ^0.8.2
- [import-fresh](https://npm.io/package/import-fresh.md) ^3.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2019-02-28
- 1.2.3 — 2019-02-22
- 1.2.2 — 2018-11-24
- 1.2.1 — 2018-11-17
- 1.2.0 — 2018-11-09
- 1.1.0 — 2018-11-06
- 1.0.1 — 2018-11-05
- 1.0.0 — 2018-11-05
- 0.3.0 — 2018-11-05
- 0.2.5 — 2018-11-05
- 0.2.4 — 2018-11-05
- 0.2.3 — 2018-11-05
- 0.2.2 — 2018-11-05
- 0.2.1 — 2018-11-05
- 0.2.0 — 2018-11-05
- … 1 more at https://npm.io/package/burj/versions

## README

# 🏗<img src="https://raw.githubusercontent.com/whereiswolf/burj/master/docs/img/burj-icon.svg?sanitize=true" alt="👷" style="margin-bottom: -10px;"/> Burj - Structure generator
<a href="https://badge.fury.io/js/burj"><img src="https://badge.fury.io/js/burj.svg" alt="npm version"></a>
<a href="https://app.buddy.works/wilkmichal/burj/pipelines/pipeline/158825"><img src="https://app.buddy.works/wilkmichal/burj/pipelines/pipeline/158825/badge.svg?token=751959f2bb6d9861152a2c0a77dbe2521d6d1bf2b421703a49c05640993a488c"></a>
<a href="https://codecov.io/gh/whereiswolf/burj"><img src="https://codecov.io/gh/whereiswolf/burj/branch/master/graph/badge.svg" /></a>
<a href="https://david-dm.org/whereiswolf/burj"><img src="https://david-dm.org/whereiswolf/burj.svg"></a>
<a href="https://david-dm.org/whereiswolf/burj?type=dev"><img src="https://david-dm.org/whereiswolf/burj/dev-status.svg"></a>
<a href="https://github.com/whereiswolf/burj/blob/HEAD/LICENSE"><img src="https://img.shields.io/packagist/l/doctrine/orm.svg"></a>

<img src="https://raw.githubusercontent.com/whereiswolf/burj/master/docs/img/burj-terminal.gif" width ="640"/>

Burj is a command line tool built to help developers create and maintain a clean project structure and speed up the process of creating components, routes, services, etc. By giving access to custom file templates it can be used in a variety of projects, no matter if they're back-end or front-end ones. It's meant to be easy and quick to use, as well as to provide a highly flexible project structure.

## Table of contents
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Default structure](#default-structure)
- [Author](#author)
- [License](#license)

## Installation
**Prerequisites**: [Node.js](https://nodejs.org/) 8.x or newer.

You can install the module from [npm](https://npmjs.com) either globally
```bash
# Using npm
$ npm install -g burj

# Using yarn
$ yarn globals add burj
```
or locally
```bash
# Using npm
$ npm install --save-dev burj

# Using yarn
$ yarn add -D burj
```
**Keep in mind that you have to use**

`$ ./node_modules/.bin/burj ...`

**instead of**

`$ burj ...`

**if you installed the package locally.**

## Usage
If you don't want to define your own project structure, you can use default file templates that will follow [this](#default-structure) hierarchy. You can create new structure elements by running commands in your command line, like below:
``` bash
# burj [type] [name] [...params]
# or burj --new [type] [name] [...params]
# or burj -n [type] [name] [...params]

$ burj component AwesomeFooter
$ burj reducer user
$ burj action savePhoto
$ burj view LoginPage class redux
$ burj route books
```
- `type` - defines which structure element will be created.
- `name` - name of the file(s) to be created.
- `params` - all other params that you want to pass to the template.

## Configuration
To define a custom structure:
- Create a `.burjrc`, `.burjrc.json` or `.burjrc.js` file in the root directory of your project.
- Create a directory for template files and code them.

### `.burjrc` file
```javascript
// ./.burjrc
{
  "baseDir": "./src", // Path to new structure elements
  "templatesDir": "./templates", // Path to templates
  "structure": {
    // Name of structure elements
    "components": {
      "wrapElements": true, // Should create files inside of a new directory
      "elements": [
        {
          "extension": ".jsx",
          "template": "./component" // Path to template
        },
        {
          "extension": ".test.js",
          "template": "./test",
          "path": "../../../test/components/" // Override default creation path
        },
        {
          "filename": "index.js", // Override file name
          "template": "./index"
        },
        {
          // components/index.js for exporting all components
          "filename": "index.js",
          "template": "./export",
          "append": true, // Append to file instead of writing
          "path": "../",
        }
      ]
    },
    "weirdOnes": {
      "elementType": "weird", // Use if plural name is not singular + 's'
      "elements": [
        { "extension": ".asd", "template": "./weird" }
      ]
    }
  }
}
```

### Template files
Template file should be created as a JavaScript module that exports a function. Below you can see an example template file that will create a simple [express.js](https://expressjs.com/) router.
```javascript
// ./templates/route.js
module.exports = ({ name, type, params } = {}) => `const express = require('express');

const router = express.Router();

router.use('/', (req, res) => res.send('This is an awesome ${name} route!'));

module.exports = router;
`;
```
Keep in mind that you can make use of `type`, `name` and `params` arguments described in [usage](#usage) section. It might be useful, e.g. for creating stateless / class components in React:
```javascript
// ./templates/component.js
module.exports = ({ name, type, params } = {}) => {
  const [variant] = params;

  return variant === 'class'
    ? classComponentString(name)
    : statelessComponentString(name);
}
```

## Default structure
You can use default templates provided with this module:

### React component
`$ burj component CoolButton`

Will create the following files:
```
|-- src
|   |-- components
|       |-- index.js - Adds export
|       |-- CoolButton
|       |   |-- CoolButton.jsx
|       |   |-- CoolButton.style.js
|       |   |-- index.js
|       | ...
|-- test
|   |-- components
|       |-- CoolButton.test.jsx
|       | ...
```
Additionaly you can specify params such as `class` or `redux`, which will generate a class component and/or connect it to redux, e.g.:
``` bash
$ burj component CoolButton class
$ burj component CoolButton redux
$ burj component CoolButton class redux
```
### React view component
It's the same as a component but can be used as a container.

`$ burj view LoginPage`

### Action
`$ burj action books`

Will create the following files:
```
|-- src
|   |-- actions
|       |-- books.js
|       | ...
|-- test
|   |-- actions
|       |-- books.js
|       | ...
```
Additionaly you can specify a name of an action creator that will be created in a new file.
```
$ burj actions books getBook
```

### Reducer
`$ burj reducer books`

Will create the following files:
```
|-- src
|   |-- reducers
|       |-- books.js
|       | ...
|-- test
|   |-- reducers
|       |-- books.js
|       | ...
```
### Route
`$ burj route auth`

Will create the following files:
```
|-- src
|   |-- routes
|       |-- auth.js
|       | ...
|-- test
|   |-- routes
|       |-- auth.js
|       | ...
```

## Author
Michał Wilk - [whereiswolf](https://github.com/whereiswolf).

## License
Burj is [MIT licensed](./LICENSE).

<div>Icons made by <a href="https://www.flaticon.com/authors/monkik" title="monkik">monkik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>

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