@lvce-editor/shared-process 0.14.10 → 0.14.12

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.10",
3
+ "version": "0.14.12",
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.10",
21
- "@lvce-editor/extension-host-helper-process": "0.14.10",
22
- "@lvce-editor/pty-host": "0.14.10",
20
+ "@lvce-editor/extension-host": "0.14.12",
21
+ "@lvce-editor/extension-host-helper-process": "0.14.12",
22
+ "@lvce-editor/pty-host": "0.14.12",
23
23
  "debug": "^4.3.4",
24
24
  "execa": "^7.1.1",
25
25
  "exit-hook": "^3.2.0",
@@ -1,20 +1,17 @@
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 { basename, dirname, join } from 'node:path'
4
+ import { 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'
9
+ import * as GetAppImagePath from '../GetAppImagePath/GetAppImagePath.js'
8
10
  import * as GetLatestReleaseVersion from '../GetLatestReleaseVersion/GetLatestReleaseVersion.js'
9
11
  import * as MakeExecutable from '../MakeExecutable/MakeExecutable.js'
10
12
  import * as Platform from '../Platform/Platform.js'
11
13
  import { VError } from '../VError/VError.js'
12
14
 
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
15
  const getOutfilePath = (version) => {
19
16
  Assert.string(version)
20
17
  const outFile = join(tmpdir(), `appimage-${version}`)
@@ -26,7 +23,7 @@ export const downloadUpdate = async (version) => {
26
23
  Assert.string(version)
27
24
  const repository = Platform.getRepository()
28
25
  const appImageName = Platform.getAppImageName()
29
- const downLoadUrl = getDownloadUrl(repository, version, appImageName)
26
+ const downLoadUrl = GetAppImageDownloadUrl.getDownloadUrl(repository, version, appImageName)
30
27
  const outFile = getOutfilePath(version)
31
28
  await Download.download(downLoadUrl, outFile)
32
29
  return outFile
@@ -49,22 +46,10 @@ export const checkForUpdatesAndNotify = async () => {
49
46
  }
50
47
  }
51
48
 
52
- const getAppImagePath = () => {
53
- return process.env.APPIMAGE
54
- }
55
-
56
49
  const installNewAppImage = async (currentAppImageFile, downloadPath) => {
57
50
  try {
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
51
+ await rename(downloadPath, currentAppImageFile)
52
+ return currentAppImageFile
68
53
  } catch (error) {
69
54
  // @ts-ignore
70
55
  throw new VError(error, `Failed to rename AppImage file`)
@@ -79,7 +64,7 @@ const restart = (downloadPath) => {
79
64
  export const installAndRestart = async (downloadPath) => {
80
65
  try {
81
66
  Assert.string(downloadPath)
82
- const currentAppImageFile = getAppImagePath()
67
+ const currentAppImageFile = GetAppImagePath.getAppImagePath()
83
68
  if (!currentAppImageFile) {
84
69
  throw new Error(`AppImage path not found`)
85
70
  }
@@ -0,0 +1,6 @@
1
+ import * as Assert from '../Assert/Assert.js'
2
+
3
+ export const getDownloadUrl = (repository, version, appImageName) => {
4
+ Assert.string(version)
5
+ return `https://github.com/${repository}/releases/download/v${version}/${appImageName}-v${version}.AppImage`
6
+ }
@@ -0,0 +1,3 @@
1
+ export const getAppImagePath = () => {
2
+ return process.env.APPIMAGE
3
+ }