Comparing version 1.0.8 to 1.0.11
@@ -35,3 +35,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/******/ // eslint-disable-next-line no-unused-vars | ||
/******/ var hotCurrentHash = "a4ce695ee9fec434bb8e"; | ||
/******/ var hotCurrentHash = "b4c26dc2f92d49fe5c1d"; | ||
/******/ var hotRequestTimeout = 10000; | ||
@@ -231,3 +231,3 @@ /******/ var hotCurrentModuleData = {}; | ||
/******/ hotUpdate = {}; | ||
/******/ var chunkId = "index"; | ||
/******/ var chunkId = 0; | ||
/******/ // eslint-disable-next-line no-lone-blocks | ||
@@ -770,179 +770,3 @@ /******/ { | ||
/***/ "./node_modules/webpack/hot/log-apply-result.js": | ||
/*!*****************************************!*\ | ||
!*** (webpack)/hot/log-apply-result.js ***! | ||
\*****************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
module.exports = function(updatedModules, renewedModules) { | ||
var unacceptedModules = updatedModules.filter(function(moduleId) { | ||
return renewedModules && renewedModules.indexOf(moduleId) < 0; | ||
}); | ||
var log = __webpack_require__(/*! ./log */ "./node_modules/webpack/hot/log.js"); | ||
if (unacceptedModules.length > 0) { | ||
log( | ||
"warning", | ||
"[HMR] The following modules couldn't be hot updated: (They would need a full reload!)" | ||
); | ||
unacceptedModules.forEach(function(moduleId) { | ||
log("warning", "[HMR] - " + moduleId); | ||
}); | ||
} | ||
if (!renewedModules || renewedModules.length === 0) { | ||
log("info", "[HMR] Nothing hot updated."); | ||
} else { | ||
log("info", "[HMR] Updated modules:"); | ||
renewedModules.forEach(function(moduleId) { | ||
if (typeof moduleId === "string" && moduleId.indexOf("!") !== -1) { | ||
var parts = moduleId.split("!"); | ||
log.groupCollapsed("info", "[HMR] - " + parts.pop()); | ||
log("info", "[HMR] - " + moduleId); | ||
log.groupEnd("info"); | ||
} else { | ||
log("info", "[HMR] - " + moduleId); | ||
} | ||
}); | ||
var numberIds = renewedModules.every(function(moduleId) { | ||
return typeof moduleId === "number"; | ||
}); | ||
if (numberIds) | ||
log( | ||
"info", | ||
"[HMR] Consider using the NamedModulesPlugin for module names." | ||
); | ||
} | ||
}; | ||
/***/ }), | ||
/***/ "./node_modules/webpack/hot/log.js": | ||
/*!****************************!*\ | ||
!*** (webpack)/hot/log.js ***! | ||
\****************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
var logLevel = "info"; | ||
function dummy() {} | ||
function shouldLog(level) { | ||
var shouldLog = | ||
(logLevel === "info" && level === "info") || | ||
(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") || | ||
(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error"); | ||
return shouldLog; | ||
} | ||
function logGroup(logFn) { | ||
return function(level, msg) { | ||
if (shouldLog(level)) { | ||
logFn(msg); | ||
} | ||
}; | ||
} | ||
module.exports = function(level, msg) { | ||
if (shouldLog(level)) { | ||
if (level === "info") { | ||
console.log(msg); | ||
} else if (level === "warning") { | ||
console.warn(msg); | ||
} else if (level === "error") { | ||
console.error(msg); | ||
} | ||
} | ||
}; | ||
/* eslint-disable node/no-unsupported-features/node-builtins */ | ||
var group = console.group || dummy; | ||
var groupCollapsed = console.groupCollapsed || dummy; | ||
var groupEnd = console.groupEnd || dummy; | ||
/* eslint-enable node/no-unsupported-features/node-builtins */ | ||
module.exports.group = logGroup(group); | ||
module.exports.groupCollapsed = logGroup(groupCollapsed); | ||
module.exports.groupEnd = logGroup(groupEnd); | ||
module.exports.setLogLevel = function(level) { | ||
logLevel = level; | ||
}; | ||
module.exports.formatError = function(err) { | ||
var message = err.message; | ||
var stack = err.stack; | ||
if (!stack) { | ||
return message; | ||
} else if (stack.indexOf(message) < 0) { | ||
return message + "\n" + stack; | ||
} else { | ||
return stack; | ||
} | ||
}; | ||
/***/ }), | ||
/***/ "./node_modules/webpack/hot/poll.js?1000": | ||
/*!**********************************!*\ | ||
!*** (webpack)/hot/poll.js?1000 ***! | ||
\**********************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(__resourceQuery) {/* | ||
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
/*globals __resourceQuery */ | ||
if (true) { | ||
var hotPollInterval = +__resourceQuery.substr(1) || 10 * 60 * 1000; | ||
var log = __webpack_require__(/*! ./log */ "./node_modules/webpack/hot/log.js"); | ||
var checkForUpdate = function checkForUpdate(fromUpdate) { | ||
if (module.hot.status() === "idle") { | ||
module.hot | ||
.check(true) | ||
.then(function(updatedModules) { | ||
if (!updatedModules) { | ||
if (fromUpdate) log("info", "[HMR] Update applied."); | ||
return; | ||
} | ||
__webpack_require__(/*! ./log-apply-result */ "./node_modules/webpack/hot/log-apply-result.js")(updatedModules, updatedModules); | ||
checkForUpdate(true); | ||
}) | ||
.catch(function(err) { | ||
var status = module.hot.status(); | ||
if (["abort", "fail"].indexOf(status) >= 0) { | ||
log("warning", "[HMR] Cannot apply update."); | ||
log("warning", "[HMR] " + log.formatError(err)); | ||
log("warning", "[HMR] You need to restart the application!"); | ||
} else { | ||
log("warning", "[HMR] Update failed: " + log.formatError(err)); | ||
} | ||
}); | ||
} | ||
}; | ||
setInterval(checkForUpdate, hotPollInterval); | ||
} else {} | ||
/* WEBPACK VAR INJECTION */}.call(this, "?1000")) | ||
/***/ }), | ||
/***/ "./src/index.ts": | ||
/*!**********************!*\ | ||
!*** ./src/index.ts ***! | ||
\**********************/ | ||
/*! exports provided: readYamlSync */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
@@ -952,25 +776,11 @@ | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */ var _sls_yaml__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sls-yaml */ "./src/sls-yaml.ts"); | ||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "readYamlSync", function() { return _sls_yaml__WEBPACK_IMPORTED_MODULE_0__["readYamlSync"]; }); | ||
// EXTERNAL MODULE: external "tslib" | ||
var external_tslib_ = __webpack_require__("tslib"); | ||
// CONCATENATED MODULE: ./src/sls-yaml-compiler.ts | ||
var fs = __webpack_require__("fs"); | ||
var path = __webpack_require__("path"); | ||
var get = __webpack_require__("lodash.get"); | ||
/***/ }), | ||
/***/ "./src/sls-yaml-compiler.ts": | ||
/*!**********************************!*\ | ||
!*** ./src/sls-yaml-compiler.ts ***! | ||
\**********************************/ | ||
/*! exports provided: compile */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compile", function() { return compile; }); | ||
/* harmony import */ var _sls_yaml__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sls-yaml */ "./src/sls-yaml.ts"); | ||
var fs = __webpack_require__(/*! fs */ "fs"); | ||
var path = __webpack_require__(/*! path */ "path"); | ||
var get = __webpack_require__(/*! lodash.get */ "lodash.get"); | ||
var YamlError = { | ||
@@ -981,3 +791,3 @@ UnknonwReference: function (name) { | ||
}; | ||
var globalObj; | ||
var sls_yaml_compiler_globalObj; | ||
var selfObj = {}; | ||
@@ -989,5 +799,5 @@ var functions = { | ||
if (ext === "yml") { | ||
var ymlObj = Object(_sls_yaml__WEBPACK_IMPORTED_MODULE_0__["default"])(resolvedPath, { | ||
var ymlObj = sls_yaml(resolvedPath, { | ||
name: parentName, | ||
self: globalObj | ||
self: sls_yaml_compiler_globalObj | ||
}); | ||
@@ -1007,3 +817,3 @@ return ymlObj; | ||
global: function (name) { | ||
return get(globalObj, name); | ||
return get(sls_yaml_compiler_globalObj, name); | ||
}, | ||
@@ -1237,4 +1047,4 @@ self: function (name) { | ||
} | ||
function parse(content, root, basePath) { | ||
if (root === void 0) { root = {}; } | ||
function parse(content, parent, basePath) { | ||
if (parent === void 0) { parent = {}; } | ||
if (typeof content === "object") { | ||
@@ -1254,3 +1064,3 @@ if (!content) { | ||
else if (typeof value === "object") { | ||
var child = {}; | ||
var child = Array.isArray(value) ? [] : {}; | ||
newValue = print(parse(value, child, basePath), basePath, key); | ||
@@ -1261,6 +1071,6 @@ } | ||
} | ||
root[key] = newValue; | ||
parent[key] = newValue; | ||
selfObj[key] = newValue; | ||
}); | ||
return root; | ||
return parent; | ||
} | ||
@@ -1272,28 +1082,14 @@ // Convert all non-objects to string | ||
var doc = _a.doc, _globalObj = _a.globalObj, basePath = _a.basePath; | ||
globalObj = _globalObj; | ||
sls_yaml_compiler_globalObj = _globalObj; | ||
selfObj = doc; | ||
var node = parse(doc, {}, basePath); | ||
var root = {}; | ||
var node = parse(doc, root, basePath); | ||
return node; | ||
} | ||
// CONCATENATED MODULE: ./src/sls-yaml.ts | ||
/***/ }), | ||
/***/ "./src/sls-yaml.ts": | ||
/*!*************************!*\ | ||
!*** ./src/sls-yaml.ts ***! | ||
\*************************/ | ||
/*! exports provided: readYamlSync, default */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "readYamlSync", function() { return readYamlSync; }); | ||
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "tslib"); | ||
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tslib__WEBPACK_IMPORTED_MODULE_0__); | ||
/* harmony import */ var _sls_yaml_compiler__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sls-yaml-compiler */ "./src/sls-yaml-compiler.ts"); | ||
var fs = __webpack_require__(/*! fs */ "fs"); | ||
var yaml = __webpack_require__(/*! js-yaml */ "js-yaml"); | ||
var sls_yaml_fs = __webpack_require__("fs"); | ||
var yaml = __webpack_require__("js-yaml"); | ||
function readYamlSync(pathOrData, parent) { | ||
@@ -1304,3 +1100,3 @@ var _a; | ||
basePath = pathOrData.substring(0, pathOrData.lastIndexOf("/")); | ||
data = fs.readFileSync(pathOrData, "utf8"); | ||
data = sls_yaml_fs.readFileSync(pathOrData, "utf8"); | ||
} | ||
@@ -1313,21 +1109,20 @@ if (pathOrData instanceof Buffer) { | ||
if (parent) { | ||
globalObj = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, parent.self, (_a = {}, _a[parent.name] = doc, _a)); | ||
globalObj = external_tslib_["__assign"]({}, parent.self, (_a = {}, _a[parent.name] = doc, _a)); | ||
} | ||
var compiledDoc = Object(_sls_yaml_compiler__WEBPACK_IMPORTED_MODULE_1__["compile"])({ doc: doc, globalObj: globalObj, basePath: basePath }); | ||
var compiledDoc = compile({ doc: doc, globalObj: globalObj, basePath: basePath }); | ||
return compiledDoc; | ||
} | ||
/* harmony default export */ __webpack_exports__["default"] = (readYamlSync); | ||
/* harmony default export */ var sls_yaml = (readYamlSync); | ||
// CONCATENATED MODULE: ./src/index.ts | ||
/* concated harmony reexport readYamlSync */__webpack_require__.d(__webpack_exports__, "readYamlSync", function() { return readYamlSync; }); | ||
/***/ }), | ||
/***/ 0: | ||
/*!**************************************************!*\ | ||
!*** multi webpack/hot/poll?1000 ./src/index.ts ***! | ||
\**************************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
__webpack_require__(/*! webpack/hot/poll?1000 */"./node_modules/webpack/hot/poll.js?1000"); | ||
module.exports = __webpack_require__(/*! ./src/index.ts */"./src/index.ts"); | ||
module.exports = __webpack_require__("./src/index.ts"); | ||
@@ -1338,6 +1133,2 @@ | ||
/***/ "fs": | ||
/*!*********************!*\ | ||
!*** external "fs" ***! | ||
\*********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
@@ -1350,6 +1141,2 @@ | ||
/***/ "js-yaml": | ||
/*!**************************!*\ | ||
!*** external "js-yaml" ***! | ||
\**************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
@@ -1362,6 +1149,2 @@ | ||
/***/ "lodash.get": | ||
/*!*****************************!*\ | ||
!*** external "lodash.get" ***! | ||
\*****************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
@@ -1374,6 +1157,2 @@ | ||
/***/ "path": | ||
/*!***********************!*\ | ||
!*** external "path" ***! | ||
\***********************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
@@ -1386,6 +1165,2 @@ | ||
/***/ "tslib": | ||
/*!************************!*\ | ||
!*** external "tslib" ***! | ||
\************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
@@ -1392,0 +1167,0 @@ |
{ | ||
"name": "sls-yaml", | ||
"version": "1.0.8", | ||
"version": "1.0.11", | ||
"description": "Serverless framework yaml extension parser", | ||
@@ -9,2 +9,10 @@ "main": "dist/index.js", | ||
"author": "Nidin Vinayakan <01@01alchemist.com>", | ||
"keywords": [ | ||
"yaml", | ||
"yml", | ||
"parser", | ||
"sls", | ||
"serverless", | ||
"configuration" | ||
], | ||
"license": "MIT", | ||
@@ -16,3 +24,4 @@ "private": false, | ||
"start": "webpack --watch", | ||
"build": "webpack", | ||
"build.dev": "webpack", | ||
"build": "NODE_ENV=production webpack", | ||
"precommit": "lint-staged", | ||
@@ -19,0 +28,0 @@ "test": "NODE_ENV=test jest --ci --config=./jest.json --coverage --reporters=default --reporters=jest-junit" |
@@ -270,3 +270,3 @@ const fs = require("fs"); | ||
function parse(content: any, root: any = {}, basePath: string): any { | ||
function parse(content: any, parent: any = {}, basePath: string): any { | ||
if (typeof content === "object") { | ||
@@ -285,3 +285,3 @@ if (!content) { | ||
} else if (typeof value === "object") { | ||
const child = {}; | ||
const child = Array.isArray(value) ? [] : {}; | ||
newValue = print(parse(value, child, basePath), basePath, key); | ||
@@ -291,6 +291,6 @@ } else { | ||
} | ||
root[key] = newValue; | ||
parent[key] = newValue; | ||
selfObj[key] = newValue; | ||
}); | ||
return root; | ||
return parent; | ||
} | ||
@@ -314,4 +314,5 @@ // Convert all non-objects to string | ||
selfObj = doc; | ||
const node = parse(doc, {}, basePath); | ||
const root = {}; | ||
const node = parse(doc, root, basePath); | ||
return node; | ||
} |
@@ -247,3 +247,97 @@ import yaml from "./sls-yaml"; | ||
}); | ||
describe("When passing an list with file reference", () => { | ||
it("Should return concatenated list", () => { | ||
const content = Buffer.from( | ||
[ | ||
"list:", | ||
" - item 1", | ||
" - ${file(src/__mocks__/file.yml)}", | ||
" - item 2" | ||
].join("\n") | ||
); | ||
const doc = yaml(content); | ||
expect(doc).toEqual({ | ||
list: ["item 1", { key: "value" }, "item 2"] | ||
}); | ||
}); | ||
}); | ||
describe("When passing an list with variable reference", () => { | ||
it("Should return concatenated list", () => { | ||
const content = Buffer.from( | ||
[ | ||
"name: variable-list", | ||
"version: 1", | ||
"list:", | ||
" - item 1", | ||
" - ${global:name}", | ||
" - ${self:version}", | ||
" - ${env:NODE_ENV}", | ||
" - item 2" | ||
].join("\n") | ||
); | ||
const doc = yaml(content); | ||
expect(doc).toEqual({ | ||
name: "variable-list", | ||
version: 1, | ||
list: ["item 1", "variable-list", 1, "test", "item 2"] | ||
}); | ||
}); | ||
}); | ||
describe("When passing a list of object with variable reference", () => { | ||
it("Should return concatenated list", () => { | ||
const content = Buffer.from( | ||
[ | ||
"name: variable-list", | ||
"version: 1", | ||
"list:", | ||
" - key1: item 1", | ||
" - key2: ${global:name}", | ||
" - key3: ${self:version}", | ||
" - key4: ${env:NODE_ENV}", | ||
" - key5: item 2" | ||
].join("\n") | ||
); | ||
const doc = yaml(content); | ||
expect(doc).toEqual({ | ||
name: "variable-list", | ||
version: 1, | ||
list: [ | ||
{ key1: "item 1" }, | ||
{ key2: "variable-list" }, | ||
{ key3: 1 }, | ||
{ key4: "test" }, | ||
{ key5: "item 2" } | ||
] | ||
}); | ||
}); | ||
}); | ||
describe("When passing a list of object with file reference", () => { | ||
it("Should return concatenated list", () => { | ||
const content = Buffer.from( | ||
[ | ||
"name: variable-list", | ||
"version: 1", | ||
"list:", | ||
" - key1: item 1", | ||
" - key2: ${file(src/__mocks__/file.yml)}", | ||
" - key3: item 2" | ||
].join("\n") | ||
); | ||
const doc = yaml(content); | ||
expect(doc).toEqual({ | ||
name: "variable-list", | ||
version: 1, | ||
list: [ | ||
{ key1: "item 1" }, | ||
{ key2: { key: "value" } }, | ||
{ key3: "item 2" } | ||
] | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,3 +5,3 @@ const fs = require("fs-extra"); | ||
const nodeExternals = require("webpack-node-externals"); | ||
const CleanWebpackPlugin = require("clean-webpack-plugin"); | ||
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); | ||
const PrettierPlugin = require("prettier-webpack-plugin"); | ||
@@ -8,0 +8,0 @@ const DeclarationBundlerPlugin = require("tsd-webpack-plugin"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117220
15
1951