From 40533b5caa8f747b67f49d60273a8cc0eb89945b Mon Sep 17 00:00:00 2001 From: akleinas Date: Wed, 4 Dec 2024 12:52:20 +0200 Subject: [PATCH 1/8] 520 added workspace rule to always provide non-relative import paths --- .vscode/settings.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 00f0b9e3..02697d48 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,6 +22,7 @@ "editor.formatOnSave": true, "editor.tabSize": 4, "editor.codeActionsOnSave": { + "source.organizeImports": "explicit", "source.fixAll.eslint": "explicit" }, "[typescript]": { @@ -30,5 +31,6 @@ "[typescriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "workbench.colorCustomizations": {} + "workbench.colorCustomizations": {}, + "typescript.preferences.importModuleSpecifier": "non-relative" } \ No newline at end of file From 335bd58fbd00c2a56f6c3739cb2ec3341678c1b9 Mon Sep 17 00:00:00 2001 From: akleinas Date: Wed, 4 Dec 2024 13:28:58 +0200 Subject: [PATCH 2/8] 520 updated existing imports --- .../Layout/Query/ColumnHeaderCell.tsx | 2 +- .../Layout/Query/QueryDropdownMenu.tsx | 10 +++--- .../Components/Layout/Query/QueryFormHead.tsx | 15 +++++---- .../Layout/Query/QueryFormTable.tsx | 8 ++--- src/view/app/Connection/connectionForm.tsx | 18 +++++++---- src/view/app/Connection/index.tsx | 4 +-- src/view/app/Fields/fields.tsx | 24 +++++++------- src/view/app/Fields/index.tsx | 6 ++-- src/view/app/Indexes/index.tsx | 6 ++-- src/view/app/Indexes/indexes.tsx | 12 +++---- src/view/app/Query/Export/export.tsx | 24 +++++++------- src/view/app/Query/Update/update.tsx | 8 ++--- src/view/app/Query/index.tsx | 6 ++-- src/view/app/Query/query.tsx | 32 +++++++++++-------- src/view/app/Welcome/index.tsx | 2 +- src/view/app/Welcome/welcome.tsx | 6 ++-- 16 files changed, 95 insertions(+), 88 deletions(-) diff --git a/src/view/app/Components/Layout/Query/ColumnHeaderCell.tsx b/src/view/app/Components/Layout/Query/ColumnHeaderCell.tsx index 8ce8e21d..b63ec2ed 100644 --- a/src/view/app/Components/Layout/Query/ColumnHeaderCell.tsx +++ b/src/view/app/Components/Layout/Query/ColumnHeaderCell.tsx @@ -1,6 +1,6 @@ +import SortArrowIcon from '@app/Components/Layout/Query/SortArrorIcon'; import { Box, TextField, Typography } from '@mui/material'; import { Fragment } from 'react'; -import SortArrowIcon from './SortArrorIcon'; interface ColumnHeaderCellProps { column: any; diff --git a/src/view/app/Components/Layout/Query/QueryDropdownMenu.tsx b/src/view/app/Components/Layout/Query/QueryDropdownMenu.tsx index 8f9ecdc3..7d27e4fe 100644 --- a/src/view/app/Components/Layout/Query/QueryDropdownMenu.tsx +++ b/src/view/app/Components/Layout/Query/QueryDropdownMenu.tsx @@ -1,8 +1,8 @@ -import { Box, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material'; -import CheckIcon from '@mui/icons-material/Check'; -import { useState } from 'react'; import { ProBroButton } from '@assets/button'; +import CheckIcon from '@mui/icons-material/Check'; import DnsIcon from '@mui/icons-material/DnsTwoTone'; +import { Box, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material'; +import { useState } from 'react'; interface QueryDropdownMenuProps { setIsFormatted: (isFormatted: boolean) => void; // Prop to set formatting state in parent @@ -16,7 +16,7 @@ enum FormatType { const QueryDropdownMenu: React.FC = ({ setIsFormatted, - isWindowSmall + isWindowSmall, }) => { const [anchorEl, setAnchorEl] = useState(null); const [selectedOption, setSelectedOption] = useState( @@ -35,13 +35,11 @@ const QueryDropdownMenu: React.FC = ({ return ( - setAnchorEl(event.currentTarget)} startIcon={} > {!isWindowSmall && 'FORMAT'} - = ({ isWindowSmall={isWindowSmall} /> + isWindowSmall={isWindowSmall} + setIsFormatted={setIsFormatted} + /> ; diff --git a/src/view/app/Connection/connectionForm.tsx b/src/view/app/Connection/connectionForm.tsx index 3137bf0d..f8fe3748 100644 --- a/src/view/app/Connection/connectionForm.tsx +++ b/src/view/app/Connection/connectionForm.tsx @@ -1,12 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import * as React from 'react'; -import { CommandAction, ICommand, IConfig } from '../model'; -import { ProBroButton } from '../assets/button'; +import { CommandAction, ICommand, IConfig } from '@app/model'; +import { ProBroButton } from '@assets/button'; import FileUploadRoundedIcon from '@mui/icons-material/FileUploadRounded'; -import { PfParser } from '../utils/PfParser'; -import { Logger } from '../../../common/Logger'; -import { ISettings } from '../../../common/IExtensionSettings'; +import { ISettings } from '@src/common/IExtensionSettings'; +import { Logger } from '@src/common/Logger'; +import { PfParser } from '@utils/PfParser'; import { getVSCodeAPI } from '@utils/vscode'; +import * as React from 'react'; interface IConfigProps { initialData: IConfig; @@ -17,7 +17,11 @@ interface IConfigState { config: IConfig; } -function ConnectionForm({ initialData, configuration, ...props}: IConfigProps) { +function ConnectionForm({ + initialData, + configuration, + ...props +}: IConfigProps) { const vscode = getVSCodeAPI(); const oldState = vscode.getState(); const initState = oldState ? oldState : { config: initialData }; diff --git a/src/view/app/Connection/index.tsx b/src/view/app/Connection/index.tsx index a4305fd1..5e82502b 100644 --- a/src/view/app/Connection/index.tsx +++ b/src/view/app/Connection/index.tsx @@ -1,10 +1,10 @@ import { createRoot } from 'react-dom/client'; -import './connection.css'; -import ConnectionForm from './connectionForm'; import { IConfig } from '@app/model'; import { ISettings } from '@src/common/IExtensionSettings'; import { VSCode } from '@utils/vscode'; +import '@Connection/connectionForm.css'; +import ConnectionForm from '@Connection/connectionForm'; declare global { interface Window { diff --git a/src/view/app/Fields/fields.tsx b/src/view/app/Fields/fields.tsx index 2607ef1f..5dfd0701 100644 --- a/src/view/app/Fields/fields.tsx +++ b/src/view/app/Fields/fields.tsx @@ -1,24 +1,24 @@ import { - useState, - useMemo, - useRef, - useEffect, - Fragment, - useLayoutEffect, ChangeEvent, - MouseEvent, + Fragment, KeyboardEvent, + MouseEvent, + useEffect, + useLayoutEffect, + useMemo, + useRef, + useState, } from 'react'; -import { FieldRow, CommandAction, TableDetails, ICommand } from '../model'; -import DataGrid, { SelectColumn } from 'react-data-grid'; +import { CommandAction, FieldRow, ICommand, TableDetails } from '@app/model'; import type { SortColumn } from 'react-data-grid'; -import { Logger } from '../../../common/Logger'; +import DataGrid, { SelectColumn } from 'react-data-grid'; -import * as columnName from './column.json'; +import * as columnName from '@Fields/column.json'; +import { HighlightFieldsCommand } from '@src/common/commands/fieldsCommands'; +import { Logger } from '@src/common/Logger'; import { OEDataTypePrimitive } from '@utils/oe/oeDataTypeEnum'; import { getVSCodeAPI, getVSCodeConfiguration } from '@utils/vscode'; -import { HighlightFieldsCommand } from '@src/common/commands/fieldsCommands'; interface FieldsExplorerEvent { id: string; diff --git a/src/view/app/Fields/index.tsx b/src/view/app/Fields/index.tsx index fd5e0fe6..1a669141 100644 --- a/src/view/app/Fields/index.tsx +++ b/src/view/app/Fields/index.tsx @@ -1,7 +1,7 @@ -import { createRoot } from 'react-dom/client'; -import './fields.css'; -import Fields from './fields'; +import Fields from '@Fields/fields'; +import '@Fields/fields.css'; import { VSCode } from '@utils/vscode'; +import { createRoot } from 'react-dom/client'; declare global { interface Window { diff --git a/src/view/app/Indexes/index.tsx b/src/view/app/Indexes/index.tsx index 4687ba42..26276279 100644 --- a/src/view/app/Indexes/index.tsx +++ b/src/view/app/Indexes/index.tsx @@ -1,8 +1,8 @@ -import { createRoot } from 'react-dom/client'; -import './indexes.css'; -import Indexes from './indexes'; +import Indexes from '@Indexes/indexes'; +import '@Indexes/indexes.css'; import { ISettings } from '@src/common/IExtensionSettings'; import { VSCode } from '@utils/vscode'; +import { createRoot } from 'react-dom/client'; declare global { interface Window { diff --git a/src/view/app/Indexes/indexes.tsx b/src/view/app/Indexes/indexes.tsx index 0ce122b5..435f783f 100644 --- a/src/view/app/Indexes/indexes.tsx +++ b/src/view/app/Indexes/indexes.tsx @@ -1,11 +1,11 @@ +import { CommandAction, IndexRow } from '@app/model'; +import * as columnName from '@Indexes/column.json'; +import { Logger } from '@src/common/Logger'; +import { getVSCodeAPI, getVSCodeConfiguration } from '@utils/vscode'; import * as React from 'react'; -import { useState, useMemo } from 'react'; -import { CommandAction, IndexRow } from '../model'; -import DataGrid from 'react-data-grid'; +import { useMemo, useState } from 'react'; import type { SortColumn } from 'react-data-grid'; -import * as columnName from './column.json'; -import { Logger } from '../../../common/Logger'; -import { getVSCodeAPI, getVSCodeConfiguration } from '@utils/vscode'; +import DataGrid from 'react-data-grid'; type Comparator = (a: IndexRow, b: IndexRow) => number; function getComparator(sortColumn: string): Comparator { diff --git a/src/view/app/Query/Export/export.tsx b/src/view/app/Query/Export/export.tsx index 2f5377ef..c0db8894 100644 --- a/src/view/app/Query/Export/export.tsx +++ b/src/view/app/Query/Export/export.tsx @@ -1,14 +1,14 @@ -import * as React from 'react'; -import Popup from 'reactjs-popup'; -import exportFromJSON from 'export-from-json'; -import { CommandAction, DataToExport, ICommand } from '../../model'; -import ExportIcon from '@mui/icons-material/FileDownloadTwoTone'; -import './export.css'; -import { ProBroButton } from '../../assets/button'; -import { Logger } from '../../../../common/Logger'; -import { SortColumn } from 'react-data-grid'; import { IFilters } from '@app/common/types'; +import { CommandAction, DataToExport, ICommand } from '@app/model'; +import { ProBroButton } from '@assets/button'; +import '@Export/export.css'; +import ExportIcon from '@mui/icons-material/FileDownloadTwoTone'; +import { Logger } from '@src/common/Logger'; import { getVSCodeAPI } from '@utils/vscode'; +import exportFromJSON from 'export-from-json'; +import * as React from 'react'; +import { SortColumn } from 'react-data-grid'; +import Popup from 'reactjs-popup'; export interface ExportPopupProps { wherePhrase: string; @@ -187,9 +187,9 @@ export default function ExportPopup({ return ( { - setPosition({ x: 0, y: 0 }); - }} + onClose={() => { + setPosition({ x: 0, y: 0 }); + }} trigger={ }> {isWindowSmall ? '' : 'Export'} diff --git a/src/view/app/Query/Update/update.tsx b/src/view/app/Query/Update/update.tsx index 4b935f04..83ab7279 100644 --- a/src/view/app/Query/Update/update.tsx +++ b/src/view/app/Query/Update/update.tsx @@ -1,6 +1,5 @@ -import { CommandAction, ICommand, ProcessAction } from '../../model'; -import './update.css'; -import { Logger } from '../../../../common/Logger'; +import { CommandAction, ICommand, ProcessAction } from '@app/model'; +import '@Update/update.css'; import { getVSCodeAPI, getVSCodeConfiguration } from '@utils/vscode'; import { Fragment, MouseEvent, ReactNode, useEffect, useState } from 'react'; @@ -8,7 +7,6 @@ import { ProBroButton } from '@assets/button'; import AddIcon from '@mui/icons-material/AddTwoTone'; import DeleteIcon from '@mui/icons-material/DeleteTwoTone'; import EditIcon from '@mui/icons-material/EditTwoTone'; -import Popup from 'reactjs-popup'; import { Box, Checkbox, @@ -16,6 +14,8 @@ import { FormControlLabel, Typography, } from '@mui/material'; +import { Logger } from '@src/common/Logger'; +import Popup from 'reactjs-popup'; export interface UpdatePopupProps { selectedRows: Set; diff --git a/src/view/app/Query/index.tsx b/src/view/app/Query/index.tsx index b70e4141..1eba4831 100644 --- a/src/view/app/Query/index.tsx +++ b/src/view/app/Query/index.tsx @@ -1,9 +1,9 @@ import { createRoot } from 'react-dom/client'; -import './query.css'; -import QueryForm from './query'; -import { IOETableData } from '@src/db/Oe'; +import QueryForm from '@Query/query'; +import '@Query/query.css'; import { ISettings } from '@src/common/IExtensionSettings'; +import { IOETableData } from '@src/db/Oe'; import { VSCode } from '@utils/vscode'; declare global { diff --git a/src/view/app/Query/query.tsx b/src/view/app/Query/query.tsx index e991a749..1b0374b6 100644 --- a/src/view/app/Query/query.tsx +++ b/src/view/app/Query/query.tsx @@ -1,25 +1,25 @@ import { Fragment, UIEvent, useEffect, useRef, useState } from 'react'; import { - SortColumn, - SelectColumn, CopyEvent, DataGridHandle, + SelectColumn, + SortColumn, } from 'react-data-grid'; -import { IOETableData } from '@src/db/Oe'; -import { CommandAction, ICommand, ProcessAction } from '../model'; -import { Logger } from '@src/common/Logger'; -import { getOEFormatLength } from '@utils/oe/format/oeFormat'; -import { OEDataTypePrimitive } from '@utils/oe/oeDataTypeEnum'; -import { IErrorObject, emptyErrorObj } from '@utils/error'; import QueryFormFooter from '@app/Components/Layout/Query/QueryFormFooter'; import QueryFormHead from '@app/Components/Layout/Query/QueryFormHead'; +import QueryFormTable from '@app/Components/Layout/Query/QueryFormTable'; import { IFilters } from '@app/common/types'; -import { getVSCodeAPI, getVSCodeConfiguration } from '@utils/vscode'; +import { CommandAction, ICommand, ProcessAction } from '@app/model'; import { green, red } from '@mui/material/colors'; +import { Logger } from '@src/common/Logger'; import { HighlightFieldsCommand } from '@src/common/commands/fieldsCommands'; -import QueryFormTable from '@app/Components/Layout/Query/QueryFormTable'; +import { IOETableData } from '@src/db/Oe'; +import { IErrorObject, emptyErrorObj } from '@utils/error'; +import { getOEFormatLength } from '@utils/oe/format/oeFormat'; +import { OEDataTypePrimitive } from '@utils/oe/oeDataTypeEnum'; +import { getVSCodeAPI, getVSCodeConfiguration } from '@utils/vscode'; interface IConfigProps { tableData: IOETableData; @@ -158,7 +158,13 @@ function QueryForm({ tableData, tableName, isReadOnly }: IConfigProps) { } else { setSelectedRows(new Set()); setOpen(false); - reloadData(loaded + (action === ProcessAction.Insert || action === ProcessAction.Copy ? 1 : 0)); + reloadData( + loaded + + (action === ProcessAction.Insert || + action === ProcessAction.Copy + ? 1 + : 0) + ); } }; @@ -186,7 +192,6 @@ function QueryForm({ tableData, tableName, isReadOnly }: IConfigProps) { }); setIsDataRetrieved(false); return; - } else if (message.data.columns.length !== columns.length) { const fontSize = +window .getComputedStyle( @@ -436,10 +441,9 @@ function QueryForm({ tableData, tableName, isReadOnly }: IConfigProps) { function handleCopy({ sourceRow, sourceColumnKey }: CopyEvent): void { if (window.isSecureContext) { navigator.clipboard.writeText(sourceRow[sourceColumnKey]); - } + } } - const getCellHeight = () => { if (configuration.gridTextSize === 'Large') { return 40; diff --git a/src/view/app/Welcome/index.tsx b/src/view/app/Welcome/index.tsx index 2e6d097c..b23918e8 100644 --- a/src/view/app/Welcome/index.tsx +++ b/src/view/app/Welcome/index.tsx @@ -1,4 +1,4 @@ -import { Welcome } from './welcome'; +import { Welcome } from '@Welcome/welcome'; import { createRoot } from 'react-dom/client'; const root = createRoot(document.getElementById('root')); diff --git a/src/view/app/Welcome/welcome.tsx b/src/view/app/Welcome/welcome.tsx index 68fe8daa..ac52fa6e 100644 --- a/src/view/app/Welcome/welcome.tsx +++ b/src/view/app/Welcome/welcome.tsx @@ -1,8 +1,8 @@ -import './welcome.css'; +import '@Welcome/welcome.css'; -import ReactMarkdown from 'react-markdown'; -import readme from '@root/README.md'; import changelog from '@root/CHANGELOG.md'; +import readme from '@root/README.md'; +import ReactMarkdown from 'react-markdown'; // Welcome.tsx function Welcome() { From 0567a987339bf05399dfa74e8a0203dfc52caa56 Mon Sep 17 00:00:00 2001 From: akleinas Date: Wed, 4 Dec 2024 13:53:21 +0200 Subject: [PATCH 3/8] 520 resolved pathing errors --- src/view/app/Connection/index.tsx | 4 ++-- src/view/app/Query/Export/export.tsx | 2 +- src/view/app/Query/Update/update.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/view/app/Connection/index.tsx b/src/view/app/Connection/index.tsx index 5e82502b..33539ab5 100644 --- a/src/view/app/Connection/index.tsx +++ b/src/view/app/Connection/index.tsx @@ -1,10 +1,10 @@ import { createRoot } from 'react-dom/client'; import { IConfig } from '@app/model'; +import '@Connection/connection.css'; +import ConnectionForm from '@Connection/connectionForm'; import { ISettings } from '@src/common/IExtensionSettings'; import { VSCode } from '@utils/vscode'; -import '@Connection/connectionForm.css'; -import ConnectionForm from '@Connection/connectionForm'; declare global { interface Window { diff --git a/src/view/app/Query/Export/export.tsx b/src/view/app/Query/Export/export.tsx index c0db8894..1159cd1b 100644 --- a/src/view/app/Query/Export/export.tsx +++ b/src/view/app/Query/Export/export.tsx @@ -1,9 +1,9 @@ import { IFilters } from '@app/common/types'; import { CommandAction, DataToExport, ICommand } from '@app/model'; import { ProBroButton } from '@assets/button'; -import '@Export/export.css'; import ExportIcon from '@mui/icons-material/FileDownloadTwoTone'; import { Logger } from '@src/common/Logger'; +import '@src/view/app/Query/Export/export.css'; import { getVSCodeAPI } from '@utils/vscode'; import exportFromJSON from 'export-from-json'; import * as React from 'react'; diff --git a/src/view/app/Query/Update/update.tsx b/src/view/app/Query/Update/update.tsx index 83ab7279..f971ce46 100644 --- a/src/view/app/Query/Update/update.tsx +++ b/src/view/app/Query/Update/update.tsx @@ -1,5 +1,5 @@ import { CommandAction, ICommand, ProcessAction } from '@app/model'; -import '@Update/update.css'; +import '@src/view/app/Query/Update/update.css'; import { getVSCodeAPI, getVSCodeConfiguration } from '@utils/vscode'; import { Fragment, MouseEvent, ReactNode, useEffect, useState } from 'react'; From 86d7ad59e9459f36ec3b4c02436cd3ad7bb47cbb Mon Sep 17 00:00:00 2001 From: akleinas Date: Wed, 4 Dec 2024 20:08:32 +0200 Subject: [PATCH 4/8] 520 changed existing paths to current standard and added rules to enforce it --- src/common/OpenEdgeJsonReaded.ts | 12 +-- src/common/commands/fieldsCommands.ts | 2 +- src/common/hooks/UseFocusRef.ts | 10 ++- src/db/IProcessor.ts | 2 +- src/db/Oe.ts | 50 +++++------ src/db/OeClient.ts | 80 +++++++++--------- src/extension.ts | 84 +++++++++++-------- src/providers/AblHoverProvider.ts | 2 +- src/repo/client/AClient.ts | 6 +- src/repo/client/ClientFactory.ts | 36 ++++---- src/repo/client/IClient.ts | 2 +- src/repo/client/IClientHelper.ts | 4 +- src/repo/client/local/LocalClient.ts | 11 ++- src/repo/client/local/LocalClientHelper.ts | 4 +- src/repo/client/remote/RemoteClient.ts | 6 +- src/repo/client/remote/RemoteClientHelper.ts | 4 +- src/repo/client/remote/RemoteClientStorage.ts | 18 ++-- src/repo/processor/IProcessor.ts | 34 ++++---- src/repo/processor/ProcessorFactory.ts | 12 +-- src/repo/processor/ProcessorType.ts | 8 +- src/repo/processor/database/DbProcessor.ts | 12 +-- src/repo/processor/mock/MockProcessor.ts | 2 +- src/repo/utils/cache.ts | 4 +- src/test/nodeTest/dumpFileFormatter.test.ts | 28 ++++--- src/test/nodeTest/testObjects.ts | 2 +- .../viewTest/utils/oe/format/oeFormat.test.ts | 2 +- src/treeview/DatabaseListProvider.ts | 31 +++---- src/treeview/DbConnectionNode.ts | 48 ++++++----- src/treeview/DbConnectionUpdater.ts | 11 ++- src/treeview/FavoritesProvider.ts | 10 +-- src/treeview/GroupListProvider.ts | 17 ++-- src/treeview/GroupNode.ts | 20 +++-- src/treeview/INode.ts | 4 +- src/treeview/TableNode.ts | 4 +- src/treeview/TablesListProvider.ts | 18 ++-- .../Components/Layout/Query/QueryFormHead.tsx | 2 +- src/view/app/Query/Export/index.ts | 4 +- src/view/app/Query/Update/index.ts | 4 +- src/view/app/Welcome/VersionChecker.ts | 2 +- src/view/app/utils/PfParser.ts | 2 +- src/view/declarations.d.ts | 8 +- src/webview/ConnectionEditor.ts | 12 +-- src/webview/DumpFileFormatter.ts | 2 +- src/webview/FieldsViewProvider.ts | 12 +-- src/webview/IndexesViewProvider.ts | 2 +- src/webview/PanelViewProvider.ts | 10 +-- src/webview/QueryEditor.ts | 22 ++--- src/webview/WelcomePageProvider.ts | 19 +++-- src/webview/queryEditor/queryEditorCache.ts | 2 +- tsconfig.json | 7 +- 50 files changed, 380 insertions(+), 330 deletions(-) diff --git a/src/common/OpenEdgeJsonReaded.ts b/src/common/OpenEdgeJsonReaded.ts index 2b38e1aa..93bee800 100644 --- a/src/common/OpenEdgeJsonReaded.ts +++ b/src/common/OpenEdgeJsonReaded.ts @@ -1,7 +1,7 @@ -import { PfParser } from '../view/app/utils/PfParser'; -import { IConfig } from '../view/app/model'; -import * as path from 'path'; +import { IConfig } from '@app/model'; +import { PfParser } from '@app/utils/PfParser'; import * as fs from 'fs'; +import * as path from 'path'; export function readFile(fileName: string): string { while (fileName.charAt(0) === '/') { @@ -12,10 +12,10 @@ export function readFile(fileName: string): string { return allFileContents; } -export function getOEVersion(fileContent: string){ +export function getOEVersion(fileContent: string) { const data = JSON.parse(fileContent); - const {oeversion} = data; - + const { oeversion } = data; + return oeversion; } diff --git a/src/common/commands/fieldsCommands.ts b/src/common/commands/fieldsCommands.ts index 1d5c37ed..a63395e2 100644 --- a/src/common/commands/fieldsCommands.ts +++ b/src/common/commands/fieldsCommands.ts @@ -1,4 +1,4 @@ -import { ICommand } from '../../view/app/model'; +import { ICommand } from '@app/model'; export interface HighlightFieldsCommand extends ICommand { column: string; diff --git a/src/common/hooks/UseFocusRef.ts b/src/common/hooks/UseFocusRef.ts index 16467ed5..83cc28b9 100644 --- a/src/common/hooks/UseFocusRef.ts +++ b/src/common/hooks/UseFocusRef.ts @@ -1,16 +1,18 @@ +import { useLayoutEffect } from '@src/common/hooks/UseLayoutEffect'; import { useRef } from 'react'; -import { useLayoutEffect } from './UseLayoutEffect'; export function useFocusRef(isSelected: boolean) { const ref = useRef(null); useLayoutEffect(() => { - if (!isSelected) {return;} + if (!isSelected) { + return; + } ref.current?.focus({ preventScroll: true }); }, [isSelected]); return { ref, - tabIndex: isSelected ? 0 : -1 + tabIndex: isSelected ? 0 : -1, }; -} \ No newline at end of file +} diff --git a/src/db/IProcessor.ts b/src/db/IProcessor.ts index 985a7651..af90b633 100644 --- a/src/db/IProcessor.ts +++ b/src/db/IProcessor.ts @@ -1,3 +1,3 @@ -import { IProcessor as ProcessorAlias } from '../repo/processor/IProcessor'; +import { IProcessor as ProcessorAlias } from '@src/repo/processor/IProcessor'; export type IProcessor = ProcessorAlias; diff --git a/src/db/Oe.ts b/src/db/Oe.ts index 78d07a80..17374716 100644 --- a/src/db/Oe.ts +++ b/src/db/Oe.ts @@ -1,52 +1,52 @@ import { Column } from 'react-data-grid'; export interface IOEVersion { - dbversion: string; - proversion: string; + dbversion: string; + proversion: string; } export interface IOEError { - error: number; - description: string; - trace: string; + error: number; + description: string; + trace: string; } export interface IOETablesList { - tables: ITable[]; + tables: ITable[]; } export interface IOEParams { - connectionString: string; - command: string; - params?: any; + connectionString: string; + command: string; + params?: any; } export interface IOETableData { - columns: Column[]; - data: string[]; + columns: Column[]; + data: string[]; } interface ITable { - name: string; - tableType: string; + name: string; + tableType: string; } export interface IExportDumpData { - rawData: any[]; - columns: IOeColumn[]; - psc: IOePsc; + rawData: any[]; + columns: IOeColumn[]; + psc: IOePsc; } interface IOeColumn { - name: string; - key: string; - label: string; - type: string; - format: string | null; + name: string; + key: string; + label: string; + type: string; + format: string | null; } export interface IOePsc { - cpstream: string; - dateformat: string; - numformat: string; - timestamp: string; + cpstream: string; + dateformat: string; + numformat: string; + timestamp: string; } diff --git a/src/db/OeClient.ts b/src/db/OeClient.ts index 485ffda0..e5943767 100644 --- a/src/db/OeClient.ts +++ b/src/db/OeClient.ts @@ -1,8 +1,8 @@ -import * as Net from 'net'; +import { Constants } from '@src/common/Constants'; import * as cp from 'child_process'; -import { Constants } from '../common/Constants'; -import * as vscode from 'vscode'; import * as fs from 'fs'; +import * as Net from 'net'; +import * as vscode from 'vscode'; import path = require('path'); class OEClient { @@ -35,36 +35,37 @@ class OEClient { public init(): Promise { // eslint-disable-next-line @typescript-eslint/no-unused-vars - return this.runProc().then((resolve) => { - this.client = new Net.Socket(); - this.client.connect(this.port, this.host, () => { - console.log( - 'TCP connection established with the server at ' + - this.port.toString() + - '.' - ); - }); - // The client can also receive data from the server by reading from its socket. - this.client.on('data', (chunk) => { - console.log('Data received from the server'); - this.data += chunk.toString(); - if (this.data.endsWith('\n')) { - this.dataFinish(this.data); - } + return this.runProc() + .then((resolve) => { + this.client = new Net.Socket(); + this.client.connect(this.port, this.host, () => { + console.log( + 'TCP connection established with the server at ' + + this.port.toString() + + '.' + ); + }); + // The client can also receive data from the server by reading from its socket. + this.client.on('data', (chunk) => { + console.log('Data received from the server'); + this.data += chunk.toString(); + if (this.data.endsWith('\n')) { + this.dataFinish(this.data); + } + }); + + this.client.on('end', () => { + console.log('Requested an end to the TCP connection'); + }); + + console.log('V1: OE Client initialized'); + return this; + }) + .catch((err) => { + return new Promise(() => { + throw new Error(err); + }); }); - - this.client.on('end', () => { - console.log('Requested an end to the TCP connection'); - }); - - console.log('V1: OE Client initialized'); - return this; - }) - .catch((err) => { - return new Promise(() => { - throw new Error(err); - }); - }); } private runProc(): Promise { @@ -167,11 +168,14 @@ class OEClient { ) ) { this.procFinish(dataString); - } - else if (dataString.startsWith('Failed to initialize client:')){ - return this.procFinish(new Promise(() => { - throw new Error(dataString); - })); + } else if ( + dataString.startsWith('Failed to initialize client:') + ) { + return this.procFinish( + new Promise(() => { + throw new Error(dataString); + }) + ); } }); @@ -233,7 +237,7 @@ async function getOEClient(): Promise { try { return await client.init(); - } catch (err : any) { + } catch (err: any) { return new Promise(() => { throw new Error(err.message); }); diff --git a/src/extension.ts b/src/extension.ts index 86ea924a..5624325b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,23 +1,27 @@ +import { + getOEVersion, + parseOEFile, + readFile, +} from '@src/common/OpenEdgeJsonReaded'; import * as vscode from 'vscode'; import { QuickPickItem } from 'vscode'; -import { ConnectionEditor } from './webview/ConnectionEditor'; -import { Constants } from './common/Constants'; -import { QueryEditor } from './webview/QueryEditor'; -import { DbConnectionNode } from './treeview/DbConnectionNode'; -import { FieldsViewProvider } from './webview/FieldsViewProvider'; -import { IndexesViewProvider } from './webview/IndexesViewProvider'; -import { GroupListProvider } from './treeview/GroupListProvider'; -import { TableNode } from './treeview/TableNode'; -import { TablesListProvider } from './treeview/TablesListProvider'; -import { DbConnectionUpdater } from './treeview/DbConnectionUpdater'; -import { IPort, IConfig } from './view/app/model'; -import { readFile, getOEVersion, parseOEFile } from './common/OpenEdgeJsonReaded'; - -import { VersionChecker } from './view/app/Welcome/VersionChecker'; -import { WelcomePageProvider } from './webview/WelcomePageProvider'; -import { AblHoverProvider } from './providers/AblHoverProvider'; -import { queryEditorCache } from './webview/queryEditor/queryEditorCache'; -import { FavoritesProvider } from './treeview/FavoritesProvider'; + +import { IConfig, IPort } from '@app/model'; +import { VersionChecker } from '@app/Welcome/VersionChecker'; +import { Constants } from '@src/common/Constants'; +import { AblHoverProvider } from '@src/providers/AblHoverProvider'; +import { DbConnectionNode } from '@src/treeview/DbConnectionNode'; +import { DbConnectionUpdater } from '@src/treeview/DbConnectionUpdater'; +import { FavoritesProvider } from '@src/treeview/FavoritesProvider'; +import { GroupListProvider } from '@src/treeview/GroupListProvider'; +import { TableNode } from '@src/treeview/TableNode'; +import { TablesListProvider } from '@src/treeview/TablesListProvider'; +import { ConnectionEditor } from '@src/webview/ConnectionEditor'; +import { FieldsViewProvider } from '@src/webview/FieldsViewProvider'; +import { IndexesViewProvider } from '@src/webview/IndexesViewProvider'; +import { QueryEditor } from '@src/webview/QueryEditor'; +import { queryEditorCache } from '@src/webview/queryEditor/queryEditorCache'; +import { WelcomePageProvider } from '@src/webview/WelcomePageProvider'; export async function activate(context: vscode.ExtensionContext) { let extensionPort: number; @@ -126,17 +130,20 @@ export async function activate(context: vscode.ExtensionContext) { const defaultRuntimeName = ablConfig.get('defaultRuntime'); const oeRuntimes: Array = ablConfig.get>('runtimes') ?? []; - const oejRuntimeName = await vscode.workspace.findFiles('openedge-project.json').then((files) => { - if (files.length > 0) { - return getOEJRuntime(files[0]); - } else { - vscode.window.showWarningMessage('No openedge-project.json file found at the root.'); - return null; - } - }); - - function getOEJRuntime (uri: vscode.Uri) - { + const oejRuntimeName = await vscode.workspace + .findFiles('openedge-project.json') + .then((files) => { + if (files.length > 0) { + return getOEJRuntime(files[0]); + } else { + vscode.window.showWarningMessage( + 'No openedge-project.json file found at the root.' + ); + return null; + } + }); + + function getOEJRuntime(uri: vscode.Uri) { allFileContent = readFile(uri.path); const oeRuntime = getOEVersion(allFileContent); return oeRuntime; @@ -144,18 +151,25 @@ export async function activate(context: vscode.ExtensionContext) { let defaultRuntime; if (Array.isArray(oeRuntimes) && oeRuntimes.length > 0) { - defaultRuntime = - oeRuntimes.some((runtime) => runtime.name === oejRuntimeName) - ? oeRuntimes.find((runtime) => runtime.name === oejRuntimeName) - : oeRuntimes.find((runtime) => runtime.name === defaultRuntimeName) || oeRuntimes[0]; + defaultRuntime = oeRuntimes.some( + (runtime) => runtime.name === oejRuntimeName + ) + ? oeRuntimes.find((runtime) => runtime.name === oejRuntimeName) + : oeRuntimes.find( + (runtime) => runtime.name === defaultRuntimeName + ) || oeRuntimes[0]; } else { - vscode.window.showWarningMessage('No OpenEdge runtime configured on this machine.'); + vscode.window.showWarningMessage( + 'No OpenEdge runtime configured on this machine.' + ); defaultRuntime = null; } if (defaultRuntime !== null) { Constants.dlc = defaultRuntime.path; - vscode.window.showInformationMessage(`Runtime selected : ${defaultRuntime.name}, Path: ${defaultRuntime.path}`); + vscode.window.showInformationMessage( + `Runtime selected : ${defaultRuntime.name}, Path: ${defaultRuntime.path}` + ); } let importConnections = vscode.workspace diff --git a/src/providers/AblHoverProvider.ts b/src/providers/AblHoverProvider.ts index 9aee065d..d3973d6d 100644 --- a/src/providers/AblHoverProvider.ts +++ b/src/providers/AblHoverProvider.ts @@ -1,3 +1,4 @@ +import { TablesListProvider } from '@src/treeview/TablesListProvider'; import { Hover, HoverProvider, @@ -6,7 +7,6 @@ import { ProviderResult, TextDocument, } from 'vscode'; -import { TablesListProvider } from '../treeview/TablesListProvider'; export class AblHoverProvider implements HoverProvider { private tableListProvider: TablesListProvider; diff --git a/src/repo/client/AClient.ts b/src/repo/client/AClient.ts index 26d4f4fc..91ba420d 100644 --- a/src/repo/client/AClient.ts +++ b/src/repo/client/AClient.ts @@ -1,5 +1,5 @@ +import { ConnectionParams } from '@app/model'; import * as Net from 'net'; -import { ConnectionParams } from '../../view/app/model'; export class AClient { protected connectionParams: ConnectionParams; @@ -24,8 +24,8 @@ export class AClient { () => { console.log( 'V2: TCP connection established with the server at ' + - this.connectionParams.port.toString() + - '.' + this.connectionParams.port.toString() + + '.' ); } ); diff --git a/src/repo/client/ClientFactory.ts b/src/repo/client/ClientFactory.ts index 18e0add1..90d1bb7a 100644 --- a/src/repo/client/ClientFactory.ts +++ b/src/repo/client/ClientFactory.ts @@ -1,22 +1,22 @@ +import { IClient } from '@src/repo/client/IClient'; +import { IClientHelper } from '@src/repo/client/IClientHelper'; +import { LocalClient } from '@src/repo/client/local/LocalClient'; +import { LocalClientHelper } from '@src/repo/client/local/LocalClientHelper'; +import { RemoteClientHelper } from '@src/repo/client/remote/RemoteClientHelper'; +import { RemoteClientStorage } from '@src/repo/client/remote/RemoteClientStorage'; import { ConnectionType, IConnectionConfig } from '../../view/app/model'; -import { IClient } from './IClient'; -import { IClientHelper } from './IClientHelper'; -import { LocalClient } from './local/LocalClient'; -import { LocalClientHelper } from './local/LocalClientHelper'; -import { RemoteClientHelper } from './remote/RemoteClientHelper'; -import { RemoteClientStorage } from './remote/RemoteClientStorage'; export class ClientFactory { public static async getInstance( connectionConfig: IConnectionConfig ): Promise { switch (connectionConfig.type) { - case ConnectionType.Local: - return LocalClient.getInstance(); - case ConnectionType.Remote: - return RemoteClientStorage.getInstance(connectionConfig); - default: - return LocalClient.getInstance(); //TODO + case ConnectionType.Local: + return LocalClient.getInstance(); + case ConnectionType.Remote: + return RemoteClientStorage.getInstance(connectionConfig); + default: + return LocalClient.getInstance(); //TODO } } @@ -24,12 +24,12 @@ export class ClientFactory { connectionConfig: IConnectionConfig ): Promise { switch (connectionConfig.connectionId) { - case 'LOCAL': - return LocalClientHelper.getInstance(); - case 'TEST': - return RemoteClientHelper.getInstance(); - default: - return LocalClientHelper.getInstance(); //TODO + case 'LOCAL': + return LocalClientHelper.getInstance(); + case 'TEST': + return RemoteClientHelper.getInstance(); + default: + return LocalClientHelper.getInstance(); //TODO } } } diff --git a/src/repo/client/IClient.ts b/src/repo/client/IClient.ts index 38235d58..be808661 100644 --- a/src/repo/client/IClient.ts +++ b/src/repo/client/IClient.ts @@ -1,3 +1,3 @@ export interface IClient { - sendRequest(cmd: string): Promise; + sendRequest(cmd: string): Promise; } diff --git a/src/repo/client/IClientHelper.ts b/src/repo/client/IClientHelper.ts index dec01576..ea646a48 100644 --- a/src/repo/client/IClientHelper.ts +++ b/src/repo/client/IClientHelper.ts @@ -1,5 +1,5 @@ -import { IConnectionConfig } from '../../view/app/model'; +import { IConnectionConfig } from '@app/model'; export interface IClientHelper { - formConnectionString(config: IConnectionConfig): string; + formConnectionString(config: IConnectionConfig): string; } diff --git a/src/repo/client/local/LocalClient.ts b/src/repo/client/local/LocalClient.ts index 0a17b25f..0418d43b 100644 --- a/src/repo/client/local/LocalClient.ts +++ b/src/repo/client/local/LocalClient.ts @@ -1,13 +1,12 @@ -import * as vscode from 'vscode'; +import { ConnectionParams } from '@app/model'; +import { Constants } from '@src/common/Constants'; +import { AClient } from '@src/repo/client/AClient'; +import { IClient } from '@src/repo/client/IClient'; import * as cp from 'child_process'; import * as fs from 'fs'; +import * as vscode from 'vscode'; import path = require('path'); -import { AClient } from '../AClient'; -import { IClient } from '../IClient'; -import { Constants } from '../../../common/Constants'; -import { ConnectionParams } from '../../../view/app/model'; - export class LocalClient extends AClient implements IClient { private static localClient: LocalClient | undefined = undefined; diff --git a/src/repo/client/local/LocalClientHelper.ts b/src/repo/client/local/LocalClientHelper.ts index c246a0bf..936edb85 100644 --- a/src/repo/client/local/LocalClientHelper.ts +++ b/src/repo/client/local/LocalClientHelper.ts @@ -1,5 +1,5 @@ -import { IConfig } from '../../../view/app/model'; -import { IClientHelper } from '../IClientHelper'; +import { IConfig } from '@app/model'; +import { IClientHelper } from '@src/repo/client/IClientHelper'; export class LocalClientHelper implements IClientHelper { // singleton diff --git a/src/repo/client/remote/RemoteClient.ts b/src/repo/client/remote/RemoteClient.ts index 56156d01..75b2025a 100644 --- a/src/repo/client/remote/RemoteClient.ts +++ b/src/repo/client/remote/RemoteClient.ts @@ -1,6 +1,6 @@ -import { ConnectionParams } from '../../../view/app/model'; -import { AClient } from '../AClient'; -import { IClient } from '../IClient'; +import { ConnectionParams } from '@app/model'; +import { AClient } from '@src/repo/client/AClient'; +import { IClient } from '@src/repo/client/IClient'; export class RemoteClient extends AClient implements IClient { public constructor(connectionParams: ConnectionParams) { diff --git a/src/repo/client/remote/RemoteClientHelper.ts b/src/repo/client/remote/RemoteClientHelper.ts index 3ba6abf5..8a3990be 100644 --- a/src/repo/client/remote/RemoteClientHelper.ts +++ b/src/repo/client/remote/RemoteClientHelper.ts @@ -1,5 +1,5 @@ -import { IRemoteConnectionConfig } from '../../../view/app/model'; -import { IClientHelper } from '../IClientHelper'; +import { IRemoteConnectionConfig } from '@app/model'; +import { IClientHelper } from '@src/repo/client/IClientHelper'; export class RemoteClientHelper implements IClientHelper { // singleton diff --git a/src/repo/client/remote/RemoteClientStorage.ts b/src/repo/client/remote/RemoteClientStorage.ts index 213adbf1..2e6c9fd9 100644 --- a/src/repo/client/remote/RemoteClientStorage.ts +++ b/src/repo/client/remote/RemoteClientStorage.ts @@ -1,20 +1,20 @@ -import { - IRemoteConnectionConfig -} from '../../../view/app/model'; -import { IClient } from '../IClient'; -import { RemoteClient } from './RemoteClient'; +import { IRemoteConnectionConfig } from '@app/model'; +import { IClient } from '@src/repo/client/IClient'; +import { RemoteClient } from '@src/repo/client/remote/RemoteClient'; export class RemoteClientStorage { private static remoteClientMap: Map = new Map< - string, - RemoteClient - >(); + string, + RemoteClient + >(); public static async getInstance( connectionConfig: IRemoteConnectionConfig ): Promise { if ( - !RemoteClientStorage.remoteClientMap.has(connectionConfig.connectionId) + !RemoteClientStorage.remoteClientMap.has( + connectionConfig.connectionId + ) ) { RemoteClientStorage.remoteClientMap.set( connectionConfig.connectionId, diff --git a/src/repo/processor/IProcessor.ts b/src/repo/processor/IProcessor.ts index a4f610b1..ec6ce9e5 100644 --- a/src/repo/processor/IProcessor.ts +++ b/src/repo/processor/IProcessor.ts @@ -1,20 +1,20 @@ -import { IConfig, ITableData, TableDetails } from '../../view/app/model'; +import { IConfig, ITableData, TableDetails } from '@app/model'; export interface IProcessor { - getDBVersion(config: IConfig): Promise; - getTablesList(config: IConfig): Promise; - getTableData( - config: IConfig | undefined, - tableName: string | undefined, - inputParams: ITableData | undefined - ): Promise; - submitTableData( - config: IConfig | undefined, - tableName: string | undefined, - inputParams: ITableData | undefined - ): Promise; - getTableDetails( - config: IConfig | undefined, - tableName: string | undefined - ): Promise; + getDBVersion(config: IConfig): Promise; + getTablesList(config: IConfig): Promise; + getTableData( + config: IConfig | undefined, + tableName: string | undefined, + inputParams: ITableData | undefined + ): Promise; + submitTableData( + config: IConfig | undefined, + tableName: string | undefined, + inputParams: ITableData | undefined + ): Promise; + getTableDetails( + config: IConfig | undefined, + tableName: string | undefined + ): Promise; } diff --git a/src/repo/processor/ProcessorFactory.ts b/src/repo/processor/ProcessorFactory.ts index 6650c580..f104896f 100644 --- a/src/repo/processor/ProcessorFactory.ts +++ b/src/repo/processor/ProcessorFactory.ts @@ -1,10 +1,10 @@ -import { IProcessor } from './IProcessor'; -import { ProcessorType } from './ProcessorType'; -import { DbProcessor } from './database/DbProcessor'; -import { MockProcessor } from './mock/MockProcessor'; -import { DatabaseProcessor } from '../../db/DatabaseProcessor'; +import { Constants } from '@src/common/Constants'; +import { DatabaseProcessor } from '@src/db/DatabaseProcessor'; +import { IProcessor } from '@src/db/IProcessor'; +import { ProcessorType } from '@src/repo/processor/ProcessorType'; +import { DbProcessor } from '@src/repo/processor/database/DbProcessor'; +import { MockProcessor } from '@src/repo/processor/mock/MockProcessor'; import * as vscode from 'vscode'; -import { Constants } from '../../common/Constants'; export class ProcessorFactory { private static readonly processorType: ProcessorType = diff --git a/src/repo/processor/ProcessorType.ts b/src/repo/processor/ProcessorType.ts index 7d215e5f..f5e79f2d 100644 --- a/src/repo/processor/ProcessorType.ts +++ b/src/repo/processor/ProcessorType.ts @@ -1,7 +1,7 @@ export enum ProcessorType { - Database = 'Database', - Mock = 'Mock', + Database = 'Database', + Mock = 'Mock', - // TODO: delete after old processor is removed - Old = 'Old', + // TODO: delete after old processor is removed + Old = 'Old', } diff --git a/src/repo/processor/database/DbProcessor.ts b/src/repo/processor/database/DbProcessor.ts index caaa2e4e..ed199c53 100644 --- a/src/repo/processor/database/DbProcessor.ts +++ b/src/repo/processor/database/DbProcessor.ts @@ -1,17 +1,17 @@ import * as vscode from 'vscode'; -import { IProcessor } from '../IProcessor'; import { ConnectionType, IConfig, IConnectionConfig, ITableData, TableDetails, -} from '../../../view/app/model'; -import { IOEParams } from '../../../db/Oe'; -import { ClientFactory } from '../../client/ClientFactory'; -import { Logger } from '../../../common/Logger'; -import { Constants } from '../../../common/Constants'; +} from '@app/model'; +import { Constants } from '@src/common/Constants'; +import { Logger } from '@src/common/Logger'; +import { IProcessor } from '@src/db/IProcessor'; +import { IOEParams } from '@src/db/Oe'; +import { ClientFactory } from '@src/repo/client/ClientFactory'; export class DbProcessor implements IProcessor { private static instance: DbProcessor | undefined = undefined; // singleton diff --git a/src/repo/processor/mock/MockProcessor.ts b/src/repo/processor/mock/MockProcessor.ts index 5ac5b4d2..0bf62a2f 100644 --- a/src/repo/processor/mock/MockProcessor.ts +++ b/src/repo/processor/mock/MockProcessor.ts @@ -1,4 +1,4 @@ -import { IProcessor } from '../IProcessor'; +import { IProcessor } from '@src/db/IProcessor'; export class MockProcessor implements IProcessor { private static instance: MockProcessor | undefined = undefined; // singleton diff --git a/src/repo/utils/cache.ts b/src/repo/utils/cache.ts index 385ef0dc..d28ec902 100644 --- a/src/repo/utils/cache.ts +++ b/src/repo/utils/cache.ts @@ -1,5 +1,5 @@ -import { TableNode } from '../../treeview/TableNode'; -import { Constants } from '../../common/Constants'; +import { Constants } from '@src/common/Constants'; +import { TableNode } from '@src/treeview/TableNode'; enum CacheKeyNames { SelectedColumns = 'selectedColumns', diff --git a/src/test/nodeTest/dumpFileFormatter.test.ts b/src/test/nodeTest/dumpFileFormatter.test.ts index d7d1f603..ed1f1fb7 100644 --- a/src/test/nodeTest/dumpFileFormatter.test.ts +++ b/src/test/nodeTest/dumpFileFormatter.test.ts @@ -1,11 +1,11 @@ import { expect, jest, test } from '@jest/globals'; -import { assert } from 'console'; +import { DumpFileFormatterTest } from '@src/test/nodeTest/DumpFileFormatterTest'; import { testObjInput, testOutputDumpData, testOutputTrailerInfo, -} from './testObjects'; -import { DumpFileFormatterTest } from './DumpFileFormatterTest'; +} from '@src/test/nodeTest/testObjects'; +import { assert } from 'console'; afterEach(() => { jest.restoreAllMocks(); @@ -14,7 +14,10 @@ afterEach(() => { test('formatDumpFile calls other methods ', () => { const dumpFileFormatterTest = new DumpFileFormatterTest(); const spyDumpData = jest.spyOn(dumpFileFormatterTest, 'formatDumpData'); - const spyTrailerInfo = jest.spyOn(dumpFileFormatterTest, 'formatTrailerInfo'); + const spyTrailerInfo = jest.spyOn( + dumpFileFormatterTest, + 'formatTrailerInfo' + ); const spyDumpFile = jest.spyOn(dumpFileFormatterTest, 'combineDumpFile'); dumpFileFormatterTest.formatDumpFile(testObjInput, 'test', 'test'); @@ -36,11 +39,11 @@ test('combineDumpFile combines data to dump file in right format', () => { dumpFileFormatterTest.combineDumpFile(); const testReturnValue = - 'test dump Data\r\n' + - '.\r\n' + - 'test trailer info\r\n' + - '.\r\n' + - '0000000021'; + 'test dump Data\r\n' + + '.\r\n' + + 'test trailer info\r\n' + + '.\r\n' + + '0000000021'; assert(testReturnValue, dumpFileFormatterTest.dumpFile); }); @@ -53,6 +56,11 @@ test('formatDumpData formatted correctly with add data types', () => { test('formatTrailerInfo formatted correctly', () => { const dumpFileFormatterTest = new DumpFileFormatterTest(); - dumpFileFormatterTest.formatTrailerInfo(testObjInput.psc, 'testing', 'testDb', 4); + dumpFileFormatterTest.formatTrailerInfo( + testObjInput.psc, + 'testing', + 'testDb', + 4 + ); assert(testOutputTrailerInfo, dumpFileFormatterTest.trailerInfo); }); diff --git a/src/test/nodeTest/testObjects.ts b/src/test/nodeTest/testObjects.ts index 4ad3b43b..68c145f4 100644 --- a/src/test/nodeTest/testObjects.ts +++ b/src/test/nodeTest/testObjects.ts @@ -1,4 +1,4 @@ -import { IExportDumpData } from '../../db/Oe'; +import { IExportDumpData } from '@src/db/Oe'; export const testObjInput: IExportDumpData = { columns: [ diff --git a/src/test/viewTest/utils/oe/format/oeFormat.test.ts b/src/test/viewTest/utils/oe/format/oeFormat.test.ts index 3a7af529..a99c286c 100644 --- a/src/test/viewTest/utils/oe/format/oeFormat.test.ts +++ b/src/test/viewTest/utils/oe/format/oeFormat.test.ts @@ -1,5 +1,5 @@ +import { getOEFormatLength } from '@app/utils/oe/format/oeFormat'; import { expect } from '@jest/globals'; -import { getOEFormatLength } from '../../../../../view/app/utils/oe/format/oeFormat'; describe('getOEFormatLength', () => { it('should return the correct length for "xxx"', () => { diff --git a/src/treeview/DatabaseListProvider.ts b/src/treeview/DatabaseListProvider.ts index 96b8cb1e..1a370284 100644 --- a/src/treeview/DatabaseListProvider.ts +++ b/src/treeview/DatabaseListProvider.ts @@ -1,20 +1,21 @@ +import { IConfig } from '@app/model'; +import { Constants } from '@src/common/Constants'; +import * as connectionNode from '@src/treeview/DbConnectionNode'; +import { INode } from '@src/treeview/INode'; +import { IRefreshCallback } from '@src/treeview/IRefreshCallback'; import * as vscode from 'vscode'; -import { Constants } from '../common/Constants'; -import { IConfig } from '../view/app/model'; -import { INode } from './INode'; -import * as connectionNode from './DbConnectionNode'; -import { IRefreshCallback } from './IRefreshCallback'; export class DatabaseListProvider implements vscode.TreeDataProvider { - private _onDidChangeTreeData: vscode.EventEmitter = - new vscode.EventEmitter(); + private _onDidChangeTreeData: vscode.EventEmitter< + INode | undefined | void + > = new vscode.EventEmitter(); readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; constructor( - private context: vscode.ExtensionContext, - private readonly groupName: string, - private readonly refreshCallback: IRefreshCallback + private context: vscode.ExtensionContext, + private readonly groupName: string, + private readonly refreshCallback: IRefreshCallback ) {} refresh(): void { @@ -35,15 +36,15 @@ export class DatabaseListProvider implements vscode.TreeDataProvider { return element.getChildren(); } private async getConnectionNodes(): Promise< - connectionNode.DbConnectionNode[] + connectionNode.DbConnectionNode[] > { const connections = this.context.globalState.get<{ - [key: string]: IConfig; - }>(`${Constants.globalExtensionKey}.dbconfig`); + [key: string]: IConfig; + }>(`${Constants.globalExtensionKey}.dbconfig`); const workspaceConnections = this.context.workspaceState.get<{ - [key: string]: IConfig; - }>(`${Constants.globalExtensionKey}.dbconfig`); + [key: string]: IConfig; + }>(`${Constants.globalExtensionKey}.dbconfig`); const connectionNodes = []; if (connections) { diff --git a/src/treeview/DbConnectionNode.ts b/src/treeview/DbConnectionNode.ts index 6c17237c..21026a00 100644 --- a/src/treeview/DbConnectionNode.ts +++ b/src/treeview/DbConnectionNode.ts @@ -1,13 +1,13 @@ -import * as vscode from 'vscode'; -import path = require('path'); -import { INode } from './INode'; -import { ConnectionStatus, IConfig } from '../view/app/model'; -import { ConnectionEditor } from '../webview/ConnectionEditor'; +import { ConnectionStatus, IConfig } from '@app/model'; +import { Constants } from '@src/common/Constants'; +import { DbConnectionUpdater } from '@src/treeview/DbConnectionUpdater'; +import { INode } from '@src/treeview/INode'; +import { IRefreshCallback } from '@src/treeview/IRefreshCallback'; +import { ConnectionEditor } from '@src/webview/ConnectionEditor'; import { spawn } from 'child_process'; -import { Constants } from '../common/Constants'; import { v4 as uuid } from 'uuid'; -import { DbConnectionUpdater } from './DbConnectionUpdater'; -import { IRefreshCallback } from './IRefreshCallback'; +import * as vscode from 'vscode'; +import path = require('path'); export class DbConnectionNode implements INode { public readonly id: string; @@ -18,7 +18,7 @@ export class DbConnectionNode implements INode { id: string, config: IConfig, refreshCallback: IRefreshCallback, - private context: vscode.ExtensionContext + private context: vscode.ExtensionContext ) { this.id = id; this.config = config; @@ -44,14 +44,14 @@ export class DbConnectionNode implements INode { private iconChooser() { switch (this.config.conStatus) { - case ConnectionStatus.Connected: - return 'progress_icon.svg'; - case ConnectionStatus.NotConnected: - return 'progress_icon_stop.svg'; - case ConnectionStatus.Connecting: - return 'loading.gif'; - default: - return 'progress_icon_stop.svg'; + case ConnectionStatus.Connected: + return 'progress_icon.svg'; + case ConnectionStatus.NotConnected: + return 'progress_icon_stop.svg'; + case ConnectionStatus.Connecting: + return 'loading.gif'; + default: + return 'progress_icon_stop.svg'; } } @@ -60,7 +60,7 @@ export class DbConnectionNode implements INode { } public async deleteConnection(context: vscode.ExtensionContext) { - //TODO fix and move to someplace else + //TODO fix and move to someplace else let connections = context.globalState.get<{ [id: string]: IConfig }>( 'pro-bro.dbconfig' @@ -107,13 +107,13 @@ export class DbConnectionNode implements INode { if (this.id) { let connections = this.context.globalState.get<{ - [id: string]: IConfig; - }>(`${Constants.globalExtensionKey}.dbconfig`); + [id: string]: IConfig; + }>(`${Constants.globalExtensionKey}.dbconfig`); if (connections && !connections[this.id]) { connections = this.context.workspaceState.get<{ - [id: string]: IConfig; - }>(`${Constants.globalExtensionKey}.dbconfig`); + [id: string]: IConfig; + }>(`${Constants.globalExtensionKey}.dbconfig`); } if (connections) { return connections[this.id]; @@ -167,7 +167,9 @@ export class DbConnectionNode implements INode { console.log(`stdout: ${data}`); }); - child.on('error', (error) => console.log('child process error: \n', error)); + child.on('error', (error) => + console.log('child process error: \n', error) + ); // Listen for the process exit event child.on('exit', (code) => { diff --git a/src/treeview/DbConnectionUpdater.ts b/src/treeview/DbConnectionUpdater.ts index 282c5bdc..3d66a921 100644 --- a/src/treeview/DbConnectionUpdater.ts +++ b/src/treeview/DbConnectionUpdater.ts @@ -1,7 +1,7 @@ +import { ConnectionStatus, IConfig } from '@app/model'; +import { ProcessorFactory } from '@src/repo/processor/ProcessorFactory'; +import { IRefreshCallback } from '@src/treeview/IRefreshCallback'; import * as vscode from 'vscode'; -import { ConnectionStatus, IConfig } from '../view/app/model'; -import { IRefreshCallback } from './IRefreshCallback'; -import { ProcessorFactory } from '../repo/processor/ProcessorFactory'; export class DbConnectionUpdater { private locked = false; @@ -106,7 +106,10 @@ export class DbConnectionUpdater { } if (this.context.workspaceState) { - await this.updateSingleStatus(connectionId, 'workspaceState'); + await this.updateSingleStatus( + connectionId, + 'workspaceState' + ); } } } finally { diff --git a/src/treeview/FavoritesProvider.ts b/src/treeview/FavoritesProvider.ts index 0e28578a..7815d7a2 100644 --- a/src/treeview/FavoritesProvider.ts +++ b/src/treeview/FavoritesProvider.ts @@ -1,9 +1,9 @@ +import { IConfig } from '@app/model'; +import { Constants } from '@src/common/Constants'; +import { TableNode, TableNodeSourceEnum } from '@src/treeview/TableNode'; +import { TablesListProvider } from '@src/treeview/TablesListProvider'; +import { PanelViewProvider } from '@src/webview/PanelViewProvider'; import * as vscode from 'vscode'; -import { TableNode, TableNodeSourceEnum } from './TableNode'; -import { TablesListProvider } from './TablesListProvider'; -import { PanelViewProvider } from '../webview/PanelViewProvider'; -import { IConfig } from '../view/app/model'; -import { Constants } from '../common/Constants'; export class FavoritesProvider extends TablesListProvider { public _onDidChangeTreeData: vscode.EventEmitter< diff --git a/src/treeview/GroupListProvider.ts b/src/treeview/GroupListProvider.ts index 0807dbfa..77d331c5 100644 --- a/src/treeview/GroupListProvider.ts +++ b/src/treeview/GroupListProvider.ts @@ -1,12 +1,13 @@ import * as vscode from 'vscode'; -import { Constants } from '../common/Constants'; -import { INode } from './INode'; -import * as groupNode from './GroupNode'; -import { IConfig } from '../view/app/model'; -import { TablesListProvider } from './TablesListProvider'; -import { DbConnectionNode } from './DbConnectionNode'; -import { IRefreshCallback } from './IRefreshCallback'; -import { FavoritesProvider } from './FavoritesProvider'; + +import { IConfig } from '@app/model'; +import { Constants } from '@src/common/Constants'; +import { DbConnectionNode } from '@src/treeview/DbConnectionNode'; +import { FavoritesProvider } from '@src/treeview/FavoritesProvider'; +import * as groupNode from '@src/treeview/GroupNode'; +import { INode } from '@src/treeview/INode'; +import { IRefreshCallback } from '@src/treeview/IRefreshCallback'; +import { TablesListProvider } from '@src/treeview/TablesListProvider'; export class GroupListProvider implements vscode.TreeDataProvider, IRefreshCallback diff --git a/src/treeview/GroupNode.ts b/src/treeview/GroupNode.ts index 24db413a..47f9850e 100644 --- a/src/treeview/GroupNode.ts +++ b/src/treeview/GroupNode.ts @@ -1,11 +1,14 @@ +import { DatabaseListProvider } from '@src/treeview/DatabaseListProvider'; +import { IRefreshCallback } from '@src/treeview/IRefreshCallback'; import * as vscode from 'vscode'; -import { DatabaseListProvider } from './DatabaseListProvider'; import { INode } from './INode'; -import { IRefreshCallback } from './IRefreshCallback'; export class GroupNode implements INode { - constructor(private context: vscode.ExtensionContext, private readonly groupName: string, private readonly refreshCallback: IRefreshCallback) {} - + constructor( + private context: vscode.ExtensionContext, + private readonly groupName: string, + private readonly refreshCallback: IRefreshCallback + ) {} public getTreeItem(): vscode.TreeItem { return { @@ -16,7 +19,10 @@ export class GroupNode implements INode { } public async getChildren(): Promise { - return new DatabaseListProvider(this.context, this.groupName, this.refreshCallback).getChildren(); + return new DatabaseListProvider( + this.context, + this.groupName, + this.refreshCallback + ).getChildren(); } - -} \ No newline at end of file +} diff --git a/src/treeview/INode.ts b/src/treeview/INode.ts index 2ef42108..f1362870 100644 --- a/src/treeview/INode.ts +++ b/src/treeview/INode.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; export interface INode { - getTreeItem(): Promise | vscode.TreeItem; - getChildren(): Promise | INode[]; + getTreeItem(): Promise | vscode.TreeItem; + getChildren(): Promise | INode[]; } diff --git a/src/treeview/TableNode.ts b/src/treeview/TableNode.ts index 9a944f4a..02ab4880 100644 --- a/src/treeview/TableNode.ts +++ b/src/treeview/TableNode.ts @@ -1,6 +1,6 @@ +import { TableDetails } from '@app/model'; +import { INode } from '@src/treeview/INode'; import * as vscode from 'vscode'; -import { TableDetails } from '../view/app/model'; -import { INode } from './INode'; export enum TableNodeSourceEnum { Tables = 'tables', diff --git a/src/treeview/TablesListProvider.ts b/src/treeview/TablesListProvider.ts index 45b3650f..1e9b15d1 100644 --- a/src/treeview/TablesListProvider.ts +++ b/src/treeview/TablesListProvider.ts @@ -1,16 +1,16 @@ -import * as vscode from 'vscode'; -import { INode } from './INode'; -import * as tableNode from './TableNode'; -import { IConfig, TableCount } from '../view/app/model'; -import { ProcessorFactory } from '../repo/processor/ProcessorFactory'; -import { TableNode, TableNodeSourceEnum } from './TableNode'; -import { PanelViewProvider } from '../webview/PanelViewProvider'; +import { IConfig, TableCount } from '@app/model'; +import { Constants } from '@src/common/Constants'; +import { ProcessorFactory } from '@src/repo/processor/ProcessorFactory'; import { getAllColumnsCache, getSelectedColumnsCache, updateAllColumnsCache, -} from '../repo/utils/cache'; -import { Constants } from '../common/Constants'; +} from '@src/repo/utils/cache'; +import { INode } from '@src/treeview/INode'; +import * as tableNode from '@src/treeview/TableNode'; +import { TableNode, TableNodeSourceEnum } from '@src/treeview/TableNode'; +import { PanelViewProvider } from '@src/webview/PanelViewProvider'; +import * as vscode from 'vscode'; export class TablesListProvider implements vscode.TreeDataProvider { public config: IConfig | undefined; diff --git a/src/view/app/Components/Layout/Query/QueryFormHead.tsx b/src/view/app/Components/Layout/Query/QueryFormHead.tsx index 87bca3ce..b2f70e3d 100644 --- a/src/view/app/Components/Layout/Query/QueryFormHead.tsx +++ b/src/view/app/Components/Layout/Query/QueryFormHead.tsx @@ -5,11 +5,11 @@ import { UpdatePopupProps } from '@Query/Update/update'; import QueryAutocompleteInput, { QueryAutocompleteInputProps, } from '@app/Components/Layout/Query/QueryAutocompleteInput'; +import QueryDropdownMenu from '@app/Components/Layout/Query/QueryDropdownMenu'; import { ProBroButton } from '@assets/button'; import PlayArrowTwoToneIcon from '@mui/icons-material/PlayArrowTwoTone'; import { Box, Stack, Typography } from '@mui/material'; import { MouseEventHandler, useEffect } from 'react'; -import QueryDropdownMenu from './QueryDropdownMenu'; interface QueryFormHeadProps extends QueryAutocompleteInputProps, diff --git a/src/view/app/Query/Export/index.ts b/src/view/app/Query/Export/index.ts index 950b6aec..36e7d8e8 100644 --- a/src/view/app/Query/Export/index.ts +++ b/src/view/app/Query/Export/index.ts @@ -1,3 +1,3 @@ -import ExportPopup from './export'; +import ExportPopup from '@Query/Export/export'; -export default ExportPopup; \ No newline at end of file +export default ExportPopup; diff --git a/src/view/app/Query/Update/index.ts b/src/view/app/Query/Update/index.ts index e22d5e19..58cc5270 100644 --- a/src/view/app/Query/Update/index.ts +++ b/src/view/app/Query/Update/index.ts @@ -1,3 +1,3 @@ -import UpdatePopup from './update'; +import UpdatePopup from '@Query/Update/update'; -export default UpdatePopup; \ No newline at end of file +export default UpdatePopup; diff --git a/src/view/app/Welcome/VersionChecker.ts b/src/view/app/Welcome/VersionChecker.ts index eef72bc8..5bc30610 100644 --- a/src/view/app/Welcome/VersionChecker.ts +++ b/src/view/app/Welcome/VersionChecker.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode'; -import { Constants } from './../../../common/Constants'; +import { Constants } from '@src/common/Constants'; export class VersionChecker{ diff --git a/src/view/app/utils/PfParser.ts b/src/view/app/utils/PfParser.ts index 482ba772..9050d3b3 100644 --- a/src/view/app/utils/PfParser.ts +++ b/src/view/app/utils/PfParser.ts @@ -1,4 +1,4 @@ -import { IConfig } from '../model'; +import { IConfig } from '@app/model'; export class PfParser { public parse(pfFile: string): IConfig { diff --git a/src/view/declarations.d.ts b/src/view/declarations.d.ts index 5145ce3a..cadffd5c 100644 --- a/src/view/declarations.d.ts +++ b/src/view/declarations.d.ts @@ -1,13 +1,13 @@ -declare module "*.md" { +declare module '*.md' { const content: string; export default content; } -declare module "*.gif" { +declare module '*.gif' { const value: { default: string }; export default value; } -declare module "*.jpg" { +declare module '*.jpg' { const value: { default: string }; export default value; -} \ No newline at end of file +} diff --git a/src/webview/ConnectionEditor.ts b/src/webview/ConnectionEditor.ts index 2807b0dd..0a92ebf9 100644 --- a/src/webview/ConnectionEditor.ts +++ b/src/webview/ConnectionEditor.ts @@ -1,10 +1,10 @@ -import path = require('path'); -import * as vscode from 'vscode'; -import { ICommand, CommandAction, IConfig } from '../view/app/model'; -import { Constants } from '../common/Constants'; -import { Logger } from '../common/Logger'; +import { CommandAction, ICommand, IConfig } from '@app/model'; +import { Constants } from '@src/common/Constants'; +import { Logger } from '@src/common/Logger'; +import { ProcessorFactory } from '@src/repo/processor/ProcessorFactory'; import { v4 as uuid } from 'uuid'; -import { ProcessorFactory } from '../repo/processor/ProcessorFactory'; +import * as vscode from 'vscode'; +import path = require('path'); export class ConnectionEditor { private readonly panel: vscode.WebviewPanel | undefined; diff --git a/src/webview/DumpFileFormatter.ts b/src/webview/DumpFileFormatter.ts index 322ad7ba..429c6cf6 100644 --- a/src/webview/DumpFileFormatter.ts +++ b/src/webview/DumpFileFormatter.ts @@ -1,4 +1,4 @@ -import { IExportDumpData, IOePsc } from '../db/Oe'; +import { IExportDumpData, IOePsc } from '@src/db/Oe'; export class DumpFileFormatter { protected dumpData = ''; diff --git a/src/webview/FieldsViewProvider.ts b/src/webview/FieldsViewProvider.ts index cbc877a8..946fe61f 100644 --- a/src/webview/FieldsViewProvider.ts +++ b/src/webview/FieldsViewProvider.ts @@ -1,10 +1,10 @@ +import { CommandAction, ICommand } from '@app/model'; +import { Logger } from '@src/common/Logger'; +import { HighlightFieldsCommand } from '@src/common/commands/fieldsCommands'; +import { updateSelectedColumnsCache } from '@src/repo/utils/cache'; +import { PanelViewProvider } from '@src/webview/PanelViewProvider'; +import { QueryEditor } from '@src/webview/QueryEditor'; import * as vscode from 'vscode'; -import { QueryEditor } from './QueryEditor'; -import { CommandAction, ICommand } from '../view/app/model'; -import { PanelViewProvider } from './PanelViewProvider'; -import { Logger } from '../common/Logger'; -import { updateSelectedColumnsCache } from '../repo/utils/cache'; -import { HighlightFieldsCommand } from '../common/commands/fieldsCommands'; export class FieldsViewProvider extends PanelViewProvider { private queryEditors: QueryEditor[] = []; diff --git a/src/webview/IndexesViewProvider.ts b/src/webview/IndexesViewProvider.ts index b5167e64..21d2f42f 100644 --- a/src/webview/IndexesViewProvider.ts +++ b/src/webview/IndexesViewProvider.ts @@ -1,3 +1,3 @@ -import { PanelViewProvider } from './PanelViewProvider'; +import { PanelViewProvider } from '@src/webview/PanelViewProvider'; export class IndexesViewProvider extends PanelViewProvider {} diff --git a/src/webview/PanelViewProvider.ts b/src/webview/PanelViewProvider.ts index c7cfb2a2..3d26203d 100644 --- a/src/webview/PanelViewProvider.ts +++ b/src/webview/PanelViewProvider.ts @@ -1,10 +1,10 @@ import path = require('path'); +import { CommandAction, ICommand } from '@app/model'; +import { Constants } from '@src/common/Constants'; +import { FavoritesProvider } from '@src/treeview/FavoritesProvider'; +import { TableNode } from '@src/treeview/TableNode'; +import { TablesListProvider } from '@src/treeview/TablesListProvider'; import * as vscode from 'vscode'; -import { Constants } from '../common/Constants'; -import { CommandAction, ICommand } from '../view/app/model'; -import { TableNode } from '../treeview/TableNode'; -import { TablesListProvider } from '../treeview/TablesListProvider'; -import { FavoritesProvider } from '../treeview/FavoritesProvider'; export class PanelViewProvider implements vscode.WebviewViewProvider { public static readonly viewType = `${Constants.globalExtensionKey}-panel`; diff --git a/src/webview/QueryEditor.ts b/src/webview/QueryEditor.ts index 7273abcc..47ab169e 100644 --- a/src/webview/QueryEditor.ts +++ b/src/webview/QueryEditor.ts @@ -1,16 +1,16 @@ import path = require('path'); +import { Constants } from '@src/common/Constants'; +import { Logger } from '@src/common/Logger'; +import { IOETableData } from '@src/db/Oe'; +import { ProcessorFactory } from '@src/repo/processor/ProcessorFactory'; +import { FavoritesProvider } from '@src/treeview/FavoritesProvider'; +import { TableNode, TableNodeSourceEnum } from '@src/treeview/TableNode'; +import { TablesListProvider } from '@src/treeview/TablesListProvider'; +import { CommandAction, ICommand, IConfig } from '@src/view/app/model'; +import { DumpFileFormatter } from '@src/webview/DumpFileFormatter'; +import { FieldsViewProvider } from '@src/webview/FieldsViewProvider'; +import { queryEditorCache } from '@src/webview/queryEditor/queryEditorCache'; import * as vscode from 'vscode'; -import { ICommand, CommandAction, IConfig } from '../view/app/model'; -import { IOETableData } from '../db/Oe'; -import { TableNode, TableNodeSourceEnum } from '../treeview/TableNode'; -import { TablesListProvider } from '../treeview/TablesListProvider'; -import { FieldsViewProvider } from './FieldsViewProvider'; -import { DumpFileFormatter } from './DumpFileFormatter'; -import { Logger } from '../common/Logger'; -import { ProcessorFactory } from '../repo/processor/ProcessorFactory'; -import { Constants } from '../common/Constants'; -import { queryEditorCache } from './queryEditor/queryEditorCache'; -import { FavoritesProvider } from '../treeview/FavoritesProvider'; export class QueryEditor { public readonly panel: vscode.WebviewPanel | undefined; diff --git a/src/webview/WelcomePageProvider.ts b/src/webview/WelcomePageProvider.ts index 7ec8ca1f..4525717e 100644 --- a/src/webview/WelcomePageProvider.ts +++ b/src/webview/WelcomePageProvider.ts @@ -1,6 +1,6 @@ +import { Constants } from '@src/common/Constants'; import path = require('path'); import * as vscode from 'vscode'; -import { Constants } from '../common/Constants'; export class WelcomePageProvider { private readonly panel: vscode.WebviewPanel | undefined; @@ -11,8 +11,8 @@ export class WelcomePageProvider { ); constructor( - private context: vscode.ExtensionContext, - private version: string + private context: vscode.ExtensionContext, + private version: string ) { this.extensionPath = context.asAbsolutePath(''); @@ -24,7 +24,9 @@ export class WelcomePageProvider { enableScripts: true, retainContextWhenHidden: true, localResourceRoots: [ - vscode.Uri.file(path.join(context.asAbsolutePath(''), 'out')), + vscode.Uri.file( + path.join(context.asAbsolutePath(''), 'out') + ), ], } ); @@ -62,16 +64,19 @@ export class WelcomePageProvider { } private getWebviewContent(): string { - // Local path to main script run in the webview + // Local path to main script run in the webview const reactAppPathOnDisk = vscode.Uri.file( path.join( vscode.Uri.file( - this.context.asAbsolutePath(path.join('out/view/app', 'welcome.js')) + this.context.asAbsolutePath( + path.join('out/view/app', 'welcome.js') + ) ).fsPath ) ); - const reactAppUri = this.panel?.webview.asWebviewUri(reactAppPathOnDisk); + const reactAppUri = + this.panel?.webview.asWebviewUri(reactAppPathOnDisk); console.log('reactAppUri', reactAppUri); const cspSource = this.panel?.webview.cspSource; console.log('cspSource', cspSource); diff --git a/src/webview/queryEditor/queryEditorCache.ts b/src/webview/queryEditor/queryEditorCache.ts index 145f2805..71536cd2 100644 --- a/src/webview/queryEditor/queryEditorCache.ts +++ b/src/webview/queryEditor/queryEditorCache.ts @@ -1,4 +1,4 @@ -import { QueryEditor } from '../QueryEditor'; +import { QueryEditor } from '@src/webview/QueryEditor'; const cache = new Map(); diff --git a/tsconfig.json b/tsconfig.json index 5846e003..4dc3fdcb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,12 @@ "lib": ["ES2020", "dom"], "sourceMap": true, "rootDir": "src", - "strict": true /* enable all strict type-checking options */ + "strict": true, /* enable all strict type-checking options */ + "baseUrl": ".", + "paths": { + "@app/*": ["src/view/app/*"], + "@src/*": ["src/*"] + } /* Additional Checks */ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ From e28b041bf4fffb32ca74fe08cdfc05e72fc9f38a Mon Sep 17 00:00:00 2001 From: akleinas Date: Wed, 4 Dec 2024 20:41:15 +0200 Subject: [PATCH 5/8] 520 updated jest configuration to account for changed import format --- jest.config.js | 4 ++++ src/test/nodeTest/DumpFileFormatterTest.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/jest.config.js b/jest.config.js index c53b2bba..1dd95f71 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,6 +6,10 @@ const config = { globals: { __DEV__: true, }, + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '/' }), + transform: { + '^.+\\.tsx?$': 'ts-jest', + }, }; module.exports = config; diff --git a/src/test/nodeTest/DumpFileFormatterTest.ts b/src/test/nodeTest/DumpFileFormatterTest.ts index 78a3b560..98a91f8f 100644 --- a/src/test/nodeTest/DumpFileFormatterTest.ts +++ b/src/test/nodeTest/DumpFileFormatterTest.ts @@ -1,19 +1,19 @@ -import { IExportDumpData } from '../../db/Oe'; -import { DumpFileFormatter } from '../../webview/DumpFileFormatter'; +import { IExportDumpData } from '@src/db/Oe'; +import { DumpFileFormatter } from '@src/webview/DumpFileFormatter'; export class DumpFileFormatterTest extends DumpFileFormatter { public dumpData: string = super.dumpData; public trailerInfo: string = super.trailerInfo; public dumpFile: string = super.dumpFile; - + public combineDumpFile() { return super.combineDumpFile(); } - + public formatDumpData(data: IExportDumpData) { return super.formatDumpData(data); } - + public formatTrailerInfo( data: any, fileName: string, @@ -22,4 +22,4 @@ export class DumpFileFormatterTest extends DumpFileFormatter { ) { return super.formatTrailerInfo(data, fileName, dbName, recordNum); } -} \ No newline at end of file +} From fb48dbecc104d4595f7aaf851fb8a3c7eede6296 Mon Sep 17 00:00:00 2001 From: akleinas Date: Wed, 4 Dec 2024 20:51:02 +0200 Subject: [PATCH 6/8] 520 fixed jest configuration --- jest.config.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jest.config.js b/jest.config.js index 1dd95f71..44ef6c49 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ -const path = require('path'); + +import { pathsToModuleNameMapper } from 'ts-jest'; +import path from 'path'; /** @type {import('jest').Config} */ const config = { roots: ['/src/test/nodeTest', '/src/test/viewTest'], @@ -12,4 +14,4 @@ const config = { }, }; -module.exports = config; +export default config; From 9ec039e6c778697b5114e4d7fc980472cc3e2c5c Mon Sep 17 00:00:00 2001 From: akleinas Date: Wed, 4 Dec 2024 20:56:06 +0200 Subject: [PATCH 7/8] 520 fixed jest configuration for real this tim --- jest.config.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/jest.config.js b/jest.config.js index 44ef6c49..ea6a921c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ +const { pathsToModuleNameMapper } = require('ts-jest/utils'); -import { pathsToModuleNameMapper } from 'ts-jest'; -import path from 'path'; /** @type {import('jest').Config} */ const config = { roots: ['/src/test/nodeTest', '/src/test/viewTest'], @@ -12,6 +11,4 @@ const config = { transform: { '^.+\\.tsx?$': 'ts-jest', }, -}; - -export default config; +}; \ No newline at end of file From db220097e694fc6d020efdb1a2afe489f21fbcab Mon Sep 17 00:00:00 2001 From: akleinas Date: Wed, 11 Dec 2024 07:50:58 +0200 Subject: [PATCH 8/8] 520 resolved import issue in jest tests --- jest.config.js | 11 ++++------- src/test/nodeTest/DumpFileFormatterTest.ts | 4 ++-- src/test/nodeTest/dumpFileFormatter.test.ts | 6 +++--- src/test/nodeTest/testObjects.ts | 2 +- src/test/viewTest/utils/oe/format/oeFormat.test.ts | 2 +- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/jest.config.js b/jest.config.js index ea6a921c..d2e56583 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,14 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention */ -const { pathsToModuleNameMapper } = require('ts-jest/utils'); - +const path = require('path'); /** @type {import('jest').Config} */ const config = { roots: ['/src/test/nodeTest', '/src/test/viewTest'], globals: { __DEV__: true, }, - moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '/' }), - transform: { - '^.+\\.tsx?$': 'ts-jest', - }, -}; \ No newline at end of file +}; + +module.exports = config; \ No newline at end of file diff --git a/src/test/nodeTest/DumpFileFormatterTest.ts b/src/test/nodeTest/DumpFileFormatterTest.ts index 98a91f8f..f3fecf94 100644 --- a/src/test/nodeTest/DumpFileFormatterTest.ts +++ b/src/test/nodeTest/DumpFileFormatterTest.ts @@ -1,5 +1,5 @@ -import { IExportDumpData } from '@src/db/Oe'; -import { DumpFileFormatter } from '@src/webview/DumpFileFormatter'; +import { IExportDumpData } from '../../db/Oe'; +import { DumpFileFormatter } from '../../webview/DumpFileFormatter'; export class DumpFileFormatterTest extends DumpFileFormatter { public dumpData: string = super.dumpData; diff --git a/src/test/nodeTest/dumpFileFormatter.test.ts b/src/test/nodeTest/dumpFileFormatter.test.ts index ed1f1fb7..3c0f5d2a 100644 --- a/src/test/nodeTest/dumpFileFormatter.test.ts +++ b/src/test/nodeTest/dumpFileFormatter.test.ts @@ -1,11 +1,11 @@ import { expect, jest, test } from '@jest/globals'; -import { DumpFileFormatterTest } from '@src/test/nodeTest/DumpFileFormatterTest'; +import { assert } from 'console'; +import { DumpFileFormatterTest } from './DumpFileFormatterTest'; import { testObjInput, testOutputDumpData, testOutputTrailerInfo, -} from '@src/test/nodeTest/testObjects'; -import { assert } from 'console'; +} from './testObjects'; afterEach(() => { jest.restoreAllMocks(); diff --git a/src/test/nodeTest/testObjects.ts b/src/test/nodeTest/testObjects.ts index 68c145f4..4ad3b43b 100644 --- a/src/test/nodeTest/testObjects.ts +++ b/src/test/nodeTest/testObjects.ts @@ -1,4 +1,4 @@ -import { IExportDumpData } from '@src/db/Oe'; +import { IExportDumpData } from '../../db/Oe'; export const testObjInput: IExportDumpData = { columns: [ diff --git a/src/test/viewTest/utils/oe/format/oeFormat.test.ts b/src/test/viewTest/utils/oe/format/oeFormat.test.ts index a99c286c..3a7af529 100644 --- a/src/test/viewTest/utils/oe/format/oeFormat.test.ts +++ b/src/test/viewTest/utils/oe/format/oeFormat.test.ts @@ -1,5 +1,5 @@ -import { getOEFormatLength } from '@app/utils/oe/format/oeFormat'; import { expect } from '@jest/globals'; +import { getOEFormatLength } from '../../../../../view/app/utils/oe/format/oeFormat'; describe('getOEFormatLength', () => { it('should return the correct length for "xxx"', () => {