diff --git a/archive_builder.py b/archive_builder.py index 6a194042..81c1f8ba 100755 --- a/archive_builder.py +++ b/archive_builder.py @@ -52,7 +52,7 @@ # Prepare file name for archive using platform, architecture & app version archive_file_name = '-'.join([APP_NAME, PLATFORM_NAME, ARCH, APP_VERSION]) -print("Composed Archive file name: '" + archive_file_name + "'") +print(f"Composed Archive file name: '{archive_file_name}'") # Ensure archive directory dist/ is created, before attempting to store archive inside it ensure_archive_directory = f"mkdir -p {ARCHIVE_DIR}" @@ -64,13 +64,13 @@ zip_command = f"powershell Compress-Archive {PACKAGE_DIR}/* {ARCHIVE_DIR}/{archive_file_name}.zip" print("Executing zip command on powershell:", zip_command) os.system(zip_command) - print(f"Zip file ready in {ARCHIVE_DIR}/ !!") + print(f"Zip file ready: {ARCHIVE_DIR}/{archive_file_name}.zip") # Prepare .tar.gz file for mac & linux else: tar_command = f"tar -czf {ARCHIVE_DIR}/{archive_file_name}.tar.gz -C {PACKAGE_DIR} ." print("Executing tar command:", tar_command) os.system(tar_command) - print(f"Tar file ready in {ARCHIVE_DIR}/ !!") + print(f"Tar file ready: {ARCHIVE_DIR}/{archive_file_name}.tar.gz") print("Build succeeded !!!") \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 48269373..6725eb2e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,15 @@ -import sqlite3 from 'sqlite3' -import { app, BrowserWindow, nativeImage, ipcMain, Menu, shell } from 'electron'; +import sqlite3 from "sqlite3"; +import { + app, + BrowserWindow, + nativeImage, + ipcMain, + Menu, + shell, +} from "electron"; -import getTemplate from './mainMenu'; -import { setUpGlobalIpcListeners, setUpWindowListeners } from './mainActions'; +import getTemplate from "./mainMenu"; +import { setUpGlobalIpcListeners, setUpWindowListeners } from "./mainActions"; // This allows TypeScript to pick up the magic constant that's auto-generated by Forge's Webpack // plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on @@ -13,7 +20,7 @@ declare const MAIN_WINDOW_WEBPACK_ENTRY: string; const isDev = !app.isPackaged; // Handle creating/removing shortcuts on Windows when installing/uninstalling. -if (require('electron-squirrel-startup')) { +if (require("electron-squirrel-startup")) { // eslint-disable-line global-require app.quit(); } @@ -57,8 +64,8 @@ export const createWindow = (): void => { // nodeIntegrationInSubFrames: true, // preload: path.join(__dirname, 'index.js'), // enableRemoteModule: true, - } - }); + }, + }); Menu.setApplicationMenu(Menu.buildFromTemplate(getTemplate())); console.log( @@ -67,14 +74,14 @@ export const createWindow = (): void => { ); // console.log("Preload URL: ", MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY); console.log("Load URL: ", MAIN_WINDOW_WEBPACK_ENTRY); - + // and load the index.html of the app. mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY); // open all URLs in default browser window // We do this only in production, to prevent hot reloads getting opened in browser - if(!isDev){ - mainWindow.webContents.on('will-navigate', (event, url) => { + if (!isDev) { + mainWindow.webContents.on("will-navigate", (event, url) => { event.preventDefault(); shell.openExternal(url); }); @@ -87,10 +94,10 @@ setUpGlobalIpcListeners(); // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. -app.on('ready', () => { +app.on("ready", () => { createWindow(); - if(app.dock){ - app.dock.setIcon(APP_ICON_NATIVE_IMAGE) + if (app.dock) { + app.dock.setIcon(APP_ICON_NATIVE_IMAGE); } }); @@ -98,17 +105,17 @@ app.on('ready', () => { // Quit when all windows are closed, except on macOS. There, it's common // for applications and their menu bar to stay active until the user quits // explicitly with Cmd + Q. -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { +app.on("window-all-closed", () => { + if (process.platform !== "darwin") { app.quit(); ipcMain.removeAllListeners(); } }); -app.on('activate', () => { +app.on("activate", () => { // On MacOS, it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } -}); \ No newline at end of file +}); diff --git a/src/pages/PageNotFound.tsx b/src/pages/PageNotFound.tsx index 137b5dbf..b973690f 100644 --- a/src/pages/PageNotFound.tsx +++ b/src/pages/PageNotFound.tsx @@ -1,28 +1,29 @@ -import React from 'react' -import { Link } from 'react-router-dom' +import React from "react"; +import { Link } from "react-router-dom"; -import { ROUTES } from '../constants/routes' +import { ROUTES } from "../constants/routes"; const PageNotFound = () => { return ( -
-
-

- 4 0 4 +
+
+
+
4 0 4
-
-

- ¯\_(ツ)_/¯ -

+
+

+ ¯\_(ツ)_/¯ +
+

Don't venture places, - + Go back Home

- ) -} + ); +}; -export default PageNotFound \ No newline at end of file +export default PageNotFound; diff --git a/src/reactApp.tsx b/src/reactApp.tsx index 729d79fc..bc2931ef 100644 --- a/src/reactApp.tsx +++ b/src/reactApp.tsx @@ -1,6 +1,6 @@ -import * as React from 'react'; -import { createRoot } from 'react-dom/client'; -import App from './App'; +import * as React from "react"; +import { createRoot } from "react-dom/client"; +import App from "./App"; // For previous react versions // import * as ReactDOM from 'react-dom'; @@ -12,11 +12,11 @@ import App from './App'; // For react 18 onwards export function renderReactApp() { - const container = document.getElementById('app'); - if(container){ + const container = document.getElementById("app"); + if (container) { const root = createRoot(container); root.render(); } else { console.log("Container for react app not found :(", container); } -} \ No newline at end of file +} diff --git a/src/renderer.ts b/src/renderer.ts index 5c8e837a..01ca879e 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -26,13 +26,13 @@ * ``` */ -import { ipcRenderer, webFrame } from 'electron'; -import { renderReactApp } from './reactApp'; +import { ipcRenderer, webFrame } from "electron"; +import { renderReactApp } from "./reactApp"; -import { GENERAL_ACTIONS } from './constants/IpcConnection'; +import { GENERAL_ACTIONS } from "./constants/IpcConnection"; -import './styles/index.css'; -import './styles/colors.css'; +import "./styles/index.css"; +import "./styles/colors.css"; // Setup general actions ipcRenderer.on(GENERAL_ACTIONS.ZOOM_IN, () => { @@ -45,5 +45,4 @@ ipcRenderer.on(GENERAL_ACTIONS.ZOOM_RESET, () => { webFrame.setZoomLevel(0); }); - -renderReactApp(); \ No newline at end of file +renderReactApp(); diff --git a/src/services/historyStore.ts b/src/services/historyStore.ts index 51c5a7ae..dc58419c 100644 --- a/src/services/historyStore.ts +++ b/src/services/historyStore.ts @@ -14,10 +14,7 @@ export const GetHistory = () => { window.localStorage.getItem(HISTORY_STORE_KEY) || "[]" ) as HistoryItem[]; history.sort(function (a, b) { - return ( - Number(moment(b.opened_at)) - - Number(moment(a.opened_at)) - ); + return Number(moment(b.opened_at)) - Number(moment(a.opened_at)); }); return JSON.parse( @@ -39,10 +36,7 @@ export const AddEntry = (entry: HistoryItem) => { existingEntry.opened_at = entry.opened_at; existingEntry.sqlite_path = entry.sqlite_path; history.sort(function (a, b) { - return ( - Number(moment(b.opened_at)) - - Number(moment(a.opened_at)) - ); + return Number(moment(b.opened_at)) - Number(moment(a.opened_at)); }); } else { // console.log("Adding new history entry:", entry); diff --git a/src/services/models/scanError.ts b/src/services/models/scanError.ts index bcac5cd9..ab876c7b 100644 --- a/src/services/models/scanError.ts +++ b/src/services/models/scanError.ts @@ -1,4 +1,3 @@ -import { Model } from "sequelize"; /* # # Copyright (c) 2018 nexB Inc. and others. All rights reserved. @@ -15,7 +14,7 @@ import { Model } from "sequelize"; # */ -import { Sequelize, DataTypes } from "sequelize"; +import { Sequelize, DataTypes, Model } from "sequelize"; export interface ScanErrorAttributes { scan_error: string; diff --git a/src/services/models/url.ts b/src/services/models/url.ts index 2117cb5e..c0d5ed3c 100644 --- a/src/services/models/url.ts +++ b/src/services/models/url.ts @@ -1,4 +1,3 @@ -import { Model } from "sequelize"; /* # # Copyright (c) 2018 nexB Inc. and others. All rights reserved. @@ -15,7 +14,7 @@ import { Model } from "sequelize"; # */ -import { Sequelize, DataTypes } from "sequelize"; +import { Sequelize, DataTypes, Model } from "sequelize"; export interface UrlAttributes { id: number; diff --git a/src/utils/bar.ts b/src/utils/bar.ts index f1ff3a90..9437e2db 100644 --- a/src/utils/bar.ts +++ b/src/utils/bar.ts @@ -40,7 +40,9 @@ export function getValidatedAttributeValues( if (!isValid(val) && attribute === "package_data_type") { continue; } - validatedAttributeValues.push(isValid(val) ? val : NO_VALUE_DETECTED_LABEL); + validatedAttributeValues.push( + isValid(val) ? val : NO_VALUE_DETECTED_LABEL + ); } } diff --git a/src/utils/cells.ts b/src/utils/cells.ts index 4f18ab2b..d040dc94 100644 --- a/src/utils/cells.ts +++ b/src/utils/cells.ts @@ -2,7 +2,7 @@ const CELL_PADDING = 22; const MAX_CELL_SIZE = 500; const CHARACTER_WIDTH = 7; -export function calculateCellWidth(textLength: number){ - const calculatedColumnSize = (textLength * CHARACTER_WIDTH) + (CELL_PADDING * 2); +export function calculateCellWidth(textLength: number) { + const calculatedColumnSize = textLength * CHARACTER_WIDTH + CELL_PADDING * 2; return Math.min(MAX_CELL_SIZE, calculatedColumnSize); -} \ No newline at end of file +} diff --git a/src/utils/checks.ts b/src/utils/checks.ts index 10ad1821..9488568a 100644 --- a/src/utils/checks.ts +++ b/src/utils/checks.ts @@ -1,9 +1,16 @@ -export function isSqliteSchemaOutdated(dbVersion: string, workbenchVersion: string) { - const majorDBVersion = dbVersion.split('.')[0]; - const majorWorkbenchVersion = workbenchVersion.split('.')[0]; - +export function isSqliteSchemaOutdated( + dbVersion: string, + workbenchVersion: string +) { + const majorDBVersion = dbVersion.split(".")[0]; + const majorWorkbenchVersion = workbenchVersion.split(".")[0]; + console.log("Comparing schema versions:", dbVersion, workbenchVersion); - console.log("Comparing major versions:", majorDBVersion, majorWorkbenchVersion); + console.log( + "Comparing major versions:", + majorDBVersion, + majorWorkbenchVersion + ); return majorDBVersion !== majorWorkbenchVersion; -} \ No newline at end of file +} diff --git a/src/utils/files.ts b/src/utils/files.ts index faf62cc9..a9c21f31 100644 --- a/src/utils/files.ts +++ b/src/utils/files.ts @@ -3,17 +3,17 @@ const validityRegex = { sqlite: /\.(sqlite)+$/i, }; -export function getFileType(file: File){ - if(validityRegex.json.test(file.name)) - return "json" - if(validityRegex.sqlite.test(file.name)) - return "sqlite" - return "unknown"; +export function getFileType(file: File) { + if (validityRegex.json.test(file.name)) return "json"; + if (validityRegex.sqlite.test(file.name)) return "sqlite"; + return "unknown"; } export function filterValidFiles(files: FileList) { return Array.from(files) .filter( - (file) => file.name.match(validityRegex.json) || file.name.match(validityRegex.sqlite) + (file) => + file.name.match(validityRegex.json) || + file.name.match(validityRegex.sqlite) ) .filter((file) => file !== null); -} \ No newline at end of file +} diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 450bbafe..5e280b5d 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -21,4 +21,4 @@ export const TimeThrottledLogger = (id: string, ...args: unknown[]) => { console.log(id, ...args); lastLogs[id] = currentTime; } -}; \ No newline at end of file +}; diff --git a/tests/historyStore.test.ts b/tests/historyStore.test.ts index 08a45869..679999e9 100644 --- a/tests/historyStore.test.ts +++ b/tests/historyStore.test.ts @@ -30,7 +30,11 @@ test("AddEntry should add a new history entry", () => { }); describe("AddEntry should update an existing history entry", () => { - const testCases: {description: string,initialEntry: HistoryItem, updatedEntry: HistoryItem}[] = [ + const testCases: { + description: string; + initialEntry: HistoryItem; + updatedEntry: HistoryItem; + }[] = [ { description: "Existing json import", initialEntry: { @@ -42,7 +46,7 @@ describe("AddEntry should update an existing history entry", () => { opened_at: moment().add(1, "days").format(), json_path: "path/to/json", sqlite_path: "path/to/sqlite", - } + }, }, { description: "Existing sqlite import", @@ -53,17 +57,17 @@ describe("AddEntry should update an existing history entry", () => { updatedEntry: { opened_at: moment().add(1, "days").format(), sqlite_path: "path/to/sqlite", - } - } - ] - it.each(testCases)("$description", ({initialEntry, updatedEntry}) => { + }, + }, + ]; + it.each(testCases)("$description", ({ initialEntry, updatedEntry }) => { AddEntry(initialEntry); AddEntry(updatedEntry); - + const history = GetHistory(); expect(history).toHaveLength(1); expect(history[0]).toEqual(updatedEntry); - }) + }); }); test("RemoveEntry should remove an existing history entry", () => { @@ -131,13 +135,13 @@ test("History should be sorted by opened_at in descending order", () => { json_path: "path/to/json/3", sqlite_path: "path/to/sqlite/3", }, - ] + ]; entries.forEach(AddEntry); const history = GetHistory(); // console.log("after add", history); - + for (let i = 0; i < history.length - 1; i++) { const currentEntry = history[i]; const nextEntry = history[i + 1]; diff --git a/tests/pie.test.ts b/tests/pie.test.ts index ccd016eb..420c57ea 100644 --- a/tests/pie.test.ts +++ b/tests/pie.test.ts @@ -1,8 +1,5 @@ import assert from "assert"; -import { - PieFormatDataSamples, - PieLimitDataSamples, -} from "./pie.test.data"; +import { PieFormatDataSamples, PieLimitDataSamples } from "./pie.test.data"; import { formatPieChartData, limitPieChartData } from "../src/utils/pie"; describe("Limit values to be shown in chart", () => { diff --git a/tests/tableviewCellRenderers.test.ts b/tests/tableviewCellRenderers.test.ts index ebd4e9f4..1d209f2e 100644 --- a/tests/tableviewCellRenderers.test.ts +++ b/tests/tableviewCellRenderers.test.ts @@ -1,11 +1,11 @@ import { ALL_COLUMNS } from "../src/pages/TableView/columnDefs"; -describe('Column Definitions', () => { - it('should have same keys as their column IDs and field', () => { +describe("Column Definitions", () => { + it("should have same keys as their column IDs and field", () => { const colDefKeys = Object.keys(ALL_COLUMNS); - const colDefIds = Object.values(ALL_COLUMNS).map(col => col.colId); - const colDefFields = Object.values(ALL_COLUMNS).map(col => col.field); + const colDefIds = Object.values(ALL_COLUMNS).map((col) => col.colId); + const colDefFields = Object.values(ALL_COLUMNS).map((col) => col.field); expect(colDefIds).toEqual(colDefKeys); expect(colDefFields).toEqual(colDefKeys); }); -}); \ No newline at end of file +}); diff --git a/tests/test-scans/email_url_info/email_url_info.json b/tests/test-scans/email_url_info/email_url_info.json index eb0d1cc4..ee7fecb2 100644 --- a/tests/test-scans/email_url_info/email_url_info.json +++ b/tests/test-scans/email_url_info/email_url_info.json @@ -154,4 +154,4 @@ "scan_errors": [] } ] -} \ No newline at end of file +} diff --git a/tests/test-scans/fileTree/empty.json b/tests/test-scans/fileTree/empty.json index 9e26dfee..0967ef42 100644 --- a/tests/test-scans/fileTree/empty.json +++ b/tests/test-scans/fileTree/empty.json @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/tests/test-scans/fileTree/sample.json b/tests/test-scans/fileTree/sample.json index 489c4423..bdfe29a7 100644 --- a/tests/test-scans/fileTree/sample.json +++ b/tests/test-scans/fileTree/sample.json @@ -37,4 +37,4 @@ "type": "file" } ] -} \ No newline at end of file +} diff --git a/tests/test-scans/licenses/withLicenses.json b/tests/test-scans/licenses/withLicenses.json index 466324b2..3ffce517 100644 --- a/tests/test-scans/licenses/withLicenses.json +++ b/tests/test-scans/licenses/withLicenses.json @@ -111,14 +111,9 @@ "is_unknown": false, "is_generic": false, "spdx_license_key": "Apache-2.0", - "other_spdx_license_keys": [ - "LicenseRef-Apache", - "LicenseRef-Apache-2.0" - ], + "other_spdx_license_keys": ["LicenseRef-Apache", "LicenseRef-Apache-2.0"], "osi_license_key": "Apache-2.0", - "text_urls": [ - "http://www.apache.org/licenses/LICENSE-2.0" - ], + "text_urls": ["http://www.apache.org/licenses/LICENSE-2.0"], "osi_url": "http://opensource.org/licenses/apache2.0.php", "faq_url": "http://www.apache.org/foundation/licence-FAQ.html", "other_urls": [ @@ -156,11 +151,7 @@ "is_unknown": false, "is_generic": false, "spdx_license_key": "GPL-2.0-only", - "other_spdx_license_keys": [ - "GPL-2.0", - "GPL 2.0", - "LicenseRef-GPL-2.0" - ], + "other_spdx_license_keys": ["GPL-2.0", "GPL 2.0", "LicenseRef-GPL-2.0"], "osi_license_key": "GPL-2.0", "text_urls": [ "http://www.gnu.org/licenses/gpl-2.0.txt", @@ -284,9 +275,7 @@ "ignorable_copyrights": [], "ignorable_holders": [], "ignorable_authors": [], - "ignorable_urls": [ - "http://www.apache.org/licenses/LICENSE-2.0.html" - ], + "ignorable_urls": ["http://www.apache.org/licenses/LICENSE-2.0.html"], "ignorable_emails": [], "text": "http://www.apache.org/licenses/LICENSE-2.0.html" }, @@ -705,13 +694,7 @@ "url": "https://github.com/Reactive-Extensions/RxJS/blob/master/authors.txt" } ], - "keywords": [ - "React", - "Reactive", - "Events", - "Rx", - "RxJS" - ], + "keywords": ["React", "Reactive", "Events", "Rx", "RxJS"], "homepage_url": "https://github.com/Reactive-Extensions/RxJS", "download_url": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", "bug_tracking_url": "https://github.com/Reactive-Extensions/RxJS/issues", diff --git a/tests/test-scans/packages_dependencies/withPackagesAndDeps.json b/tests/test-scans/packages_dependencies/withPackagesAndDeps.json index 9cb6df09..eb77c4f9 100644 --- a/tests/test-scans/packages_dependencies/withPackagesAndDeps.json +++ b/tests/test-scans/packages_dependencies/withPackagesAndDeps.json @@ -91,12 +91,8 @@ "repository_download_url": null, "api_data_url": null, "package_uid": "pkg:about/scancode-toolkit?uuid=3b5a9865-8101-430a-ac7c-9f184631b803", - "datafile_paths": [ - "python-sample-trimmed/scancode-toolkit.ABOUT" - ], - "datasource_ids": [ - "about_file" - ], + "datafile_paths": ["python-sample-trimmed/scancode-toolkit.ABOUT"], + "datasource_ids": ["about_file"], "purl": "pkg:about/scancode-toolkit" } ], @@ -460,4 +456,4 @@ "scan_errors": [] } ] -} \ No newline at end of file +} diff --git a/tests/test-scans/sanity/minimal.json b/tests/test-scans/sanity/minimal.json index 27dd0b5b..d804f619 100644 --- a/tests/test-scans/sanity/minimal.json +++ b/tests/test-scans/sanity/minimal.json @@ -10,4 +10,4 @@ "path": "manifests/FirebaseAnalytics.podspec.json" } ] -} \ No newline at end of file +} diff --git a/tests/test-scans/scan-errors/withErrors.json b/tests/test-scans/scan-errors/withErrors.json index 20feb09d..72a494f2 100644 --- a/tests/test-scans/scan-errors/withErrors.json +++ b/tests/test-scans/scan-errors/withErrors.json @@ -11,10 +11,7 @@ "start_timestamp": "2019-04-20T035642.140687", "end_timestamp": "2019-04-20T035653.827335", "message": null, - "errors": [ - "Path: samples/README", - "Path: samples/EULA" - ] + "errors": ["Path: samples/README", "Path: samples/EULA"] } ], "files": [