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

@dimerapp/config-parser

v2.0.4

Published

Parses the dimer.json file

Downloads

37

Readme

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.