-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9006f90
commit ddd58cc
Showing
16 changed files
with
336 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
apps/remix-ide/src/app/plugins/electron/scriptRunnerPlugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ElectronPlugin } from '@remixproject/engine-electron'; | ||
|
||
export class scriptRunnerPlugin extends ElectronPlugin { | ||
constructor(){ | ||
super({ | ||
displayName: 'scriptRunner', | ||
name: 'scriptRunner', | ||
description: 'scriptRunner' | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Minified by jsDelivr using Terser v5.19.2. | ||
* Original file: /npm/[email protected]/lib.commonjs/index.js | ||
* | ||
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ethers=void 0;const tslib_1=require("tslib"),ethers=tslib_1.__importStar(require("./ethers.js"));exports.ethers=ethers,tslib_1.__exportStar(require("./ethers.js"),exports); | ||
//# sourceMappingURL=/sm/a1c32dfeb6df16b35d6019f0c3e6ba14be89dc94667adee6e919d228ff2f0493.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { ElectronBasePlugin, ElectronBasePluginClient } from "@remixproject/plugin-electron" | ||
import { utilityProcess } from "electron" | ||
import path from "path" | ||
import * as esbuild from 'esbuild' | ||
import { RemixURLResolver } from '@remix-project/remix-url-resolver' | ||
import fs from 'fs/promises' | ||
import os, { arch } from 'os' | ||
|
||
const resolver = new RemixURLResolver() | ||
export const cacheDir = path.join(os.homedir(), '.cache_remix_ide') | ||
|
||
const profile = { | ||
"name": "scriptRunner", | ||
"displayName": "Script Runner", | ||
"description": "Execute script and emit logs", | ||
} | ||
|
||
const convertPathToPosix = (pathName: string): string => { | ||
return pathName.split(path.sep).join(path.posix.sep) | ||
} | ||
|
||
export class ScriptRunnerPlugin extends ElectronBasePlugin { | ||
constructor() { | ||
super(profile, clientProfile, ScriptRunnerClient) | ||
this.methods = [...super.methods, 'execute'] | ||
} | ||
} | ||
|
||
const clientProfile = { | ||
"name": "scriptRunner", | ||
"displayName": "Script Runner", | ||
"description": "Execute script and emit logs", | ||
"methods": ["execute"] | ||
} | ||
|
||
class ScriptRunnerClient extends ElectronBasePluginClient { | ||
workingDir: string = '' | ||
constructor(webContentsId: number, profile: any) { | ||
super(webContentsId, profile) | ||
this.onload(() => { | ||
this.on('fs' as any, 'workingDirChanged', async (path: string) => { | ||
this.workingDir = path | ||
}) | ||
}) | ||
} | ||
|
||
async execute(content: string, path: string): Promise<void> { | ||
path = convertPathToPosix(this.fixPath(path)) | ||
console.log('execute', path) | ||
const out = convertPathToPosix(this.fixPath('dist')) | ||
const build = await esbuild.build({ | ||
entryPoints: [path], | ||
bundle: true, | ||
outdir: out, | ||
plugins: [onResolvePlugin], | ||
}) | ||
console.log(build) | ||
if(build.errors.length > 0) { | ||
console.log('ERRORS', build.errors) | ||
return | ||
} | ||
|
||
} | ||
|
||
fixPath(path: string): string { | ||
if (this.workingDir === '') throw new Error('workingDir is not set') | ||
if (path) { | ||
if (path.startsWith('/')) { | ||
path = path.slice(1) | ||
} | ||
} | ||
path = this.workingDir + (!this.workingDir.endsWith('/') ? '/' : '') + path | ||
return path | ||
} | ||
} | ||
|
||
|
||
const onResolvePlugin = { | ||
name: 'onResolve', | ||
setup(build: esbuild.PluginBuild) { | ||
|
||
build.onLoad({ | ||
filter: /.*/, | ||
}, async args => { | ||
console.log('onLoad', args) | ||
/*if(args.namespace && args.namespace !== 'file'){ | ||
const imported = await resolver.resolve(args.path) | ||
console.log('imported', imported) | ||
return { | ||
contents: imported.content, | ||
loader: 'js', | ||
} | ||
}*/ | ||
return undefined | ||
|
||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
console.log('Starting utilities') | ||
process.parentPort.postMessage('start utilities') | ||
import { spawn } from 'node:child_process'; | ||
const ls = spawn('ls', ['-la']) | ||
ls.stdout.on('data', (data) => { | ||
console.log(`stdout: ${data}`); | ||
process.parentPort.postMessage(data.toString()) | ||
}); | ||
|
||
process.parentPort.postMessage(JSON.stringify(process.env)) | ||
|
||
const ls2 = spawn('yarn', ['-v']) | ||
ls2.stdout.on('data', (data) => { | ||
console.log(`stdout: ${data}`); | ||
process.parentPort.postMessage(data.toString()) | ||
}); | ||
ls.stderr.on('data', (data) => { | ||
console.error(`stderr: ${data}`); | ||
process.parentPort.postMessage(data.toString()) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.