@lvce-editor/update-worker 1.1.0 → 1.2.0
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/dist/updateWorkerMain.js +50 -28
- package/package.json +1 -1
package/dist/updateWorkerMain.js
CHANGED
|
@@ -903,6 +903,13 @@ const promptRestart = () => {
|
|
|
903
903
|
return i18nString(UiStrings.DoYouWantToRestart);
|
|
904
904
|
};
|
|
905
905
|
|
|
906
|
+
// TODO avoid js prompt in elctron, since it crashes electron
|
|
907
|
+
|
|
908
|
+
const confirmPrompt = async message => {
|
|
909
|
+
// TODO
|
|
910
|
+
return true;
|
|
911
|
+
};
|
|
912
|
+
|
|
906
913
|
const downloadUpdate = async updateUrl => {
|
|
907
914
|
const response = await fetch(updateUrl, {
|
|
908
915
|
priority: 'low',
|
|
@@ -951,7 +958,7 @@ const getLatestReleaseVersion = async repository => {
|
|
|
951
958
|
const finalUrlResponse = await fetch(url, {
|
|
952
959
|
method: 'HEAD'
|
|
953
960
|
});
|
|
954
|
-
const finalUrl =
|
|
961
|
+
const finalUrl = finalUrlResponse.url;
|
|
955
962
|
const version = parseVersionFromUrl(finalUrl, repository);
|
|
956
963
|
return {
|
|
957
964
|
version
|
|
@@ -998,38 +1005,53 @@ const shouldUpdate = async (updateSetting, version) => {
|
|
|
998
1005
|
if (updateSetting && updateSetting !== 'none') {
|
|
999
1006
|
return true;
|
|
1000
1007
|
}
|
|
1001
|
-
|
|
1002
|
-
const shouldUpdate = await
|
|
1003
|
-
confirmMessage: '',
|
|
1004
|
-
title: ''
|
|
1005
|
-
});
|
|
1008
|
+
promptMessage(version);
|
|
1009
|
+
const shouldUpdate = await confirmPrompt();
|
|
1006
1010
|
return shouldUpdate;
|
|
1007
1011
|
};
|
|
1008
1012
|
|
|
1009
1013
|
const checkForUpdates = async (updateSetting, repository) => {
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1014
|
+
try {
|
|
1015
|
+
const info = await getLatestReleaseVersion(repository);
|
|
1016
|
+
if (!info || !info.version) {
|
|
1017
|
+
return {
|
|
1018
|
+
updated: false,
|
|
1019
|
+
error: undefined
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
if (!(await shouldUpdate(updateSetting, info.version))) {
|
|
1023
|
+
return {
|
|
1024
|
+
updated: false,
|
|
1025
|
+
error: undefined
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
// @ts-ignore
|
|
1029
|
+
await invoke('Layout.setUpdateState', {
|
|
1030
|
+
state: 'downloading',
|
|
1031
|
+
progress: 0
|
|
1032
|
+
});
|
|
1033
|
+
await downloadUpdateToCache(repository, info.version);
|
|
1034
|
+
const messageRestart = promptRestart();
|
|
1035
|
+
const shouldRestart = await confirmPrompt(messageRestart);
|
|
1036
|
+
if (!shouldRestart) {
|
|
1037
|
+
return {
|
|
1038
|
+
updated: false,
|
|
1039
|
+
error: undefined
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
const downloadPath = ''; // TODO get it from cache to disk somehow
|
|
1043
|
+
await installAndRestart(downloadPath);
|
|
1044
|
+
return {
|
|
1045
|
+
updated: true,
|
|
1046
|
+
error: undefined
|
|
1047
|
+
};
|
|
1048
|
+
} catch (error) {
|
|
1049
|
+
console.error(error);
|
|
1050
|
+
return {
|
|
1051
|
+
updated: false,
|
|
1052
|
+
error: undefined
|
|
1053
|
+
};
|
|
1031
1054
|
}
|
|
1032
|
-
await installAndRestart(downloadPath);
|
|
1033
1055
|
};
|
|
1034
1056
|
|
|
1035
1057
|
const commandMap = {
|