script runner

pull/4346/head
filip mertens 1 year ago
parent 9b6437d0ce
commit 1c538acd80
  1. 4
      apps/remix-ide/src/app/files/electronProvider.ts
  2. 12
      apps/remix-ide/src/app/panels/file-panel.js
  3. 16
      apps/remix-ide/src/index.tsx
  4. 1
      apps/remix-ide/src/remixAppManager.js
  5. 4
      apps/remixdesktop/src/plugins/fsPlugin.ts
  6. 65
      apps/remixdesktop/src/plugins/ripgrepPlugin.ts
  7. 3
      apps/remixdesktop/src/plugins/scriptRunner.ts
  8. 12
      libs/remix-ui/workspace/src/lib/actions/events.ts
  9. 7
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  10. 4
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  11. 8
      libs/remix-ui/workspace/src/lib/reducers/workspace.ts
  12. 1
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -16,7 +16,8 @@ export class ElectronProvider extends FileProvider {
}
async init() {
this._appManager.on('fs', 'change', (event, path) => {
this._appManager.on('fs', 'change', async (event, path) => {
console.log('change', event, path)
switch (event) {
case 'add':
this.event.emit('fileAdded', path)
@ -74,7 +75,6 @@ export class ElectronProvider extends FileProvider {
* @param {*} path is the folder to be removed
*/
async remove(path: string) {
console.log('remove', path)
try {
await window.remixFileSystem.rmdir(path)
return true

@ -43,7 +43,8 @@ const profile = {
'renameWorkspace',
'deleteWorkspace',
'loadTemplate',
'clone'
'clone',
'isExpanded',
],
events: ['setWorkspace', 'workspaceRenamed', 'workspaceDeleted', 'workspaceCreated'],
icon: 'assets/img/fileManager.webp',
@ -72,6 +73,8 @@ module.exports = class Filepanel extends ViewPlugin {
this.workspaces = []
this.appManager = appManager
this.currentWorkspaceMetadata = null
this.expandPath = []
}
render() {
@ -229,5 +232,12 @@ module.exports = class Filepanel extends ViewPlugin {
workspaceCreated(workspace) {
this.emit('workspaceCreated', workspace)
}
isExpanded(path) {
console.log('isExpanded', path, this.expandPath)
if(path === '/') return true
return this.expandPath.includes(path)
}
/** end section */
}

@ -8,10 +8,6 @@ import Config from './config'
import {Registry} from '@remix-project/remix-lib'
import {Storage} from '@remix-project/remix-lib'
import * as esbuild from 'esbuild-wasm'
;(async function () {
try {
@ -21,18 +17,6 @@ import * as esbuild from 'esbuild-wasm'
} catch (e) {}
const theme = new ThemeModule()
theme.initTheme()
await esbuild.initialize({
wasmURL: './assets/esbuild.wasm',
})
const code = `import { ethers } from 'ethers'`
const result = await esbuild.transform(code, {})
await esbuild.build({
})
console.log(result)
render(
<React.StrictMode>

@ -237,7 +237,6 @@ export class RemixAppManager extends PluginManager {
const res = await fetch(this.pluginsDirectory)
plugins = await res.json()
plugins = plugins.filter((plugin) => {
if(plugin.name === 'scriptRunner') return false
if (plugin.targets && Array.isArray(plugin.targets) && plugin.targets.length > 0) {
return plugin.targets.includes('remix')
}

@ -108,6 +108,7 @@ class FSPluginClient extends ElectronBasePluginClient {
// best for non recursive
async readdir(path: string): Promise<string[]> {
if (this.workingDir === '') throw new Error('workingDir is not set')
// call node fs.readdir
if (!path) return []
const startTime = Date.now()
@ -203,7 +204,6 @@ class FSPluginClient extends ElectronBasePluginClient {
ignorePermissionErrors: true,
ignoreInitial: true,
ignored: [
'**/node_modules/**',
'**/.git/index.lock', // this file is created and unlinked all the time when git is running on Windows
],
})
@ -211,7 +211,7 @@ class FSPluginClient extends ElectronBasePluginClient {
let pathWithoutPrefix = path.replace(this.workingDir, '')
pathWithoutPrefix = convertPathToPosix(pathWithoutPrefix)
if (pathWithoutPrefix.startsWith('/')) pathWithoutPrefix = pathWithoutPrefix.slice(1)
console.log('eventName', eventName, pathWithoutPrefix)
if (eventName === 'change') {
// remove workingDir from path
const newContent = await fs.readFile(path, 'utf-8')

@ -1,9 +1,6 @@
import {PluginClient} from '@remixproject/plugin'
import {Profile} from '@remixproject/plugin-utils'
import {
ElectronBasePlugin,
ElectronBasePluginClient,
} from '@remixproject/plugin-electron'
import {ElectronBasePlugin, ElectronBasePluginClient} from '@remixproject/plugin-electron'
import path from 'path'
import {rgPath} from '@vscode/ripgrep'
import byline from 'byline'
@ -47,42 +44,42 @@ export class RipgrepPluginClient extends ElectronBasePluginClient {
}
async glob(path: string, pattern: string, options?: any) {
path = convertPathToPosix(this.fixPath(path))
try {
const fixedPath = this.fixPath(path)
path = convertPathToPosix(fixedPath)
return new Promise((c, e) => {
// replace packed app path with unpacked app path for release on windows
return new Promise((c, e) => {
// replace packed app path with unpacked app path for release on windows
const customRgPath = rgPath.includes('app.asar.unpacked')
? rgPath
: rgPath.replace('app.asar', 'app.asar.unpacked')
const rg = spawn(customRgPath, ['.', '-l', path])
const customRgPath = rgPath.includes('app.asar.unpacked') ? rgPath : rgPath.replace('app.asar', 'app.asar.unpacked')
const rg = spawn(customRgPath, ['.', '-l', path])
const resultrg: any[] = []
const resultrg: any[] = []
const stream = byline(rg.stdout.setEncoding('utf8'))
stream.on('data', (rgresult: string) => {
let pathWithoutWorkingDir = rgresult.replace(
convertPathToPosix(this.workingDir),
''
)
if (pathWithoutWorkingDir.endsWith('/')) {
pathWithoutWorkingDir = pathWithoutWorkingDir.slice(0, -1)
}
if (pathWithoutWorkingDir.startsWith('/')) {
pathWithoutWorkingDir = pathWithoutWorkingDir.slice(1)
}
if (pathWithoutWorkingDir.startsWith('\\')) {
pathWithoutWorkingDir = pathWithoutWorkingDir.slice(1)
}
resultrg.push({
path: convertPathToPosix(pathWithoutWorkingDir),
isDirectory: false,
const stream = byline(rg.stdout.setEncoding('utf8'))
stream.on('data', (rgresult: string) => {
let pathWithoutWorkingDir = rgresult.replace(convertPathToPosix(this.workingDir), '')
if (pathWithoutWorkingDir.endsWith('/')) {
pathWithoutWorkingDir = pathWithoutWorkingDir.slice(0, -1)
}
if (pathWithoutWorkingDir.startsWith('/')) {
pathWithoutWorkingDir = pathWithoutWorkingDir.slice(1)
}
if (pathWithoutWorkingDir.startsWith('\\')) {
pathWithoutWorkingDir = pathWithoutWorkingDir.slice(1)
}
resultrg.push({
path: convertPathToPosix(pathWithoutWorkingDir),
isDirectory: false,
})
})
stream.on('end', () => {
c(resultrg)
})
})
stream.on('end', () => {
c(resultrg)
})
})
} catch (e) {
return []
}
}
fixPath(path: string): string {

@ -132,7 +132,8 @@ class ScriptRunnerClient extends ElectronBasePluginClient {
bundle: true,
outdir: out,
plugins: [],
platform: 'node'
platform: 'node',
inject: ['/Volumes/bunsen/code/basic6/remix.ts']
})
console.log('build', build)
if (build.errors.length > 0) {

@ -175,6 +175,12 @@ const removePluginActions = (plugin, cb: (err: Error, result?: string | number |
}
const fileAdded = async (filePath: string) => {
const path = extractParentFromKey(filePath) || ROOT_PATH
console.log('fileAdded', filePath, path)
const isExpanded = await plugin.call('filePanel', 'isExpanded', path)
if(!isExpanded) return
await dispatch(fileAddedSuccess(filePath))
if (filePath.includes('_test.sol')) {
plugin.emit('newTestFileCreated', filePath)
@ -185,6 +191,12 @@ const folderAdded = async (folderPath: string) => {
const provider = plugin.fileManager.currentFileProvider()
const path = extractParentFromKey(folderPath) || ROOT_PATH
const isExpanded = await plugin.call('filePanel', 'isExpanded', path)
console.log('folderAdded', folderPath, path, isExpanded)
if(!isExpanded) return
const promise: Promise<FileTree> = new Promise((resolve) => {
provider.resolveDirectory(path, (error, fileTree: FileTree) => {
if (error) console.error(error)

@ -350,9 +350,12 @@ export const fetchWorkspaceDirectory = async (path: string) => {
if (!path) return
const provider = plugin.fileManager.currentFileProvider()
const promise: Promise<FileTree> = new Promise((resolve) => {
const promise: Promise<FileTree> = new Promise((resolve, reject) => {
provider.resolveDirectory(path, (error, fileTree: FileTree) => {
if (error) console.error(error)
if (error) {
reject(error)
console.error(error)
}
resolve(fileTree)
})
})

@ -287,6 +287,10 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
}
}, [fs.popup])
useEffect(() => {
plugin.expandPath = fs.browser.expandPath
},[fs.browser.expandPath])
const handleHideModal = () => {
setFocusModal((modal) => {
return {...modal, hide: true, message: null}

@ -326,10 +326,6 @@ export const browserReducer = (state = browserInitialState, action: Actions) =>
state.mode === 'browser'
? fileAdded(state, payload)
: state.browser.files,
expandPath:
state.mode === 'browser'
? [...new Set([...state.browser.expandPath, payload])]
: state.browser.expandPath
},
localhost: {
...state.localhost,
@ -356,10 +352,6 @@ export const browserReducer = (state = browserInitialState, action: Actions) =>
state.mode === 'browser'
? fetchDirectoryContent(state, payload)
: state.browser.files,
expandPath:
state.mode === 'browser'
? [...new Set([...state.browser.expandPath, payload.folderPath])]
: state.browser.expandPath
},
localhost: {
...state.localhost,

@ -74,6 +74,7 @@ export interface FilePanelType extends ViewPlugin {
initialWorkspace: string
resetNewFile: () => void
getWorkspaces: () => string[]
expandPath: string[]
}
/* eslint-disable-next-line */

Loading…
Cancel
Save