scryptlib
Advanced tools
Comparing version 2.1.33 to 2.1.34
@@ -9,3 +9,2 @@ "use strict"; | ||
var path_1 = require("path"); | ||
var compareVersions = require("compare-versions"); | ||
var showNoCompilerFound = require("../util/showerror"); | ||
@@ -25,24 +24,2 @@ function getPlatformScryptc() { | ||
exports.getPlatformScryptc = getPlatformScryptc; | ||
function find_compiler_vscode() { | ||
var homedir = os.homedir(); | ||
var extensionPath = (0, path_1.join)(homedir, '.vscode/extensions'); | ||
if (!(0, fs_1.existsSync)(extensionPath)) { | ||
return undefined; | ||
} | ||
var sCryptPrefix = 'bsv-scrypt.scrypt-'; | ||
var versions = (0, fs_1.readdirSync)(extensionPath).reduce(function (filtered, item) { | ||
if (item.indexOf(sCryptPrefix) > -1) { | ||
var version = item.substring(sCryptPrefix.length); | ||
if (compareVersions.validate(version)) { | ||
filtered.push(version); | ||
} | ||
} | ||
return filtered; | ||
}, []); | ||
// compareVersions is ascending, so reverse. | ||
versions = versions.sort(compareVersions).reverse(); | ||
var sCryptExtensionDirName = sCryptPrefix + versions[0]; | ||
var scryptc = (0, path_1.join)(extensionPath, sCryptExtensionDirName, getPlatformScryptc()); | ||
return (0, fs_1.existsSync)(scryptc) ? scryptc : undefined; | ||
} | ||
function find_compiler_local(directory) { | ||
@@ -91,6 +68,2 @@ if (directory === void 0) { directory = __dirname; } | ||
} | ||
scryptc = find_compiler_vscode(); | ||
if (scryptc && (0, fs_1.existsSync)(scryptc)) { | ||
return scryptc; | ||
} | ||
showNoCompilerFound(); | ||
@@ -97,0 +70,0 @@ } |
{ | ||
"name": "scryptlib", | ||
"version": "2.1.33", | ||
"version": "2.1.34", | ||
"description": "Javascript SDK for integration of Bitcoin SV Smart Contracts written in sCrypt language.", | ||
@@ -69,3 +69,5 @@ "engines": { | ||
"find-node-modules": "^2.1.3", | ||
"get-proxy-settings": "^0.1.13", | ||
"glob": "^7.2.3", | ||
"https-proxy-agent": "^7.0.2", | ||
"json-bigint": "^1.0.0", | ||
@@ -77,2 +79,2 @@ "node-fetch": "^3.0.0", | ||
} | ||
} | ||
} |
@@ -5,7 +5,2 @@ | ||
autoPatch(); | ||
if (fs.existsSync('./dist')) { | ||
var { getBinary } = require("./util/getBinary") | ||
getBinary() | ||
} | ||
autoPatch(); |
@@ -8,3 +8,6 @@ const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args)); | ||
const chalk = require("chalk"); | ||
const { findCompiler, compilerVersion, getPlatformScryptc } = require('../dist'); | ||
const { getProxySettings } = require("get-proxy-settings"); | ||
const { HttpsProxyAgent } = require('https-proxy-agent'); | ||
const { compilerVersion, getPlatformScryptc } = require('../dist'); | ||
const { showDownloadFailed } = require('./showerror'); | ||
@@ -30,4 +33,7 @@ const DEFAULT_COMPILER_VERSION = '1.19.1'; | ||
const proxy = await getProxySettings(); | ||
if (version === "latest") { | ||
const fromAPI = await fetch('https://api.github.com/repos/scrypt-inc/compiler_dist/releases'); | ||
const fromAPI = await fetch('https://api.github.com/repos/scrypt-inc/compiler_dist/releases', | ||
proxy !== null && proxy.https ? { agent: new HttpsProxyAgent(proxy.https) } : {}); | ||
const res = await fromAPI.json(); | ||
@@ -54,11 +60,2 @@ | ||
const compilerPath = findCompiler(); | ||
if (compilerPath && safeCompilerVersion(compilerPath).startsWith(version)) { | ||
console.log(`${chalk.green.bold(` | ||
${chalk.green.bold("✔")}`)}`, `${chalk.green.bold(`A latest sCrypt compiler found at: ${compilerPath}`)}`); | ||
return | ||
} | ||
const streamPipeline = util.promisify(stream.pipeline); | ||
@@ -74,22 +71,24 @@ const urlCompiler = `https://github.com/sCrypt-Inc/compiler_dist/releases/download/v${version}/scryptc-${version}-${FILENAME}` | ||
console.info(`${chalk.yellow.bold(` | ||
${chalk.grey("•")}`, `Downloading sCrypt compiler ${urlCompiler} ...`)}`); | ||
${chalk.grey("•")}`, `Downloading sCrypt compiler: ${version} ...`)}`); | ||
const fromRelease = await fetch(urlCompiler); | ||
if (!fromRelease.ok) { | ||
console.log(`⛔️ ${chalk.bgRed('Download Unsuccesful:')} ${fromRelease.statusText}`); | ||
} else { | ||
await streamPipeline(fromRelease.body, fs.createWriteStream(filePathCompiler)); | ||
fs.chmodSync(filePathCompiler, '755'); | ||
console.info(`${chalk.green.bold(` | ||
${chalk.green("✔")}`)}`, chalk.green.bold(`Download Successful.`)); | ||
try { | ||
const fromRelease = await fetch(urlCompiler, proxy !== null && proxy.https ? { | ||
agent: new HttpsProxyAgent(proxy.https) | ||
} : {}); | ||
if (!fromRelease.ok) { | ||
showDownloadFailed(); | ||
return | ||
} else { | ||
await streamPipeline(fromRelease.body, fs.createWriteStream(filePathCompiler)); | ||
fs.chmodSync(filePathCompiler, '755'); | ||
console.info(`${chalk.green.bold(` | ||
${chalk.green("✔")}`)}`, chalk.green.bold(`Successfully downloaded. File Path: ${filePathCompiler}`)); | ||
console.info(`${chalk.yellow.bold(` | ||
${chalk.grey("•")}`, `Compiler file path: ${filePathCompiler}`)}`); | ||
} | ||
} catch (error) { | ||
showDownloadFailed(); | ||
} | ||
console.info(`${chalk.yellow.bold(` | ||
${chalk.grey("•")}`, `Compiler vesion: ${safeCompilerVersion(filePathCompiler)}`)}`); | ||
} | ||
} | ||
@@ -96,0 +95,0 @@ |
const chalk = require('chalk'); | ||
function showNoCompilerFound() { | ||
console.info(`${chalk.bgRed.bold('**ERROR**: No sCrypt compiler found.')}`); | ||
} | ||
console.info(`${chalk.green.bold('You can install the compiler in the following ways: \n')}`); | ||
console.info(`${chalk.grey('•')}`, `Run ${chalk.yellow.bold('npx scryptlib download')} to download the sCrypt compiler.`); | ||
console.info(`${chalk.grey('•')}`, `Install ${chalk.bold('sCrypt IDE')} at vscode extension marketplace: ${chalk.blue.bold('https://marketplace.visualstudio.com/items?itemName=bsv-scrypt.sCrypt')}`); | ||
function showDownloadFailed() { | ||
console.info(`${chalk.bgRed.bold('**ERROR**: Downloading sCrypt compiler failed.')}`); | ||
console.info(`Go to ${chalk.blue.bold('https://github.com/sCrypt-Inc/compiler_dist/releases')} to download sCrypt compiler.\n`); | ||
} | ||
module.exports = showNoCompilerFound; | ||
module.exports = { showNoCompilerFound, showDownloadFailed }; |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
975687
13
24052
6
+ Addedget-proxy-settings@^0.1.13
+ Addedhttps-proxy-agent@^7.0.2
+ Addedagent-base@7.1.3(transitive)
+ Addedconfig-chain@1.1.13(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedget-proxy-settings@0.1.13(transitive)
+ Addedhttps-proxy-agent@7.0.6(transitive)
+ Addedms@2.1.3(transitive)
+ Addednpm-conf@1.1.3(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedproto-list@1.2.4(transitive)