@dimerapp/config-parser
Parses the dimer.json file
Last updated 2 years ago by virk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @dimerapp/config-parser 
SYNC missed versions from official npm registry.
Dimer App

Dimer is an open source project and CMS to help you publish your documentation online.


We believe every project/product is incomplete without documentation.
We want to help you publish user facing documentation, without worrying about tools or code to write.


Dimer Config Parser

Parses dimer.json

travis-image npm-image

This module parses the dimer.json file and returns a normalised config object back.

Installation

npm i @dimerapp/config-parser

# yarn
yarn add @dimerapp/config-parser

Usage

const ConfigParser = require('@dimerapp/config-parser')
const Context = require('@dimerapp/context')

const ctx = new Context(__dirname)

// masterOptions are optional
const configParser = new ConfigParser(ctx, masterOptions)

Master Options

You can optionally pass masterOptions to the constructor. The masterOptions are merged (with more priority) the compiler options defined inside the config file.

Compiler options

Following options are allowed inside dimer.json config file as compileOptions.

validateDomain (boolean)

Whether or not to validate the domain. default=true

apiUrl? (string)

API url from which the api is served. default=http://localhost:5000. Defining this in options, will override the value explicitly defined in config.

assetsUrl? (string)

The assets url from where the assets will be served. If not defined, it will be created from the apiUrl.

createSearchIndex

Whether or not to create the search index.

detectAssets

Whether or not to detect assets.

API

parse

Parse the config file and returns normalised config object.

try {
  const { errors, config } = await configParser.parse()
  
  if (errors) {
    errors.forEach(({ message, ruleId }) => console.log(message, ruleId))
    return
  }

  // use config
} catch (error) {
  // file is missing or bad JSON
}

init

Create a new config file (if missing).

await configParser.init()

// or pass custom config

await configParser.init({
  domain: '',
  versions: {}
})

Config file sample

{
  domain: 'adonisjs.dimerapp.com',
  cname?: 'adonisjs.com',
  defaultVersion: 'master',
  versions: {
    master: 'docs/master'
  },
  websiteOptions?: {},
  compilerOptions: {
    apiUrl: 'http://localhost:5000',
    detectAssets: true,
    createSearchIndex: true,
    assetsUrl?: 'http://localhost:5000/__assets',
    validateDomain?: true
  }
}

Change log

The change log can be found in the CHANGELOG.md file.

Contributing

Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.

Authors & License

thetutlage and contributors.

MIT License, see the included MIT file.

Current Tags

  • 2.0.4                                ...           latest (2 years ago)

15 Versions

  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 15
Last Day 0
Last Week 15
Last Month 2
Dependencies (3)
Dev Dependencies (9)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |