@@ -320,7 +330,8 @@
- + + Rocket Ship @@ -332,7 +343,8 @@ {{ title }} app is running! - + + Rocket Ship Smoke @@ -345,24 +357,24 @@
- Learn Angular - - CLI Documentation - - Angular Blog + + + + + Angular DevTools @@ -375,41 +387,35 @@
-
- - +
- -
- + +
- -
- + +
+ -
+
+ -
+
+ -
+
+
@@ -419,7 +425,7 @@
ng add @angular/pwa
ng add _____
ng test
-
ng build --prod
+
ng build
@@ -435,7 +441,8 @@ - + + Angular CLI Logo @@ -446,57 +453,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Meetup Logo - - - - - - - - - - - - - + + + Discord Logo + +
@@ -515,7 +483,8 @@ - + + Gray Clouds Background @@ -529,6 +498,4 @@ - - - \ No newline at end of file + diff --git a/src/angular/app/app.component.scss b/workspaces/angular-app/src/app/app.component.scss similarity index 100% rename from src/angular/app/app.component.scss rename to workspaces/angular-app/src/app/app.component.scss diff --git a/src/angular/app/app.component.spec.ts b/workspaces/angular-app/src/app/app.component.spec.ts similarity index 62% rename from src/angular/app/app.component.spec.ts rename to workspaces/angular-app/src/app/app.component.spec.ts index 61ef744..f0ed53e 100644 --- a/src/angular/app/app.component.spec.ts +++ b/workspaces/angular-app/src/app/app.component.spec.ts @@ -1,10 +1,10 @@ -import { TestBed, async } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { AppComponent } from './app.component'; describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ + beforeEach(async () => { + await TestBed.configureTestingModule({ imports: [ RouterTestingModule ], @@ -12,7 +12,7 @@ describe('AppComponent', () => { AppComponent ], }).compileComponents(); - })); + }); it('should create the app', () => { const fixture = TestBed.createComponent(AppComponent); @@ -20,16 +20,16 @@ describe('AppComponent', () => { expect(app).toBeTruthy(); }); - it(`should have as title 'electron-angular-quick-start'`, () => { + it(`should have as title 'angular-app'`, () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; - expect(app.title).toEqual('electron-angular-quick-start'); + expect(app.title).toEqual('angular-app'); }); it('should render title', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); - const compiled = fixture.nativeElement; - expect(compiled.querySelector('.content span').textContent).toContain('electron-angular-quick-start app is running!'); + const compiled = fixture.nativeElement as HTMLElement; + expect(compiled.querySelector('.content span')?.textContent).toContain('angular-app app is running!'); }); }); diff --git a/src/angular/app/app.component.ts b/workspaces/angular-app/src/app/app.component.ts similarity index 83% rename from src/angular/app/app.component.ts rename to workspaces/angular-app/src/app/app.component.ts index e941f67..bd35f08 100644 --- a/src/angular/app/app.component.ts +++ b/workspaces/angular-app/src/app/app.component.ts @@ -3,7 +3,7 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'] + styleUrls: ['./app.component.scss'], }) export class AppComponent { title = 'electron-angular-quick-start'; diff --git a/src/angular/app/app.module.ts b/workspaces/angular-app/src/app/app.module.ts similarity index 90% rename from src/angular/app/app.module.ts rename to workspaces/angular-app/src/app/app.module.ts index 3d6a1d1..1ccb298 100644 --- a/src/angular/app/app.module.ts +++ b/workspaces/angular-app/src/app/app.module.ts @@ -2,7 +2,6 @@ import { HttpClient, HttpClientModule } from '@angular/common/http'; import { NgModule } from '@angular/core'; import { ReactiveFormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; -import { RouterModule } from '@angular/router'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { AppRoutingModule } from './app-routing.module'; @@ -29,7 +28,6 @@ export function HttpLoaderFactory(http: HttpClient) { deps: [HttpClient], }, }), - RouterModule.forRoot([{ path: '', component: MutiplesComponent }]), ], providers: [], bootstrap: [AppComponent], diff --git a/src/angular/app/components/mutiples/mutiples.component.html b/workspaces/angular-app/src/app/components/mutiples/mutiples.component.html similarity index 100% rename from src/angular/app/components/mutiples/mutiples.component.html rename to workspaces/angular-app/src/app/components/mutiples/mutiples.component.html diff --git a/src/angular/app/components/mutiples/mutiples.component.scss b/workspaces/angular-app/src/app/components/mutiples/mutiples.component.scss similarity index 100% rename from src/angular/app/components/mutiples/mutiples.component.scss rename to workspaces/angular-app/src/app/components/mutiples/mutiples.component.scss diff --git a/src/angular/app/components/mutiples/mutiples.component.spec.ts b/workspaces/angular-app/src/app/components/mutiples/mutiples.component.spec.ts similarity index 82% rename from src/angular/app/components/mutiples/mutiples.component.spec.ts rename to workspaces/angular-app/src/app/components/mutiples/mutiples.component.spec.ts index a5b2e74..2785906 100644 --- a/src/angular/app/components/mutiples/mutiples.component.spec.ts +++ b/workspaces/angular-app/src/app/components/mutiples/mutiples.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { MutiplesComponent } from './mutiples.component'; @@ -6,7 +6,7 @@ describe('MutiplesComponent', () => { let component: MutiplesComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ MutiplesComponent ] }) diff --git a/src/angular/app/components/mutiples/mutiples.component.ts b/workspaces/angular-app/src/app/components/mutiples/mutiples.component.ts similarity index 89% rename from src/angular/app/components/mutiples/mutiples.component.ts rename to workspaces/angular-app/src/app/components/mutiples/mutiples.component.ts index 7ac11a5..2e2dc49 100644 --- a/src/angular/app/components/mutiples/mutiples.component.ts +++ b/workspaces/angular-app/src/app/components/mutiples/mutiples.component.ts @@ -1,8 +1,8 @@ import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { TranslateService } from '@ngx-translate/core'; -import { ElectronIpcService } from 'angular/app/services/electron-ipc.service'; -import { WindowApiConst } from 'shared'; +import { WindowApiConst } from 'shared-lib'; +import { ElectronIpcService } from '../../services/electron-ipc.service'; @Component({ selector: 'app-mutiples', @@ -23,7 +23,7 @@ export class MutiplesComponent implements OnInit { ngOnInit(): void { // Specifying what to do with received data from main process - this.electronIpc.receive(WindowApiConst.MULTIPLES_OUTPUT, (...data) => { + this.electronIpc.receive(WindowApiConst.MULTIPLES_OUTPUT, (...data: []) => { // Update current data this.multiples = data; }); diff --git a/src/angular/app/services/electron-ipc.service.spec.ts b/workspaces/angular-app/src/app/services/electron-ipc.service.spec.ts similarity index 100% rename from src/angular/app/services/electron-ipc.service.spec.ts rename to workspaces/angular-app/src/app/services/electron-ipc.service.spec.ts diff --git a/src/angular/app/services/electron-ipc.service.ts b/workspaces/angular-app/src/app/services/electron-ipc.service.ts similarity index 84% rename from src/angular/app/services/electron-ipc.service.ts rename to workspaces/angular-app/src/app/services/electron-ipc.service.ts index d1d6fc9..fe24f87 100644 --- a/src/angular/app/services/electron-ipc.service.ts +++ b/workspaces/angular-app/src/app/services/electron-ipc.service.ts @@ -1,11 +1,11 @@ import { Injectable, NgZone } from '@angular/core'; -import { WindowApi } from 'shared'; +import { WindowApi } from 'shared-lib'; @Injectable({ providedIn: 'root', }) export class ElectronIpcService { - private _api: WindowApi; + private _api!: WindowApi; constructor(private zone: NgZone) { if (window && (window as any).api) { @@ -20,7 +20,7 @@ export class ElectronIpcService { } } - public receive(channel: string, func: (...data) => void): void { + public receive(channel: string, func: (...data: any) => void): void { if (this._api) { this._api.receive(channel, (...data) => { console.log(`Received from main process channel [${channel}]`, data); @@ -35,7 +35,7 @@ export class ElectronIpcService { } } - public send(channel: string, ...data): void { + public send(channel: string, ...data: any): void { if (this._api) { console.log(`Sending to main process channel [${channel}]`, data); this._api.send(channel, ...data); diff --git a/src/angular/assets/.gitkeep b/workspaces/angular-app/src/assets/.gitkeep similarity index 100% rename from src/angular/assets/.gitkeep rename to workspaces/angular-app/src/assets/.gitkeep diff --git a/src/angular/assets/i18n/en.json b/workspaces/angular-app/src/assets/i18n/en.json similarity index 100% rename from src/angular/assets/i18n/en.json rename to workspaces/angular-app/src/assets/i18n/en.json diff --git a/src/angular/assets/i18n/fr.json b/workspaces/angular-app/src/assets/i18n/fr.json similarity index 100% rename from src/angular/assets/i18n/fr.json rename to workspaces/angular-app/src/assets/i18n/fr.json diff --git a/src/angular/environments/environment.prod.ts b/workspaces/angular-app/src/environments/environment.prod.ts similarity index 100% rename from src/angular/environments/environment.prod.ts rename to workspaces/angular-app/src/environments/environment.prod.ts diff --git a/src/angular/environments/environment.ts b/workspaces/angular-app/src/environments/environment.ts similarity index 78% rename from src/angular/environments/environment.ts rename to workspaces/angular-app/src/environments/environment.ts index 7b4f817..f56ff47 100644 --- a/src/angular/environments/environment.ts +++ b/workspaces/angular-app/src/environments/environment.ts @@ -1,5 +1,5 @@ // This file can be replaced during build by using the `fileReplacements` array. -// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. +// `ng build` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. export const environment = { @@ -13,4 +13,4 @@ export const environment = { * This import should be commented out in production mode because it will have a negative impact * on performance if an error is thrown. */ -// import 'zone.js/dist/zone-error'; // Included with Angular CLI. +// import 'zone.js/plugins/zone-error'; // Included with Angular CLI. diff --git a/src/angular/favicon.ico b/workspaces/angular-app/src/favicon.ico similarity index 100% rename from src/angular/favicon.ico rename to workspaces/angular-app/src/favicon.ico diff --git a/src/angular/index.html b/workspaces/angular-app/src/index.html similarity index 79% rename from src/angular/index.html rename to workspaces/angular-app/src/index.html index a225e49..a8dd21e 100644 --- a/src/angular/index.html +++ b/workspaces/angular-app/src/index.html @@ -4,8 +4,8 @@ ElectronAngularQuickStart - + diff --git a/src/angular/main.ts b/workspaces/angular-app/src/main.ts similarity index 100% rename from src/angular/main.ts rename to workspaces/angular-app/src/main.ts diff --git a/src/angular/polyfills.ts b/workspaces/angular-app/src/polyfills.ts similarity index 95% rename from src/angular/polyfills.ts rename to workspaces/angular-app/src/polyfills.ts index 03711e5..373f538 100644 --- a/src/angular/polyfills.ts +++ b/workspaces/angular-app/src/polyfills.ts @@ -18,7 +18,9 @@ * BROWSER POLYFILLS */ -/** IE10 and IE11 requires the following for NgClass support on SVG elements */ +/** + * IE11 requires the following for NgClass support on SVG elements + */ // import 'classlist.js'; // Run `npm install --save classlist.js`. /** @@ -55,7 +57,7 @@ /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ -import 'zone.js/dist/zone'; // Included with Angular CLI. +import 'zone.js'; // Included with Angular CLI. /*************************************************************************************************** diff --git a/src/angular/styles.scss b/workspaces/angular-app/src/styles.scss similarity index 100% rename from src/angular/styles.scss rename to workspaces/angular-app/src/styles.scss diff --git a/src/angular/test.ts b/workspaces/angular-app/src/test.ts similarity index 95% rename from src/angular/test.ts rename to workspaces/angular-app/src/test.ts index 50193eb..2042356 100644 --- a/src/angular/test.ts +++ b/workspaces/angular-app/src/test.ts @@ -1,6 +1,6 @@ // This file is required by karma.conf.js and loads recursively all the .spec and framework files -import 'zone.js/dist/zone-testing'; +import 'zone.js/testing'; import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, diff --git a/workspaces/angular-app/tsconfig.app.json b/workspaces/angular-app/tsconfig.app.json new file mode 100644 index 0000000..82d91dc --- /dev/null +++ b/workspaces/angular-app/tsconfig.app.json @@ -0,0 +1,15 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/workspaces/angular-app/tsconfig.json b/workspaces/angular-app/tsconfig.json new file mode 100644 index 0000000..3fc1c86 --- /dev/null +++ b/workspaces/angular-app/tsconfig.json @@ -0,0 +1,31 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "moduleResolution": "node", + "importHelpers": true, + "target": "es2017", + "module": "es2020", + "lib": [ + "es2018", + "dom" + ] + }, + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + }, + "references": [{ "path": "../shared-lib" }] +} diff --git a/workspaces/angular-app/tsconfig.spec.json b/workspaces/angular-app/tsconfig.spec.json new file mode 100644 index 0000000..092345b --- /dev/null +++ b/workspaces/angular-app/tsconfig.spec.json @@ -0,0 +1,18 @@ +/* To learn more about this file see: https://angular.io/config/tsconfig. */ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/spec", + "types": [ + "jasmine" + ] + }, + "files": [ + "src/test.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/src/static/config.json b/workspaces/electron-app/main/assets/config.json similarity index 96% rename from src/static/config.json rename to workspaces/electron-app/main/assets/config.json index efac02a..da94b28 100644 --- a/src/static/config.json +++ b/workspaces/electron-app/main/assets/config.json @@ -24,6 +24,6 @@ "mainLogFile": "main.log", "mainLogLevel": "error", "isIconAvailable": false, - "isOpenDevTools": false + "isOpenDevTools": true } } diff --git a/src/static/icons/icon.png b/workspaces/electron-app/main/assets/icons/icon.png similarity index 100% rename from src/static/icons/icon.png rename to workspaces/electron-app/main/assets/icons/icon.png diff --git a/src/electron/components/app.ts b/workspaces/electron-app/main/components/app.ts similarity index 100% rename from src/electron/components/app.ts rename to workspaces/electron-app/main/components/app.ts diff --git a/src/electron/components/window.ts b/workspaces/electron-app/main/components/window.ts similarity index 76% rename from src/electron/components/window.ts rename to workspaces/electron-app/main/components/window.ts index 7d30d21..7eb7c47 100644 --- a/src/electron/components/window.ts +++ b/workspaces/electron-app/main/components/window.ts @@ -1,12 +1,12 @@ -import { app, BrowserWindow, ipcMain, nativeImage } from 'electron'; -import * as path from 'path'; -import * as url from 'url'; -import { AbstractService } from '../services/abstract-service'; -import { MultiplesService } from '../services/multiples-service'; -import { Logger } from '../utils/logger'; +import { app, BrowserWindow, ipcMain, nativeImage } from "electron"; +import * as path from "path"; +import * as url from "url"; +import { AbstractService } from "../services/abstract-service"; +import { MultiplesService } from "../services/multiples-service"; +import { Logger } from "../utils/logger"; declare const global: any; -declare const __static: string; +declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string; export class Window { private _window: BrowserWindow | any; @@ -21,8 +21,9 @@ export class Window { this._window = new BrowserWindow({ width: 800, height: 600, - backgroundColor: '#FFFFFF', - icon: this.loadIcon(), + backgroundColor: "#FFFFFF", + // FIXME + // icon: this.loadIcon(), webPreferences: { // Default behavior in Electron since 5, that // limits the powers granted to remote content @@ -38,7 +39,7 @@ export class Window { // except in e2e test when that access is required by Spectron enableRemoteModule: global.gConfig.isEnableRemoteModule, // Use a preload script to enhance security - preload: path.join(app.getAppPath(), 'preload.js'), + preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, }, }); } @@ -46,11 +47,11 @@ export class Window { private loadIcon(): Electron.NativeImage { let iconObj = null; if (global.gConfig.isIconAvailable) { - const iconPath = path.join(__static, 'icons/icon.png'); - Logger.debug('Icon Path', iconPath); + const iconPath = path.join(__dirname, "icons/icon.png"); + Logger.debug("Icon Path", iconPath); iconObj = nativeImage.createFromPath(iconPath); // Change dock icon on MacOS - if (iconObj && process.platform === 'darwin') { + if (iconObj && process.platform === "darwin") { app.dock.setIcon(iconObj); } } @@ -58,14 +59,14 @@ export class Window { } private loadRenderer(): void { - if (global.gConfig.config_id === 'development') { + if (global.gConfig.config_id === "development") { // Dev mode, take advantage of the live reload by loading local URL this.window.loadURL(`http://localhost:4200`); } else { // Else mode, we simply load angular bundle const indexPath = url.format({ - pathname: path.join(__dirname, `index.html`), - protocol: 'file:', + pathname: path.join(__dirname, `../renderer/angular_window/index.html`), + protocol: "file:", slashes: true, }); this.window.loadURL(indexPath); @@ -76,7 +77,7 @@ export class Window { } // When the window is closed` - this._window.on('closed', () => { + this._window.on("closed", () => { // Remove IPC Main listeners ipcMain.removeAllListeners(); // Delete current reference @@ -86,7 +87,7 @@ export class Window { private openDevTools(): void { this._window.webContents.openDevTools(); - this._window.webContents.on('devtools-opened', () => { + this._window.webContents.on("devtools-opened", () => { this._window.focus(); setImmediate(() => { this._window.focus(); diff --git a/workspaces/electron-app/main/index.ts b/workspaces/electron-app/main/index.ts new file mode 100644 index 0000000..cdc2219 --- /dev/null +++ b/workspaces/electron-app/main/index.ts @@ -0,0 +1,19 @@ +import * as fs from "fs-extra"; +import * as _ from "lodash"; +import * as path from "path"; +import { App } from "./components/app"; + +declare const global: any; + +// Load config +const currentEnv = process.env.X_NODE_ENV || process.env.NODE_ENV; +const appConfig = + currentEnv === "development" + ? fs.readJsonSync(path.join(__dirname, "config.json")) + : fs.readJsonSync(path.join(__dirname, "config.json")); +const defaultConf = appConfig.development; +const currentConf = appConfig[currentEnv]; +global.gConfig = _.merge(defaultConf, currentConf); + +// Launch app +App.launch(); diff --git a/src/electron/services/abstract-service.ts b/workspaces/electron-app/main/services/abstract-service.ts similarity index 100% rename from src/electron/services/abstract-service.ts rename to workspaces/electron-app/main/services/abstract-service.ts diff --git a/src/electron/services/multiples-service.ts b/workspaces/electron-app/main/services/multiples-service.ts similarity index 80% rename from src/electron/services/multiples-service.ts rename to workspaces/electron-app/main/services/multiples-service.ts index 09d8b48..c1e1356 100644 --- a/src/electron/services/multiples-service.ts +++ b/workspaces/electron-app/main/services/multiples-service.ts @@ -1,5 +1,5 @@ -import { WindowApiConst } from 'shared'; -import { AbstractService } from './abstract-service'; +import { WindowApiConst } from "shared-lib"; +import { AbstractService } from "./abstract-service"; export class MultiplesService extends AbstractService { receptionChannel(): string { diff --git a/src/electron/utils/logger.ts b/workspaces/electron-app/main/utils/logger.ts similarity index 88% rename from src/electron/utils/logger.ts rename to workspaces/electron-app/main/utils/logger.ts index 0cae265..02353ef 100644 --- a/src/electron/utils/logger.ts +++ b/workspaces/electron-app/main/utils/logger.ts @@ -1,7 +1,7 @@ -import { app } from 'electron'; -import * as os from 'os'; -import * as path from 'path'; -import * as winston from 'winston'; +import { app } from "electron"; +import * as os from "os"; +import * as path from "path"; +import * as winston from "winston"; declare const global: any; @@ -52,9 +52,9 @@ export class Logger { private constructor() { this._logger = winston.createLogger({ - level: 'debug', + level: "debug", format: winston.format.json(), - defaultMeta: { service: 'user-service' }, + defaultMeta: { service: "user-service" }, transports: [ new winston.transports.File({ filename: this.getLogFilename(), @@ -69,10 +69,10 @@ export class Logger { // If we're not in production then log also to the `console` with the format: // `${info.timestamp} ${info.level}: ${info.message} JSON.stringify({ ...rest }) ` - if (global.gConfig.config_id === 'development') { + if (global.gConfig.config_id === "development") { this._logger.add( new winston.transports.Console({ - stderrLevels: ['error', 'warn'], + stderrLevels: ["error", "warn"], format: winston.format.combine( winston.format.timestamp(), this.consoleFormat @@ -88,13 +88,13 @@ export class Logger { */ private getLogFilename() { let filename = global.gConfig.mainLogFile; - if (global.gConfig.config_id === 'production') { + if (global.gConfig.config_id === "production") { const appName = app.getName(); - if (process.platform == 'linux') { + if (process.platform == "linux") { filename = `.config/${appName}/${filename}`; - } else if (process.platform == 'darwin') { + } else if (process.platform == "darwin") { filename = `Library/Logs/${appName}/${filename}`; - } else if (process.platform == 'win32') { + } else if (process.platform == "win32") { filename = `AppData\\Roaming\\${appName}\\${filename}`; } } diff --git a/workspaces/electron-app/renderer/README.md b/workspaces/electron-app/renderer/README.md new file mode 100644 index 0000000..175da21 --- /dev/null +++ b/workspaces/electron-app/renderer/README.md @@ -0,0 +1,3 @@ +preload.ts is the only file that matters in this directory. + +The others files are not needed at all, but they are required for electron forge webpack config. diff --git a/workspaces/electron-app/renderer/index.css b/workspaces/electron-app/renderer/index.css new file mode 100644 index 0000000..22fd849 --- /dev/null +++ b/workspaces/electron-app/renderer/index.css @@ -0,0 +1,6 @@ +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; + margin: auto; + max-width: 38rem; + padding: 2rem; +} diff --git a/workspaces/electron-app/renderer/index.html b/workspaces/electron-app/renderer/index.html new file mode 100644 index 0000000..5bbb695 --- /dev/null +++ b/workspaces/electron-app/renderer/index.html @@ -0,0 +1,12 @@ + + + + + Hello World! + + + +

💖 Hello World!

+

Welcome to your Electron application.

+ + diff --git a/workspaces/electron-app/renderer/index.ts b/workspaces/electron-app/renderer/index.ts new file mode 100644 index 0000000..4a35347 --- /dev/null +++ b/workspaces/electron-app/renderer/index.ts @@ -0,0 +1,31 @@ +/** + * This file will automatically be loaded by webpack and run in the "renderer" context. + * To learn more about the differences between the "main" and the "renderer" context in + * Electron, visit: + * + * https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes + * + * By default, Node.js integration in this file is disabled. When enabling Node.js integration + * in a renderer process, please be aware of potential security implications. You can read + * more about security risks here: + * + * https://electronjs.org/docs/tutorial/security + * + * To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration` + * flag: + * + * ``` + * // Create the browser window. + * mainWindow = new BrowserWindow({ + * width: 800, + * height: 600, + * webPreferences: { + * nodeIntegration: true + * } + * }); + * ``` + */ + +import './index.css'; + +console.log('👋 This message is being logged by "renderer.js", included via webpack'); diff --git a/src/electron/preload.ts b/workspaces/electron-app/renderer/preload.ts similarity index 77% rename from src/electron/preload.ts rename to workspaces/electron-app/renderer/preload.ts index dd35ed8..89b6edf 100644 --- a/src/electron/preload.ts +++ b/workspaces/electron-app/renderer/preload.ts @@ -1,7 +1,7 @@ // To secure user platform when running renderer process stuff, // Node.JS and Electron APIs are only available in this script -import { contextBridge, ipcRenderer } from 'electron'; -import { WindowApi, WindowApiConst } from 'shared'; +import { contextBridge, ipcRenderer } from "electron"; +import { WindowApi, WindowApiConst } from "shared-lib"; // So we expose protected methods that allow the renderer process // to use the ipcRenderer without exposing the entire object @@ -20,13 +20,13 @@ const windowApi: WindowApi = { }; declare const window: any; -if (process.env.X_NODE_ENV === 'e2e-test') { +if (process.env.X_NODE_ENV === "e2e-test") { // Injecting windowApi directly window.api = windowApi; } else { // ContextBridge API can only be used when contextIsolation is enabled // which is normally the case except in e2e test mode - contextBridge.exposeInMainWorld('api', windowApi); + contextBridge.exposeInMainWorld("api", windowApi); } -console.log('The preload script has been injected successfully.'); +console.log("The preload script has been injected successfully."); diff --git a/workspaces/electron-app/tsconfig.json b/workspaces/electron-app/tsconfig.json new file mode 100644 index 0000000..b805081 --- /dev/null +++ b/workspaces/electron-app/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "references": [{ "path": "../shared-lib" }] +} diff --git a/e2e/electron/jasmine.js b/workspaces/electron-e2e/jasmine.js similarity index 91% rename from e2e/electron/jasmine.js rename to workspaces/electron-e2e/jasmine.js index 94b9849..484b227 100644 --- a/e2e/electron/jasmine.js +++ b/workspaces/electron-e2e/jasmine.js @@ -5,7 +5,7 @@ const jasmine = new Jasmine(); jasmine.loadConfig({ showColors: true, defaultTimeoutInterval: 15000, - spec_dir: "e2e/electron", + spec_dir: "workspaces/electron-e2e", spec_files: ["./**/*-spec.ts"], helpers: ["./**/*-helper.ts"], random: false, @@ -18,5 +18,5 @@ require("ts-node").register({ project: require("path").join(__dirname, "./tsconfig.json"), }); jasmine.env.clearReporters(); -jasmine.addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); +jasmine.addReporter(new SpecReporter({ spec: { displayStacktrace: 'pretty' } })); jasmine.execute(); diff --git a/e2e/electron/src/app.e2e-spec.ts b/workspaces/electron-e2e/src/app.e2e-spec.ts similarity index 59% rename from e2e/electron/src/app.e2e-spec.ts rename to workspaces/electron-e2e/src/app.e2e-spec.ts index 92fe84d..d88e048 100644 --- a/e2e/electron/src/app.e2e-spec.ts +++ b/workspaces/electron-e2e/src/app.e2e-spec.ts @@ -1,11 +1,11 @@ -import * as path from 'path'; -import { Application } from 'spectron'; +import * as path from "path"; +import { Application } from "spectron"; -describe('A simple test to verify a visible window is opened with a title', () => { +describe("A simple test to verify a visible window is opened with a title", () => { // Init local app let app = new Application({ - path: path.join(__dirname, '../../../node_modules/.bin/electron'), - args: [path.join(__dirname, '../../../dist/build/main.js')], + path: path.join(__dirname, "../../../node_modules/.bin/electron"), + args: [path.join(__dirname, "../../../.webpack/main/index.js")], }); beforeAll(async () => { @@ -22,14 +22,14 @@ describe('A simple test to verify a visible window is opened with a title', () = } }); - it('shows an initial window', async () => { + it("shows an initial window", async () => { // Checking there is one visible window expect(await app.browserWindow.isVisible()).toEqual(true); // Please note that getWindowCount() will return 2 if `dev tools` are opened. expect(await app.client.getWindowCount()).toEqual(1); }); - it('should have expected title', async () => { - expect(await app.client.getTitle()).toEqual('ElectronAngularQuickStart'); + it("should have expected title", async () => { + expect(await app.client.getTitle()).toEqual("ElectronAngularQuickStart"); }); }); diff --git a/e2e/electron/tsconfig.json b/workspaces/electron-e2e/tsconfig.json similarity index 90% rename from e2e/electron/tsconfig.json rename to workspaces/electron-e2e/tsconfig.json index 8ad53b9..06f3fd4 100644 --- a/e2e/electron/tsconfig.json +++ b/workspaces/electron-e2e/tsconfig.json @@ -4,6 +4,7 @@ "outDir": "../out-tsc/e2e", "module": "commonjs", "target": "es5", + "noEmit": true, "types": ["jasmine", "jasminewd2", "node"] } } diff --git a/workspaces/shared-lib/.gitignore b/workspaces/shared-lib/.gitignore new file mode 100644 index 0000000..ae7edd9 --- /dev/null +++ b/workspaces/shared-lib/.gitignore @@ -0,0 +1,2 @@ +# Generated JS files +dist \ No newline at end of file diff --git a/src/shared/apis/window-api-consts.ts b/workspaces/shared-lib/apis/window-api-consts.ts similarity index 81% rename from src/shared/apis/window-api-consts.ts rename to workspaces/shared-lib/apis/window-api-consts.ts index d26eeba..e263b2e 100644 --- a/src/shared/apis/window-api-consts.ts +++ b/workspaces/shared-lib/apis/window-api-consts.ts @@ -1,9 +1,9 @@ export class WindowApiConst { /** Channel used by the renderer process to send data to the main process */ - public static readonly MULTIPLES_INPUT = 'getMultiplesInput'; + public static readonly MULTIPLES_INPUT = "getMultiplesInput"; /** Channel used by the renderer process to receive data from the main process */ - public static readonly MULTIPLES_OUTPUT = 'getMultiplesOutput'; + public static readonly MULTIPLES_OUTPUT = "getMultiplesOutput"; /** Whitelist of the safe channels to use when sending data to the main process */ public static readonly SENDING_SAFE_CHANNELS = [ diff --git a/src/shared/apis/window-api.ts b/workspaces/shared-lib/apis/window-api.ts similarity index 100% rename from src/shared/apis/window-api.ts rename to workspaces/shared-lib/apis/window-api.ts diff --git a/src/shared/index.ts b/workspaces/shared-lib/index.ts similarity index 100% rename from src/shared/index.ts rename to workspaces/shared-lib/index.ts diff --git a/workspaces/shared-lib/package.json b/workspaces/shared-lib/package.json new file mode 100644 index 0000000..c329499 --- /dev/null +++ b/workspaces/shared-lib/package.json @@ -0,0 +1,9 @@ +{ + "name": "shared-lib", + "version": "1.0.2", + "main": "dist/index.js", + "scripts": { + }, + "author": "Sourcygen", + "license": "MIT" +} diff --git a/src/shared/tsconfig.json b/workspaces/shared-lib/tsconfig.json similarity index 75% rename from src/shared/tsconfig.json rename to workspaces/shared-lib/tsconfig.json index 117475e..56f0f72 100644 --- a/src/shared/tsconfig.json +++ b/workspaces/shared-lib/tsconfig.json @@ -1,9 +1,10 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "sourceMap": true, "composite": true, "declaration": true, - "outDir": "../../dist/node_modules/shared" + "outDir": "./dist" }, "include": ["./**/*.ts"] }