@goldstack/utils-config
Advanced tools
Comparing version 0.1.37 to 0.1.38
@@ -7,12 +7,12 @@ "use strict"; | ||
exports.getAwsConfigPath = exports.getPackageConfigPaths = exports.parseConfig = exports.validateConfig = void 0; | ||
var ajv_1 = __importDefault(require("ajv")); | ||
var utils_sh_1 = require("@goldstack/utils-sh"); | ||
exports.validateConfig = function (config, schema, options) { | ||
var ajv = new ajv_1.default(); | ||
const ajv_1 = __importDefault(require("ajv")); | ||
const utils_sh_1 = require("@goldstack/utils-sh"); | ||
exports.validateConfig = (config, schema, options) => { | ||
const ajv = new ajv_1.default(); | ||
if (options === null || options === void 0 ? void 0 : options.additionalSchemas) { | ||
options.additionalSchemas.forEach(function (schema) { return ajv.addSchema(schema); }); | ||
options.additionalSchemas.forEach((schema) => ajv.addSchema(schema)); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var buildError = function (e) { | ||
return new Error(((options === null || options === void 0 ? void 0 : options.errorMessage) || 'Cannot read configuration') + "\n" + | ||
const buildError = (e) => { | ||
return new Error(`${(options === null || options === void 0 ? void 0 : options.errorMessage) || 'Cannot read configuration'}\n` + | ||
ajv.errorsText() || | ||
@@ -22,3 +22,3 @@ '' + e || | ||
}; | ||
var valid; | ||
let valid; | ||
try { | ||
@@ -35,13 +35,13 @@ valid = ajv.validate(schema, config); | ||
}; | ||
exports.parseConfig = function (data, schema, options) { | ||
var config = JSON.parse(data); | ||
exports.parseConfig = (data, schema, options) => { | ||
const config = JSON.parse(data); | ||
return exports.validateConfig(config, schema, options); | ||
}; | ||
exports.getPackageConfigPaths = function (workspacePath) { | ||
var res = utils_sh_1.sh.ls('-A', workspacePath + 'packages/*/goldstack.json'); | ||
exports.getPackageConfigPaths = (workspacePath) => { | ||
const res = utils_sh_1.sh.ls('-A', workspacePath + 'packages/*/goldstack.json'); | ||
return Array.from(res.values()); | ||
}; | ||
exports.getAwsConfigPath = function (workspacePath) { | ||
exports.getAwsConfigPath = (workspacePath) => { | ||
return workspacePath + 'config/infra/aws/config.json'; | ||
}; | ||
//# sourceMappingURL=utilsConfig.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utilsConfig_1 = require("./utilsConfig"); | ||
describe('Config utils', function () { | ||
it('Should determine package paths', function () { | ||
var paths = utilsConfig_1.getPackageConfigPaths('./../../'); | ||
const utilsConfig_1 = require("./utilsConfig"); | ||
describe('Config utils', () => { | ||
it('Should determine package paths', () => { | ||
const paths = utilsConfig_1.getPackageConfigPaths('./../../'); | ||
expect(paths.length).toBeGreaterThan(0); | ||
@@ -8,0 +8,0 @@ }); |
{ | ||
"name": "@goldstack/utils-config", | ||
"version": "0.1.37", | ||
"version": "0.1.38", | ||
"description": "Utilities to work with JSON configuration files.", | ||
@@ -25,3 +25,3 @@ "license": "MIT", | ||
"@goldstack/utils-log": "0.1.36", | ||
"@goldstack/utils-sh": "0.2.2", | ||
"@goldstack/utils-sh": "0.2.3", | ||
"ajv": "^6.12.2", | ||
@@ -28,0 +28,0 @@ "handlebars": "^4.7.6" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
6303
+ Added@goldstack/utils-sh@0.2.3(transitive)
- Removed@goldstack/utils-sh@0.2.2(transitive)
Updated@goldstack/utils-sh@0.2.3