From 3b04e0df7c3dc2c8de21a75f7c23ea0e0c788546 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Mon, 26 Jun 2023 18:06:15 +0200 Subject: [PATCH] ripgrep --- apps/remixdesktop/package.json | 3 +- apps/remixdesktop/src/main.ts | 26 ++++++++++++- apps/remixdesktop/src/tools/search.ts | 55 +++++++++++++++++++++++++++ apps/remixdesktop/yarn.lock | 13 +++++++ 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 apps/remixdesktop/src/tools/search.ts diff --git a/apps/remixdesktop/package.json b/apps/remixdesktop/package.json index f53ae41ac3..28d449e238 100644 --- a/apps/remixdesktop/package.json +++ b/apps/remixdesktop/package.json @@ -41,6 +41,7 @@ "@remixproject/engine-electron": "0.3.37", "@remixproject/plugin": "0.3.37", "@remixproject/plugin-electron": "0.3.37", + "@vscode/ripgrep": "^1.15.4", "chokidar": "^3.5.3", "glob": "9.3.5", "isomorphic-git": "^1.24.2", @@ -102,4 +103,4 @@ "output": "release" } } -} \ No newline at end of file +} diff --git a/apps/remixdesktop/src/main.ts b/apps/remixdesktop/src/main.ts index 04f4a209e8..9a82975b34 100644 --- a/apps/remixdesktop/src/main.ts +++ b/apps/remixdesktop/src/main.ts @@ -97,6 +97,7 @@ import EditMenu from './menus/edit'; import GitMenu from './menus/git'; import ViewMenu from './menus/view'; import { execCommand } from './menus/commands'; +import { searchProxy } from './tools/search'; const commandKeys: Record = { 'window:new': 'CmdOrCtrl+N', @@ -111,4 +112,27 @@ ViewMenu(commandKeys, execCommand), WindowMenu(commandKeys, execCommand, []), ] -Menu.setApplicationMenu(Menu.buildFromTemplate(menu)) \ No newline at end of file +Menu.setApplicationMenu(Menu.buildFromTemplate(menu)) + +/* +searchProxy.checkIfGrepIsInstalled().then((result) => { + console.log('grep --version', result) +}) + +searchProxy.checkIffindstrIsInstalled().then((result) => { + console.log('findstr /?', result) +}) + +searchProxy.checkIfSelectStringIsInstalled().then((result) => { + console.log('get-help Select-String', result) +}) +*/ + +searchProxy.checkIfRgIsInstalled().then((result) => { + console.log('rg --version', result) +} +).catch((error) => { + console.log('rg --version', error) +}) + + diff --git a/apps/remixdesktop/src/tools/search.ts b/apps/remixdesktop/src/tools/search.ts new file mode 100644 index 0000000000..aeb79db389 --- /dev/null +++ b/apps/remixdesktop/src/tools/search.ts @@ -0,0 +1,55 @@ +import { exec } from 'child_process'; +import { CommitObject, ReadCommitResult } from 'isomorphic-git'; +import { promisify } from 'util'; +import { rgPath } from '@vscode/ripgrep'; + +const rgDiskPath = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked'); + +const execAsync = promisify(exec); + + +export const searchProxy = { + checkIfGrepIsInstalled: async () => { + try { + const result = await execAsync('grep --version'); + console.log('grep --version', result.stdout) + return result.stdout + } catch (error) { + return false; + } + }, + + checkIffindstrIsInstalled: async () => { + try { + const result = await execAsync('findstr /?'); + console.log('findstr /?', result.stdout) + return result.stdout + } catch (error) { + return false; + } + }, + + checkIfSelectStringIsInstalled: async () => { + try { + const result = await execAsync('get-help Select-String'); + console.log('get-help Select-String', result.stdout) + return result.stdout + } catch (error) { + return false; + } + }, + + checkIfRgIsInstalled: async () => { + try { + + const result = await execAsync(`${rgDiskPath} 'remix'`, { cwd: process.cwd(), env: { PATH: process.env.PATH }}); + console.log('rg --version', result.stdout) + return result.stdout + } catch (error) { + return false; + } + } + + + +} \ No newline at end of file diff --git a/apps/remixdesktop/yarn.lock b/apps/remixdesktop/yarn.lock index dc908d27da..45b84fc9f1 100644 --- a/apps/remixdesktop/yarn.lock +++ b/apps/remixdesktop/yarn.lock @@ -701,6 +701,14 @@ dependencies: "@types/node" "*" +"@vscode/ripgrep@^1.15.4": + version "1.15.4" + resolved "https://registry.yarnpkg.com/@vscode/ripgrep/-/ripgrep-1.15.4.tgz#ca8946b5580bbea1e706ed8d3b1eed5f0d551ab6" + integrity sha512-+EPIS2aoD95MFLrgGHd/D2fck42aMRV2cBrT7BiNvKBeSyCTybSaTJ+PGQf6zV/95AhaXHHYqYPVRk3DZoGU9w== + dependencies: + https-proxy-agent "^5.0.0" + proxy-from-env "^1.1.0" + abbrev@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" @@ -3757,6 +3765,11 @@ proxy-addr@~2.0.7: forwarded "0.2.0" ipaddr.js "1.9.1" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + psl@^1.1.28: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"