Skip to content

Commit

Permalink
1. Add Mailpit Module
Browse files Browse the repository at this point in the history
2. Change App Name to PerfectEnv
  • Loading branch information
xpf0000 committed Nov 16, 2024
1 parent b4f41f2 commit 3155abd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 43 deletions.
1 change: 1 addition & 0 deletions configs/electron-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const conf: Configuration = {
target: {
target: 'default',
arch: ['x64', 'arm64']
// arch: ['arm64']
},
asarUnpack: ['**/*.node'],
extendInfo: {
Expand Down
20 changes: 10 additions & 10 deletions latest-mac.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
version: 4.5.5
files:
- url: FlyEnv-4.5.5-mac.zip
sha512: 20X3kmSQY9+NMVxFP/+bwcy8IIeeDATvF8M7JzjunHmk0zjDrQA/O8/3QxF3l2KufNHaDjUeUTZr6qnAolbfZg==
size: 116907782
sha512: dcokkO2K0alXw7IFFFDX5syXUPtty/Iw2pFYWHFQ62sI0pr8espMnKmjZJQ9yEF3hbKx0UXoEIFc9aIJcBRVTA==
size: 116767618
- url: FlyEnv-4.5.5-arm64-mac.zip
sha512: L+mFgVtb3CYKHsWYra9A7Ud3aVNdyxHVwtwtB5b7+db5dij1zPWY+0m+WxwJ831zW1OqjNNs/AhYKioPRm6fZQ==
size: 109879944
sha512: WBSjxr8mztVM51+OyNhO1Ogl+jvgqJQZwKCpAyrxw6NSBg0wXxbO1c27WqeVcW1fE4kpUeUSkSzh5T5/LTTQxg==
size: 109740485
- url: FlyEnv-4.5.5.dmg
sha512: 91/0+HUWLNWwlSb8bWbhIWxiYc/0Oc0a05OYyqLbQFGUxsj5eu/E0ROqAThMI0Ija19sN2hs+nP8Qa25R0X/bg==
size: 122550081
sha512: zniuLBuPywX8QThVglSCjIsTX1K31SkCT+m3ohIl8avBFuKxVa5T+QCSqW/dBD/JQY2FRI1iU87EutARqJaf4g==
size: 122473377
- url: FlyEnv-4.5.5-arm64.dmg
sha512: k4rwutQN6fYQgrxXb30c/5EJkhlhn78RCPzn1cdA7dviBVZ8ggjKO5ig1vSuKkqKeMdyEx+2kkdGdtS7h60FHQ==
size: 115547449
sha512: zDeU/uX/Y+ZZAsOI+FDwmyv4QJyksKyj7Cj3exDIRe2I+qbeo2Z6BfdHzdgEX5g2GJP3HW8Ovf6BthLViFaChw==
size: 115461882
path: FlyEnv-4.5.5-mac.zip
sha512: 20X3kmSQY9+NMVxFP/+bwcy8IIeeDATvF8M7JzjunHmk0zjDrQA/O8/3QxF3l2KufNHaDjUeUTZr6qnAolbfZg==
releaseDate: '2024-11-16T06:45:23.390Z'
sha512: dcokkO2K0alXw7IFFFDX5syXUPtty/Iw2pFYWHFQ62sI0pr8espMnKmjZJQ9yEF3hbKx0UXoEIFc9aIJcBRVTA==
releaseDate: '2024-11-16T14:13:07.192Z'
60 changes: 27 additions & 33 deletions src/fork/module/Tool.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createReadStream, readFileSync, realpathSync, statSync } from 'fs'
import { Base } from './Base'
import { getAllFileAsync, execPromise, uuid, systemProxyGet } from '../Fn'
import { getAllFileAsync, uuid, systemProxyGet } from '../Fn'
import { ForkPromise } from '@shared/ForkPromise'
import { existsSync, mkdirp, readdir, readFile, remove, writeFile } from 'fs-extra'
import { appendFile, existsSync, mkdirp, readdir, readFile, remove, writeFile } from 'fs-extra'
import { TaskQueue, TaskItem, TaskQueueProgress } from '@shared/TaskQueue'
import { join, dirname } from 'path'
import { I18nT } from '../lang'
Expand Down Expand Up @@ -101,22 +101,18 @@ class Manager extends Base {
systemEnvFiles() {
return new ForkPromise(async (resolve, reject) => {
const envFiles = [
'~/.config/fish/config.fish',
'~/.bashrc',
'~/.profile',
'~/.bash_login',
'~/.zprofile',
'~/.zshrc',
'~/.bash_profile',
join(global.Server.UserHome!, '.config/fish/config.fish'),
join(global.Server.UserHome!, '.bashrc'),
join(global.Server.UserHome!, '.profile'),
join(global.Server.UserHome!, '.bash_login'),
join(global.Server.UserHome!, '.zprofile'),
join(global.Server.UserHome!, '.zshrc'),
join(global.Server.UserHome!, '.bash_profile'),
'/etc/paths',
'/etc/profile'
]
try {
const home = await execPromise(`echo $HOME`)
console.log('home: ', home)
const files = envFiles
.map((e) => e.replace('~', home.stdout.trim()))
.filter((e) => existsSync(e))
const files = envFiles.filter((e) => existsSync(e))
resolve(files)
} catch (e) {
reject(e)
Expand Down Expand Up @@ -154,16 +150,13 @@ class Manager extends Base {
}

fetchPATH(): ForkPromise<string[]> {
return new ForkPromise(async (resolve, reject) => {
let file = '~/.zshrc'
return new ForkPromise(async (resolve) => {
const file = join(global.Server.UserHome!, '.zshrc')
if (!existsSync(file)) {
resolve([])
return
}
try {
const home = await execPromise(`echo $HOME`)
console.log('home: ', home)
file = file.replace('~', home.stdout.trim())
if (!existsSync(file)) {
reject(new Error('~/.zshrc not found'))
return
}
const content = await readFile(file, 'utf-8')
const x: any = content.match(
/(#PHPWEBSTUDY-PATH-SET-BEGIN#)([\s\S]*?)(#PHPWEBSTUDY-PATH-SET-END#)/g
Expand All @@ -184,20 +177,18 @@ class Manager extends Base {
.filter((f) => existsSync(f) && statSync(f).isDirectory())
resolve(allFile)
} catch (e) {
reject(e)
resolve([])
}
})
}

updatePATH(item: SoftInstalled, flag: string) {
return new ForkPromise(async (resolve) => {
console.log('updatePATH: ', item, flag)
const all = await this.fetchPATH()
let bin = dirname(item.bin)
if (flag === 'php') {
bin = dirname(item?.phpBin ?? join(item.path, 'bin/php'))
}
console.log('updatePATH: ', item, flag, bin)
const envDir = join(dirname(global.Server.AppDir!), 'env')
if (!existsSync(envDir)) {
await mkdirp(envDir)
Expand All @@ -211,7 +202,6 @@ class Manager extends Base {
await execPromiseRoot(['ln', '-s', bin, flagDir])
} catch (e) {}
}

let allFile = await readdir(envDir)
allFile = allFile
.filter((f) => existsSync(join(envDir, f)))
Expand All @@ -227,11 +217,11 @@ class Manager extends Base {
return check
})

const files = ['~/.zshrc', '~/.config/fish/config.fish']
const home = await execPromise(`echo $HOME`)

const files = [
join(global.Server.UserHome!, '.zshrc'),
join(global.Server.UserHome!, '.config/fish/config.fish')
]
const handleFile = async (file: string) => {
file = file.replace('~', home.stdout.trim())
if (file.includes('.zshrc') && !existsSync(file)) {
try {
await writeFile(file, '')
Expand Down Expand Up @@ -319,8 +309,12 @@ class Manager extends Base {
}
}
}

await Promise.all(files.map((f) => handleFile(f)))
try {
await Promise.all(files.map((f) => handleFile(f)))
} catch (e) {
const debugFile = join(global.Server.BaseDir!, 'debug.log')
await appendFile(debugFile, `[updatePATH][error]: ${e} !!!\n`)
}
resolve(allFile.map((f) => realpathSync(f)))
})
}
Expand Down
1 change: 1 addition & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface ServerType {
Local?: string
MacPorts?: string
ForceStart?: boolean
UserHome?: string
}

declare global {
Expand Down
1 change: 1 addition & 0 deletions src/main/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export default class Application extends EventEmitter {
console.log('userData: ', app.getPath('userData'))
const runpath = app.getPath('userData').replace('Application Support/', '')
this.setProxy()
global.Server.UserHome = app.getPath('home')
global.Server.isAppleSilicon = isAppleSilicon()
global.Server.BaseDir = join(runpath, 'server')
global.Server.AppDir = join(runpath, 'app')
Expand Down

0 comments on commit 3155abd

Please sign in to comment.