mirror of
https://github.com/ivabus/gui
synced 2025-04-23 14:07:14 +03:00
report overall progress from libtea (#656)
This commit is contained in:
parent
17acada221
commit
f9031a59df
3 changed files with 9 additions and 25 deletions
|
@ -23,34 +23,18 @@ export async function installPackage(
|
||||||
}
|
}
|
||||||
|
|
||||||
function newInstallProgressNotifier(full_name: string, notifyMainWindow: MainWindowNotifier) {
|
function newInstallProgressNotifier(full_name: string, notifyMainWindow: MainWindowNotifier) {
|
||||||
// the totall number of packages to install - this is set by the "resolved" message
|
|
||||||
let numberOfPackages = 1;
|
|
||||||
|
|
||||||
// the current package number - this is incremented by the "installed" or "downloaded" message
|
|
||||||
let currentPackageNumber = 0;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
resolved: ({ pending }: Resolution) => {
|
resolved: ({ pending }: Resolution) => {
|
||||||
numberOfPackages = pending.length ?? 1;
|
log.info(`resolved ${pending.length} packages to install`);
|
||||||
log.info(`resolved ${numberOfPackages} packages to install`);
|
|
||||||
},
|
},
|
||||||
installing: ({ pkg, progress }: { pkg: Package; progress: number | undefined }) => {
|
progress: (progress: number) => {
|
||||||
log.info(`installing ${pkg.project}@${pkg.version} - ${progress}`);
|
if (progress > 0 && progress <= 1) {
|
||||||
if (progress && progress > 0) {
|
notifyMainWindow("install-progress", { full_name, progress: progress * 100 });
|
||||||
// how many total packages are completed
|
|
||||||
const completedProgress = (currentPackageNumber / numberOfPackages) * 100;
|
|
||||||
// overallProgress is the total packages completed plus the percentage of the current package
|
|
||||||
const overallProgress = completedProgress + (progress / numberOfPackages) * 100;
|
|
||||||
notifyMainWindow("install-progress", { full_name, progress: overallProgress });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
installed: (installation: Installation) => {
|
installed: (installation: Installation) => {
|
||||||
log.info("installed", installation);
|
log.info("installed", installation);
|
||||||
const { project, version } = installation.pkg;
|
const { project, version } = installation.pkg;
|
||||||
|
|
||||||
currentPackageNumber++;
|
|
||||||
const progress = (currentPackageNumber / numberOfPackages) * 100;
|
|
||||||
notifyMainWindow("install-progress", { full_name, progress });
|
|
||||||
notifyMainWindow("pkg-installed", { full_name: project, version: version.toString() });
|
notifyMainWindow("pkg-installed", { full_name: project, version: version.toString() });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
"@sentry/electron": "^4.4.0",
|
"@sentry/electron": "^4.4.0",
|
||||||
"@sentry/svelte": "^7.47.0",
|
"@sentry/svelte": "^7.47.0",
|
||||||
"@sentry/vite-plugin": "^0.7.2",
|
"@sentry/vite-plugin": "^0.7.2",
|
||||||
"@teaxyz/lib": "^0.3.0",
|
"@teaxyz/lib": "0.4.1",
|
||||||
"@types/electron": "^1.6.10",
|
"@types/electron": "^1.6.10",
|
||||||
"@types/mousetrap": "^1.6.11",
|
"@types/mousetrap": "^1.6.11",
|
||||||
"@vitest/coverage-c8": "^0.27.1",
|
"@vitest/coverage-c8": "^0.27.1",
|
||||||
|
|
|
@ -27,7 +27,7 @@ importers:
|
||||||
'@sveltejs/adapter-static': ^1.0.0-next.48
|
'@sveltejs/adapter-static': ^1.0.0-next.48
|
||||||
'@sveltejs/kit': ^1.15.9
|
'@sveltejs/kit': ^1.15.9
|
||||||
'@tea/ui': workspace:*
|
'@tea/ui': workspace:*
|
||||||
'@teaxyz/lib': ^0.3.0
|
'@teaxyz/lib': 0.4.1
|
||||||
'@testing-library/jest-dom': ^5.16.5
|
'@testing-library/jest-dom': ^5.16.5
|
||||||
'@testing-library/svelte': ^3.2.2
|
'@testing-library/svelte': ^3.2.2
|
||||||
'@testing-library/webdriverio': ^3.2.1
|
'@testing-library/webdriverio': ^3.2.1
|
||||||
|
@ -106,7 +106,7 @@ importers:
|
||||||
'@sentry/electron': 4.5.0
|
'@sentry/electron': 4.5.0
|
||||||
'@sentry/svelte': 7.51.2_svelte@3.59.1
|
'@sentry/svelte': 7.51.2_svelte@3.59.1
|
||||||
'@sentry/vite-plugin': 0.7.2
|
'@sentry/vite-plugin': 0.7.2
|
||||||
'@teaxyz/lib': 0.3.0
|
'@teaxyz/lib': 0.4.1
|
||||||
'@types/electron': 1.6.10
|
'@types/electron': 1.6.10
|
||||||
'@types/mousetrap': 1.6.11
|
'@types/mousetrap': 1.6.11
|
||||||
'@vitest/coverage-c8': 0.27.3_jsdom@21.1.2
|
'@vitest/coverage-c8': 0.27.3_jsdom@21.1.2
|
||||||
|
@ -3624,8 +3624,8 @@ packages:
|
||||||
tailwindcss: 3.3.2
|
tailwindcss: 3.3.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@teaxyz/lib/0.3.0:
|
/@teaxyz/lib/0.4.1:
|
||||||
resolution: {integrity: sha512-NFoVdSE4iX5JBdiXXOo0aGk4fsTb5zjBOqkY9ldA8asa8pITSJjPOxoa34H7gkkxuTcjv/zjeiOREveWdibcdA==}
|
resolution: {integrity: sha512-DVXOFyhbS1fM5acBU4jdR6WybK6Rt15NaO7qqpkRx7TuNz5mX3AHFszHgoNAhnnyyxvXc8cYSeL7OxYzT04hxQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@deno/shim-crypto': 0.3.1
|
'@deno/shim-crypto': 0.3.1
|
||||||
'@deno/shim-deno': 0.16.1
|
'@deno/shim-deno': 0.16.1
|
||||||
|
|
Loading…
Reference in a new issue