Skip to content

Commit

Permalink
Updated publish comments & code formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Omkar Phansopkar <omkarphansopkar@gmail.com>
  • Loading branch information
OmkarPh committed Aug 28, 2023
1 parent 2ebe01b commit 989e44d
Show file tree
Hide file tree
Showing 23 changed files with 120 additions and 135 deletions.
6 changes: 3 additions & 3 deletions archive_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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 !!!")
41 changes: 24 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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();
}
Expand Down Expand Up @@ -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(
Expand All @@ -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);
});
Expand All @@ -87,28 +94,28 @@ 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);
}
});

// @TOIMPROVE
// 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();
}
});
});
31 changes: 16 additions & 15 deletions src/pages/PageNotFound.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className='text-center'>
<div className='display-4'>
<br/><br/>
4 0 4
<div className="text-center">
<div className="display-4">
<br />
<br />4 0 4
</div>
<br/>
<h3 className='display-2'>
¯\_(ツ)_/¯
<br/><br/>
<br />
<h3 className="display-2">
¯\_(ツ)_/¯
<br />
<br />
</h3>
<h3>
Don't venture places,
<Link to={ROUTES.HOME} className='m-2'>
<Link to={ROUTES.HOME} className="m-2">
Go back Home
</Link>
</h3>
</div>
)
}
);
};

export default PageNotFound
export default PageNotFound;
12 changes: 6 additions & 6 deletions src/reactApp.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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(<App />);
} else {
console.log("Container for react app not found :(", container);
}
}
}
13 changes: 6 additions & 7 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, () => {
Expand All @@ -45,5 +45,4 @@ ipcRenderer.on(GENERAL_ACTIONS.ZOOM_RESET, () => {
webFrame.setZoomLevel(0);
});


renderReactApp();
renderReactApp();
10 changes: 2 additions & 8 deletions src/services/historyStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/services/models/scanError.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Model } from "sequelize";
/*
#
# Copyright (c) 2018 nexB Inc. and others. All rights reserved.
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/services/models/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Model } from "sequelize";
/*
#
# Copyright (c) 2018 nexB Inc. and others. All rights reserved.
Expand All @@ -15,7 +14,7 @@ import { Model } from "sequelize";
#
*/

import { Sequelize, DataTypes } from "sequelize";
import { Sequelize, DataTypes, Model } from "sequelize";

export interface UrlAttributes {
id: number;
Expand Down
4 changes: 3 additions & 1 deletion src/utils/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
19 changes: 13 additions & 6 deletions src/utils/checks.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
16 changes: 8 additions & 8 deletions src/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export const TimeThrottledLogger = (id: string, ...args: unknown[]) => {
console.log(id, ...args);
lastLogs[id] = currentTime;
}
};
};
Loading

0 comments on commit 989e44d

Please sign in to comment.