()
| 51 | } |
| 52 | |
| 53 | async command() { |
| 54 | let command = '' |
| 55 | let icns = `` |
| 56 | |
| 57 | const tmpDir = join(tmpdir(), uuid()) |
| 58 | const dataPath = dirname(global.Server.AppDir!) |
| 59 | const appRoot = PathResolve(global.Server.Static!, '../../../../') |
| 60 | await mkdirp(tmpDir) |
| 61 | await chmod(tmpDir, '0755') |
| 62 | if (is.production()) { |
| 63 | if (isMacOS()) { |
| 64 | const uinfo = userInfo() |
| 65 | const role = `${uinfo.uid}:${uinfo.gid}` |
| 66 | const binDir = PathResolve(global.Server.Static!, '../../../../') |
| 67 | const plist = join(binDir, 'plist/com.flyenv.helper.plist') |
| 68 | const bin = join(binDir, 'helper/flyenv-helper') |
| 69 | const shDir = join(binDir, 'helper') |
| 70 | const shFile = join(shDir, 'flyenv-helper-init.sh') |
| 71 | |
| 72 | const tmpFile = join(tmpDir, `${uuid()}.sh`) |
| 73 | await copyFile(shFile, tmpFile) |
| 74 | await chmod(tmpFile, '0755') |
| 75 | |
| 76 | const tmpPlist = join(tmpDir, `${uuid()}.plist`) |
| 77 | await copyFile(plist, tmpPlist) |
| 78 | await chmod(tmpPlist, '0755') |
| 79 | |
| 80 | const tmpBin = join(tmpDir, `${uuid()}.helper`) |
| 81 | await copyFile(bin, tmpBin) |
| 82 | await chmod(tmpBin, '0755') |
| 83 | |
| 84 | command = `cd "${tmpDir}" && sudo /bin/zsh ./${basename(tmpFile)} "${tmpPlist}" "${tmpBin}" "${role}" "${dataPath}" "${appRoot}" && sudo rm -rf "${tmpDir}"` |
| 85 | icns = join(binDir, 'icon.icns') |
| 86 | } else if (isLinux()) { |
| 87 | const uinfo = userInfo() |
| 88 | const role = `${uinfo.uid}:${uinfo.gid}` |
| 89 | const binDir = PathResolve(global.Server.Static!, '../../../../') |
| 90 | const bin = join(binDir, 'helper/flyenv-helper') |
| 91 | const shDir = join(binDir, 'helper') |
| 92 | const shFile = join(shDir, 'flyenv-helper-init.sh') |
| 93 | |
| 94 | const tmpFile = join(tmpDir, `${uuid()}.sh`) |
| 95 | await copyFile(shFile, tmpFile) |
| 96 | await chmod(tmpFile, '0755') |
| 97 | |
| 98 | const tmpBin = join(tmpDir, `${uuid()}.helper`) |
| 99 | await copyFile(bin, tmpBin) |
| 100 | await chmod(tmpBin, '0755') |
| 101 | |
| 102 | command = `cd "${tmpDir}" && sudo /bin/bash ./${basename(tmpFile)} "${tmpBin}" "${role}" "${dataPath}" "${appRoot}" && sudo rm -rf "${tmpDir}"` |
| 103 | icns = join(binDir, 'Icon@256x256.icns') |
| 104 | } else if (isWindows()) { |
| 105 | if (!windowsHelperBinaryExists()) { |
| 106 | throw new AppHelperError( |
| 107 | 'helper_binary_missing', |
| 108 | `Windows helper binary missing: ${getWindowsHelperBinaryPath()}` |
| 109 | ) |
| 110 | } |
no test coverage detected