parent
9006f906a8
commit
ddd58cc6a5
@ -0,0 +1,11 @@ |
||||
import { ElectronPlugin } from '@remixproject/engine-electron'; |
||||
|
||||
export class scriptRunnerPlugin extends ElectronPlugin { |
||||
constructor(){ |
||||
super({ |
||||
displayName: 'scriptRunner', |
||||
name: 'scriptRunner', |
||||
description: 'scriptRunner' |
||||
}) |
||||
} |
||||
} |
@ -0,0 +1,8 @@ |
||||
/** |
||||
* Minified by jsDelivr using Terser v5.19.2. |
||||
* Original file: /npm/ethers@6.8.1/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 |
@ -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 |
||||
|
||||
}) |
||||
} |
||||
} |
@ -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()) |
||||
}) |
Loading…
Reference in new issue