@lvce-editor/shared-process 0.17.0 → 0.17.1
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 +5 -5
- package/src/parts/AutoUpdaterWindowsNsis/AutoUpdaterWindowsNsis.js +12 -43
- package/src/parts/GetFirstSpawnedProcessEvent/GetFirstSpawnedProcessEvent.js +9 -0
- package/src/parts/GetNsisUpdateArgs/GetNsisUpdateArgs.js +7 -0
- package/src/parts/GetNsisUpdateDownloadPath/GetNsisUpdateDownloadPath.js +11 -0
- package/src/parts/GetWindowsNsisDownloadUrl/GetWindowsNsisDownloadUrl.js +2 -0
- package/src/parts/Platform/Platform.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Utility package for @lvce-editor/server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/code-frame": "^7.22.5",
|
|
20
|
-
"@lvce-editor/extension-host": "0.17.
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.17.
|
|
22
|
-
"@lvce-editor/pty-host": "0.17.
|
|
20
|
+
"@lvce-editor/extension-host": "0.17.1",
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.17.1",
|
|
22
|
+
"@lvce-editor/pty-host": "0.17.1",
|
|
23
23
|
"debug": "^4.3.4",
|
|
24
|
-
"execa": "^7.
|
|
24
|
+
"execa": "^7.2.0",
|
|
25
25
|
"exit-hook": "^3.2.0",
|
|
26
26
|
"got": "^13.0.0",
|
|
27
27
|
"is-object": "^1.0.2",
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process'
|
|
2
|
-
import { tmpdir } from 'node:os'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
2
|
import * as Assert from '../Assert/Assert.js'
|
|
5
3
|
import * as Download from '../Download/Download.js'
|
|
4
|
+
import * as FirstNodeWorkerEventType from '../FirstNodeWorkerEventType/FirstNodeWorkerEventType.js'
|
|
5
|
+
import * as GetFirstSpawnedProcessEvent from '../GetFirstSpawnedProcessEvent/GetFirstSpawnedProcessEvent.js'
|
|
6
|
+
import * as GetNsisUpdateArgs from '../GetNsisUpdateArgs/GetNsisUpdateArgs.js'
|
|
7
|
+
import * as GetNsisDownloadPath from '../GetNsisUpdateDownloadPath/GetNsisUpdateDownloadPath.js'
|
|
6
8
|
import * as GetWindowsNsisDownloadUrl from '../GetWindowsNsisDownloadUrl/GetWindowsNsisDownloadUrl.js'
|
|
7
9
|
import * as Logger from '../Logger/Logger.js'
|
|
8
10
|
import * as Platform from '../Platform/Platform.js'
|
|
9
11
|
import { VError } from '../VError/VError.js'
|
|
10
12
|
|
|
11
|
-
const getOutfilePath = (version) => {
|
|
12
|
-
Assert.string(version)
|
|
13
|
-
const outFile = join(tmpdir(), `nsis-update-${version}`)
|
|
14
|
-
return outFile
|
|
15
|
-
}
|
|
16
|
-
|
|
17
13
|
export const downloadUpdate = async (version) => {
|
|
18
14
|
try {
|
|
19
15
|
Assert.string(version)
|
|
@@ -21,7 +17,7 @@ export const downloadUpdate = async (version) => {
|
|
|
21
17
|
const setupName = Platform.getSetupName()
|
|
22
18
|
const fileName = `${setupName}-v${version}.exe`
|
|
23
19
|
const downLoadUrl = GetWindowsNsisDownloadUrl.getDownloadUrl(repository, version, fileName)
|
|
24
|
-
const outFile =
|
|
20
|
+
const outFile = GetNsisDownloadPath.getNsisUpdateDownloadPath(version)
|
|
25
21
|
Logger.info(`[shared-process] downloading nsis update: ${downLoadUrl} -> ${outFile}`)
|
|
26
22
|
await Download.download(downLoadUrl, outFile)
|
|
27
23
|
Logger.info(`[shared-process] downloaded nsis update: ${outFile}`)
|
|
@@ -31,44 +27,17 @@ export const downloadUpdate = async (version) => {
|
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
const getNsisUpdateArgs = () => {
|
|
35
|
-
const args = []
|
|
36
|
-
args.push('--updated')
|
|
37
|
-
args.push('/S')
|
|
38
|
-
args.push('--force-run')
|
|
39
|
-
return args
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const getFirstNsisProcessEvent = async (childProcess) => {
|
|
43
|
-
const { type, event } = await new Promise((resolve) => {
|
|
44
|
-
const cleanup = (value) => {
|
|
45
|
-
childProcess.off('error', handleError)
|
|
46
|
-
childProcess.off('exit', handleExit)
|
|
47
|
-
resolve(value)
|
|
48
|
-
}
|
|
49
|
-
const handleError = (event) => {
|
|
50
|
-
cleanup({ type: 'error', event })
|
|
51
|
-
}
|
|
52
|
-
const handleExit = (event) => {
|
|
53
|
-
cleanup({ type: 'exit', event })
|
|
54
|
-
}
|
|
55
|
-
childProcess.on('error', handleError)
|
|
56
|
-
childProcess.on('exit', handleExit)
|
|
57
|
-
})
|
|
58
|
-
return {
|
|
59
|
-
type,
|
|
60
|
-
event,
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
30
|
export const installAndRestart = async (downloadPath) => {
|
|
65
31
|
try {
|
|
66
32
|
Assert.string(downloadPath)
|
|
67
|
-
const args = getNsisUpdateArgs()
|
|
33
|
+
const args = GetNsisUpdateArgs.getNsisUpdateArgs()
|
|
68
34
|
Logger.info(`[shared-process] spawning nsis update: ${downloadPath}`)
|
|
69
|
-
const child = spawn(downloadPath, args, {
|
|
70
|
-
|
|
71
|
-
|
|
35
|
+
const child = spawn(downloadPath, args, {
|
|
36
|
+
stdio: 'inherit',
|
|
37
|
+
detached: true,
|
|
38
|
+
})
|
|
39
|
+
const { type, event } = await GetFirstSpawnedProcessEvent.getFirstSpawnedProcessEvent(child)
|
|
40
|
+
if (type === FirstNodeWorkerEventType.Error) {
|
|
72
41
|
throw new Error(`Child process error: ${event}`)
|
|
73
42
|
}
|
|
74
43
|
Logger.info(`[shared-process] finished nsis update`)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as GetFirstEvent from '../GetFirstEvent/GetFirstEvent.js'
|
|
2
|
+
import * as FirstNodeWorkerEventType from '../FirstNodeWorkerEventType/FirstNodeWorkerEventType.js'
|
|
3
|
+
|
|
4
|
+
export const getFirstSpawnedProcessEvent = (childProcess) => {
|
|
5
|
+
return GetFirstEvent.getFirstEvent(childProcess, {
|
|
6
|
+
error: FirstNodeWorkerEventType.Error,
|
|
7
|
+
exit: FirstNodeWorkerEventType.Exit,
|
|
8
|
+
})
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { tmpdir } from 'node:os'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
import * as Assert from '../Assert/Assert.js'
|
|
4
|
+
import * as Platform from '../Platform/Platform.js'
|
|
5
|
+
|
|
6
|
+
export const getNsisUpdateDownloadPath = (version) => {
|
|
7
|
+
Assert.string(version)
|
|
8
|
+
const name = Platform.applicationName
|
|
9
|
+
const outFile = join(tmpdir(), `${name}-update-${version}.exe`)
|
|
10
|
+
return outFile
|
|
11
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as Assert from '../Assert/Assert.js'
|
|
2
2
|
|
|
3
3
|
export const getDownloadUrl = (repository, version, fileName) => {
|
|
4
|
+
Assert.string(repository)
|
|
4
5
|
Assert.string(version)
|
|
6
|
+
Assert.string(fileName)
|
|
5
7
|
return `https://github.com/${repository}/releases/download/v${version}/${fileName}`
|
|
6
8
|
}
|
|
@@ -169,11 +169,11 @@ export const getSetupName = () => {
|
|
|
169
169
|
return 'Lvce-Setup'
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
export const version = '0.17.
|
|
172
|
+
export const version = '0.17.1'
|
|
173
173
|
|
|
174
|
-
export const commit = '
|
|
174
|
+
export const commit = 'b3e9c7f'
|
|
175
175
|
|
|
176
|
-
export const date = '2023-08-
|
|
176
|
+
export const date = '2023-08-05T20:50:47.000Z'
|
|
177
177
|
|
|
178
178
|
export const getVersion = () => {
|
|
179
179
|
return version
|