Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wrhs/extract-config

Package Overview
Dependencies
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wrhs/extract-config

Extract warehouse.ai configuration from a given unpacked directory

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

@wrhs/extract-config

Version npm npm Downloads Build Status Dependencies

Extracts warehouse.ai configuration from a given unpacked directory

Installation

npm install --save @wrhs/extract-config

Usage

const extract = require('@wrhs/extract-config');
const path = require('path');
const unpackedRepo = path.join('path', 'to', 'repo');

const config = await extract(unpackedRepo);

What is in config?

At most, the config will provide the following information:

{
  pkg: {
    // the entire contents of the repo's package.json
  },
  wrhs: {
    // Whether or not to perform a webpack build for this package, or if
    // we can just use the source of this directory as-is.
    //
    // Optional (default: none)
    build: 'webpack',

    // Different locales in which to build the package, this is helpful for
    // parallelizing builds for any number of locales.
    //
    // Optional (default: [])
    locales: [
      'en-US',
      'es-CO',
      'de-DE',
      'zh-CN'
    ],

    // What recommended files to use in each environment
    files: {
      dev: [
        'dist/output.css',
        'dist/output.js'
      ],
      test: [
        'dist/output.min.css',
        'dist/output.min.js'
      ],
      prod: [
        'dist/output.min.css',
        'dist/output.min.js'
      ]
    },

    // Minification options to apply to the output code
    minify: {
      compress: {
        unsafe: true,
        dead_code: true,
        collapse_vars: true,
        drop_console: true,
        conditionals: true,
        booleans: true,
        unused: true,
        if_return: true,
        join_vars: true
      }
    }
  }
}

Allowed files

@wrhs/extract-config will recognize the following configuration files and formats.

.wrhsrc

This is a simple json file that contains information in the above format

{
  "build": "webpack",
  "locales": [
    "C",
    "C++",
    "ArnoldC"
  ]
}

package.json

Similar to .wrhsrc you can place these values into either the base level of your package.json, or into a wrhs object (we will merge the base level into the wrhs object if any)

{
  "name": "my-cool-package",
  "version": "1.2.3",
  "wrhs": {
    "build": "webpack",
    "locales": [
      "en-US",
      "es-CO",
      "de-DE"
    ],
    "files": {
      "test": ["dist/output.js", "dist/output.css"],
      "prod": ["dist/output.min.js", "dist/output.min.css"]
    }
  }
}

wrhs.toml

[files]
dev = ['output.js', 'output.css']
test = ['output.min.js', 'output.min.css']
prod = ['output.min.js', 'output.min.css']

build = 'webpack'

locales = [
  'English',
  'Sindarin',
  'Klingon',
  'Dothraki'
]

[minify]
[minify.compress]
unsafe = true
dead_code = true
unsafe = true
dead_code = true
collapse_vars = true
drop_console = true
conditionals = true
booleans = true
unused = true
if_return = true
join_vars = true

Order of configuration precedence

They are listed in order above, but we will resolve potentially conflicting information based on this precedence:

  1. .wrhsrc
  2. package.json
  3. wrhs.toml

Any configuration from earlier in the list will override identically named configuration later in the list. For example, I have these 2 files present:

.wrhsrc

{
  "build" :"webpack",
  "locales": [
    "Earth", "Mars"
  ]
}

wrhs.toml

locales=['Krypton', 'Oa']

[files]
test = ['output.css']
prod = ['output.min.css']

The final configuration object will be:

{
  build: 'webpack',
  locales: [
    'Earth', 'Mars'
  ],
  files: {
    test: ['output.css']
    prod: ['output.min.css']
  }
}

It's important to note that nested lists and objects will not be merged, just overridden.

We highly recommended keeping all of your configuration in one single location, but to support legacy formats, we allow multiple points of entry.

Testing

npm test

FAQs

Package last updated on 27 Feb 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