mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 00:17:17 +08:00
move runMode from env to args. remove support of cli mode.
This commit is contained in:
@@ -46,7 +46,6 @@ industryFilterExemption.forEach(item => {
|
|||||||
ensureConfigFileExist()
|
ensureConfigFileExist()
|
||||||
ensureStorageFileExist()
|
ensureStorageFileExist()
|
||||||
|
|
||||||
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
|
||||||
const isUiDev = process.env.NODE_ENV === 'development'
|
const isUiDev = process.env.NODE_ENV === 'development'
|
||||||
export const autoStartChatEventBus = new EventEmitter()
|
export const autoStartChatEventBus = new EventEmitter()
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
runtimeFolderPath,
|
runtimeFolderPath,
|
||||||
ensureEditThisCookie,
|
ensureEditThisCookie,
|
||||||
editThisCookieExtensionPath,
|
editThisCookieExtensionPath,
|
||||||
isRunFromUi,
|
|
||||||
} from './utils.mjs'
|
} from './utils.mjs'
|
||||||
|
|
||||||
import { EventEmitter } from 'node:events'
|
import { EventEmitter } from 'node:events'
|
||||||
@@ -56,10 +55,8 @@ export async function main() {
|
|||||||
|
|
||||||
page.once('close', async () => {
|
page.once('close', async () => {
|
||||||
browser.close()
|
browser.close()
|
||||||
if (isRunFromUi) {
|
const electron = await import('electron')
|
||||||
const electron = await import('electron')
|
electron.app.quit()
|
||||||
electron.app.quit()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const { dispose: disposeNavigationLock } = await blockNavigation(page, (req) => !req.url().startsWith('https://www.zhipin.com'))
|
const { dispose: disposeNavigationLock } = await blockNavigation(page, (req) => !req.url().startsWith('https://www.zhipin.com'))
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import os from 'node:os'
|
|||||||
import extractZip from 'extract-zip'
|
import extractZip from 'extract-zip'
|
||||||
import packageJson from './package.json' assert {type: 'json'}
|
import packageJson from './package.json' assert {type: 'json'}
|
||||||
|
|
||||||
export const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
|
||||||
const isUiDev = process.env.NODE_ENV === 'development'
|
const isUiDev = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
export const runtimeFolderPath = path.join(os.homedir(), '.geekgeekrun')
|
export const runtimeFolderPath = path.join(os.homedir(), '.geekgeekrun')
|
||||||
@@ -28,12 +27,8 @@ async function getEditThisCookieZipPath () {
|
|||||||
if (editThisCookieZipPath) {
|
if (editThisCookieZipPath) {
|
||||||
return editThisCookieZipPath
|
return editThisCookieZipPath
|
||||||
}
|
}
|
||||||
if (isRunFromUi) {
|
const { app } = await import('electron')
|
||||||
const { app } = await import('electron')
|
editThisCookieZipPath = path.join(app.getAppPath(), './node_modules', packageJson.name, 'extensions', 'EditThisCookie.zip')
|
||||||
editThisCookieZipPath = path.join(app.getAppPath(), './node_modules', packageJson.name, 'extensions', 'EditThisCookie.zip')
|
|
||||||
} else {
|
|
||||||
editThisCookieZipPath = path.join(__dirname, 'extensions', 'EditThisCookie.zip')
|
|
||||||
}
|
|
||||||
return editThisCookieZipPath
|
return editThisCookieZipPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
import * as path from 'node:path';
|
|
||||||
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
|
||||||
const isUiDev = process.env.NODE_ENV === 'development'
|
|
||||||
|
|
||||||
export function requireTypeorm () {
|
export function requireTypeorm () {
|
||||||
const importResult = require('typeorm')
|
const importResult = require('typeorm')
|
||||||
return importResult
|
return importResult
|
||||||
|
|||||||
@@ -25,14 +25,10 @@ function runWithDaemon({ runRecordId, runMode, parentProcessPipe }) {
|
|||||||
const subProcessOfCore = childProcess.spawn(
|
const subProcessOfCore = childProcess.spawn(
|
||||||
process.argv[0],
|
process.argv[0],
|
||||||
isUiDev
|
isUiDev
|
||||||
? [...process.argv.slice(1), `--run-record-id=${runRecordId}`]
|
? [process.argv[1], `--run-record-id=${runRecordId}`, `--mode=${runMode}`]
|
||||||
: [`--run-record-id=${runRecordId}`],
|
: [`--run-record-id=${runRecordId}`, `--mode=${runMode}`],
|
||||||
{
|
{
|
||||||
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'ipc'],
|
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'ipc']
|
||||||
env: {
|
|
||||||
...process.env,
|
|
||||||
MAIN_BOSSGEEKGO_UI_RUN_MODE: runMode
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -151,12 +151,15 @@ export default function initIpc() {
|
|||||||
}
|
}
|
||||||
const subProcessEnv = {
|
const subProcessEnv = {
|
||||||
...process.env,
|
...process.env,
|
||||||
MAIN_BOSSGEEKGO_UI_RUN_MODE: 'geekAutoStartWithBossDaemon',
|
|
||||||
PUPPETEER_EXECUTABLE_PATH: puppeteerExecutable.executablePath
|
PUPPETEER_EXECUTABLE_PATH: puppeteerExecutable.executablePath
|
||||||
}
|
}
|
||||||
subProcessOfPuppeteer = childProcess.spawn(
|
subProcessOfPuppeteer = childProcess.spawn(
|
||||||
process.argv[0],
|
process.argv[0],
|
||||||
[...process.argv.slice(1), '--mode-to-daemon=geekAutoStartWithBossMain'],
|
[
|
||||||
|
...process.argv.slice(1),
|
||||||
|
`--mode=geekAutoStartWithBossDaemon`,
|
||||||
|
`--mode-to-daemon=geekAutoStartWithBossMain`
|
||||||
|
],
|
||||||
{
|
{
|
||||||
env: subProcessEnv,
|
env: subProcessEnv,
|
||||||
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'ipc']
|
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'ipc']
|
||||||
@@ -205,13 +208,16 @@ export default function initIpc() {
|
|||||||
}
|
}
|
||||||
const subProcessEnv = {
|
const subProcessEnv = {
|
||||||
...process.env,
|
...process.env,
|
||||||
MAIN_BOSSGEEKGO_UI_RUN_MODE: 'readNoReplyAutoReminder',
|
|
||||||
PUPPETEER_EXECUTABLE_PATH: puppeteerExecutable.executablePath
|
PUPPETEER_EXECUTABLE_PATH: puppeteerExecutable.executablePath
|
||||||
}
|
}
|
||||||
subProcessOfPuppeteer = childProcess.spawn(process.argv[0], process.argv.slice(1), {
|
subProcessOfPuppeteer = childProcess.spawn(
|
||||||
env: subProcessEnv,
|
process.argv[0],
|
||||||
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'ipc']
|
[...process.argv.slice(1), `--mode=readNoReplyAutoReminder`],
|
||||||
})
|
{
|
||||||
|
env: subProcessEnv,
|
||||||
|
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'ipc']
|
||||||
|
}
|
||||||
|
)
|
||||||
// console.log(subProcessOfPuppeteer)
|
// console.log(subProcessOfPuppeteer)
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
subProcessOfPuppeteer!.stdio[3]!.pipe(JSONStream.parse()).on('data', async (raw) => {
|
subProcessOfPuppeteer!.stdio[3]!.pipe(JSONStream.parse()).on('data', async (raw) => {
|
||||||
@@ -264,15 +270,10 @@ export default function initIpc() {
|
|||||||
if (subProcessOfCheckAndDownloadDependencies) {
|
if (subProcessOfCheckAndDownloadDependencies) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const subProcessEnv = {
|
|
||||||
...process.env,
|
|
||||||
MAIN_BOSSGEEKGO_UI_RUN_MODE: 'checkAndDownloadDependenciesForInit'
|
|
||||||
}
|
|
||||||
subProcessOfCheckAndDownloadDependencies = childProcess.spawn(
|
subProcessOfCheckAndDownloadDependencies = childProcess.spawn(
|
||||||
process.argv[0],
|
process.argv[0],
|
||||||
process.argv.slice(1),
|
[...process.argv.slice(1), `--mode="checkAndDownloadDependenciesForInit"`],
|
||||||
{
|
{
|
||||||
env: subProcessEnv,
|
|
||||||
stdio: [null, null, null, 'pipe', 'ipc']
|
stdio: [null, null, null, 'pipe', 'ipc']
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -334,12 +335,11 @@ export default function initIpc() {
|
|||||||
}
|
}
|
||||||
const subProcessEnv = {
|
const subProcessEnv = {
|
||||||
...process.env,
|
...process.env,
|
||||||
MAIN_BOSSGEEKGO_UI_RUN_MODE: 'launchBossZhipinLoginPageWithPreloadExtension',
|
|
||||||
PUPPETEER_EXECUTABLE_PATH: (await getAnyAvailablePuppeteerExecutable())!.executablePath
|
PUPPETEER_EXECUTABLE_PATH: (await getAnyAvailablePuppeteerExecutable())!.executablePath
|
||||||
}
|
}
|
||||||
subProcessOfBossZhipinLoginPageWithPreloadExtension = childProcess.spawn(
|
subProcessOfBossZhipinLoginPageWithPreloadExtension = childProcess.spawn(
|
||||||
process.argv[0],
|
process.argv[0],
|
||||||
process.argv.slice(1),
|
[...process.argv.slice(1), `--mode=launchBossZhipinLoginPageWithPreloadExtension`],
|
||||||
{
|
{
|
||||||
env: subProcessEnv,
|
env: subProcessEnv,
|
||||||
stdio: [null, null, null, 'pipe', 'ipc']
|
stdio: [null, null, null, 'pipe', 'ipc']
|
||||||
@@ -415,13 +415,16 @@ export default function initIpc() {
|
|||||||
const puppeteerExecutable = await getAnyAvailablePuppeteerExecutable()
|
const puppeteerExecutable = await getAnyAvailablePuppeteerExecutable()
|
||||||
const subProcessEnv = {
|
const subProcessEnv = {
|
||||||
...process.env,
|
...process.env,
|
||||||
MAIN_BOSSGEEKGO_UI_RUN_MODE: 'launchBossSite',
|
|
||||||
PUPPETEER_EXECUTABLE_PATH: puppeteerExecutable!.executablePath
|
PUPPETEER_EXECUTABLE_PATH: puppeteerExecutable!.executablePath
|
||||||
}
|
}
|
||||||
subProcessOfOpenBossSite = childProcess.spawn(process.argv[0], process.argv.slice(1), {
|
subProcessOfOpenBossSite = childProcess.spawn(
|
||||||
env: subProcessEnv,
|
process.argv[0],
|
||||||
stdio: ['inherit', 'inherit', 'inherit', 'pipe']
|
[...process.argv.slice(1), `--mode=launchBossSite`],
|
||||||
})
|
{
|
||||||
|
env: subProcessEnv,
|
||||||
|
stdio: ['inherit', 'inherit', 'inherit', 'pipe']
|
||||||
|
}
|
||||||
|
)
|
||||||
subProcessOfOpenBossSite.once('exit', () => {
|
subProcessOfOpenBossSite.once('exit', () => {
|
||||||
subProcessOfOpenBossSiteDefer = null
|
subProcessOfOpenBossSiteDefer = null
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
const runMode = process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE
|
import minimist from 'minimist'
|
||||||
|
const isUiDev = process.env.NODE_ENV === 'development'
|
||||||
|
const commandlineArgs = minimist(isUiDev ? process.argv.slice(2) : process.argv.slice(1))
|
||||||
|
console.log(commandlineArgs)
|
||||||
|
|
||||||
|
const runMode = commandlineArgs['mode'];
|
||||||
|
|
||||||
;(async () => {
|
;(async () => {
|
||||||
switch (runMode) {
|
switch (runMode) {
|
||||||
|
|||||||
Reference in New Issue
Block a user