@lvce-editor/shared-process 0.14.8 → 0.14.10
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.10",
|
|
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.10",
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.14.10",
|
|
22
|
+
"@lvce-editor/pty-host": "0.14.10",
|
|
23
23
|
"debug": "^4.3.4",
|
|
24
24
|
"execa": "^7.1.1",
|
|
25
25
|
"exit-hook": "^3.2.0",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process'
|
|
2
|
-
import {
|
|
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
8
|
import * as GetLatestReleaseVersion from '../GetLatestReleaseVersion/GetLatestReleaseVersion.js'
|
|
9
|
+
import * as MakeExecutable from '../MakeExecutable/MakeExecutable.js'
|
|
9
10
|
import * as Platform from '../Platform/Platform.js'
|
|
10
11
|
import { VError } from '../VError/VError.js'
|
|
11
12
|
|
|
@@ -28,6 +29,7 @@ export const downloadUpdate = async (version) => {
|
|
|
28
29
|
const downLoadUrl = getDownloadUrl(repository, version, appImageName)
|
|
29
30
|
const outFile = getOutfilePath(version)
|
|
30
31
|
await Download.download(downLoadUrl, outFile)
|
|
32
|
+
return outFile
|
|
31
33
|
} catch (error) {
|
|
32
34
|
// @ts-ignore
|
|
33
35
|
throw new VError(error, `Failed to download new version ${version}`)
|
|
@@ -51,9 +53,18 @@ const getAppImagePath = () => {
|
|
|
51
53
|
return process.env.APPIMAGE
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
const installNewAppImage = async (
|
|
56
|
+
const installNewAppImage = async (currentAppImageFile, downloadPath) => {
|
|
55
57
|
try {
|
|
56
|
-
|
|
58
|
+
const currentFileName = basename(currentAppImageFile)
|
|
59
|
+
const newFileName = basename(downloadPath)
|
|
60
|
+
if (currentFileName === newFileName) {
|
|
61
|
+
await rename(downloadPath, currentAppImageFile)
|
|
62
|
+
return currentAppImageFile
|
|
63
|
+
}
|
|
64
|
+
const destinationFolder = dirname(currentAppImageFile)
|
|
65
|
+
const destinationPath = join(destinationFolder, newFileName)
|
|
66
|
+
await rename(downloadPath, destinationPath)
|
|
67
|
+
return destinationPath
|
|
57
68
|
} catch (error) {
|
|
58
69
|
// @ts-ignore
|
|
59
70
|
throw new VError(error, `Failed to rename AppImage file`)
|
|
@@ -65,19 +76,16 @@ const restart = (downloadPath) => {
|
|
|
65
76
|
spawn(downloadPath, { stdio: 'inherit' })
|
|
66
77
|
}
|
|
67
78
|
|
|
68
|
-
const makeExecutable = async (file) => {
|
|
69
|
-
await chmod(file, 0o755)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
79
|
export const installAndRestart = async (downloadPath) => {
|
|
73
80
|
try {
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
Assert.string(downloadPath)
|
|
82
|
+
const currentAppImageFile = getAppImagePath()
|
|
83
|
+
if (!currentAppImageFile) {
|
|
76
84
|
throw new Error(`AppImage path not found`)
|
|
77
85
|
}
|
|
78
|
-
await makeExecutable(downloadPath)
|
|
79
|
-
await installNewAppImage(
|
|
80
|
-
await restart(
|
|
86
|
+
await MakeExecutable.makeExecutable(downloadPath)
|
|
87
|
+
const installedPath = await installNewAppImage(currentAppImageFile, downloadPath)
|
|
88
|
+
await restart(installedPath)
|
|
81
89
|
} catch (error) {
|
|
82
90
|
// @ts-ignore
|
|
83
91
|
throw new VError(error, `Failed to install AppImage update`)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { chmod } from 'node:fs/promises'
|
|
2
|
+
import { VError } from '../VError/VError.js'
|
|
3
|
+
|
|
4
|
+
export const makeExecutable = async (file) => {
|
|
5
|
+
try {
|
|
6
|
+
await chmod(file, 0o755)
|
|
7
|
+
} catch (error) {
|
|
8
|
+
throw new VError(error, `Failed to make file executable`)
|
|
9
|
+
}
|
|
10
|
+
}
|