diff --git a/README.md b/README.md index 4fffc9290ca21427bf629eb2525a1fce9843a09d_UkVBRE1FLm1k..f7461f519f7f2faf7b2fffb78d37e9def4ee4a5b_UkVBRE1FLm1k 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,63 @@ It is compatible from Node 10.x (only for its Common.JS version) and from 13.2 for its ESM version. Node 10 support will be dropped when it will loose its LTS status. -**Note:** The test suite needing the `worker_threads` module, it does not run on node 10. +**Note:** The test suite needing the `worker_threads` module (ATM), it does not run on node 10. + +## Introduction + +Though you should read the [Getting started](#getting-started) section to understand properly all concepts underlying this lib, you can skip reading to the [Full examples](#full-examples) if you prefer seeing sample use cases first and understand them properly later. + +## Topics + +<!-- toc --> + +- [Getting started](#getting-started) + * [Core concepts of the library](#core-concepts-of-the-library) + * [Basic file naming scheme](#basic-file-naming-scheme) + * [Auto start](#auto-start) + * [Folder structure](#folder-structure) + * [`null` and `undefined`](#null-and-undefined) + * [Let's try it out!](#lets-try-it-out) +- [Full examples](#full-examples) + * [With `simpleMode`](#with-simplemode) + * [Without `simpleMode`](#without-simplemode) +- [Options](#options) + * [simpleMode](#simplemode) + * [readOnly](#readonly) + * [autoSave](#autosave) + * [save](#save) + * [allowAsync](#allowasync) + * [throwIfNotReady](#throwifnotready) + * [customTags](#customtags) + * [mapFilenamesTpl](#mapfilenamestpl) + * [environments](#environments) + * [inspectMode](#inspectmode) + * [resolve](#resolve) + * [autoload](#autoload) + * [baseDir](#basedir) + * [configDir](#configdir) +- [CommonJS and ESM](#commonjs-and-esm) +- [Tags provided by default](#tags-provided-by-default) + * [!cmdline-option](#cmdline-option) + * [!config](#config) + * [!env](#env) + * [!fallback](#fallback) + * [!import](#import) + * [!path](#path) + * [!regexp](#regexp) + * [!!timestamp](#timestamp) +- [API](#api) + * [Starting `config.io`](#starting-configio) + * [Waiting for async values](#waiting-for-async-values) + * [Loading a single namespace explicitely](#loading-a-single-namespace-explicitely) +- [Writing to the configuration](#writing-to-the-configuration) + * [Basic](#basic) + * [Generate configuration files](#generate-configuration-files) +- [Creating custom tags](#creating-custom-tags) +- [Using the library in a npm package](#using-the-library-in-a-npm-package) +- [Contributing](#contributing) + +<!-- tocstop --> ## Getting started @@ -14,4 +70,6 @@ ## Getting started +As usual, install config.io through npm: + ``` @@ -17,4 +75,339 @@ ``` -TODO +npm install config.io +``` + +Once it's done, you will usually need to create a `config` folder at the root of your project. + +### Core concepts of the library + +There are 3 core concepts to understand to use this lib: +- namespaces +- environments +- configuration tags + +Namespaces are the basic scoping mechanism of config values inside `config.io`. They will be filled out in different files. You can deactivate namespaces by setting the `simpleMode` option to `true` (see later in the configuration to know how to achieve this). It will basically make the library hide the namespace concept and expose a single unnamed namespace (that will sometimes be reffered as the `@` namespace) instead (though namespaces can still be used explicitely with the API). + +Environments are sub units to namespaces. They allow you to easily change the configuration based on the context your program is executing. By default, `config.io` will load the following environments, in this order: `'default'`, `process.env.NODE_ENV || 'development'`, `'local'`. The later an environment is loaded, the more priority it has. If you have defined: `port: 3000` in the default env and `port: 80` in the local env, your app will get `port: 80` when reading the configuration. + +Configuration tags are custom tags exposed thanks to the YAML syntax being so powerful. By default, you get access to a collection of custom tags allowing you to create more complex configurations easily. You can deactivate tags you don't like, and you can also add tags that you need, the library being very extensible on those points. Here is an exemple so you can see what it can do: + +```yaml +port: !fallback +- !env NODE_PORT +- 3000 +``` + +When accessing the `port` value, your app will read `3000` if the `NODE_PORT` environment variable is not set. Otherwise, it will get the `NODE_PORT` value. + +### Basic file naming scheme + +The file naming conventions can be modified using the `mapFilenamesTpl` option that contains a lodash template string. It defaults to `<%= ns || env %><% if (ns && env !== 'default') { %>.<%= env %><% } %>` but you are free to change it as you wish. + +That generates the following names for the files (for each environment): +```sh +# simpleMode = true (unnamed namespace) +[envName] -> [envName].yaml + +# simpleMode = false +[ns] + default -> ns.yaml +[ns] + [otherEnv] -> ns.[otherEnv].yaml +``` + +### Auto start + +By default, `config.io` will try to be helpful and to load everything properly without you doing anything. It will "auto start" using default values. + +The *auto start* mechanism is doing the following: +- load the `configio` namespace explicitely +- start the lib using the values in the namespace as its options + +If you want to prevent the lib from doing an *auto start*, you can either: +- set the `CONFIGIO_NO_AUTO_START` environment variable to any non empty value +- pass the `--configio-no-auto-start` option to your program when starting it + +If you prevent *auto start*, you will need to perform a [manual start](#starting-configio) using the API. + +### Folder structure + +There 2 important folders in the `config.io` library. The `baseDir` folder, and the `configDir` folder. + +The `baseDir` is the folder from which every path in the configuration will be resolved. It defaults to a value that should be your project root. It can be provided either as a relative path from `process.cwd()` or as an absolute path. If not provided, `config.io` relies on the [npm's find-root package](https://www.npmjs.com/package/find-root). It basically search for the closest `package.json` in a folder stucture and is invoked like this: `findRoot(process.argv[1])`. + +The `configDir` is the folder in which `config.io` looks for configuration files. It can be provided as either a relative path from `baseDir` or an absolute path. It defaults to `config` (the `config` folder in `baseDir`). + +To explicitely set `baseDir`, you can either: +- set the `CONFIGIO_BASE_DIR` environment variable +- pass a `--configio-base-dir` option to your program +- prevent `config.io` from doing an auto start (see above) and start the lib manually using the [`baseDir` option](#starting-configio) + +To explicitely set `configDir`, you can either: +- set the `CONFIGIO_DIR` environment variable +- pass a `--configio-dir` option to your program +- prevent `config.io` from doing an auto start (see above) and start the lib manually using the [`configDir` option](#starting-configio) + +### `null` and `undefined` + +Good to know: YAML as no concept of `undefined` but its definition of `null` is nearly exactly the same as the definition of `undefined` in JS. So `config.io` always casts `null` values to `undefined` in JS and `undefined` values in JS as `null` in YAML. + +That as the big advantadge that most validation libraries in JS do not treat `null` in a property the same way as `undefined`. If a property is optional, it can often be `undefined` but not `null`. This way, your lib will get `undefined` and not complain! + +The big issue is that, for now, there is absolutely no way to get a `null` out of the `config.io` library if needed. + +You can create pretty easily a `!null` custom tag to achieve this though. If it turns out it's a common use case, I'll gladly accept a PR on this. + +### Let's try it out! + +Create a `config` folder with the following files: + +`configio.yaml`: +```yaml +autoload: +- server +``` + +`server.yaml`: +```yaml +port: !fallback +- !env NODE_PORT +- 3000 +``` + +Then create a `test.js` file in your project root looking like: +```js +const configIO = require('configIO') + +console.log(configIO.server.port) +``` + +And here are results from executing this very simple program: +```sh +node test.js +# 3000 + +NODE_ENV=8080 node test.js +# 8080 +``` + +As you can see, your namespace values are readily available from the API, under a nested property. The name of the namespace in the library will be a `camelCase` version of the namespace name used in the configuration. Meaning you can safely name your namespaces using either `-` or `_` like: `server-plugins` that will become `serverPlugins` in the JS API but will load the `server-plugins.yaml` and `server-plugins.[env].yaml` files. + +If you are using the `simpleMode`, then the API will directly give you access to your namespace values. Eg: + +`config/configio.yaml`: +```yaml +simpleMode: true +``` + +`config/default.yaml`: +```yaml +port: !fallback +- !env NODE_PORT +- 3000 +``` + +`./test.js`: +```js +const configIO = require('configIO') + +console.log(configIO.port) +``` + +Will have the same effects as the program described earlier. + +**Note:** You can safely use custom tags in the `configio.yaml` file too. And since the API loads the config.io files as a namespace, you can also change the configuration using environments. + +## Full examples + +Those examples relies mostly on default values that should be fine for most projects. + +### With `simpleMode` + +Let's say we want to make a very simple server to serve static files. We only need to get some basic server configuration, like `port`, the `static` folder in which to get the files, etc. The `static` folder in most use case should be looked into the `dist` folder of the project, because we compile them. But when developing, we'd like to serve the `src` folder instead. In production, we'd also like to be able to change the folder served using the `--static` option. + +The `simpleMode` is very usefull for this use case, because it can limit the number of files we create. + +Let's create the following folder structure: +* package.json +* config + * configio.yaml (it will contain options for `config.io`) + * default.yaml (it will contain default values for our app) + * development.yaml (it will contain specific dev values) + * local.yaml (it will contain specific local values, this file should usually not be commited) +* app.js + +`config/configio.yaml` +```yaml +# we only need to activate simpleMode, other defaults are fine +simpleMode: true +``` + +`config/default.yaml` +```yaml +# define good defaults +server: + # use the --port option, fallback to NODE_PORT env var and then to 3000 if needed + port: !fallback + - !cmdline-option + name: port + type: number + description: port on wich the server should listen to + - !env NODE_PORT + - 3000 + + # more options here + +# by default, the static folder is in +static: !fallback +- !cmdline-option + name: static + type: string + description: path to the static folder to serve +- !path dist +``` + +`config/development.yaml` +```yaml +# redefine specific values +static: !path src +``` + +`config/local.yaml` +```yaml +# I'm lazy and on my computer, I don't like to use --port or NODE_PORT so I override port +server: + port: 8080 +``` + +`app.js` +```js +const configIO = require('configIO') + +// just for the example, get the values from the configuration +console.log(configIO.server.port, configIO.static) +``` + +And here are some results: +```sh +node app.js # 8080 /path/to/project/src +NODE_ENV=production node app.js # 8080 /path/to/project/dist +node app.js --static www # 8080 www + +# let's remove config/local.yaml +rm config/local.yaml + +node app.js # 3000 /path/to/project/src +NODE_PORT=8081 node app.js --port 8080 app.js # 8080 /path/to/project/src +NODE_PORT=8081 node app.js # 8081 /path/to/project/src +``` + +### Without `simpleMode` + +If we have a more involved application, where the server part is only one part out of many, we might find it cleaner to separate configuration values by namespaces. This will help finding them by separating concerns. The easier way to use those is either by autoloading them all, making them available as properties on the root object, or loading part of them using the `!config` custom tag. + +In this example, we will use a little of both, so you can grab a complex case in one go. + +We won't create environments for every namespace to keep it cleaner, but you obviously can. + +Let's create the following structure: +* package.json +* config + * configio.yaml + * logger.yaml + * server.yaml + * plugin-static.yaml + * plugin-static.development.yaml +* app.js + +`config/configio.yaml` +```yaml +autoload: +- server +- logger +``` + +`logger.yaml` +```yaml +mode: detailed +transports: + console: true + logstash: http://url.to.logstash:port/ +``` + +`config/server.yaml` +```yaml +port: !fallback +- !env NODE_PORT +- 3000 +plugins: + static: + bindTo: + hostname: http://localhost:3000/ + options: !config plugin-static +``` + +`config/plugin-static.yaml` +```yaml +chroot: true +addTrailingSlash: true +path: !fallback +- !cmdline-option + name: static + type: string + description: path to the static folder to serve +- !path dist +# … +``` + +`config/plugin-static.development.yaml` +```yaml +path: !path src +``` + +`app.js` +```js +const configIO = require('configIO') + +// just for the example, get the values from the configuration +console.log( + configIO.logger.transports.logstash, + configIO.server.port, + configIO.plugins.static.options.path, +) + +// the plugin-static namespace is also made available on the root object +console.log(configIO.pluginStatic.path) +``` + +## Options + +Here is a list of the options and their default values you can give the API to start it or set in your `configio.yaml` file: +```js +{ + simpleMode: false, + readOnly: true, + autoSave: true, + save: 'sync', + allowAsync: + yargs.argv.allowAsync || + !!process.env.CONFIGIO_ALLOW_ASYNC || + false, + throwIfNotReady: true, + customTags: {}, + mapFilenamesTpl: + "<%= ns || env %><% if (ns && env !== 'default') { %>.<%= env %><% } %>" + environments: [ + 'default', + process.env.NODE_ENV || 'development' + ], + inspectMode: 'detailed', + resolve: {}, + autoload: [], + baseDir: + yargs.argv.configioBaseDir || + process.env.CONFIGIO_BASE_DIR || + findRoot(process.argv[1]), + configDir: yargs.argv.configioDir || + process.env.CONFIGIO_DIR || + 'config', +} ``` @@ -19,5 +412,438 @@ ``` +### simpleMode + +*boolean* (defaults to **false**) + +Allows to activate the `simpleMode`, very useful for simpler use cases. + +### readOnly + +*boolean* (defaults to **true**) + +Allows to deactivate read-only mode. Without setting this to `false` explicitely, you won't be able to make change to configuration values. Since it is an edge case, the library considers safer to treat configuration as read only by default. + +### autoSave + +*boolean* (defaults to **true**) + +If changes are allowed, should `config.io` try to save them automatically when you make one? + +### save + +*string* (defaults to **'sync'**) + +If changes are allowed, how should they be saved when save occurs. Available values are: +- **sync**: save changes synchronously and immediately, very safe but slow +- **async**: wait for no changes for 10 consecutive ms, then save +- **logger**: don't actually save, log what would have been saved (using the `debug()` method of the logger) + +### allowAsync + +*boolean* (defaults to **false**) + +Should `config.io` allow namespaces to load values that need an async op to be available? + +### throwIfNotReady + +*boolean* (defaults to **true**) + +Throws if trying to access a namespace that has not loaded all its values yet. +It obviously has no meaning if `allowAsync` is `false`. + +**Note:** It is very dangerous to set this to `false` since you have no more garantees that you use namespaces safely. You might try to access a value that will be still `undefined` and set later by `config.io`. + +### customTags + +*{tagName: string}: boolean | customTag* (defaults to **{}**) + +It allows you to (de)activate already existing custom tags (using a boolean). By default, all `config.io` tags are available as well as the YAML 1.1 `timestamp` tag. + +`config.io` use the underlying [yaml NPM package](https://eemeli.org/yaml/#yaml) to parse YAML files. You should look there to have more info on other basic tags you can activate (like `!!set`, `!!map`, etc). + +### mapFilenamesTpl + +*string* (defaults to **"<%= ns || env %><% if (ns && env !== 'default') { %>.<%= env %><% } %>"**) + +Allows to change the file scheme used by `config.io`. See above for more details. + +### environments + +*[string]* (defaults to **['default', process.env.NODE_ENV || 'development']**) + +Changes the environments loaded by `config.io`. It always append `'local'` last no matter what so don't put it in there. + +### inspectMode + +*string* (defaults to **'detailed'**) + +Changes how `console.log()` and more generally how `util.inspect()` behaves on configuration objects and arrays. Possible values are: +- **detailed**: show how the values where constructed by displaying where custom tags where used and what their resolved values are +- **js**: show how your program will see the configuration +- **debug**: more useful for contributing to `config.io` than for using the lib, it shows internals + +### resolve + +*{namespace: string}: ({env: string}: string)* (defaults to **{}**) + +It allows to change directories and names to load a specific env file. Eg: + +```yaml +resolve: + # use @ to refer to the unnamed namespace in simpleMode + @: + # load development.yaml instead of test.yaml for env test + test: development.yaml + # write namespaces names here using camel case (same for envs below) + nsName: + # load the [nsName].yaml file from [configDir]/sub/dir + default: sub/dir + # load [configDir]/sub/dir/other.yaml instead of [configDir]/[nsName].test.yaml + test: sub/dir/other.yaml +``` + +### autoload + +*[string]* (defaults to **[]**) + +Namespaces to make available automatically after *auto start* or *manual start*. + +**Note:** this option is not allowed in `simpleMode`. + +### baseDir + +*string* (defaults to **yargs.argv.configioBaseDir || process.env.CONFIGIO_BASE_DIR || findRoot(process.argv[1])**) + +Change the base directory of `config.io`. It's not advised to set this option in `configio.yaml` file since either the file won't be found (since *auto start* won't be able to locate it) or it will only be active for subsequent loads, splitting namespaces folder between `configio`'s namespace and the others. + +### configDir + +*string* (defaults to **yargs.argv.configioDir || process.env.CONFIGIO_DIR || 'config'**) + +Change the config directory of `config.io`. It's not advised to set this option in `configio.yaml` file since either the file won't be found (since *auto start* won't be able to locate it) or it will only be active for subsequent loads, splitting namespaces folder between `configio`'s namespace and the others. + +## CommonJS and ESM + +This package is available on both CommonJS & ESM versions. It uses the `exports` property of `package.json` to ease usage. So a simple: +```js +import configIO from 'config.io' +``` + +should load the ESM version of the package properly and lead to the same usage patterns as: +```js +const configIO = require('config.io') +``` + +that should load the CJS version. + +Though there are some tests ensuring that if both versions are used simultaneously everything works properly, important data being shared using a global safekeeped behind a Symbol property, it is still advised to stick with one version only (since some edge cases might arise). + +## Tags provided by default + +Most of the following tags accept sub tags in some of their properties when they have a map form. That allows for more complex tags combinations. + +### !cmdline-option + +This tag is useful to load data from the process' command line option into the configuration. It uses the [yargs NPM package](https://www.npmjs.com/package/yargs) behind the scene to parse the arguments. + +We strongly advise you to use the same lib if you want to support custom options of your own (not loaded in the configuration). + +There are two ways to use this tag, as a scalar, or as a map: +```yaml +# this will read the value of --some-option +someOption: !cmdline-option some-option +# this will read the value of --some-other-option but pass options to yargs to help it +# generate a beautiful --help message +someOpterOption: !cmdline-option + name: some-other-option # accept sub tags + type: string + description: very useful option + # … +``` + +### !config + +This tag allows you to load a namespace explicitely (so it works even in `simpleMode`). It only allows for a namespace name in scalar form (for now at least), like this: + +```yaml +# will load the server namespace and make it available in the server property of the config +server: !config server +``` + +Be careful, if the server namespace is loading async values, it will also make this one async! + +### !env + +Just like `!cmdline-option` but for environment variables. It has also 2 forms, either a scalar or a map: + +```yaml +# set the value of the NODE_ENV environment variable in the mode property of the configuration +mode: !env NODE_ENV + +# read the content of APP_DATA and try to parse it using JSON.parse() +# if parsing fails, use its string value instead +data: !env + name: APP_DATA # accept sub tags + json: true # json defaults to false +``` + +If you don't set `json` to `true` or use the scalar version, `!env` will try to cast the value as a +`Number`. If the result of the cast is not `NaN`, it will use this value instead of the string. Eg: +```yaml +port: !env NODE_PORT # returns 3000 and not '3000' for NODE_PORT=3000 +``` + +### !fallback + +This tag allows you to consider multiple values in order and return the first non `null` / `undefined` one: + +```yaml +# Expose in port the value of the command line option --port +# if it's not set, fallback to the NODE_ENV environment variable +# if it's not set either, use 3000 +port: !fallback +- !cmdline-option port +- !env NODE_PORT +- 3000 +``` + +### !import + +This tag allows you to load data from external files. It currently support 4 loading mechanisms: +- `yaml` +- `cjs` (loading CommonJS files) +- `mjs` (loading ESM modules) +- `js` (loading CommonJS files by default, can be configured more) + +**Note**: loading an ESM module causes an async op, thus to do this you need to have set the option `allowAsync` to `true`, otherwise it will fail to load the namespace. + +You can use this tag in its simpler scalar form: +```yaml +# supported file extensions: +# yaml, yml, json: use the yaml mode +# js, cjs: load CJS module (in this form, these are the same) +# mjs: load ESM module +import: !import some/file.cjs +``` + +Be careful, relative paths are resolved from `baseDir` and not `configDir` (this is usually more practical). You can also use absolute paths. + +There is also a map form for this tag: +```yaml +import: + path: some/file.js # accept sub tags + # type, string, only available if the file extension is '.js', can be either: + # - (default) commonjs (use require() to load the file) + # - module (use import() to load the file, careful: async op even for CJS modules!) + type: commonjs + # property, string, path to a property in the module to expose instead of the whole loaded value + property: some.sub.prop # supports sub properties + # throw, boolean (defaults to true), throws if imported value in null or undefined + throw: true +``` + +### !path + +This tag allows to easily denote paths and handle their resolution from `baseDir`. It supports the 3 forms of YAML (scalar, map, seq): + +```yaml +# most basic usage, will resolve(baseDir, 'some/path') +simplePath: !path some/path + +# map form, useful to use sub tags, here causing it to resolve(baseDir, process.env.STATIC_DIR) +staticFolder: !path + path: !env STATIC_DIR + +# seq form, joins every element in the array, supports sub tags +# this will result in: 'public/' + process.env.IMAGE_DIR_NAME +imageFolder: +- public/ +- !env IMAGE_DIR_NAME +``` + +### !regexp + +This tags allows to easily load regexps from your configuration: + +```yaml +re: !regexp /test/g +``` + +You can also write regexp directly in your configuration using this (see [Writing to the configuration](#writing-to-the-configuration) for more on this). + +### !!timestamp + +The YAML 1.1 `!!timestamp` tag is also available by default. It causes all strings looking like a date to be loaded as a `Date()` instead of a simple string. + +```yaml +# will create a Date() on 2020-01-12 at 00:00:00 UTC +# here is the spec for the allowed formats: https://yaml.org/type/timestamp.html +from: 2020-01-12 +``` + +## API + +### Starting `config.io` + +If you disabled *auto start*, you can perform at any time a *manual start*. If you do a *manual start* after an *auto start* or another *manual start*, it will extend the global options internally and conform to *simpleMode* or *autoload* once again. You should avoid to switch the *simpleMode* value (except if *auto start* did nothing). + +```js +const configIO = require('config.io') + +// performs a manual start +configIO({ + // options (see the options section) +}) + +// access your configuration values +console.log(configIO.server.port) +``` + +### Waiting for async values + +If you are using async values, you need to wait for the load to be done. You can do this by performing a manual start with no options (that will basically do nothing but return a promise on the previous start completion) or wait the result of your manual start: + +```js +const configIO = require('config.io') + +const start = async () => {} + // performs a manual start and wait for it to be done + await configIO({ + // options (see the options section) + }) + //- or wait for previous start to be ready + await configIO() + + // access your configuration values + console.log(configIO.server.port) +} + +start() +``` + +### Loading a single namespace explicitely + +You can always load explicitely a namespace, even in `simpleMode`. Here is how to achieve this: + +```js +const configIO = require('config.io') + +// ... +const namespace = /* await */ configIO('server') + +console.log(namespace.port) +// ... +``` + +You can pass options to override defaults when loading a namespace: +```js +configIO('server', options) +``` + +Options are basically the same as the global ones with the following differences: +- `simpleMode` & `autoLoad` can't be provided +- `resolve` takes only a **{env: string}: string** object since the namespace only needs to know how to resolve its own envirnoment files + +And there are 2 specific options that are available only in this case: +- `prependEnvironments` *[string]* (defaults to **[]**): environments to load before the default ones +- `appendEnvironments` *[string]* (defaults to **[]**): environments to load after the default ones (but still before local) + +## Writing to the configuration + +### Basic + +The most simple use case is just to save configuration changes that could be done maybe through, let's say, an API call: + +```js +const configIO = require('config.io') + +// ... + +const changePort = port => + configIO.server.port = port +``` + +And... That's it! `config.io` will take care to save the changes automatically. All changes are always made in the `local` environment. You cannot change other environments for safety reasons, and also to make changes easier to stop, since only changes will be visible in the `local` env and not all values loaded from other environments! + +If you use `autoSave: false`, you need a way to save a namespace manually. That is achieved through the `saveConfigIO()` method, available on namespace's root: +```js +// manually trigger a save (using the specified strategy in the 'save' option) +configIO.server.saveConfigIO() +``` + +### Generate configuration files + +To help you generate configuration files, the customTags classes used in the library are exposed. On recent node versions (supporting the `exports` property of `package.json`), you can access those using `config.io/tags/tag-name[.mjs]` modules. + +**Note:** on older version of node, you will have to use the `config.io/commonjs/tags/tag-name` form to access those exports. + +```js +const configIO = require('config.io') +const { Env } = require('config.io/tags/fallback') +const { Fallback } = require('config.io/tags/fallback') + +configIO.server.port = new Fallback([ + new Env({ name: 'NODE_PORT' }), + 3000, +]) +``` + +We advise you to use `autoSave: false` to do this. Once you have completed the values you want in `default.yaml`, save, and rename the local file to the correct name for the `default` env of this namespace. If you want to generate more than one env for a configuration, you will need to load different instances of node for each one, since, for now, there is no way to force reload a namespace that is already loaded. We might implement this later. + +## Creating custom tags + +You can easily create your own tags. For that, you can use either the [YAML API](https://eemeli.org/yaml/#custom-data-types) or use the higher level `createTag` method exposed. + +`tags/null.js`: +```js +const { createTag } = require('config.io/create-tag') // careful, old node versions need commonjs/ +const Null = module.exports.Null = class Null { + valueOf() { + return null + } + + static yaml = { + toYAML() { + return null + } + } +} + +module.exports.nullTag = createTag(Null) +``` + +`config/configio.yaml`: +```yaml +customTags: + null: !import + path: ./tags/null.js + property: nullTag +``` + +And you're done! + +## Using the library in a npm package + +This is a very specific use case, but we wanted it to work! In this case, we strongly advise you to load your namespace explicitely and to provide your defaults through a prepended environment: + +```js +const configIO = require('config.io') +const path = require('path') + +const myPkgConfig = configIO('my-pkg', { + allowAsync: false, // recommended + prependedEnvironments: ['my-pkg-default-values'], + resolve: { + // you can change this path to whatever seems fine to you + myPkgDefaultValues: path.join(__dirname, 'default-values.yaml'), + } +}) +``` + +We strongly advise you either not to accept async ops and thus to force it being false or to always await your config safely. + +If you want to load internal values that should not be changed by the software you are using, you can have them in a separate, private, namespace (where you specify `configDir` when loading it so it cannot be looked for in the normal configuration folder of the main software). + ## Contributing To get started, you need mercurial and the correct plugins. Here is how to install those: @@ -36,9 +862,12 @@ [extensions] evolve = topic = + +[hooks] +pretxncommit.prepublish = npm run prepublishOnly ``` Create a topic branch to host your code: ```sh hg topic my-feature ``` @@ -39,10 +868,10 @@ ``` Create a topic branch to host your code: ```sh hg topic my-feature ``` - + i For more on topic branches, [read this tutorial](https://www.mercurial-scm.org/doc/evolution/tutorials/topic-tutorial.html). Make your changes, commit as you wish, do your thing! Once you're ready to submit a change, request `Developer` access through Gitlab (you need an account). You should be granted some quickly. diff --git a/package-lock.json b/package-lock.json index 4fffc9290ca21427bf629eb2525a1fce9843a09d_cGFja2FnZS1sb2NrLmpzb24=..f7461f519f7f2faf7b2fffb78d37e9def4ee4a5b_cGFja2FnZS1sb2NrLmpzb24= 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,32 +21,4 @@ "source-map": "^0.5.0" }, "dependencies": { - "anymatch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", - "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", - "dev": true, - "optional": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "binary-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", - "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", - "dev": true, - "optional": true - }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "optional": true, - "requires": { - "fill-range": "^7.0.1" - } - }, "chokidar": { @@ -52,24 +24,7 @@ "chokidar": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.0.tgz", - "integrity": "sha512-aXAaho2VJtisB/1fg1+3nlLJqGOuewTzQpd/Tz0yTg2R0e4IGtshYvtjowyEumcBv2z+y4+kc75Mz7j5xJskcQ==", - "dev": true, - "optional": true, - "requires": { - "anymatch": "~3.1.1", - "braces": "~3.0.2", - "fsevents": "~2.1.2", - "glob-parent": "~5.1.0", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.4.0" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", + "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", "dev": true, "optional": true, "requires": { @@ -73,61 +28,18 @@ "dev": true, "optional": true, "requires": { - "to-regex-range": "^5.0.1" - } - }, - "fsevents": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", - "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", - "dev": true, - "optional": true - }, - "glob-parent": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", - "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", - "dev": true, - "optional": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "optional": true, - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "optional": true - }, - "readdirp": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", - "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==", - "dev": true, - "optional": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "optional": true, - "requires": { - "is-number": "^7.0.0" + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" } } } @@ -1319,6 +1231,15 @@ } } }, + "ansi-red": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", + "integrity": "sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=", + "dev": true, + "requires": { + "ansi-wrap": "0.1.0" + } + }, "ansi-regex": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", @@ -1333,6 +1254,35 @@ "color-convert": "^2.0.1" } }, + "ansi-wrap": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", + "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", + "dev": true + }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "optional": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "optional": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, "append-transform": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", @@ -1410,9 +1360,16 @@ "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, + "async-each": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", + "dev": true, + "optional": true + }, "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, @@ -1413,9 +1370,18 @@ "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, + "autolinker": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/autolinker/-/autolinker-0.28.1.tgz", + "integrity": "sha1-BlK0kYgYefB3XazgzcoyM5QqTkc=", + "dev": true, + "requires": { + "gulp-header": "^1.7.1" + } + }, "babel-eslint": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", @@ -1439,32 +1405,4 @@ "chokidar": "^2.0.4" }, "dependencies": { - "anymatch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", - "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", - "dev": true, - "optional": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "binary-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", - "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", - "dev": true, - "optional": true - }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "optional": true, - "requires": { - "fill-range": "^7.0.1" - } - }, "chokidar": { @@ -1470,24 +1408,7 @@ "chokidar": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.0.tgz", - "integrity": "sha512-aXAaho2VJtisB/1fg1+3nlLJqGOuewTzQpd/Tz0yTg2R0e4IGtshYvtjowyEumcBv2z+y4+kc75Mz7j5xJskcQ==", - "dev": true, - "optional": true, - "requires": { - "anymatch": "~3.1.1", - "braces": "~3.0.2", - "fsevents": "~2.1.2", - "glob-parent": "~5.1.0", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.4.0" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", + "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", "dev": true, "optional": true, "requires": { @@ -1491,61 +1412,18 @@ "dev": true, "optional": true, "requires": { - "to-regex-range": "^5.0.1" - } - }, - "fsevents": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", - "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", - "dev": true, - "optional": true - }, - "glob-parent": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", - "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", - "dev": true, - "optional": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "optional": true, - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "optional": true - }, - "readdirp": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", - "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==", - "dev": true, - "optional": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "optional": true, - "requires": { - "is-number": "^7.0.0" + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "upath": "^1.1.1" } } } @@ -1649,6 +1527,23 @@ } } }, + "binary-extensions": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", + "dev": true, + "optional": true + }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1706,6 +1601,12 @@ "pkg-up": "^2.0.0" } }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -2002,6 +1903,12 @@ "wrap-ansi": "^6.2.0" } }, + "coffee-script": { + "version": "1.12.7", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.12.7.tgz", + "integrity": "sha512-fLeEhqwymYat/MpTPUjSKHVYYl0ec2mOyALEMLmzr5i1isuG+6jfI2j2d5oBO3VIzgUXgBVIcOT9uH1TFxBckw==", + "dev": true + }, "collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", @@ -2049,6 +1956,35 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "concat-with-sourcemaps": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz", + "integrity": "sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg==", + "dev": true, + "requires": { + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "concurrently": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-5.2.0.tgz", @@ -2262,6 +2198,12 @@ } } }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, "cross-spawn": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.2.tgz", @@ -2401,6 +2343,12 @@ } } }, + "diacritics-map": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/diacritics-map/-/diacritics-map-0.1.0.tgz", + "integrity": "sha1-bfwP+dAQAKLt8oZTccrDFulJd68=", + "dev": true + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", @@ -2927,6 +2875,57 @@ } } }, + "expand-range": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", + "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", + "dev": true, + "requires": { + "fill-range": "^2.1.0" + }, + "dependencies": { + "fill-range": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", + "integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==", + "dev": true, + "requires": { + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^3.0.0", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" + } + }, + "is-number": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", + "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + } + }, + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, "extend-shallow": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", @@ -3060,6 +3059,13 @@ "flat-cache": "^2.0.1" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -3248,6 +3254,17 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "dev": true, + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -3303,6 +3320,29 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "dev": true, + "optional": true, + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "optional": true, + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -3315,9 +3355,33 @@ "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", "dev": true }, + "gray-matter": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-2.1.1.tgz", + "integrity": "sha1-MELZrewqHe1qdwep7SOA+KF6Qw4=", + "dev": true, + "requires": { + "ansi-red": "^0.1.1", + "coffee-script": "^1.12.4", + "extend-shallow": "^2.0.1", + "js-yaml": "^3.8.1", + "toml": "^2.3.2" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, @@ -3318,9 +3382,20 @@ "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, + "gulp-header": { + "version": "1.8.12", + "resolved": "https://registry.npmjs.org/gulp-header/-/gulp-header-1.8.12.tgz", + "integrity": "sha512-lh9HLdb53sC7XIZOYzTXM4lFuXElv3EVkSDhsd7DoJBj7hm+Ni7D3qYbb+Rr8DuM8nRanBvkVO9d7askreXGnQ==", + "dev": true, + "requires": { + "concat-with-sourcemaps": "*", + "lodash.template": "^4.4.0", + "through2": "^2.0.0" + } + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -3546,6 +3621,16 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "optional": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", @@ -3973,6 +4058,15 @@ "graceful-fs": "^4.1.11" } }, + "lazy-cache": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-2.0.2.tgz", + "integrity": "sha1-uRkKT5EzVGlIQIWfio9whNiCImQ=", + "dev": true, + "requires": { + "set-getter": "^0.1.0" + } + }, "leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", @@ -3998,6 +4092,47 @@ "type-check": "~0.4.0" } }, + "list-item": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/list-item/-/list-item-1.1.1.tgz", + "integrity": "sha1-DGXQDih8tmPMs8s4Sad+iewmilY=", + "dev": true, + "requires": { + "expand-range": "^1.8.1", + "extend-shallow": "^2.0.1", + "is-number": "^2.1.0", + "repeat-string": "^1.5.2" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-number": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", + "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, "load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -4046,6 +4181,12 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + }, "lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", @@ -4058,6 +4199,25 @@ "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", "dev": true }, + "lodash.template": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.5.0.tgz", + "integrity": "sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A==", + "dev": true, + "requires": { + "lodash._reinterpolate": "^3.0.0", + "lodash.templatesettings": "^4.0.0" + } + }, + "lodash.templatesettings": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz", + "integrity": "sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==", + "dev": true, + "requires": { + "lodash._reinterpolate": "^3.0.0" + } + }, "log-symbols": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", @@ -4109,6 +4269,38 @@ "object-visit": "^1.0.0" } }, + "markdown-link": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/markdown-link/-/markdown-link-0.1.1.tgz", + "integrity": "sha1-MsXGUZmmRXMWMi0eQinRNAfIx88=", + "dev": true + }, + "markdown-toc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/markdown-toc/-/markdown-toc-1.2.0.tgz", + "integrity": "sha512-eOsq7EGd3asV0oBfmyqngeEIhrbkc7XVP63OwcJBIhH2EpG2PzFcbZdhy1jutXSlRBBVMNXHvMtSr5LAxSUvUg==", + "dev": true, + "requires": { + "concat-stream": "^1.5.2", + "diacritics-map": "^0.1.0", + "gray-matter": "^2.1.0", + "lazy-cache": "^2.0.2", + "list-item": "^1.1.1", + "markdown-link": "^0.1.1", + "minimist": "^1.2.0", + "mixin-deep": "^1.1.3", + "object.pick": "^1.2.0", + "remarkable": "^1.7.1", + "repeat-string": "^1.6.1", + "strip-color": "^0.1.0" + } + }, + "math-random": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.4.tgz", + "integrity": "sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==", + "dev": true + }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", @@ -4254,10 +4446,10 @@ } }, "chokidar": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.0.tgz", - "integrity": "sha512-aXAaho2VJtisB/1fg1+3nlLJqGOuewTzQpd/Tz0yTg2R0e4IGtshYvtjowyEumcBv2z+y4+kc75Mz7j5xJskcQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", + "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", "dev": true, "requires": { "anymatch": "~3.1.1", "braces": "~3.0.2", @@ -4260,9 +4452,9 @@ "dev": true, "requires": { "anymatch": "~3.1.1", "braces": "~3.0.2", - "fsevents": "~2.1.2", + "fsevents": "~2.1.1", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", @@ -4265,19 +4457,8 @@ "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", - "readdirp": "~3.4.0" - }, - "dependencies": { - "readdirp": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", - "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==", - "dev": true, - "requires": { - "picomatch": "^2.2.1" - } - } + "readdirp": "~3.2.0" } }, "cliui": { @@ -4425,6 +4606,7 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", + "dev": true, "requires": { "picomatch": "^2.0.4" } @@ -4535,6 +4717,13 @@ "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, + "nan": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==", + "dev": true, + "optional": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -4999,6 +5188,13 @@ } } }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true, + "optional": true + }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -5065,7 +5261,8 @@ "picomatch": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", - "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==" + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "dev": true }, "pify": { "version": "4.0.1", @@ -5242,6 +5439,12 @@ "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", "dev": true }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, "process-on-spawn": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", @@ -5274,6 +5477,25 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "randomatic": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.1.tgz", + "integrity": "sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw==", + "dev": true, + "requires": { + "is-number": "^4.0.0", + "kind-of": "^6.0.0", + "math-random": "^1.0.1" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + } + } + }, "react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -5371,6 +5593,33 @@ } } }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "dev": true, + "optional": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" + } + }, "regenerate": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", @@ -5463,6 +5712,23 @@ "es6-error": "^4.0.1" } }, + "remarkable": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/remarkable/-/remarkable-1.7.4.tgz", + "integrity": "sha512-e6NKUXgX95whv7IgddywbeN/ItCkWbISmc2DiqHJb0wTrqZIexqdco5b8Z3XZoo/48IdNVKM9ZCvTPJ4F5uvhg==", + "dev": true, + "requires": { + "argparse": "^1.0.10", + "autolinker": "~0.28.0" + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true, + "optional": true + }, "repeat-element": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", @@ -5584,6 +5850,15 @@ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, + "set-getter": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/set-getter/-/set-getter-0.1.0.tgz", + "integrity": "sha1-12nBgsnVpR9AkUXy+6guXoboA3Y=", + "dev": true, + "requires": { + "to-object-path": "^0.3.0" + } + }, "set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", @@ -6256,6 +6531,15 @@ "es-abstract": "^1.17.5" } }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, "strip-ansi": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", @@ -6270,6 +6554,12 @@ "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", "dev": true }, + "strip-color": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/strip-color/-/strip-color-0.1.0.tgz", + "integrity": "sha1-EG9l09PmotlAHKwOsM6LinArT3s=", + "dev": true + }, "strip-json-comments": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", @@ -6360,6 +6650,16 @@ "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "dev": true, + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -6417,6 +6717,12 @@ "repeat-string": "^1.6.1" } }, + "toml": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/toml/-/toml-2.3.6.tgz", + "integrity": "sha512-gVweAectJU3ebq//Ferr2JUY4WKSDe5N+z0FvjDncLGyHmIDoxgY/2Ie4qfEIDm4IS7OA6Rmdm7pdEEdMcV/xQ==", + "dev": true + }, "tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", @@ -6450,6 +6756,12 @@ "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", "dev": true }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, "typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", @@ -6551,6 +6863,13 @@ } } }, + "upath": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", + "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", + "dev": true, + "optional": true + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", @@ -6572,6 +6891,12 @@ "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", "dev": true }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", diff --git a/package.json b/package.json index 4fffc9290ca21427bf629eb2525a1fce9843a09d_cGFja2FnZS5qc29u..f7461f519f7f2faf7b2fffb78d37e9def4ee4a5b_cGFja2FnZS5qc29u 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "test": "npm run build && concurrently npm:test:*", "preinstall": "npx npm-force-resolutions", "prepare": "cd test && npm i --no-package-lock", - "prepublishOnly": "npm run test", + "prepublishOnly": "markdown-toc -i README.md && npm run test", "update:all": "ncu -u && rimraf node_modules package-lock.json && echo '{}' > package-lock.json && npm i && npm i" }, "keywords": [ @@ -77,6 +77,7 @@ "eslint-formatter-gitlab": "^2.0.0", "find-root": "^1.1.0", "glob": "^7.1.6", + "markdown-toc": "^1.2.0", "mocha": "^7.1.2", "nyc": "^15.0.1", "patch-package": "^6.2.2", diff --git a/src/configuration.mjs b/src/configuration.mjs index 4fffc9290ca21427bf629eb2525a1fce9843a09d_c3JjL2NvbmZpZ3VyYXRpb24ubWpz..f7461f519f7f2faf7b2fffb78d37e9def4ee4a5b_c3JjL2NvbmZpZ3VyYXRpb24ubWpz 100644 --- a/src/configuration.mjs +++ b/src/configuration.mjs @@ -73,7 +73,7 @@ const mapFilenames = this.mapFilenames = _.wrap( _.template(this.options.mapFilenamesTpl), (envToPath, ns, env) => { - const resolvePath = this.options.resolve[env] || '.' + const resolvePath = this.options.resolve[_.camelCase(env)] || '.' const name = extname(resolvePath) === '.yaml' ? '' : envToPath({ ns, env }) + '.yaml' diff --git a/src/expose-proxy.mjs b/src/expose-proxy.mjs index 4fffc9290ca21427bf629eb2525a1fce9843a09d_c3JjL2V4cG9zZS1wcm94eS5tanM=..f7461f519f7f2faf7b2fffb78d37e9def4ee4a5b_c3JjL2V4cG9zZS1wcm94eS5tanM= 100644 --- a/src/expose-proxy.mjs +++ b/src/expose-proxy.mjs @@ -12,8 +12,8 @@ return target.config.save.bind(target.config) } const subConfig = target.config.getSubConfig(property) - let val = subConfig.value + const val = subConfig.value if (val === null || typeof val !== 'object') { return val ?? undefined } if (val.constructor.yaml) { @@ -16,9 +16,8 @@ if (val === null || typeof val !== 'object') { return val ?? undefined } if (val.constructor.yaml) { - val = val.valueOf() - return val ?? undefined + return val.valueOf() } if (val.constructor !== Object && val.constructor !== Array) { return val diff --git a/src/load.mjs b/src/load.mjs index 4fffc9290ca21427bf629eb2525a1fce9843a09d_c3JjL2xvYWQubWpz..f7461f519f7f2faf7b2fffb78d37e9def4ee4a5b_c3JjL2xvYWQubWpz 100644 --- a/src/load.mjs +++ b/src/load.mjs @@ -28,6 +28,8 @@ if (options === globalOptions) { options = genericToConfigurationOpts(camelNs, options) + } else { + options = _.merge({}, genericToConfigurationOpts(camelNs, globalOptions), options) } if (!NAMESPACES.has(camelNs)) { diff --git a/src/schemas.mjs b/src/schemas.mjs index 4fffc9290ca21427bf629eb2525a1fce9843a09d_c3JjL3NjaGVtYXMubWpz..f7461f519f7f2faf7b2fffb78d37e9def4ee4a5b_c3JjL3NjaGVtYXMubWpz 100644 --- a/src/schemas.mjs +++ b/src/schemas.mjs @@ -50,7 +50,8 @@ const environmentsWithoutDefaults = Joi.array() .items( Joi.string() - .pattern(NAME_RE), + .pattern(NAME_RE) + .invalid('local'), ) .min(1) .unique()