Skip to content

Commit

Permalink
fix: remove electron/remote dep from core
Browse files Browse the repository at this point in the history
This PR also removes some old unused deps from the core. Doing this identified a missing dep in plugin-bash-like (on properties-parser). This PR thus also adds that dep to plugin-bash-like, and adds the properties-parser types, and then shifts a require to an import.
  • Loading branch information
starpit committed Jan 28, 2023
1 parent 340cce9 commit cef337e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
29 changes: 23 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"npm": ">=6.9.0"
},
"dependencies": {
"@electron/remote": "^2.0.9",
"@kui-shell/client": "file:plugins/plugin-client-default",
"@kui-shell/core": "file:packages/core",
"@kui-shell/plugin-bash-like": "file:plugins/plugin-bash-like",
Expand Down
3 changes: 0 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,15 @@
"@types/yargs-parser": "^21.0.0"
},
"dependencies": {
"@electron/remote": "^2.0.9",
"colors": "^1.4.0",
"columnify": "^1.6.0",
"debug": "^4.3.4",
"fs-extra": "^11.1.0",
"mkdirp": "^1.0.4",
"pretty-ms": "^7.0.1",
"properties-parser": "^0.3.1",
"tmp": "^0.2.1",
"trie-search": "^1.3.6",
"uuid": "^9.0.0",
"word-wrap": "^1.2.3",
"yargs-parser": "^21.1.1"
},
"publishConfig": {
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/main/spawn-electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ export async function createWindow(
}

if (electronRemoteNeedsInit) {
require('@electron/remote/main').initialize()
// some hacks to allow @kui-shell/core to avoid specifying a
// direct dependence on @electron/remote; this dep pulls in
// all of electron, which some clients will not need
const foolWebpackHack = 'index.js'
require('@electron/remote/main/' + foolWebpackHack).initialize()
electronRemoteNeedsInit = false
}

Expand Down
2 changes: 2 additions & 0 deletions plugins/plugin-bash-like/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"devDependencies": {
"@types/cookie": "^0.5.1",
"@types/debug": "^4.1.7",
"@types/properties-parser": "0.3.0",
"@types/shelljs": "^0.8.11",
"@types/tmp": "^0.2.3",
"@types/uuid": "^9.0.0"
Expand All @@ -40,6 +41,7 @@
"debug": "^4.3.4",
"globby": "^11.0.4",
"node-pty": "0.11.0-beta27",
"properties-parser": "0.3.1",
"shelljs": "^0.8.5",
"slash": "^3.0.0",
"speed-date": "^1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions plugins/plugin-bash-like/src/pty/prefetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Debug from 'debug'
const debug = Debug('plugins/bash-like/pty/prefetch')

import { exec } from 'child_process'
import * as propertiesParser from 'properties-parser'

/**
* Preprocess bash/zsh environment variables
Expand All @@ -37,7 +36,7 @@ function prefetchEnv() {
const shell = await getLoginShell()
debug('prefetchEnv got shell', shell)

exec(`${shell} -l -c printenv`, (err, stdout, stderr) => {
exec(`${shell} -l -c printenv`, async (err, stdout, stderr) => {
try {
if (stderr) {
debug(stderr)
Expand All @@ -46,6 +45,7 @@ function prefetchEnv() {
debug('error in prefetchEnv 1', err)
reject(err)
} else {
const { default: propertiesParser } = await import('properties-parser')
const env = propertiesParser.parse(stdout.toString())
debug('got env', env)
for (const key in env) {
Expand Down

0 comments on commit cef337e

Please sign in to comment.