Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
This tiny library will parse YAML extensions used in serverless framework.
npm install sls-yaml
import yaml from "sls-yaml";
const compiledYamlAsJsonObject = yaml(YAML_FILE_PATH_OR_BUFFER);
${file(path/to/file.yml)}
${env:NODE_ENV}
${global:path.to.variable}
${self:path.to.variable}
${git:branch}
${git:sha1}
${replace(str, searchPattern, replaceValue )}
* - New extension not present in serverless yaml
const context = {
custom: ([arg]: string[]) => {
return `${arg}-beta`;
}
};
const result = yaml(content, null, context);
name: service
version: v1.0.2
subset: service@${custom(${self:version})}
name: service
version: v1.0.2
subset: service@v1.0.2-beta
This extension will include content of external yaml files.
version: 1
env: dev
config: ${file(./common.yml)}
endpoint: http://service-url
version: 1
env: dev
config:
endpoint: http://service-url
This extension will inject envronment values
export NODE_ENV = development
version: 1
env: ${env:NODE_ENV}
version: 1
env: development
This extension will inject variable from global scope.
version: 1
env: stage
config: ${file(./common.yml)}
endpoint: http://service-${global:env}
version: 1
env: stage
config:
endpoint: http://service-stage
This extension will inject variable from local scope.
version: 1
env: stage
config: ${file(./common.yml)}
port: 8080
endpoint: http://service:${self:port}
version: 1
env: stage
config:
port: 8080
endpoint: http://service:8080
This extension will inject current git branch name
branch: ${git:branch}
This extension will inject last git commit hash
image.tag: ${git:sha1}
replace(str:string, searchPattern:RegExp|string, replaceValue:string )
This extension will returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match. If pattern is a string, only the first occurrence will be replaced.
version: v1.0.0
name: ServiceName@${replace(${ self : version }, /\\./gi, - )}
version: v1.0.0
name: ServiceName@v1-0-0
FAQs
Serverless framework yaml extension parser
The npm package sls-yaml receives a total of 13 weekly downloads. As such, sls-yaml popularity was classified as not popular.
We found that sls-yaml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.