Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
feat: update dependencies [CAT-1533] (#31)
Browse files Browse the repository at this point in the history
* feat: allowed wider range of hapi/hoek versions: v9, v10, v11
* feat: updated dot-prop version to v6
* chore: updated outdated packages
* feat: replaced deprecated ESLint plugins for Hapi with hapi/eslint-plugin
* chore: cosmetic changes, typos fix
* chore: configured Dependabot to ignore major updates for dot-prop and semantic-release
  • Loading branch information
kisaiev authored Feb 8, 2023
1 parent 7fbe3ef commit 87af525
Show file tree
Hide file tree
Showing 8 changed files with 1,662 additions and 1,623 deletions.
12 changes: 3 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
{
"extends": ["eslint-config-hapi"],
"extends": ["plugin:@hapi/recommended"],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
"ecmaVersion": 2018
},
"env": {
"browser": false,
"node": true
},
"rules": {
"strict": [0],
"no-cond-assign": [0],
"no-console": [0],
"hapi/hapi-scope-start": [0],
"no-shadow": [0],
"no-trailing-spaces": [0]
"@hapi/scope-start": "off"
}
}
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ updates:
reviewers:
- "@ExpediaGroup/catalyst-committers"
open-pull-requests-limit: 10
ignore:
# Ignore Dot Prop major updates
- dependency-name: "dot-prop"
update-types: ["version-update:semver-major"]
# Ignore Semantic Release major updates
- dependency-name: "semantic-release"
update-types: ["version-update:semver-major"]
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ const Determination = require('@vrbo/determination');
**Determination.create(options)**

- `options` (_Object_) - an options object containing:
- `config` (_String_ | _Object_) - required, either a path to a JSON configuration file or an object.
- `basedir` (_String_) - optional path used for resolving relative imports within configs. If config is a file, it defaults to the config file's directory. If config is an object, it defaults to `process.cwd()`.
- `criteria` (_Object_) - optional resolution criteria. See [confidence](https://github.com/hapijs/confidence). Minimally will always contain `process.env` under the key `env`.
- `protocols` (_Object_) - optional mapping of protocols for [shortstop](https://github.com/krakenjs/shortstop). Protocols are bound with context `config`, where `config` is the configuration being resolved. Obviously this doesn't work with arrow functions.
- `defaults` (_Object_ | _String_) - optional default pre-resolved configuration values.
- `overrides` (_Object_ | _String_) - optional override pre-resolved configuration values.
- `config` (_String_ | _Object_) - required, either a path to a JSON configuration file or an object.
- `basedir` (_String_) - optional path used for resolving relative imports within configs. If config is a file, it defaults to the config file's directory. If config is an object, it defaults to `process.cwd()`.
- `criteria` (_Object_) - optional resolution criteria. See [confidence](https://github.com/hapijs/confidence). Minimally will always contain `process.env` under the key `env`.
- `protocols` (_Object_) - optional mapping of protocols for [shortstop](https://github.com/krakenjs/shortstop). Protocols are bound with context `config`, where `config` is the configuration being resolved. Obviously this doesn't work with arrow functions.
- `defaults` (_Object_ | _String_) - optional default pre-resolved configuration values.
- `overrides` (_Object_ | _String_) - optional override pre-resolved configuration values.
- returns - a resolver.

**resolver.resolve([callback])**
Expand All @@ -45,8 +45,8 @@ const resolver = Determination.create({
});

resolver.resolve((error, config) => {
//config.get
//config.set
// config.get
// config.set
});
```

Expand All @@ -60,8 +60,14 @@ resolver.resolve((error, config) => {

```javascript
config.set('some.key.name', 'value');
config.merge({ some: { key: other: 'another value' }});
config.get('some.key.other'); //'another value'
config.merge({
some: {
key: {
other: 'another value',
},
},
});
config.get('some.key.other'); // 'another value'
```

### Shortstop Protocol Handlers
Expand Down Expand Up @@ -97,7 +103,7 @@ const protocols = {
};

Determination.create({ config: Path.join(__dirname, './config.json'), protocols }).resolve((error, config) => {
config.get('things'); //"one and two"
config.get('things'); // "one and two"
});
```

Expand Down
9 changes: 5 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
* MIT License
*
* Copyright (c) 2019 Expedia, Inc
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
**/
'use strict';

Expand Down Expand Up @@ -53,6 +53,7 @@ const create = function (options) {
});
});
}

Resolver(validation.value).then((resolved) => callback(null, new Store(resolved))).catch(callback);
}
};
Expand Down
12 changes: 7 additions & 5 deletions lib/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
* MIT License
*
* Copyright (c) 2019 Expedia, Inc
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
**/

'use strict';
Expand Down Expand Up @@ -72,7 +72,7 @@ const loadAndParseJson = function (file) {
const resolver = async function ({ config, basedir, criteria, protocols, defaults, overrides }) {

let configobject = config;

if (typeof config === 'string') {
configobject = loadAndParseJson(config);
basedir = Path.dirname(config);
Expand All @@ -81,6 +81,7 @@ const resolver = async function ({ config, basedir, criteria, protocols, default
if (typeof defaults === 'string') {
defaults = loadAndParseJson(defaults);
}

if (typeof overrides === 'string') {
overrides = loadAndParseJson(overrides);
}
Expand All @@ -99,6 +100,7 @@ const resolver = async function ({ config, basedir, criteria, protocols, default
console.log('@vrbo/determination: No basedir set, defaulting to "process.cwd()" for resolving relative json imports.');
basedir = process.cwd();
}

return resolveCriteria(loadAndParseJson(Path.resolve(Path.join(basedir, key))), criteria);
}
});
Expand Down
8 changes: 4 additions & 4 deletions lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
* MIT License
*
* Copyright (c) 2019 Expedia, Inc
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
**/

'use strict';
Expand Down
Loading

0 comments on commit 87af525

Please sign in to comment.