Skip to content

Commit

Permalink
feat: update/reinstall/uninstall
Browse files Browse the repository at this point in the history
Signed-off-by: uiuing <uiuing@foxmail.com>
  • Loading branch information
uiuing committed Sep 7, 2022
1 parent 39fb227 commit f781510
Show file tree
Hide file tree
Showing 39 changed files with 708 additions and 159 deletions.
3 changes: 2 additions & 1 deletion ingop/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"react/react-in-jsx-scope": "off",
"react-hooks/exhaustive-deps": "off",
"react/jsx-no-useless-fragment": "off",
"react/require-default-props": "off"
"react/require-default-props": "off",
"react/no-array-index-key": "off"
}
}
2 changes: 1 addition & 1 deletion ingop/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ app.on('ready', async () => {
).toString()

await mainWindow.loadURL(url)

if (isDev) mainWindow.webContents.openDevTools()
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
Expand Down
3 changes: 0 additions & 3 deletions ingop/main/ipc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ipcMain, shell } from 'electron'

import {
AutoSaveFile,
compile,
envManage,
existsAllEnv,
ingopHome,
Expand Down Expand Up @@ -33,8 +32,6 @@ ipcMain.handle(
new AutoSaveFile(fileData).env.go()
)

ipcMain.handle('compile-gop', async () => compile.gop())

ipcMain.handle('env-gop-init', () => {
envManage.initGop()
})
Expand Down
26 changes: 7 additions & 19 deletions ingop/main/ipc/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ import { join } from 'path'

import { execCommand, existsEnv } from '../methods/check'
import { ingopPaths, ingopPathsArray, isWin } from '../methods/config'
import { buildGop } from '../methods/env/compile'
import { EnvManage } from '../methods/env/types'
import { envManage as unixEnvManage } from '../methods/env/unix/execute'
import { envManage as winEnvManage } from '../methods/env/win/execute'
import { initDirs, removeDirs, saveFile } from '../methods/files'
import {
Compile,
ExistsAllEnvParams,
ExistsAllEnvResult,
FileDataParams
} from './types'
import { ExistsAllEnvParams, ExistsAllEnvResult, FileDataParams } from './types'

export const ingopHome = {
init: () => {
Expand Down Expand Up @@ -59,14 +53,12 @@ export async function existsAllEnv(
if (iv) {
r.env.go.isNew = iv
i = await existsEnv.gop.exist()
if (i.e) {
r.gop.exist = i.e
r.gop.version = i.v
iv = await existsEnv.gop.isNew(p.gopNewVersion)
r.gop.isIngop = await existsEnv.env.go.isIngop()
if (iv) {
r.gop.isNew = true
}
r.gop.exist = i.e
r.gop.version = i.v
iv = await existsEnv.gop.isNew(p.gopNewVersion)
r.gop.isIngop = await existsEnv.env.go.isIngop()
if (iv) {
r.gop.isNew = true
}
}
}
Expand Down Expand Up @@ -107,10 +99,6 @@ export class AutoSaveFile {
}
}

export const compile: Compile = {
gop: async (): Promise<boolean> => buildGop()
}

export const envManage: EnvManage = isWin ? winEnvManage : unixEnvManage

export function rebootWindows() {
Expand Down
4 changes: 0 additions & 4 deletions ingop/main/ipc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ export type ExistsAllEnvResult = {
arch: string
}
}

export type Compile = {
gop: () => Promise<boolean>
}
9 changes: 0 additions & 9 deletions ingop/main/methods/__test__/compile_env.test.ts

This file was deleted.

8 changes: 2 additions & 6 deletions ingop/main/methods/check/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ async function isNewVersion(cmd: string, newVersion: string): AsyncBoolean {
export const existsEnv: ExistsEnv = {
gop: {
exist: async () => {
let v = await checkVersionEnv('gop')
let e = v !== ''
if (!e) {
v = await checkVersionEnv(join(ingopPaths.gopBin, 'gop'))
e = v !== ''
}
const v = await checkVersionEnv('gop')
const e = v !== ''
return { e, v }
},
isNew: async (newVersion: string) => isNewVersion('gop', newVersion),
Expand Down
17 changes: 0 additions & 17 deletions ingop/main/methods/env/compile.ts

This file was deleted.

8 changes: 7 additions & 1 deletion ingop/main/methods/env/unix/env/gop.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
#
# ----------------------------------------------------------------------------

# Change the environment variables for GO+ in the registry
if ! ping -c 1 -W 3 google.com > /dev/null; then
export GO111MODULE=on
export GOPROXY="https://goproxy.cn,direct"
fi

cd $HOME/.ingop/gop
go run cmd/make.go --build || $HOME/.ingop/env/go/bin/go run cmd/make.go --build

# Check two common environment variable profiles
env_profiles=("$HOME"/.bash_profile )
Expand Down
11 changes: 10 additions & 1 deletion ingop/main/methods/env/win/env/gop.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@
::
:: ----------------------------------------------------------------------------

:: Change the environment variables for GO in the registry

ping google.com -n 1 -w 3 > nul
if not %errorlevel% leq 0 (
set GO111MODULE=on
set GOPROXY=https://goproxy.cn,direct
)

cd %USERPROFILE%\.ingop\gop

go run cmd/make.go --build || "%USERPROFILE%\.ingop\env\go\bin\go" run cmd/make.go --build

@echo off
set USERregpath=HKEY_CURRENT_USER\Environment
Expand Down
2 changes: 2 additions & 0 deletions ingop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build": "npm run build-renderer && npm run build-electron",
"pack-app": "npm run build && electron-builder --dir",
"dist": "npm run build && electron-builder",
"dist-win": "npm run build && electron-builder build --win --x64",
"type-check": "tsc -p ./renderer/tsconfig.json && tsc -p main/tsconfig.json",
"lint": "npm run prettier && npm run lint:eslint && npm run lint:stylelint",
"prettier": "prettier --write 'renderer/**/*.{html,ts,js,tsx,jsx,css,json}' 'main/**/*.{ts,js}'",
Expand Down Expand Up @@ -58,6 +59,7 @@
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-i18next": "^11.18.4",
"react-markdown": "^8.0.3",
"react-router-dom": "^6.3.0",
"recoil": "^0.7.5",
"rimraf": "^3.0.2",
Expand Down
Loading

0 comments on commit f781510

Please sign in to comment.