Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

overlays-cli

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

overlays-cli - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

apply-overlay.js

54

index.js

@@ -1,31 +0,33 @@

const Nimma = require('nimma').default
const axios = require('axios')
const getStdin = require('./get-stdin')
const applyOverlay = require('./apply-overlay')
const unset = require('lodash/unset')
const set = require('lodash/set')
const get = require('lodash/get')
const overlaysSchema = require('./overlays.schema.json')
const jsYaml = require('js-yaml')
const Ajv = require('ajv')
const ajv = new Ajv({allErrors: true}) // options can be passed, e.g. {allErrors: true}
const validateOverlays = ajv.compile(overlaysSchema)
module.exports = {
applyOverlay
}
run().then(console.log, (err) => {
console.error(err)
process.exit(1)
})
async function applyOverlay(overlay, resolver) {
const source = await resolver(overlay.extends)
const {actions} = overlay
actions.forEach(action => {
const n = new Nimma([action.target]);
n.query(source, {
[action.target]({ path }) {
if(action.remove === true) {
unset(source, path)
} else if(action.update && typeof action.update === 'object') {
let merged = Object.assign({}, get(source, path), action.update)
set(source, path, merged)
} else if(typeof action.update !== 'undefined') {
set(source, path, action.update)
}
},
});
// Functions
async function run() {
const overlay = jsYaml.load(await getStdin())
const valid = validateOverlays(overlay)
if(!valid) {
throw validateOverlays.errors
}
})
return source
const applied = await applyOverlay(overlay, extendsResolver)
return jsYaml.dump(applied)
}
async function extendsResolver(url) {
const {data} = await axios.get(url)
if(typeof data === 'string')
return jsYaml.load(data)
return data
}
{
"name": "overlays-cli",
"version": "0.1.0",
"version": "0.2.0",
"description": "A cli tool to execute an Overlays document. See https://github.com/OAI/Overlay-Specification/",

@@ -17,2 +17,3 @@ "bin": {

"dependencies": {
"axios": "^0.27.2",
"js-yaml": "^4.1.0",

@@ -19,0 +20,0 @@ "lodash": "^4.17.21",

const fs = require('fs');
const path = require('path')
const jsYaml = require('js-yaml')
const {applyOverlay} = require('./index')
const applyOverlay = require('./apply-overlay')

@@ -6,0 +6,0 @@ describe('Test Suite', () => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc