From 6211606a2200273e843184093a33fb8413766149 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sat, 11 Nov 2023 17:38:16 +0000 Subject: [PATCH] Desktop: Fixed import error report --- packages/app-desktop/app.ts | 3 ++- packages/app-desktop/checkForUpdates.ts | 3 ++- packages/app-desktop/gui/ErrorBoundary.tsx | 4 ++-- packages/app-desktop/gui/MenuBar.tsx | 4 ++-- packages/lib/makeDiscourseDebugUrl.ts | 17 ++++++++++++++--- packages/lib/versionInfo.ts | 15 ++++++++++++++- 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/packages/app-desktop/app.ts b/packages/app-desktop/app.ts index f0a46509a..b5f3a527b 100644 --- a/packages/app-desktop/app.ts +++ b/packages/app-desktop/app.ts @@ -26,7 +26,7 @@ const { FoldersScreenUtils } = require('@joplin/lib/folders-screen-utils.js'); import Folder from '@joplin/lib/models/Folder'; import Tag from '@joplin/lib/models/Tag'; import { reg } from '@joplin/lib/registry'; -const packageInfo = require('./packageInfo.js'); +const packageInfo: PackageInfo = require('./packageInfo.js'); import DecryptionWorker from '@joplin/lib/services/DecryptionWorker'; import ClipperServer from '@joplin/lib/ClipperServer'; const { webFrame } = require('electron'); @@ -68,6 +68,7 @@ import path = require('path'); import { checkPreInstalledDefaultPlugins, installDefaultPlugins, setSettingsForDefaultPlugins } from '@joplin/lib/services/plugins/defaultPlugins/defaultPluginsUtils'; import userFetcher, { initializeUserFetcher } from '@joplin/lib/utils/userFetcher'; import { parseNotesParent } from '@joplin/lib/reducer'; +import { PackageInfo } from '@joplin/lib/versionInfo'; const pluginClasses = [ require('./plugins/GotoAnything').default, diff --git a/packages/app-desktop/checkForUpdates.ts b/packages/app-desktop/checkForUpdates.ts index 977ffb069..e5ee175de 100644 --- a/packages/app-desktop/checkForUpdates.ts +++ b/packages/app-desktop/checkForUpdates.ts @@ -5,8 +5,9 @@ import bridge from './services/bridge'; import KvStore from '@joplin/lib/services/KvStore'; import * as ArrayUtils from '@joplin/lib/ArrayUtils'; import { CheckForUpdateOptions, extractVersionInfo, GitHubRelease } from './utils/checkForUpdatesUtils'; -const packageInfo = require('./packageInfo.js'); +import { PackageInfo } from '@joplin/lib/versionInfo'; import { compareVersions } from 'compare-versions'; +const packageInfo: PackageInfo = require('./packageInfo.js'); const logger = Logger.create('checkForUpdates'); diff --git a/packages/app-desktop/gui/ErrorBoundary.tsx b/packages/app-desktop/gui/ErrorBoundary.tsx index 0a6182c83..a28e7212c 100644 --- a/packages/app-desktop/gui/ErrorBoundary.tsx +++ b/packages/app-desktop/gui/ErrorBoundary.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; -import versionInfo from '@joplin/lib/versionInfo'; +import versionInfo, { PackageInfo } from '@joplin/lib/versionInfo'; import PluginService, { Plugins } from '@joplin/lib/services/plugins/PluginService'; import Setting from '@joplin/lib/models/Setting'; import restart from '../services/restart'; -const packageInfo = require('../packageInfo.js'); +const packageInfo: PackageInfo = require('../packageInfo.js'); const ipcRenderer = require('electron').ipcRenderer; interface ErrorInfo { diff --git a/packages/app-desktop/gui/MenuBar.tsx b/packages/app-desktop/gui/MenuBar.tsx index e49df45d3..d879bd2db 100644 --- a/packages/app-desktop/gui/MenuBar.tsx +++ b/packages/app-desktop/gui/MenuBar.tsx @@ -8,7 +8,7 @@ import KeymapService from '@joplin/lib/services/KeymapService'; import { PluginStates, utils as pluginUtils } from '@joplin/lib/services/plugins/reducer'; import shim from '@joplin/lib/shim'; import Setting from '@joplin/lib/models/Setting'; -import versionInfo from '@joplin/lib/versionInfo'; +import versionInfo, { PackageInfo } from '@joplin/lib/versionInfo'; import makeDiscourseDebugUrl from '@joplin/lib/makeDiscourseDebugUrl'; import { ImportModule } from '@joplin/lib/services/interop/Module'; import InteropServiceHelper from '../InteropServiceHelper'; @@ -25,7 +25,7 @@ import { ProfileConfig } from '@joplin/lib/services/profileConfig/types'; import PluginService, { PluginSettings } from '@joplin/lib/services/plugins/PluginService'; import { getListRendererById, getListRendererIds } from '@joplin/lib/services/noteList/renderers'; import useAsyncEffect from '@joplin/lib/hooks/useAsyncEffect'; -const packageInfo = require('../packageInfo.js'); +const packageInfo: PackageInfo = require('../packageInfo.js'); const { clipboard } = require('electron'); const Menu = bridge().Menu; diff --git a/packages/lib/makeDiscourseDebugUrl.ts b/packages/lib/makeDiscourseDebugUrl.ts index 002b314a1..2d9769e58 100644 --- a/packages/lib/makeDiscourseDebugUrl.ts +++ b/packages/lib/makeDiscourseDebugUrl.ts @@ -1,21 +1,32 @@ import { PluginSettings } from './services/plugins/PluginService'; import type PluginService from './services/plugins/PluginService'; -import versionInfo from './versionInfo'; +import versionInfo, { PackageInfo } from './versionInfo'; const renderErrorBlock = (errors: any[]): string => { if (!errors.length) return ''; return `\`\`\`\n${errors.map(e => typeof e === 'string' ? e.trim() : e.message.trim())}\n\`\`\``; }; -export default (title: string, body: string, errors: any[], packageInfo: any, pluginService: PluginService, pluginSettings: PluginSettings) => { +const getOsName = (platform: typeof process.platform) => { + if (platform === 'win32') return 'Windows'; + if (platform === 'darwin') return 'macOS'; + if (platform === 'linux') return 'Linux'; + if (platform === 'android') return 'Android'; + return ''; +}; + +export default (title: string, body: string, errors: any[], packageInfo: PackageInfo, pluginService: PluginService, pluginSettings: PluginSettings) => { const v = versionInfo(packageInfo, pluginService.enabledPlugins(pluginSettings)); const errorBlock = renderErrorBlock(errors); const query: Record = { title, - body: `# About\n\n${v.body.trim()}\n\n# Body\n\n${body}${errorBlock ? `\n\n# Errors\n\n${errorBlock}` : ''}`, category: 'support', + version: packageInfo.version, + os: getOsName(process.platform), + 'desktop-about-content': v.body, + content: `#### Body\n\n${body}${errorBlock ? `\n\n#### Errors\n\n${errorBlock}` : ''}`, }; const queryString = Object.keys(query).map(k => `${k}=${encodeURIComponent(query[k])}`).join('&'); diff --git a/packages/lib/versionInfo.ts b/packages/lib/versionInfo.ts index 8214f3188..928518b97 100644 --- a/packages/lib/versionInfo.ts +++ b/packages/lib/versionInfo.ts @@ -3,6 +3,19 @@ import Setting from './models/Setting'; import { reg } from './registry'; import { Plugins } from './services/plugins/PluginService'; +export interface PackageInfo { + name: string; + version: string; + description: string; + build: { + appId: string; + }; + git: { + branch: string; + hash: string; + }; +} + interface PluginList { completeList: string; summary: string; @@ -40,7 +53,7 @@ function getPluginLists(plugins: Plugins): PluginList { }; } -export default function versionInfo(packageInfo: any, plugins: Plugins) { +export default function versionInfo(packageInfo: PackageInfo, plugins: Plugins) { const p = packageInfo; let gitInfo = ''; if ('git' in p) {