Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/split more libs #558

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 111 additions & 10 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["projects/app-state/**/*.ts"]
"lintFilePatterns": [
"projects/app-state/**/*.ts"
]
}
}
}
Expand Down Expand Up @@ -298,8 +300,12 @@
"polyfills": "src/polyfills-test.ts",
"tsConfig": "tsconfig.spec.json",
"scripts": [],
"styles": ["src/styles.scss"],
"assets": ["src/assets"],
"styles": [
"src/styles.scss"
],
"assets": [
"src/assets"
],
"customWebpackConfig": {
"path": "./angular.webpack.cjs",
"target": "electron-renderer"
Expand Down Expand Up @@ -364,7 +370,9 @@
"architect": {
"build": {
"builder": "@nrwl/node:build",
"outputs": ["{options.outputPath}"],
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/projects/server",
"main": "server/server.ts",
Expand All @@ -382,14 +390,20 @@
},
"lint": {
"builder": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": ["server/**/*.ts"]
"lintFilePatterns": [
"server/**/*.ts"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/projects/server"],
"outputs": [
"coverage/projects/server"
],
"options": {
"jestConfig": "projects/server/jest.config.js",
"passWithNoTests": true
Expand Down Expand Up @@ -530,7 +544,9 @@
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["projects/utils/**/*.ts"]
"lintFilePatterns": [
"projects/utils/**/*.ts"
]
}
}
}
Expand Down Expand Up @@ -564,7 +580,9 @@
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/projects/recipe-ui"],
"outputs": [
"coverage/projects/recipe-ui"
],
"options": {
"jestConfig": "projects/recipe-ui/jest.config.js",
"passWithNoTests": true
Expand Down Expand Up @@ -601,13 +619,93 @@
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/projects/recipe-core"],
"outputs": [
"coverage/projects/recipe-core"
],
"options": {
"jestConfig": "projects/recipe-core/jest.config.js",
"passWithNoTests": true
}
}
}
},
"server-common": {
"projectType": "library",
"root": "projects/server-common",
"sourceRoot": "projects/server-common/src",
"prefix": "memebox",
"architect": {
"build": {
"builder": "@nrwl/angular:ng-packagr-lite",
"options": {
"tsConfig": "projects/server-common/tsconfig.lib.json",
"project": "projects/server-common/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/server-common/tsconfig.lib.prod.json"
}
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/server-common/src/**/*.ts",
"projects/server-common/src/**/*.html"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": [
"coverage/projects/server-common"
],
"options": {
"jestConfig": "projects/server-common/jest.config.js",
"passWithNoTests": true
}
}
}
},
"twitch-api": {
"projectType": "library",
"root": "projects/twitch-api",
"sourceRoot": "projects/twitch-api/src",
"prefix": "memebox",
"architect": {
"build": {
"builder": "@nrwl/angular:ng-packagr-lite",
"options": {
"tsConfig": "projects/twitch-api/tsconfig.lib.json",
"project": "projects/twitch-api/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/twitch-api/tsconfig.lib.prod.json"
}
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/twitch-api/src/**/*.ts",
"projects/twitch-api/src/**/*.html"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": [
"coverage/projects/twitch-api"
],
"options": {
"jestConfig": "projects/twitch-api/jest.config.js",
"passWithNoTests": true
}
}
}
}
},
"cli": {
Expand All @@ -630,6 +728,9 @@
"prefix": "app",
"style": "scss",
"skipTests": true
},
"@nrwl/angular:component": {
"style": "scss"
}
}
}
70 changes: 34 additions & 36 deletions electron-shell.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as electron from 'electron';
import { app, BrowserWindow, dialog, ipcMain, Menu, MessageBoxSyncOptions, nativeImage, shell, Tray } from 'electron';
import * as os from 'os';
import {app, BrowserWindow, dialog, ipcMain, Menu, MessageBoxSyncOptions, nativeImage, shell, Tray} from 'electron';
import * as path from 'path';
import {join} from 'path';
import {NEW_CONFIG_PATH} from "./server/path.utils";
import {bootstrapTsED} from "./server/server.bootstrap";
import {getAppRootPath, getElectronPath, isInElectron} from "./server/file.utilts";
import { join } from 'path';
import { NEW_CONFIG_PATH } from "@memebox/server-common";
import { bootstrapTsED } from "./server/server.bootstrap";
import { getAppRootPath, getElectronPath, isInElectron } from "./server/file.utilts";

// TODO Refactor / Abstract the electron usages

Expand Down Expand Up @@ -42,14 +42,14 @@ const openExternalLinksInOSBrowser = (event, url) => {
const addPresentationIcons = (
target: electron.NativeImage,
source: electron.NativeImage,
baseSize: number,
baseSize: number
): void => {
[1, 1.25, 1.5, 2, 3].forEach(scale => {
target.addRepresentation({
scaleFactor: scale,
width: baseSize * scale,
height: baseSize * scale,
buffer: source.resize({ width: baseSize * scale, height: baseSize * scale }).toBitmap(),
buffer: source.resize({width: baseSize * scale, height: baseSize * scale}).toBitmap()
});
});
};
Expand Down Expand Up @@ -77,11 +77,10 @@ const createTrayIcon = (appRootPath: string): electron.NativeImage => {
};

var initPath = path.join(NEW_CONFIG_PATH, "init.json");
var data = { bounds: { width: 800, height: 600 }};
var data = {bounds: {width: 800, height: 600}};
try {
data = JSON.parse(fs.readFileSync(initPath, 'utf8'));
}
catch(e) {
} catch (e) {
}

let alreadyAllowedToBeHidden = false;
Expand All @@ -91,8 +90,8 @@ let tray;
* Create the application's tray icon in the system menu bar, setting up the platform dependent icon
* as well as menu items and further tray information.
*/
function createTray () {
function toggle () {
function createTray() {
function toggle() {
if (win !== null) {
win.close();
} else {
Expand Down Expand Up @@ -126,7 +125,7 @@ function createTray () {
var trayMenu = Menu.buildFromTemplate(template);
tray.setContextMenu(trayMenu);
tray.setToolTip('Meme-Box');
tray.addListener('double-click', (event: KeyboardEvent) => {
tray.addListener('double-click', (event: KeyboardEvent) => {
alreadyAllowedToBeHidden = true;
toggle();
});
Expand All @@ -137,7 +136,7 @@ function createWindow(): BrowserWindow {

const electronPath = getElectronPath();

console.info({ isInElectron, __dirname });
console.info({isInElectron, __dirname});

// Create the browser window.
win = new BrowserWindow({
Expand All @@ -148,8 +147,8 @@ function createWindow(): BrowserWindow {
// protect against prototype pollution
contextIsolation: true,
// Preload script
preload: path.join(electronPath, 'preload.js'),
},
preload: path.join(electronPath, 'preload.js')
}
});

portPromise.then((port) => {
Expand All @@ -162,35 +161,35 @@ function createWindow(): BrowserWindow {
});
win.loadURL(`http://localhost:4200?port=${port}`);
} else {
win.loadURL( `http://localhost:${port}`);
win.loadURL(`http://localhost:${port}`);
}
});

win.on("close", function(e) {
win.on("close", function (e) {
var data = {
bounds: win.getBounds()
};
fs.writeFileSync(initPath, JSON.stringify(data));

// ask it hide or close if its triggered from the Electron Window
if (!alreadyAllowedToBeHidden) {
const result = dialog.showMessageBoxSync(win, {
message: 'Hide to tray or quit?',
buttons: [
'To Tray',
'Quit Meme-Box'
]
} as MessageBoxSyncOptions);

if (result === 0) {
// do nothing :)
alreadyAllowedToBeHidden = true;
}
if (!alreadyAllowedToBeHidden) {
const result = dialog.showMessageBoxSync(win, {
message: 'Hide to tray or quit?',
buttons: [
'To Tray',
'Quit Meme-Box'
]
} as MessageBoxSyncOptions);

if (result === 0) {
// do nothing :)
alreadyAllowedToBeHidden = true;
}

if (result === 1) {
app.quit();
if (result === 1) {
app.quit();
}
}
}
});

const ipcSelectDirEvent = async (event) => {
Expand All @@ -199,7 +198,7 @@ function createWindow(): BrowserWindow {
})
console.log('directories selected', result.filePaths);

const arg = result.filePaths?.[0] ?? '';
const arg = result.filePaths?.[0] ?? '';

event.sender.send('dir-selected', arg);
};
Expand All @@ -224,7 +223,6 @@ function createWindow(): BrowserWindow {
}



try {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
Expand Down
Loading