@arso-project/sonar-tantivy
Advanced tools
Comparing version 0.2.11 to 0.2.12
{ | ||
"name": "@arso-project/sonar-tantivy", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"description": "A tantivy search engine", | ||
@@ -5,0 +5,0 @@ "main": "src-nodejs/index.js", |
@@ -6,3 +6,3 @@ const fs = require('fs') | ||
const toml = require('toml') | ||
const { execSync, exec } = require('child_process') | ||
const { exec, spawnSync } = require('child_process') | ||
const debug = require('debug') | ||
@@ -20,3 +20,3 @@ | ||
win32: { | ||
x64: 'x86_64-pc-windows-gnu' | ||
x64: 'x86_64-pc-windows-msvc' | ||
}, | ||
@@ -42,4 +42,13 @@ darwin: { | ||
const ct = cargoToml() | ||
const platform = os.platform() | ||
const platform = process.env.CI_PLATFORM || os.platform() | ||
const arch = process.env.CI_ARCH || os.arch() | ||
if (!TARGETS[platform]) { | ||
throw new Error(`Platform ${platform} is not supported.`) | ||
} | ||
if (!TARGETS[platform][arch]) { | ||
throw new Error(`Architecture ${arch} is not supported on platform ${platform}.`) | ||
} | ||
const targetTriple = TARGETS[platform][arch] | ||
const binaries = ct.bin ? ct.bin.map(b => b.name) : [ct.name] | ||
@@ -53,4 +62,5 @@ binaries.forEach((bin, i) => { | ||
binaries, | ||
targetTriple: targetTriple(), | ||
dest: DIST_PATH | ||
targetTriple, | ||
dest: DIST_PATH, | ||
platform | ||
} | ||
@@ -93,17 +103,37 @@ | ||
cb = once(cb) | ||
const { tag, targetTriple, dest } = opts | ||
const { tag, targetTriple, platform, dest } = opts | ||
const filename = `${REPO_NAME}-${tag}-${targetTriple}.tar.gz` | ||
let filename | ||
if (platform === 'win32') { | ||
filename = `${REPO_NAME}-${tag}-${targetTriple}.zip` | ||
} else { | ||
filename = `${REPO_NAME}-${tag}-${targetTriple}.tar.gz` | ||
} | ||
const url = `https://github.com/${REPO_ORG}/${REPO_NAME}/releases/download/${tag}/${filename}` | ||
const tarfile = p.join(dest, filename) | ||
const filepath = p.join(dest, filename) | ||
console.log(` Download: ${url}`) | ||
download(url, tarfile, extract) | ||
download(url, filepath, extract) | ||
function extract (err) { | ||
if (err) return done(err) | ||
if (!fs.existsSync(tarfile)) return done(new Error('Error: Download failed.')) | ||
if (!fs.existsSync(filepath)) return done(new Error('Error: Download failed.')) | ||
// TODO: Handle windows? | ||
try { | ||
execSync(`tar -xzf ${tarfile} -C ${dest}`) | ||
let res | ||
if (opts.platform === 'win32') { | ||
// Taken from https://github.com/feross/cross-zip/blob/master/index.js | ||
res = spawnSync('powershell.exe', [ | ||
'-nologo', | ||
'-noprofile', | ||
'-command', '& { param([String]$myInPath, [String]$myOutPath); Add-Type -A "System.IO.Compression.FileSystem"; [IO.Compression.ZipFile]::ExtractToDirectory($myInPath, $myOutPath); }', | ||
'-myInPath', filepath, | ||
'-myOutPath', dest | ||
]) | ||
} else { | ||
res = spawnSync('tar', ['-xzf', filepath, '-C', dest]) | ||
} | ||
if (res.error) { | ||
throw new Error('Failed to extract archive, Error: ' + res.error.message) | ||
} | ||
for (let bin of opts.binaries) { | ||
@@ -119,19 +149,6 @@ if (!fs.existsSync(p.join(dest, bin))) return done(new Error('Error: Binary is not in archive.')) | ||
function done (err) { | ||
fs.unlink(tarfile, err2 => cb(err || err2)) | ||
fs.unlink(filepath, err2 => cb(err || err2)) | ||
} | ||
} | ||
function targetTriple () { | ||
const platform = os.platform() | ||
const arch = os.arch() | ||
if (!TARGETS[platform]) { | ||
throw new Error(`Platform ${platform} is not supported.`) | ||
} | ||
if (!TARGETS[platform][arch]) { | ||
throw new Error(`Architecture ${arch} is not supported on platform ${platform}.`) | ||
} | ||
return TARGETS[platform][arch] | ||
} | ||
function cargoToml () { | ||
@@ -138,0 +155,0 @@ const str = fs.readFileSync(CARGO_PATH).toString() |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
66121
721
9