install slither as postinstall script

pull/2450/head
Aniket-Engg 2 years ago
parent 1b233b3eea
commit 519cd58c6a
  1. 3
      libs/remixd/package.json
  2. 9
      libs/remixd/src/bin/remixd.ts
  3. 25
      libs/remixd/src/scripts/installSlither.ts
  4. 29
      libs/remixd/src/services/slitherClient.ts

@ -13,7 +13,8 @@
"npip": "npip",
"lint": "eslint ./src --ext .ts",
"build": "tsc -p ./ && chmod +x ./src/bin/remixd.js",
"dev": "nodemon"
"dev": "nodemon",
"postinstall": "node src/scripts/installSlither.js"
},
"publishConfig": {
"access": "public"

@ -63,7 +63,6 @@ function errorHandler (error: any, service: string) {
.description('Establish a two-way websocket connection between the local computer and Remix IDE for a folder')
.option('-u, --remix-ide <url>', 'URL of remix instance allowed to connect')
.option('-s, --shared-folder <path>', 'Folder to share with Remix IDE (Default: CWD)')
.option('-i, --install <name>', 'Module name to install locally')
.option('-r, --read-only', 'Treat shared folder as read-only (experimental)')
.on('--help', function () {
console.log('\nExample:\n\n remixd -s ./shared_project -u http://localhost:8080')
@ -72,14 +71,6 @@ function errorHandler (error: any, service: string) {
await warnLatestVersion()
if (program.install && !program.readOnly) {
const availableModulesToInstall = ['slither']
const service = program.install
if (availableModulesToInstall.includes(program.install)) services[service](false)['install']()
else console.log('\x1b[32m%s\x1b[0m', `[INFO] ${service} can not be installed using remixd`)
process.exit(0)
}
if (!program.remixIde) {
console.log('\x1b[33m%s\x1b[0m', '[WARN] You can only connect to remixd from one of the supported origins.')
} else {

@ -0,0 +1,25 @@
const { execSync } = require('child_process') // eslint-disable-line
try {
const solcVersion = '0.8.15'
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: requires Python3.6+ (pip3) to be installed on your system`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select will be installed along with Slither to set different solc compiler versions.`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: checking pip3 availability ...`)
const pip3OP = execSync('pip3 --version')
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: pip3 found: ${pip3OP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing slither...`)
const slitherOP = execSync('pip3 install slither-analyzer')
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither installation output: ${slitherOP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc-select...`)
const solcSelectOP = execSync('pip3 install solc-select')
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select installation output: ${solcSelectOP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc ${solcVersion}...`)
const solcInstallOP = execSync(`solc-select install ${solcVersion}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc installation output: ${solcInstallOP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: setting solc version to ${solcVersion}...`)
const solcUseOP = execSync(`solc-select use ${solcVersion}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc setting installation output: ${solcUseOP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: Slither is ready to use!`)
} catch (err) {
console.log('\x1b[31m%s\x1b[0m', `[Slither Installation]: Error occured: ${err}`)
}

@ -14,7 +14,7 @@ export class SlitherClient extends PluginClient {
constructor (private readOnly = false) {
super()
this.methods = ['analyse', 'install']
this.methods = ['analyse']
}
setWebSocket (websocket: WS): void {
@ -25,33 +25,6 @@ export class SlitherClient extends PluginClient {
this.currentSharedFolder = currentSharedFolder
}
install (): void {
try {
const solcVersion = '0.8.15'
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: requires Python3.6+ (pip3) to be installed on your system`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select will be installed along with Slither to set different solc compiler versions.`)
const options = { cwd: this.currentSharedFolder, shell: true }
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: checking pip3 availability ...`)
const pip3OP = execSync('pip3 --version', options)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: pip3 found: ${pip3OP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing slither...`)
const slitherOP = execSync('pip3 install slither-analyzer', options)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither installation output: ${slitherOP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc-select...`)
const solcSelectOP = execSync('pip3 install solc-select', options)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select installation output: ${solcSelectOP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc ${solcVersion}...`)
const solcInstallOP = execSync(`solc-select install ${solcVersion}`, options)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc installation output: ${solcInstallOP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: setting solc version to ${solcVersion}...`)
const solcUseOP = execSync(`solc-select use ${solcVersion}`, options)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc setting installation output: ${solcUseOP.toString()}`)
console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: Slither is ready to use!`)
} catch (err) {
console.log('\x1b[31m%s\x1b[0m', `[Slither Installation]: Error occured: ${err}`)
}
}
mapNpmDepsDir (list) {
const remixNpmDepsPath = utils.absolutePath('.deps/npm', this.currentSharedFolder)
const localNpmDepsPath = utils.absolutePath('node_modules', this.currentSharedFolder)

Loading…
Cancel
Save