npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

burj

v1.3.0

Published

Customizable project structure generator. 🏗👷

Downloads

4

Readme

🏗 Burj - Structure generator

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

Prerequisites: Node.js 8.x or newer.

You can install the module from npm either globally

# Using npm
$ npm install -g burj

# Using yarn
$ yarn globals add burj

or locally

# 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 hierarchy. You can create new structure elements by running commands in your command line, like below:

# 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

// ./.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 router.

// ./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 section. It might be useful, e.g. for creating stateless / class components in React:

// ./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.:

$ 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.

License

Burj is MIT licensed.