New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flavor-manager

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flavor-manager - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

16

package.json
{
"name": "flavor-manager",
"version": "1.0.0",
"version": "1.1.0",
"description": "",

@@ -8,3 +8,5 @@ "main": "src/index.js",

"scripts": {
"test": "snyk test"
"test": "snyk test",
"snyk-protect": "snyk protect",
"prepare": "npm run snyk-protect"
},

@@ -14,5 +16,6 @@ "author": "Fabio Cigliano <fabio.cigliano@gmail.com> (http://fabio.cigliano.name)",

"dependencies": {
"mkdirp": "^0.5.1",
"regex-replace-file": "^2.1.1",
"scandir": "^0.1.2",
"yargs": "^12.0.5"
"yargs": "^12.0.5",
"snyk": "^1.90.0"
},

@@ -22,5 +25,4 @@ "bin": {

},
"devDependencies": {
"snyk": "^1.90.0"
}
"devDependencies": {},
"snyk": true
}
const path = require('path')
const fs = require('fs')
const assert = require('assert')
const regexReplace = require('regex-replace-file')

@@ -19,3 +21,16 @@ const rollback = require('./rollback')

const r = rollback.create(flavor)
const patchList = []
// filter out files like example.patch.json
fileList = fileList.filter(filename => {
if (filename.endsWith('patch.json')) {
patchList.push(filename)
return false
}
return true
})
// copy flavor file and structure
fileList.forEach(async file => {

@@ -49,2 +64,46 @@ const sourceFile = path.join(sourceDir, file)

// apply patches
patchList.forEach(async file => {
console.info(`* apply patch ${file}`)
let data
let targetFile
let terms
try {
data = fs.readFileSync(path.join(sourceDir, file), {encoding: 'utf-8'})
data = JSON.parse(data)
assert(data.file, 'missing patch.file attribute')
targetFile = path.join(targetDir, data.file)
assert(fs.existsSync(targetFile), `missing target file ${targetFile}`)
assert(data.replace, 'missing patch.replace attribute')
assert(data.replace.length > 0, 'missing patch.replace content')
terms = data.replace
} catch (err) {
console.error(`invalid patch file ${file}`, err)
return
}
for (var i = 0; i < terms.length; i++) {
let {search, replace} = terms[i]
// console.log(search, replace)
const m = /\$\((.*)\)/.exec(replace)
if (m) {
replace = eval(m[1])
}
console.log(`* replace ${search} with ${replace} within ${data.file}`)
try {
await regexReplace(search, replace, targetFile, {
filenamesOnly: false,
fileContentsOnly: true
})
} catch (err) {
console.error('err > regexReplace', err)
}
}
})
return r.close()

@@ -51,0 +110,0 @@ }

const fs = require('fs')
const path = require('path')
const mkdirp = require('mkdirp')

@@ -6,0 +5,0 @@ function mkdirSync (targetDir) {

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