diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..213cfc8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Electron Main Renderer", + "type": "node", + "request": "launch", + "protocol": "inspector", + // Prelaunch task compiles main.ts for Electron & starts Angular dev server. + "preLaunchTask": "Build.All", + "cwd": "${workspaceFolder}", + "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", + "runtimeArgs": [ + "--serve", + ".", + "--remote-debugging-port=9222" + ], + "windows": { + "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd" + } + }, { + "name": "Karma Attach Chrome", + "type": "chrome", + "request": "attach", + "port": 9222, + "webRoot": "${workspaceFolder}/", + "sourceMaps": true, + "timeout": 30000, + "trace": true + } + + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..6149711 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,27 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build.All", + "type": "shell", + "command": "npm run electron:serve-tsc && ng serve", + "isBackground": true, + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": { + "owner": "typescript", + "source": "ts", + "applyTo": "closedDocuments", + "fileLocation": ["relative", "${cwd}"], + "pattern": "$tsc", + "background": { + "activeOnStart": true, + "beginsPattern": "^.*", + "endsPattern": "^.*Compiled successfully.*" + } + } + } + ] + } \ No newline at end of file diff --git a/main.ts b/main.ts index 8001f8c..7868694 100644 --- a/main.ts +++ b/main.ts @@ -24,10 +24,15 @@ function createWindow(): BrowserWindow { }); if (serve) { + + require('devtron').install(); + win.webContents.openDevTools(); + require('electron-reload')(__dirname, { electron: require(`${__dirname}/node_modules/electron`) }); win.loadURL('http://localhost:4200'); + } else { win.loadURL(url.format({ pathname: path.join(__dirname, 'dist/index.html'), @@ -36,10 +41,6 @@ function createWindow(): BrowserWindow { })); } - if (serve) { - win.webContents.openDevTools(); - } - // Emitted when the window is closed. win.on('closed', () => { // Dereference the window object, usually you would store window diff --git a/package.json b/package.json index ad6587f..b7447a1 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "electron:linux": "npm run build:prod && electron-builder build --linux", "electron:windows": "npm run build:prod && electron-builder build --windows", "electron:mac": "npm run build:prod && electron-builder build --mac", - "test": "ng test", + "test": "ng test --watch=false", + "test:watch": "ng test", "e2e": "npm run build:prod && cross-env TS_NODE_PROJECT='e2e/tsconfig.e2e.json' mocha --timeout 300000 --require ts-node/register e2e/**/*.e2e.ts", "version": "conventional-changelog -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md", "lint": "ng lint" @@ -65,6 +66,7 @@ "conventional-changelog-cli": "2.0.32", "core-js": "3.6.5", "cross-env": "7.0.2", + "devtron": "1.4.0", "electron": "8.2.3", "electron-builder": "22.5.1", "electron-reload": "1.5.0", @@ -81,8 +83,8 @@ "npm-run-all": "4.1.5", "rxjs": "6.5.5", "spectron": "10.0.1", - "tslib": "1.11.1", "ts-node": "8.9.1", + "tslib": "1.11.1", "typescript": "3.8.3", "wait-on": "4.0.2", "webdriver-manager": "12.1.7", diff --git a/src/karma.conf.js b/src/karma.conf.js index 95aa757..cae82b3 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -24,9 +24,7 @@ module.exports = function (config) { port: 9876, colors: true, logLevel: config.LOG_INFO, - autoWatch: true, browsers: ['AngularElectron'], - singleRun: true, customLaunchers: { AngularElectron: { base: 'Electron', @@ -43,4 +41,4 @@ module.exports = function (config) { } } }); -}; +}; \ No newline at end of file