diff --git a/common/scripts/svelte-check-show.sh b/common/scripts/svelte-check-show.sh new file mode 100755 index 0000000000..bb0c70d847 --- /dev/null +++ b/common/scripts/svelte-check-show.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +roots=$(rush list -p --json | grep "path" | cut -f 2 -d ':' | cut -f 2 -d '"') +files="svelte-check.log svelte-check-err.log" +for file in $roots; do + for check in $files; do + f="$file/.svelte-check/$check" + if [ -f $f ]; then + if grep -q "error" "$f"; then + if ! grep -q "0 errors" "$f"; then + if ! grep -q "error.ts" "$f"; then + echo "\nErrors in $f\n" + cat "$f" | grep -B1 "Error:" | grep -v "^--$" | sed "s/Error:/$(echo '\033[31m')Error:$(echo '\033[0m')/" + fi + fi + fi + fi + done +done \ No newline at end of file diff --git a/packages/platform-rig/bin/do-svelte-check.js b/packages/platform-rig/bin/do-svelte-check.js index bafa9f4b7a..c61c46a3cb 100755 --- a/packages/platform-rig/bin/do-svelte-check.js +++ b/packages/platform-rig/bin/do-svelte-check.js @@ -1,10 +1,47 @@ -const { join, dirname } = require("path") +const { join, dirname } = require('path') const { readFileSync, existsSync, mkdirSync, createWriteStream } = require('fs') const { spawn } = require('child_process') +function parseSvelteCheckLog(logContent) { + const lines = logContent.split('\n') + const errors = [] + let currentError = null + + let pline = '' + for (const line of lines) { + if (line.includes('Error:')) { + // Start of a new error + if (currentError) { + errors.push(currentError) + } + currentError = { + file: pline, + message: line.split('Error:')[1].trim() + } + } else if (line.includes('====================================')) { + // End of log, push last error if exists + if (currentError) { + errors.push(currentError) + } + break + } + pline = line + } + + // Print errors + if (errors.length === 0) { + console.log('No errors found') + } else { + errors.forEach((error) => { + console.log(`File: ${error.file}`) + console.log(`Message: \x1b[31m ${error.message} \x1b[0m\n`) + }) + } +} + async function execProcess(cmd, logFile, args, useConsole) { let compileRoot = dirname(dirname(process.argv[1])) - console.log("Svelte check...\n", process.cwd(), args) + console.log('Svelte check...\n') if (!existsSync(join(process.cwd(), '.svelte-check'))) { mkdirSync(join(process.cwd(), '.svelte-check')) @@ -15,16 +52,15 @@ async function execProcess(cmd, logFile, args, useConsole) { const stdoutFilePath = `.svelte-check/${logFile}.log` const stderrFilePath = `.svelte-check/${logFile}-err.log` - const outPromise = new Promise((resolve) => { if (compileOut.stdout != null) { let outPipe = createWriteStream(stdoutFilePath) compileOut.stdout.pipe(outPipe) compileOut.stdout.on('end', function (data) { outPipe.close() - if( useConsole ) { - console.log(readFileSync(stdoutFilePath).toString()) - console.log(readFileSync(stderrFilePath).toString()) + if (useConsole) { + const data = readFileSync(stdoutFilePath).toString() + readFileSync(stderrFilePath).toString() + parseSvelteCheckLog(data) } resolve() }) @@ -47,7 +83,7 @@ async function execProcess(cmd, logFile, args, useConsole) { }) let editCode = 0 - const closePromise = new Promise(resolve => { + const closePromise = new Promise((resolve) => { compileOut.on('close', (code) => { editCode = code resolve() @@ -61,30 +97,26 @@ async function execProcess(cmd, logFile, args, useConsole) { await Promise.all([outPromise, errPromise, closePromise]) if (editCode !== 0) { - const data = readFileSync(stdoutFilePath) - const errData = readFileSync(stderrFilePath) - console.error('\n' + data.toString() + '\n' + errData.toString()) + if( !useConsole) { + const data = readFileSync(stdoutFilePath).toString() + const errData = readFileSync(stderrFilePath).toString() + parseSvelteCheckLog(data) + console.error('\n' + errData.toString()) + } process.exit(editCode) } } let args = [] // process.argv.slice(2) let useConsole = false -for(const a of process.argv.slice(2)) { - if( a === '--console') { +for (const a of process.argv.slice(2)) { + if (a === '--console') { useConsole = true } else { args.push(a) } } let st = performance.now() -execProcess( - 'svelte-check', - 'svelte-check', [ - '--output', 'human', - ...args -], useConsole) - .then(() => { - console.log("Svelte check time: ", Math.round((performance.now() - st) * 100) / 100) - }) - +execProcess('svelte-check', 'svelte-check', ['--output', 'human', ...args], useConsole).then(() => { + console.log('Svelte check time: ', Math.round((performance.now() - st) * 100) / 100) +}) diff --git a/plugins/calendar-resources/src/components/AddParticipant.svelte b/plugins/calendar-resources/src/components/AddParticipant.svelte index 7c499c62ad..62aef19052 100644 --- a/plugins/calendar-resources/src/components/AddParticipant.svelte +++ b/plugins/calendar-resources/src/components/AddParticipant.svelte @@ -203,6 +203,7 @@ bind:value placeholder={phTranslate} {style} + class="search" on:input={(ev) => { computeSize(ev.target) }} diff --git a/plugins/contact/package.json b/plugins/contact/package.json index 57d4156aa6..0f9d938152 100644 --- a/plugins/contact/package.json +++ b/plugins/contact/package.json @@ -40,7 +40,6 @@ "eslint-config-standard-with-typescript": "^40.0.0", "prettier": "^3.1.0", "typescript": "^5.3.3", - "svelte": "^4.2.19", "jest": "^29.7.0", "ts-jest": "^29.1.1", "@types/jest": "^29.5.5" diff --git a/plugins/diffview-resources/src/components/InlineDiffView.svelte b/plugins/diffview-resources/src/components/InlineDiffView.svelte index a3862e8fd1..b294350810 100644 --- a/plugins/diffview-resources/src/components/InlineDiffView.svelte +++ b/plugins/diffview-resources/src/components/InlineDiffView.svelte @@ -29,7 +29,7 @@ index 3aa8590..6b64999 100644 +++ b/${fileName} ` - $: diffFiles = parseDiff(prefix + patch ?? '') + $: diffFiles = parseDiff(prefix + patch) {#each diffFiles as diffFile} diff --git a/plugins/gmail-resources/src/components/FullMessage.svelte b/plugins/gmail-resources/src/components/FullMessage.svelte index 8990019235..69cc920933 100644 --- a/plugins/gmail-resources/src/components/FullMessage.svelte +++ b/plugins/gmail-resources/src/components/FullMessage.svelte @@ -24,14 +24,11 @@ import attachment, { Attachment } from '@hcengineering/attachment' import { AttachmentPresenter } from '@hcengineering/attachment-resources' import { getEmbeddedLabel } from '@hcengineering/platform' - import core, { Ref } from '@hcengineering/core' + import { Ref } from '@hcengineering/core' export let currentMessage: SharedMessage export let newMessage: boolean - let editor: HTMLDivElement - $: if (editor) editor.innerHTML = currentMessage.content - const dispatch = createEventDispatcher() const hasError = (currentMessage as unknown as NewMessage)?.status === 'error' diff --git a/plugins/gmail-resources/src/components/Message.svelte b/plugins/gmail-resources/src/components/Message.svelte index 1d1b9fe4ec..bda7fe3e6f 100644 --- a/plugins/gmail-resources/src/components/Message.svelte +++ b/plugins/gmail-resources/src/components/Message.svelte @@ -63,9 +63,8 @@ {/if} {#if isError}
- Error: {errorMessage?.error - ? JSON.parse(errorMessage.error)?.data?.error_description - : undefined ?? 'unknown error'} + Error: {(errorMessage?.error ? JSON.parse(errorMessage.error)?.data?.error_description : undefined) ?? + 'unknown error'}
{/if} diff --git a/plugins/guest-resources/src/utils.ts b/plugins/guest-resources/src/utils.ts index 30e15b4653..2e63271e7d 100644 --- a/plugins/guest-resources/src/utils.ts +++ b/plugins/guest-resources/src/utils.ts @@ -1,22 +1,37 @@ +import { + type AccountClient, + type WorkspaceLoginInfo, + getClient as getAccountClientRaw +} from '@hcengineering/account-client' import client from '@hcengineering/client' import { type Doc, AccountRole } from '@hcengineering/core' import login from '@hcengineering/login' -import { getMetadata, getResource } from '@hcengineering/platform' +import { getMetadata, getResource, setMetadata } from '@hcengineering/platform' import presentation from '@hcengineering/presentation' import { getCurrentLocation, navigate } from '@hcengineering/ui' import view from '@hcengineering/view' import { getObjectLinkFragment } from '@hcengineering/view-resources' import { workbenchId } from '@hcengineering/workbench' +function getAccountClient (token: string | undefined | null): AccountClient { + const accountsUrl = getMetadata(login.metadata.AccountsUrl) + return getAccountClientRaw(accountsUrl, token !== null ? token : undefined) +} + export async function checkAccess (doc: Doc): Promise { const loc = getCurrentLocation() const ws = loc.path[1] - const selectWorkspace = await getResource(login.function.SelectWorkspace) - const wsLoginInfo = (await selectWorkspace(ws, null))[1] - if (wsLoginInfo === undefined || wsLoginInfo.role === AccountRole.DocGuest) return + let wsLoginInfo: WorkspaceLoginInfo | undefined - const token = wsLoginInfo.token + try { + wsLoginInfo = await getAccountClient(null).selectWorkspace(ws) + if (wsLoginInfo === undefined || wsLoginInfo.role === AccountRole.DocGuest) return + } catch (err: any) { + return + } + + const token = wsLoginInfo?.token const endpoint = getMetadata(presentation.metadata.Endpoint) if (token === undefined || endpoint === undefined) return @@ -33,7 +48,7 @@ export async function checkAccess (doc: Doc): Promise { loc.path[0] = workbenchId loc.path[1] = ws // We have access, let's set correct tokens and redirect) - // setMetadata(presentation.metadata.Token, token) + setMetadata(presentation.metadata.Token, token) navigate(loc) } } diff --git a/plugins/love-resources/src/components/MeetingData.svelte b/plugins/love-resources/src/components/MeetingData.svelte index cd16c10e17..ab99412e37 100644 --- a/plugins/love-resources/src/components/MeetingData.svelte +++ b/plugins/love-resources/src/components/MeetingData.svelte @@ -22,19 +22,25 @@ export let state: Writable> - function changeRoom (val: Ref) { + function changeRoom (val: Ref): void { $state.room = val } - function changeIsMeeting () { - $state.isMeeting = isMeeting + function changeIsMeeting (val: boolean): void { + $state.isMeeting = val } let isMeeting = false
- + { + changeIsMeeting(ev.detail) + }} + />
diff --git a/plugins/love-resources/src/components/Settings.svelte b/plugins/love-resources/src/components/Settings.svelte index 1242a2d4ab..84096879bf 100644 --- a/plugins/love-resources/src/components/Settings.svelte +++ b/plugins/love-resources/src/components/Settings.svelte @@ -69,7 +69,7 @@
{#if !withoutActivity} @@ -67,8 +64,7 @@ props={{ object, showCommenInput: true, - focusIndex: 1000, - boundary: content + focusIndex: 1000 }} /> diff --git a/plugins/test-management-resources/src/components/test-run/EditTestRun.svelte b/plugins/test-management-resources/src/components/test-run/EditTestRun.svelte index df5fe5ba75..78f4da5e42 100644 --- a/plugins/test-management-resources/src/components/test-run/EditTestRun.svelte +++ b/plugins/test-management-resources/src/components/test-run/EditTestRun.svelte @@ -51,8 +51,6 @@ } } - let content: HTMLElement - $: if (oldLabel !== object?.name) { oldLabel = object?.name rawLabel = object?.name @@ -98,7 +96,6 @@ bind:this={descriptionBox} identifier={object?._id} placeholder={testManagement.string.DescriptionPlaceholder} - boundary={content} /> diff --git a/plugins/text-editor-resources/src/components/CollaboratorEditor.svelte b/plugins/text-editor-resources/src/components/CollaboratorEditor.svelte index dff1d6912f..0ceca720ec 100644 --- a/plugins/text-editor-resources/src/components/CollaboratorEditor.svelte +++ b/plugins/text-editor-resources/src/components/CollaboratorEditor.svelte @@ -48,8 +48,6 @@ export let requestSideSpace: ((width: number) => void) | undefined = undefined export let enableInlineComments: boolean = true - let element: HTMLElement - let collaborativeEditor: CollaborativeTextEditor export function commands (): TextEditorCommandHandler | undefined { @@ -68,7 +66,7 @@ const { idx, focusManager } = registerFocus(focusIndex, { focus: () => { focus() - return element !== null + return true }, isFocus: () => isFocused(), canBlur: () => false diff --git a/plugins/text-editor-resources/src/components/extension/inlinePopup.ts b/plugins/text-editor-resources/src/components/extension/inlinePopup.ts index 6a229eafba..44b5697467 100644 --- a/plugins/text-editor-resources/src/components/extension/inlinePopup.ts +++ b/plugins/text-editor-resources/src/components/extension/inlinePopup.ts @@ -6,7 +6,7 @@ export const InlinePopupExtension: Extension = BubbleMenu.ext return { ...this.parent?.(), pluginKey: 'inline-popup', - element: null, + element: null as any, tippyOptions: { maxWidth: '46rem', zIndex: 500, diff --git a/plugins/tracker-resources/src/components/issues/StatusEditor.svelte b/plugins/tracker-resources/src/components/issues/StatusEditor.svelte index 83388bd47b..3256cac578 100644 --- a/plugins/tracker-resources/src/components/issues/StatusEditor.svelte +++ b/plugins/tracker-resources/src/components/issues/StatusEditor.svelte @@ -124,7 +124,7 @@ id: s._id, component: StatusPresenter, props: { value: s, size: 'small', space: value.space }, - isSelected: selectedStatus?._id === s._id ?? false + isSelected: selectedStatus?._id === s._id } }) $: smallgap = size === 'inline' || size === 'small' diff --git a/plugins/tracker-resources/src/components/issues/StatusSelector.svelte b/plugins/tracker-resources/src/components/issues/StatusSelector.svelte index 598935b105..86ea837ebc 100644 --- a/plugins/tracker-resources/src/components/issues/StatusSelector.svelte +++ b/plugins/tracker-resources/src/components/issues/StatusSelector.svelte @@ -106,7 +106,7 @@ id: s._id, component: StatusPresenter, props: { value: s, size: 'small' }, - isSelected: selectedStatus?._id === s._id ?? false + isSelected: selectedStatus?._id === s._id } }) ?? [] const handleStatusEditorOpened = (event: MouseEvent) => { diff --git a/plugins/tracker-resources/src/components/milestones/MilestoneBrowser.svelte b/plugins/tracker-resources/src/components/milestones/MilestoneBrowser.svelte index 21a48bb9f0..f6acc29a60 100644 --- a/plugins/tracker-resources/src/components/milestones/MilestoneBrowser.svelte +++ b/plugins/tracker-resources/src/components/milestones/MilestoneBrowser.svelte @@ -58,10 +58,6 @@ asideFloat = false asideShown = false } - let docWidth: number - let docSize: boolean = false - $: if (docWidth <= 900 && !docSize) docSize = true - $: if (docWidth > 900 && docSize) docSize = false const handleViewModeChanged = (newMode: MilestoneViewMode) => { if (newMode === undefined || newMode === mode) { diff --git a/plugins/view-resources/src/components/filter/FilterSection.svelte b/plugins/view-resources/src/components/filter/FilterSection.svelte index 30697acd62..7ac1e37075 100644 --- a/plugins/view-resources/src/components/filter/FilterSection.svelte +++ b/plugins/view-resources/src/components/filter/FilterSection.svelte @@ -48,7 +48,7 @@ } } const targetClass = getTargetClass() - $: isState = targetClass === core.class.Status ?? false + $: isState = targetClass === core.class.Status const dispatch = createEventDispatcher() async function getCountStates (ids: Array>): Promise { diff --git a/tests/sanity/tests/tracker/tracker.spec.ts b/tests/sanity/tests/tracker/tracker.spec.ts index b119b24fab..217fc22dd5 100644 --- a/tests/sanity/tests/tracker/tracker.spec.ts +++ b/tests/sanity/tests/tracker/tracker.spec.ts @@ -159,7 +159,7 @@ test.describe('Tracker tests', () => { await issuesPage.clickAssignee() await issuesPage.setEstimation() await issuesPage.inputTextPlaceholderFill('1') - await issuesPage.setDueDate('24') + await issuesPage.setDueDate('19') await issuesPage.pressEscapeTwice() await issuesPage.clickOnNewIssue() await checkIssueDraft(page, { @@ -169,7 +169,7 @@ test.describe('Tracker tests', () => { priority: 'Urgent', assignee: 'Appleseed John', estimation: '1', - dueDate: '24' + dueDate: '19' }) })