@lvce-editor/shared-process 0.14.9 → 0.14.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.11",
|
|
4
4
|
"description": "Utility package for @lvce-editor/server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/code-frame": "^7.21.4",
|
|
20
|
-
"@lvce-editor/extension-host": "0.14.
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.14.
|
|
22
|
-
"@lvce-editor/pty-host": "0.14.
|
|
20
|
+
"@lvce-editor/extension-host": "0.14.11",
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.14.11",
|
|
22
|
+
"@lvce-editor/pty-host": "0.14.11",
|
|
23
23
|
"debug": "^4.3.4",
|
|
24
24
|
"execa": "^7.1.1",
|
|
25
25
|
"exit-hook": "^3.2.0",
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process'
|
|
2
2
|
import { rename } from 'node:fs/promises'
|
|
3
3
|
import { tmpdir } from 'node:os'
|
|
4
|
-
import { join } from 'node:path'
|
|
4
|
+
import { basename, dirname, join } from 'node:path'
|
|
5
5
|
import * as Assert from '../Assert/Assert.js'
|
|
6
6
|
import * as CompareVersion from '../CompareVersion/CompareVersion.js'
|
|
7
7
|
import * as Download from '../Download/Download.js'
|
|
8
|
+
import * as GetAppImageDownloadUrl from '../GetAppImageDownloadUrl/GetAppImageDownloadUrl.js'
|
|
8
9
|
import * as GetLatestReleaseVersion from '../GetLatestReleaseVersion/GetLatestReleaseVersion.js'
|
|
9
10
|
import * as MakeExecutable from '../MakeExecutable/MakeExecutable.js'
|
|
10
11
|
import * as Platform from '../Platform/Platform.js'
|
|
11
12
|
import { VError } from '../VError/VError.js'
|
|
12
13
|
|
|
13
|
-
const getDownloadUrl = (repository, version, appImageName) => {
|
|
14
|
-
Assert.string(version)
|
|
15
|
-
return `https://github.com/${repository}/releases/download/v${version}/${appImageName}-v${version}.AppImage`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
const getOutfilePath = (version) => {
|
|
19
15
|
Assert.string(version)
|
|
20
16
|
const outFile = join(tmpdir(), `appimage-${version}`)
|
|
@@ -26,7 +22,7 @@ export const downloadUpdate = async (version) => {
|
|
|
26
22
|
Assert.string(version)
|
|
27
23
|
const repository = Platform.getRepository()
|
|
28
24
|
const appImageName = Platform.getAppImageName()
|
|
29
|
-
const downLoadUrl = getDownloadUrl(repository, version, appImageName)
|
|
25
|
+
const downLoadUrl = GetAppImageDownloadUrl.getDownloadUrl(repository, version, appImageName)
|
|
30
26
|
const outFile = getOutfilePath(version)
|
|
31
27
|
await Download.download(downLoadUrl, outFile)
|
|
32
28
|
return outFile
|
|
@@ -53,9 +49,18 @@ const getAppImagePath = () => {
|
|
|
53
49
|
return process.env.APPIMAGE
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
const installNewAppImage = async (
|
|
52
|
+
const installNewAppImage = async (currentAppImageFile, downloadPath) => {
|
|
57
53
|
try {
|
|
58
|
-
|
|
54
|
+
const currentFileName = basename(currentAppImageFile)
|
|
55
|
+
const newFileName = basename(downloadPath)
|
|
56
|
+
if (currentFileName === newFileName) {
|
|
57
|
+
await rename(downloadPath, currentAppImageFile)
|
|
58
|
+
return currentAppImageFile
|
|
59
|
+
}
|
|
60
|
+
const destinationFolder = dirname(currentAppImageFile)
|
|
61
|
+
const destinationPath = join(destinationFolder, newFileName)
|
|
62
|
+
await rename(downloadPath, destinationPath)
|
|
63
|
+
return destinationPath
|
|
59
64
|
} catch (error) {
|
|
60
65
|
// @ts-ignore
|
|
61
66
|
throw new VError(error, `Failed to rename AppImage file`)
|
|
@@ -70,13 +75,13 @@ const restart = (downloadPath) => {
|
|
|
70
75
|
export const installAndRestart = async (downloadPath) => {
|
|
71
76
|
try {
|
|
72
77
|
Assert.string(downloadPath)
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
78
|
+
const currentAppImageFile = getAppImagePath()
|
|
79
|
+
if (!currentAppImageFile) {
|
|
75
80
|
throw new Error(`AppImage path not found`)
|
|
76
81
|
}
|
|
77
82
|
await MakeExecutable.makeExecutable(downloadPath)
|
|
78
|
-
await installNewAppImage(
|
|
79
|
-
await restart(
|
|
83
|
+
const installedPath = await installNewAppImage(currentAppImageFile, downloadPath)
|
|
84
|
+
await restart(installedPath)
|
|
80
85
|
} catch (error) {
|
|
81
86
|
// @ts-ignore
|
|
82
87
|
throw new VError(error, `Failed to install AppImage update`)
|