Commit 549ff0ef authored by ioedeveloper's avatar ioedeveloper Committed by yann300

Fixed remixd linting errors

parent 1af16b14
...@@ -47,6 +47,7 @@ jobs: ...@@ -47,6 +47,7 @@ jobs:
- checkout - checkout
- run: npm install - run: npm install
- run: npm run lint - run: npm run lint
- run: npm run lint remix-ide-e2e
- run: npm run build:libs - run: npm run build:libs
- run: npm run downloadsolc_root - run: npm run downloadsolc_root
- run: npm run build - run: npm run build
...@@ -84,6 +85,7 @@ jobs: ...@@ -84,6 +85,7 @@ jobs:
- checkout - checkout
- run: npm install - run: npm install
- run: npm run lint - run: npm run lint
- run: npm run lint remix-ide-e2e
- run: npm run build:libs - run: npm run build:libs
- run: npm run downloadsolc_root - run: npm run downloadsolc_root
- run: npm run build - run: npm run build
...@@ -126,6 +128,7 @@ jobs: ...@@ -126,6 +128,7 @@ jobs:
- checkout - checkout
- run: npm install - run: npm install
- run: npm run lint - run: npm run lint
- run: npm run lint remix-ide-e2e
- run: npm run build:libs - run: npm run build:libs
- run: npm run downloadsolc_root - run: npm run downloadsolc_root
- run: npm run build - run: npm run build
......
#!/usr/bin/env node #!/usr/bin/env node
import WebSocket from '../websocket' import WebSocket from '../websocket'
import * as servicesList from '../serviceList' import * as servicesList from '../serviceList'
import * as WS from 'ws' import * as WS from 'ws' // eslint-disable-line
import { getDomain } from '../utils' import { getDomain } from '../utils'
import Axios from 'axios' import Axios from 'axios'
import * as fs from 'fs-extra' import * as fs from 'fs-extra'
...@@ -10,14 +10,14 @@ import * as program from 'commander' ...@@ -10,14 +10,14 @@ import * as program from 'commander'
(async () => { (async () => {
program program
.usage('-s <shared folder>') .usage('-s <shared folder>')
.description('Provide a two-way connection between the local computer and Remix IDE') .description('Provide a two-way connection between the local computer and Remix IDE')
.option('--remix-ide <url>', 'URL of remix instance allowed to connect to this web sockect connection') .option('--remix-ide <url>', 'URL of remix instance allowed to connect to this web sockect connection')
.option('-s, --shared-folder <path>', 'Folder to share with Remix IDE') .option('-s, --shared-folder <path>', 'Folder to share with Remix IDE')
.option('--read-only', 'Treat shared folder as read-only (experimental)') .option('--read-only', 'Treat shared folder as read-only (experimental)')
.on('--help', function(){ .on('--help', function () {
console.log('\nExample:\n\n remixd -s ./ --remix-ide http://localhost:8080') console.log('\nExample:\n\n remixd -s ./ --remix-ide http://localhost:8080')
}).parse(process.argv) }).parse(process.argv)
// eslint-disable-next-line // eslint-disable-next-line
const killCallBack: Array<Function> = [] const killCallBack: Array<Function> = []
...@@ -38,7 +38,7 @@ import * as program from 'commander' ...@@ -38,7 +38,7 @@ import * as program from 'commander'
console.log('\x1b[33m%s\x1b[0m', '[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.') console.log('\x1b[33m%s\x1b[0m', '[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.')
console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolic links are not forwarded to Remix IDE\n') console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolic links are not forwarded to Remix IDE\n')
try { try {
const sharedFolderClient = new servicesList['sharedfolder']() const sharedFolderClient = new servicesList.Sharedfolder()
const websocketHandler = new WebSocket(65520, { remixIdeUrl: program.remixIde }, sharedFolderClient) const websocketHandler = new WebSocket(65520, { remixIdeUrl: program.remixIde }, sharedFolderClient)
websocketHandler.start((ws: WS) => { websocketHandler.start((ws: WS) => {
...@@ -47,7 +47,7 @@ import * as program from 'commander' ...@@ -47,7 +47,7 @@ import * as program from 'commander'
sharedFolderClient.sharedFolder(program.sharedFolder, program.readOnly || false) sharedFolderClient.sharedFolder(program.sharedFolder, program.readOnly || false)
}) })
killCallBack.push(websocketHandler.close.bind(websocketHandler)) killCallBack.push(websocketHandler.close.bind(websocketHandler))
} catch(error) { } catch (error) {
throw new Error(error) throw new Error(error)
} }
} else { } else {
...@@ -64,7 +64,7 @@ import * as program from 'commander' ...@@ -64,7 +64,7 @@ import * as program from 'commander'
} }
} }
} }
process.on('SIGINT', kill) // catch ctrl-c process.on('SIGINT', kill) // catch ctrl-c
process.on('SIGTERM', kill) // catch kill process.on('SIGTERM', kill) // catch kill
process.on('exit', kill) process.on('exit', kill)
...@@ -73,23 +73,23 @@ import * as program from 'commander' ...@@ -73,23 +73,23 @@ import * as program from 'commander'
if (!origin) return false if (!origin) return false
const domain = getDomain(origin) const domain = getDomain(origin)
const gistUrl = 'https://gist.githubusercontent.com/EthereumRemix/091ccc57986452bbb33f57abfb13d173/raw/3367e019335746b73288e3710af2922d4c8ef5a3/origins.json' const gistUrl = 'https://gist.githubusercontent.com/EthereumRemix/091ccc57986452bbb33f57abfb13d173/raw/3367e019335746b73288e3710af2922d4c8ef5a3/origins.json'
try { try {
const { data } = await Axios.get(gistUrl) const { data } = await Axios.get(gistUrl)
try { try {
await fs.writeJSON(path.resolve(__dirname + '/../origins.json'), { data }) await fs.writeJSON(path.resolve(path.join(__dirname, '..', 'origins.json')), { data })
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} }
return data.includes(origin) ? data.includes(origin) : data.includes(domain) return data.includes(origin) ? data.includes(origin) : data.includes(domain)
} catch (e) { } catch (e) {
try { try {
// eslint-disable-next-line // eslint-disable-next-line
const origins = require('../origins.json') const origins = require('../origins.json')
const { data } = origins const { data } = origins
return data.includes(origin) ? data.includes(origin) : data.includes(domain) return data.includes(origin) ? data.includes(origin) : data.includes(domain)
} catch (e) { } catch (e) {
return false return false
......
import { RemixdClient as sharedfolder } from './services/remixdClient' export { RemixdClient as Sharedfolder } from './services/remixdClient'
export { sharedfolder }
import { PluginClient } from '@remixproject/plugin' import { PluginClient } from '@remixproject/plugin'
import { SharedFolderArgs, TrackDownStreamUpdate, Filelist, ResolveDirectory, FileContent } from '../types' import { SharedFolderArgs, TrackDownStreamUpdate, Filelist, ResolveDirectory, FileContent } from '../types' // eslint-disable-line
import * as WS from 'ws' import * as WS from 'ws' // eslint-disable-line
import * as utils from '../utils' import * as utils from '../utils'
import * as chokidar from 'chokidar' import * as chokidar from 'chokidar'
import * as fs from 'fs-extra' import * as fs from 'fs-extra'
...@@ -49,9 +49,9 @@ export class RemixdClient extends PluginClient { ...@@ -49,9 +49,9 @@ export class RemixdClient extends PluginClient {
try { try {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const path = utils.absolutePath(args.path, this.currentSharedFolder) const path = utils.absolutePath(args.path, this.currentSharedFolder)
if (!fs.existsSync(path)) { if (!fs.existsSync(path)) {
return reject('File not found ' + path) return reject(new Error('File not found ' + path))
} }
if (!isRealPath(path)) return if (!isRealPath(path)) return
isbinaryfile(path, (error: Error, isBinary: boolean) => { isbinaryfile(path, (error: Error, isBinary: boolean) => {
...@@ -76,7 +76,7 @@ export class RemixdClient extends PluginClient { ...@@ -76,7 +76,7 @@ export class RemixdClient extends PluginClient {
const path = utils.absolutePath(args.path, this.currentSharedFolder) const path = utils.absolutePath(args.path, this.currentSharedFolder)
return fs.existsSync(path) return fs.existsSync(path)
} catch(error) { } catch (error) {
throw new Error(error) throw new Error(error)
} }
} }
...@@ -84,21 +84,21 @@ export class RemixdClient extends PluginClient { ...@@ -84,21 +84,21 @@ export class RemixdClient extends PluginClient {
set (args: SharedFolderArgs): Promise<void> { set (args: SharedFolderArgs): Promise<void> {
try { try {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.readOnly) reject('Cannot write file: read-only mode selected') if (this.readOnly) reject(new Error('Cannot write file: read-only mode selected'))
const isFolder = args.path.endsWith('/') const isFolder = args.path.endsWith('/')
const path = utils.absolutePath(args.path, this.currentSharedFolder) const path = utils.absolutePath(args.path, this.currentSharedFolder)
const exists = fs.existsSync(path) const exists = fs.existsSync(path)
if (exists && !isRealPath(path)) reject() if (exists && !isRealPath(path)) reject(new Error(''))
if (args.content === 'undefined') { // no !!!!! if (args.content === 'undefined') { // no !!!!!
console.log('trying to write "undefined" ! stopping.') console.log('trying to write "undefined" ! stopping.')
reject('trying to write "undefined" ! stopping.') reject(new Error('trying to write "undefined" ! stopping.'))
} }
this.trackDownStreamUpdate[path] = path this.trackDownStreamUpdate[path] = path
if (isFolder) { if (isFolder) {
fs.mkdirp(path).then(() => { fs.mkdirp(path).then(() => {
let splitPath = args.path.split('/') let splitPath = args.path.split('/')
splitPath = splitPath.filter(dir => dir) splitPath = splitPath.filter(dir => dir)
const dir = '/' + splitPath.join('/') const dir = '/' + splitPath.join('/')
...@@ -130,14 +130,14 @@ export class RemixdClient extends PluginClient { ...@@ -130,14 +130,14 @@ export class RemixdClient extends PluginClient {
rename (args: SharedFolderArgs): Promise<boolean> { rename (args: SharedFolderArgs): Promise<boolean> {
try { try {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.readOnly) reject('Cannot rename file: read-only mode selected') if (this.readOnly) reject(new Error('Cannot rename file: read-only mode selected'))
const oldpath = utils.absolutePath(args.oldPath, this.currentSharedFolder) const oldpath = utils.absolutePath(args.oldPath, this.currentSharedFolder)
if (!fs.existsSync(oldpath)) { if (!fs.existsSync(oldpath)) {
reject('File not found ' + oldpath) reject(new Error('File not found ' + oldpath))
} }
const newpath = utils.absolutePath(args.newPath, this.currentSharedFolder) const newpath = utils.absolutePath(args.newPath, this.currentSharedFolder)
if (!isRealPath(oldpath)) return if (!isRealPath(oldpath)) return
fs.move(oldpath, newpath, (error: Error) => { fs.move(oldpath, newpath, (error: Error) => {
if (error) { if (error) {
...@@ -156,15 +156,15 @@ export class RemixdClient extends PluginClient { ...@@ -156,15 +156,15 @@ export class RemixdClient extends PluginClient {
remove (args: SharedFolderArgs): Promise<boolean> { remove (args: SharedFolderArgs): Promise<boolean> {
try { try {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.readOnly) reject('Cannot remove file: read-only mode selected') if (this.readOnly) reject(new Error('Cannot remove file: read-only mode selected'))
const path = utils.absolutePath(args.path, this.currentSharedFolder) const path = utils.absolutePath(args.path, this.currentSharedFolder)
if (!fs.existsSync(path)) reject('File not found ' + path) if (!fs.existsSync(path)) reject(new Error('File not found ' + path))
if (!isRealPath(path)) return if (!isRealPath(path)) return
return fs.remove(path, (error: Error) => { return fs.remove(path, (error: Error) => {
if (error) { if (error) {
console.log(error) console.log(error)
reject('Failed to remove file/directory: ' + error) reject(new Error('Failed to remove file/directory: ' + error))
} }
this.emit('fileRemoved', args.path) this.emit('fileRemoved', args.path)
resolve(true) resolve(true)
...@@ -239,4 +239,4 @@ function isRealPath (path: string): boolean { ...@@ -239,4 +239,4 @@ function isRealPath (path: string): boolean {
// throw new Error(mes) // throw new Error(mes)
} }
return isRealPath return isRealPath
} }
\ No newline at end of file
...@@ -36,4 +36,4 @@ export type SharedFolderArgs = FolderArgs & KeyPairString ...@@ -36,4 +36,4 @@ export type SharedFolderArgs = FolderArgs & KeyPairString
export type WS = typeof Websocket export type WS = typeof Websocket
export type Filelist = KeyPairString export type Filelist = KeyPairString
\ No newline at end of file
import { ResolveDirectory, Filelist } from './types' import { ResolveDirectory, Filelist } from './types' // eslint-disable-line
import * as fs from 'fs-extra' import * as fs from 'fs-extra'
import * as isbinaryfile from 'isbinaryfile' import * as isbinaryfile from 'isbinaryfile'
import * as pathModule from 'path' import * as pathModule from 'path'
...@@ -49,7 +49,7 @@ function walkSync (dir: string, filelist: Filelist, sharedFolder: string): Filel ...@@ -49,7 +49,7 @@ function walkSync (dir: string, filelist: Filelist, sharedFolder: string): Filel
filelist = walkSync(subElement, filelist, sharedFolder) filelist = walkSync(subElement, filelist, sharedFolder)
} else { } else {
const relative = relativePath(subElement, sharedFolder) const relative = relativePath(subElement, sharedFolder)
filelist[relative] = isbinaryfile.sync(subElement) filelist[relative] = isbinaryfile.sync(subElement)
} }
} }
...@@ -79,7 +79,7 @@ function resolveDirectory (dir: string, sharedFolder: string): ResolveDirectory ...@@ -79,7 +79,7 @@ function resolveDirectory (dir: string, sharedFolder: string): ResolveDirectory
* @param {String} url - Remix-IDE URL instance * @param {String} url - Remix-IDE URL instance
* @return {String} extracted domain name from url * @return {String} extracted domain name from url
*/ */
function getDomain(url: string) { function getDomain (url: string) {
// eslint-disable-next-line // eslint-disable-next-line
const domainMatch = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/img) const domainMatch = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/img)
......
import * as WS from 'ws' import * as WS from 'ws'
import * as http from 'http' import * as http from 'http'
import { WebsocketOpt, SharedFolderClient } from './types' import { WebsocketOpt, SharedFolderClient } from './types' // eslint-disable-line
import { getDomain } from './utils' import { getDomain } from './utils'
import { createClient } from '@remixproject/plugin-ws' import { createClient } from '@remixproject/plugin-ws'
export default class WebSocket { export default class WebSocket {
server: http.Server server: http.Server
wsServer: WS.Server wsServer: WS.Server
constructor (public port: number, public opt: WebsocketOpt, public sharedFolder: SharedFolderClient) {} constructor (public port: number, public opt: WebsocketOpt, public sharedFolder: SharedFolderClient) {} //eslint-disable-line
start (callback?: (ws: WS) => void): void { start (callback?: (ws: WS) => void): void {
this.server = http.createServer((request, response) => { this.server = http.createServer((request, response) => {
...@@ -35,7 +35,7 @@ export default class WebSocket { ...@@ -35,7 +35,7 @@ export default class WebSocket {
const { sharedFolder } = this const { sharedFolder } = this
createClient(ws, sharedFolder as any) createClient(ws, sharedFolder as any)
if(callback) callback(ws) if (callback) callback(ws)
}) })
} }
...@@ -58,7 +58,7 @@ function originIsAllowed (origin: string, self: WebSocket): boolean { ...@@ -58,7 +58,7 @@ function originIsAllowed (origin: string, self: WebSocket): boolean {
const origins = require('./origins.json') const origins = require('./origins.json')
const domain = getDomain(origin) const domain = getDomain(origin)
const { data } = origins const { data } = origins
if (data.includes(origin) || data.includes(domain)) { if (data.includes(origin) || data.includes(domain)) {
self.opt.remixIdeUrl = origin self.opt.remixIdeUrl = origin
console.log('\x1b[33m%s\x1b[0m', '[WARN] You may now only use IDE at ' + self.opt.remixIdeUrl + ' to connect to that instance') console.log('\x1b[33m%s\x1b[0m', '[WARN] You may now only use IDE at ' + self.opt.remixIdeUrl + ' to connect to that instance')
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
"workspace-schematic": "nx workspace-schematic", "workspace-schematic": "nx workspace-schematic",
"dep-graph": "nx dep-graph", "dep-graph": "nx dep-graph",
"help": "nx help", "help": "nx help",
"lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-debugger-ui,remix-ui-utils,remix-ui-clipboard",
"build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd",
"test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd",
"publish:libs": "npm run build:libs; lerna publish --skip-git; npm run bumpVersion:libs", "publish:libs": "npm run build:libs; lerna publish --skip-git; npm run bumpVersion:libs",
...@@ -182,7 +182,6 @@ ...@@ -182,7 +182,6 @@
"@types/axios": "^0.14.0", "@types/axios": "^0.14.0",
"@types/chai": "^4.2.11", "@types/chai": "^4.2.11",
"@types/fs-extra": "^9.0.1", "@types/fs-extra": "^9.0.1",
"@types/jest": "25.1.4",
"@types/mocha": "^7.0.2", "@types/mocha": "^7.0.2",
"@types/nightwatch": "^1.1.6", "@types/nightwatch": "^1.1.6",
"@types/node": "~8.9.4", "@types/node": "~8.9.4",
...@@ -279,4 +278,4 @@ ...@@ -279,4 +278,4 @@
"yo-yo": "github:ioedeveloper/yo-yo", "yo-yo": "github:ioedeveloper/yo-yo",
"yo-yoify": "^3.7.3" "yo-yoify": "^3.7.3"
} }
} }
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
"@remix-project/remix-tests": ["dist/libs/remix-tests/src/index.js"], "@remix-project/remix-tests": ["dist/libs/remix-tests/src/index.js"],
"@remix-project/remix-url-resolver": ["dist/libs/remix-url-resolver/index.js"], "@remix-project/remix-url-resolver": ["dist/libs/remix-url-resolver/index.js"],
"@remix-project/remixd": ["dist/libs/remixd/index.js"], "@remix-project/remixd": ["dist/libs/remixd/index.js"],
"@remix-project/debugger-ui": ["libs/debugger-ui/src/index.ts"],
"@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"], "@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"],
"@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"], "@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"],
"@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"], "@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment