New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@discoveryjs/cli

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discoveryjs/cli

CLI tools to serve & build projects based on Discovery.js

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
91
decreased by-18.75%
Maintainers
2
Weekly downloads
 
Created
Source

Discovery.js project logo

CLI Tools for Discovery.js

NPM version Twitter

CLI tools to serve & build projects based on Discovery.js

Install

npm install @discoveryjs/cli

Commands

discovery (serve)

Usage:

  discovery [config] [options]

Options:

      --cache [dir]        Enable data caching and specify path for cache files, use working directory when
                           is not set
  -c, --config <filename>  Path to config (JavaScript or JSON file)
      --dev                Enable developer mode
  -h, --help               Output usage information
  -m, --model <name>       Specify a model (multi-model mode only)
      --no-warmup          Disable warm up model data cache on server start
  -p, --port <n>           Listening port (default: 8123)
  -v, --version            Output version

discovery-build (build)

Usage:

  discovery-build [config] [options]

Options:

      --cleanup               Delete all files of output path before saving a result to it
  -c, --config <filename>     Path to config (JavaScript or JSON file)
  -h, --help                  Output usage information
  -m, --model <name>          Specify a model (multi-model mode only)
  -o, --output <path>         Path for a build result
      --pretty-data [indent]  Pretty print of data.json
  -s, --single-file           Output a model build as a single file
  -v, --version               Output version

Modes

Discovery can work in following modes:

  • Model-free (when no any model specified)
  • Single model
  • Multiple models

Model-free

In this mode you can upload any data by clicking "Load data" button, or drag'n'drop file right into the browser.

Multiple models

In this mode discovery will start with model selection page. Every model will have own route namespace, and you can switch models and reports at any time.

Single model

If you want only one model, you should start discovery with --model %modelName%. In this mode index page will represent your model default page.

Configuration

To configure discovery you should specify one of config files:

  • .discoveryrc.js
  • .discoveryrc.json
  • .discoveryrc (the same as .discoveryrc.json)

Or you can add a section in your package.json file with discovery as a key.

Multi-model config

Config should provide JSON or exports an object with following properties:

  • name - name of discovery instance (used in page title)
  • models - object with model configurations, where for each entry the key used as a slug and the value as a config

Example:

module.exports = {
    name: 'My cool dashboards',
    models: {
        one: <modelConfig>,
        two: <modelConfig>
    }
};

Model config

Model config may consists of the following fields (all fields are optional):

  • name – name of model (used in title)
  • data – function which returns any|Promise<any>. Result of this function must be JSON serializable
  • prepare – path to a script with additional initialization logic (e.g. add cyclic links and relations, extensions for query engine etc)
  • view – object with following fields:
    • basedir – directory to resolve relative path in assets and libs
    • libs – path to libs, where key is local name available in asset's scope and value is a path to library file or an array of files (.js or .css)
    • assets – path to .js and .css files

    js files has own scope (as modules) with a reference discovery that points to discovery instance

  • extendRouterfunction(router, modelConfig, options)
  • cache
  • cacheTtl
  • cacheBgUpdate

Example:

const path = require('path');

module.exports = {
    name: 'Model config',
    data: () => ({ hello: 'world' }),
    prepare: path.join(__dirname, 'path/to/prepare.js'),
    view: {
        basedir: __dirname,
        assets: [
            'ui/page/default.js',
            'ui/view/model-custom-view.css',
            'ui/view/model-custom-view.js',
            'ui/sidebar.css',
            'ui/sidebar.js'
        ]
    }
};

License

MIT

Keywords

FAQs

Package last updated on 14 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc