Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/debitoor/nocms
"NO, You don't need a CMS"
https://github.com/debitoor/nocms
cli static-site-generator
Last synced: about 1 month ago
JSON representation
"NO, You don't need a CMS"
- Host: GitHub
- URL: https://github.com/debitoor/nocms
- Owner: debitoor
- Created: 2017-01-18T17:34:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-09-12T09:08:58.000Z (about 4 years ago)
- Last Synced: 2024-10-23T03:00:03.866Z (about 2 months ago)
- Topics: cli, static-site-generator
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/nocms
- Size: 2.68 MB
- Stars: 14
- Watchers: 26
- Forks: 1
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - debitoor/nocms - "NO, You don't need a CMS" (cli)
README
# NOCMS
"NO, You don't need a CMS" is what you are going to tell your boss the next time he comes running waving his arms and yelling incomprehensibly about some new microsite for his wife's pony he wants to make in drupal, wordpress or any of the 1 billion other "let's stuff all your content in a mysql database and front it with some 10 year old php scripts" things that pop up in your facebook feed disguised as content.[![Build Status](https://travis-ci.org/debitoor/nocms.svg?branch=master)](https://travis-ci.org/debitoor/nocms)
[![NPM Version](https://img.shields.io/npm/v/nocms.svg)](https://www.npmjs.com/package/nocms)## Install
``` bash
$ npm install nocms --save
```### Plugins by @debitoor
* [nocms-plugin-directory-resources](https://www.npmjs.com/package/nocms-plugin-directory-resources)
* [nocms-plugin-file-resources](https://www.npmjs.com/package/nocms-plugin-file-resources)
* [nocms-plugin-image-resources](https://www.npmjs.com/package/nocms-plugin-image-resources)
* [nocms-plugin-json-resources](https://www.npmjs.com/package/nocms-plugin-json-resources)## CLI Usage
### Compile
Compiles all resources in the input directory and writes them to the output directory.``` bash
$ nocms compile --in-dir ./src/ --out-dir ./compiled/
```### Server
Runs a webserver on the port given and compiles resources in the input directory and writes them to the output directory before serving them to the user.
``` bash
$ nocms server --in-dir ./src/ --out-dir ./compiled/ --port 1234
```NOCMS is multithreaded and spins of one worker instance for each cpu as reported by `os.cpus()`.
## Plugins
A Plugin is any module that exports an `activate` function that when invoked registers one or more providers.``` javascript
export function activate (pluginActivationContext)
```Plugins installed in `node_modules` will be activated automatically.
### pluginActivationContext
The plugin activation context gives plugins access to provider registration and to IO functions bound to the input and output directories.* findFiles
* readFile
* registerResourceProvider
* watchFiles
* writeFile#### findFiles
Finds files relative to the input directory. Returns a `Promise` that resolves with an `Array` of file paths relative to the input directory.``` javascript
async function findFiles (pattern, options)
```Parameters:
* pattern: [Glob](https://github.com/isaacs/node-glob) pattern,
* options: Glob options#### readFile
Asynchronously reads the contents of a file relative to the input directory. Returns a `Promise` that resolves with the contents of the file, a `String` or a `Buffer`.``` javascript
async function readFile (file, options)
```Parameters:
* file: File path relative to the input directory
* options: Same as when calling fs.readFile#### registerResourceProvider
Registers a resource provider with NOCMS. See [Resource Provider](#resource-provider).``` javascript
function registerResourceProvider (resourceProvider)
```Parameters:
* resourceProvider: An instance of a resource provider#### watchFiles
Watches files relative to the input directory. Returns a [chokidar](https://github.com/paulmillr/chokidar) instance.``` javascript
function watchFiles (pattern, options)
```Parameters:
* pattern: Glob pattern
* options: Chokidar options#### writeFile
Asynchronously writes a file to the output directory. Automatically creates any missing parts of the file path before writing the file. Returns a promise.``` javascript
async function writeFile (file, data, options) {}
```Parameters:
* file: file path relative to the output directory.
* data: `String` or `Buffer`
* options: Same as fs.writeFileExample:
``` javascript
let html = '';
await writeFile('index.html', html, 'utf8');
```### Resource Provider
Resource Providers are responsible for collecting meta data for, and compiling resources. A resource provider has two functions:#### getResources
Asynchronously provides an `Array` of resource objects. A resource must as a minimum have an `id` field.``` javascript
async function getResources ()
```#### compileResource
Asynchronously compiles a resource object and writes the result to the file system. Returns a `Promise` that resolves with `undefined`.``` javascript
async function compileResource (resource, resourceCompilationContext)
```Parameters:
* resource: a resource object
* resourceCompilationContext: a resource compilation context.#### Resource Compilation Context
The resource compilation context is an object with two fields.* resourceMap: a id/resource map of all resources from all resource providers
* resourceTree: a resource tree of all resources from all resource providersThe resource compilation context can be used to provide resource meta data to templates during compilation.
## Config
Configurations can be written in a `.nocmsrc` file at the root of the project, and will be served as json to plugins.
## Develop
### Bootstrap
Run lerna bootstrap``` bash
$ npm run bootstrap
```### Build
``` bash
$ npm run build
```### Test
``` bash
$ npm test
```The end to end tests (rather integration than e2e) are in the root of the project in `example-sites` and make use of lerna to link the local modules, so if they are built, they are immediately tested as the newest version, as they are a symlink.
The expected rendered HTML/CSS/JS will be compared to the actually produced output.
## License
MIT LicenseCopyright (c) 2017 [Debitoor](https://debitoor.com/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.