Comparing version
@@ -35,3 +35,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/******/ // eslint-disable-next-line no-unused-vars | ||
/******/ var hotCurrentHash = "681b9e457b43d59a72c6"; | ||
/******/ var hotCurrentHash = "de2101b7e1d32736d60f"; | ||
/******/ var hotRequestTimeout = 10000; | ||
@@ -781,3 +781,2 @@ /******/ var hotCurrentModuleData = {}; | ||
var path = __webpack_require__("path"); | ||
var spawnSync = __webpack_require__("child_process").spawnSync; | ||
var get = __webpack_require__("lodash.get"); | ||
@@ -810,16 +809,2 @@ | ||
}, | ||
git: function (name) { | ||
var cmds; | ||
switch (name) { | ||
case "branch": | ||
cmds = ["rev-parse", "--abbrev-ref", "HEAD"]; | ||
break; | ||
case "sha1": | ||
cmds = ["rev-parse", "HEAD"]; | ||
break; | ||
} | ||
var result = spawnSync("git", cmds); | ||
var output = result.output.toString().replace(/,|\n/gi, ""); | ||
return output; | ||
}, | ||
env: function (name) { | ||
@@ -1058,4 +1043,4 @@ return process.env[name]; | ||
} | ||
function parse(content, parent, basePath) { | ||
if (parent === void 0) { parent = {}; } | ||
function parse(content, root, basePath) { | ||
if (root === void 0) { root = {}; } | ||
if (typeof content === "object") { | ||
@@ -1075,3 +1060,3 @@ if (!content) { | ||
else if (typeof value === "object") { | ||
var child = Array.isArray(value) ? [] : {}; | ||
var child = {}; | ||
newValue = print(parse(value, child, basePath), basePath, key); | ||
@@ -1082,6 +1067,6 @@ } | ||
} | ||
parent[key] = newValue; | ||
root[key] = newValue; | ||
selfObj[key] = newValue; | ||
}); | ||
return parent; | ||
return root; | ||
} | ||
@@ -1095,4 +1080,3 @@ // Convert all non-objects to string | ||
selfObj = doc; | ||
var root = {}; | ||
var node = parse(doc, root, basePath); | ||
var node = parse(doc, {}, basePath); | ||
return node; | ||
@@ -1141,9 +1125,2 @@ } | ||
/***/ "child_process": | ||
/***/ (function(module, exports) { | ||
module.exports = require("child_process"); | ||
/***/ }), | ||
/***/ "fs": | ||
@@ -1150,0 +1127,0 @@ /***/ (function(module, exports) { |
{ | ||
"name": "sls-yaml", | ||
"version": "1.0.12", | ||
"version": "1.0.14", | ||
"description": "Serverless framework yaml extension parser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
## Serverless YAML extension parser | ||
[](https://circleci.com/gh/01alchemist/sls-yaml/tree/master) [](https://codeclimate.com/github/01alchemist/sls-yaml/maintainability) [](https://codeclimate.com/github/01alchemist/sls-yaml/test_coverage) | ||
[![CircleCI]][ci-sls-yaml] [![Maintainability]][codeclimate] [![Test Coverage]][coverage] | ||
@@ -11,3 +11,7 @@ This tiny library will parse YAML extensions used in serverless framework. | ||
- [Inject local variables](#inject-local-variables) `${self:path.to.variable}` | ||
- [Inject current git branch](#inject-current-git-branch)* `${git:branch}` | ||
- [Inject last git commit hash](#inject-last-git-commit-hash)* `${git:sha1}` | ||
`* - New extension not present in serverless yaml` | ||
### Include external file | ||
@@ -98,2 +102,26 @@ This extension will include content of external yaml files. | ||
endpoint: http://service:8080 | ||
``` | ||
``` | ||
### Inject current git branch | ||
This extension will inject current git branch name | ||
- config.yml | ||
```yaml | ||
branch: ${git:branch} | ||
``` | ||
### Inject last git commit hash | ||
This extension will inject last git commit hash | ||
- config.yml | ||
```yaml | ||
image.tag: ${git:sha1} | ||
``` | ||
[CircleCI]:https://circleci.com/gh/01alchemist/sls-yaml/tree/master.svg?style=svg | ||
[ci-sls-yaml]:https://circleci.com/gh/01alchemist/sls-yaml/tree/master | ||
[Maintainability]:https://api.codeclimate.com/v1/badges/d3b19c4c45ebf451faf3/maintainability | ||
[codeclimate]:https://codeclimate.com/github/01alchemist/sls-yaml/maintainability | ||
[Test Coverage]:https://api.codeclimate.com/v1/badges/d3b19c4c45ebf451faf3/test_coverage | ||
[coverage]:https://codeclimate.com/github/01alchemist/sls-yaml/test_coverage |
@@ -57,2 +57,5 @@ const fs = require("fs"); | ||
return get(selfObj, name); | ||
}, | ||
helm: (template: string) => { | ||
return `{{ ${template} }}`; | ||
} | ||
@@ -213,3 +216,3 @@ }; | ||
}); | ||
valueNode.nextChild = node; | ||
@@ -220,17 +223,2 @@ | ||
// function cast(value: any) { | ||
// switch (value) { | ||
// case "undefined": | ||
// return undefined; | ||
// case "null": | ||
// return null; | ||
// case "true": | ||
// return true; | ||
// case "false": | ||
// return false; | ||
// default: | ||
// return value; | ||
// } | ||
// } | ||
function print(node: Node | null, basePath: string, parentName: string): any { | ||
@@ -237,0 +225,0 @@ if (!node) { |
@@ -357,2 +357,13 @@ import yaml from "./sls-yaml"; | ||
}); | ||
describe("Helm template syntax test suite", () => { | ||
describe("When passing a helm template syntax", () => { | ||
it("Should pass-through those syntax", () => { | ||
const content = Buffer.from("replicas: ${helm:.Values.replicas}"); | ||
const result = yaml(content); | ||
console.log(result); | ||
expect(result.replicas).toBe("{{ .Values.replicas }}"); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
394543
229.42%29
93.33%2593
29.71%126
28.57%0
-100%1
Infinity%