# boxescms

> ExpressJS based API centric CMS.

Latest version **0.13.2** (published 2019-06-25) · MIT license · 0 weekly downloads

## Install

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

Provides the command `boxes`.

## 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.13.2 |
| Published | 2019-06-25 |
| First published | 2018-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 53 |
| Unpacked size | 73.1 KB |
| Known vulnerabilities | 0 (+21 in 7 direct dependencies) |
| Install scripts | no |
| Author | JSON object |
| Maintainers | jsonobject |

## Links

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

## Dependencies (53)

- [qs](https://npm.io/package/qs.md) ^6.5.2
- [ava](https://npm.io/package/ava.md) ^0.25.0
- [del](https://npm.io/package/del.md) ^3.0.0
- [ncp](https://npm.io/package/ncp.md) ^2.0.0
- [pug](https://npm.io/package/pug.md) ^2.0.3
- [vue](https://npm.io/package/vue.md) ^2.5.17
- [glob](https://npm.io/package/glob.md) ^7.1.3
- [knex](https://npm.io/package/knex.md) ^0.15.2
- [bulma](https://npm.io/package/bulma.md) ^0.7.1
- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [apidoc](https://npm.io/package/apidoc.md) ^0.17.6
- [dotenv](https://npm.io/package/dotenv.md) ^6.0.0
- [eslint](https://npm.io/package/eslint.md) ^5.6.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [multer](https://npm.io/package/multer.md) ^1.3.1
- [express](https://npm.io/package/express.md) ^4.16.3
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.12.0
- [nodemon](https://npm.io/package/nodemon.md) ^1.18.4
- [webpack](https://npm.io/package/webpack.md) ^4.20.0
- [chokidar](https://npm.io/package/chokidar.md) ^2.0.4
- [get-port](https://npm.io/package/get-port.md) ^4.0.0
- [mustache](https://npm.io/package/mustache.md) ^3.0.0
- [pug-lint](https://npm.io/package/pug-lint.md) ^2.5.0
- [standard](https://npm.io/package/standard.md) ^12.0.1
- [through2](https://npm.io/package/through2.md) ^2.0.3
- [commander](https://npm.io/package/commander.md) ^2.18.0
- [node-sass](https://npm.io/package/node-sass.md) ^4.9.3
- [css-loader](https://npm.io/package/css-loader.md) ^1.0.0
- [raw-loader](https://npm.io/package/raw-loader.md) ^0.5.1
- [vue-loader](https://npm.io/package/vue-loader.md) ^15.4.2
- [vue-router](https://npm.io/package/vue-router.md) ^3.0.1
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.1.0
- [compression](https://npm.io/package/compression.md) ^1.7.3
- [sass-loader](https://npm.io/package/sass-loader.md) ^7.1.0
- [vinyl-named](https://npm.io/package/vinyl-named.md) ^1.1.0
- [autoprefixer](https://npm.io/package/autoprefixer.md) ^9.1.5
- [babel-eslint](https://npm.io/package/babel-eslint.md) ^9.0.0
- [babel-loader](https://npm.io/package/babel-loader.md) ^8.0.2
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.3.0
- [normalize.css](https://npm.io/package/normalize.css.md) ^8.0.0
- [webpack-merge](https://npm.io/package/webpack-merge.md) ^4.1.4
- [dotenv-webpack](https://npm.io/package/dotenv-webpack.md) ^1.5.7
- [postcss-loader](https://npm.io/package/postcss-loader.md) ^3.0.0
- [pug-plain-loader](https://npm.io/package/pug-plain-loader.md) ^1.0.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.1.0
- [eslint-plugin-vue](https://npm.io/package/eslint-plugin-vue.md) ^5.0.0-beta.3
- [babel-plugin-lodash](https://npm.io/package/babel-plugin-lodash.md) ^3.3.4
- [vue-template-compiler](https://npm.io/package/vue-template-compiler.md) ^2.5.17
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.1.0
- [@babel/plugin-proposal-decorators](https://npm.io/package/@babel/plugin-proposal-decorators.md) ^7.1.0
- [@babel/plugin-syntax-dynamic-import](https://npm.io/package/@babel/plugin-syntax-dynamic-import.md) ^7.0.0
- [@babel/plugin-proposal-class-properties](https://npm.io/package/@babel/plugin-proposal-class-properties.md) ^7.1.0

## Recent versions

- 0.13.2 (latest) — 2019-06-25
- 0.13.1 — 2019-04-22
- 0.13.0 — 2019-02-13
- 0.12.2 — 2019-02-07
- 0.12.1 — 2019-01-07
- 0.12.0 — 2019-01-07
- 0.11.8 — 2018-12-20
- 0.11.7 — 2018-12-20
- 0.11.6 — 2018-11-29
- 0.11.5 — 2018-11-08
- 0.11.4 — 2018-11-08
- 0.11.3 — 2018-11-06
- 0.11.2 — 2018-11-02
- 0.11.1 — 2018-10-31
- 0.11.0 — 2018-10-09
- … 57 more at https://npm.io/package/boxescms/versions

## README

# boxescms

ExpressJS based API centric static site CMS.

## Underlying tools

* [Express](https://expressjs.com/)
* [Sass](http://sass-lang.com/)
* [Pug](https://pugjs.org)
* [Webpack](https://webpack.js.org/)
* [Babel](https://babeljs.io/)
* [Vue.js](https://vuejs.org/)

## Kickstart Development

1. `npm init` (If you haven't already)

2. `npm install boxescms`

3. `npx boxes init`

4. `npm start dev`

## Folder/File Structure

### /.env

Env variables. Copy from .env.example.

### /app.js (optional)

Optional `app.js` to extend the Express app instantiated from BoxesCMS. Must export a function or `preinit`/`postinit` functions that receives the app as first argument.

### /data/**/*.{js,json,yml}

Data layer as Pug locals for static HTML generation. For `js` type, it must export an object. See [Template Data](#template-data) section for more details.

### /server/

Server and node related files.

#### /server/api/

Only API routes. All routes are prepended with `/api`, appended with folder/file relative path. Routes should be declared using `require('express').Router()`.

#### /server/routes/

Additional custom routes.

### /web/

Web related files (html, pug, sass, scss, js, images, statics).

#### /web/pug

Pug files that will be compiled `/public/**/*.html`.

#### /web/{sass,scss}

SASS/SCSS files that will be compiled to `/public/css/**/*.css`.

#### /web/js

JS files that will be compiled to `/public/js/**/*.js`.

#### /web/images

Images that will be copied to `/public/images`.

#### /web/static

Statics that will be copied to `/public/static`.

#### /web/template

Pug template files for data use. See [Template Data](#template-data) section for more details.

### /public/

Web files will be compiled here, and served as root static by Node server.

### /storage/

Contents should be ignored. Storage folder for various runtime data usage.

### /conf/

External configuration files.

### /webpack.merge.js

Optional Webpack configuration. This configuration will be merged into the default configuration.

## Builders

### JS

There is 2 special env var that you can use in your JS files:

- process.env.VERSION
- process.env.BUILD_HASH

`process.env.VERSION` is taken from your project's `package.json`.version.

`process.env.BUILD_HASH` is a randomly generated per build 64 length hex char.

## Template Data

The data files in `/data/**/*.{js,json,yml}` is used in 2 ways:

1. When compiling `/web/pug/[**/*].pug` file, if there is a matching `/data/[**/*].{js,json,yml}` file, it will use the data file as the locals for Pug compilation. The pug files will be compiled to `/public/[**/*].html`.

  - /web/pug/page.pug

  ```
  head
    title=pagetitle
  ```

  - /data/page.yml

  ```
  pagetitle: Hello World
  ```

  - /public/page.html

  ```
  <head><title>Hello World</title></head>
  ```

2. If a data file in `/data/**/*.{js,json,yml}` has a key `.template`, the `.template` value will use `/web/template` as root to search for the pug file to compile, e.g.: `/web/template/['.template'].pug}`. The output file for `/data/[**/*].{js,json,yml}` is `/public/[**/*].html`

  - /data/page.json

  ```
  {
    ".template": "base.pug",
    "pagetitle": "Hello World"
  }
  ```

  - /web/template/base.pug

  ```
  head
    title=pagetitle
  ```

  - /public/page.html

  ```
  <head><title>Hello World</title></head>
  ```

## Dotfiles Template Data (JS)

Apart from a general template data, you can create dotfiles to create multiple pages under a single template. Currently only supports `.js` file, in `/data/**/.*.js`

The data file must contain `.template` key to define what template to use. Subsequent keys will be the page to create, and the value is an object of the locals to use for that page.

The file should export a Promise instance, in which allows you to perform async operations to populate the final object to resolve.

  - /data/.pages.js

  ```
  const data = {
    '.template': 'index.pug',
    '/dashboard': {
      title: 'Dashboard'
    }
  }

  module.exports = new Promise((resolve, reject) => {
    // async operations if needed

    resolve(data)
  })
  ```

  - /public/dashboard.html

  ```
  <head><title>Dashboard</title></head>
  ```

## Server Debug Mode

The node inspector can be enabled by passing `--inspect [port=9229]` to `boxes start` command. You can either use `chrome://inspect` on Chrome browser to use the default `.vscode/launch.json` from init to attach debugger.

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