diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..c949a46
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,64 @@
+# This is a basic workflow to help you get started with Actions
+name: 'CI'
+
+# Controls when the action will run.
+on:
+ # Triggers the workflow on push or pull request events but only for the master branch
+ push:
+ branches:
+ - master
+ - develop
+ pull_request:
+ branches:
+ - master
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ build:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [macOS-latest, ubuntu-latest, windows-latest]
+ node-version: [14.x, 15.x, 16.x]
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Cache node modules
+ uses: actions/cache@v2
+ env:
+ cache-name: cache-node-modules
+ with:
+ # npm cache files are stored in `~/.npm`
+ path: ~/.npm
+ key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-build-${{ env.cache-name }}-
+ ${{ runner.os }}-build-
+ ${{ runner.os }}-
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v1
+ with:
+ node-version: ${{ matrix.node-version }}
+ - name: Upgrade to the latest version of npm
+ run: npm install -g npm@latest
+ - name: Upgrade to the latest version of Angular CLI
+ run: npm install -g @angular/cli@latest
+ - name: Install dependencies
+ run: npm install
+ - name: Test Angular E2E
+ uses: GabrielBB/xvfb-action@v1
+ with:
+ run: npm run test:angular-e2e
+ - name: Test Electron E2E
+ uses: GabrielBB/xvfb-action@v1
+ with:
+ run: npm run test:electron-e2e
+ - name: Check lint
+ run: npm run lint
+ - name: Make app distributables
+ run: npm run make
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index dd2a591..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-language: node_js
-dist: xenial
-os:
- - linux
- - osx
-node_js:
- - "14"
-addons:
- chrome: stable
-services:
- - xvfb
-install:
- - npm install
-script:
- - npm run test:electron-e2e
- - npm run make
diff --git a/README.md b/README.md
index 31cad58..714fc83 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
+
-
@@ -47,18 +47,28 @@ Depending on your need, putting up [Electron](https://www.electronjs.org/) and [
## Getting started
-To clone and run this repository, you'll need [Git](https://git-scm.com), [Node.js](https://nodejs.org/en/download/) and [Angular-CLI](https://angular.io/cli) installed on your computer. And then from your command line:
+To clone and run this repository, you'll need installed on your computer at least :
+
+- [Git](https://git-scm.com)
+- [Node 14](https://nodejs.org/en/download/)
+- [Npm 7](https://docs.npmjs.com/about-npm)
+- [Angular-CLI 12](https://angular.io/cli)
+
+Then from your command line:
```bash
-# First, clone this repository
+# Upgrade to the latest version of npm (if necessary)
+npm install -g npm@latest
+
+# Upgrade to the latest version of Angular CLI (if necessary)
+npm install -g @angular/cli@latest
+
+# Clone this repository
git clone https://github.com/sourcygen/electron-angular-quick-start.git
# Then go into the repository
cd electron-angular-quick-start
-# Install Angular CLI globally (if necessary)
-npm install -g @angular/cli
-
# After that, install dependencies
npm install
diff --git a/package-lock.json b/package-lock.json
index 0c52f44..f3ec487 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,10 +1,11 @@
{
- "name": "electron-angular-quick-start",
+ "name": "electron-angular-app",
"version": "2.2.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
+ "name": "electron-angular-app",
"version": "2.2.0",
"hasInstallScript": true,
"license": "MIT",
diff --git a/package.json b/package.json
index db408bd..05d5c64 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
- "name": "electron-angular-quick-start",
- "productName": "electron-angular-quick-start",
+ "name": "electron-angular-app",
+ "productName": "Electron Angular App",
"version": "2.2.0",
"description": "An Electron and Angular Quick-starter",
"repository": "https://github.com/sourcygen/electron-angular-quick-start.git",
@@ -30,13 +30,14 @@
"start:electron-app": "node scripts/electron-forge-start-watch.js",
"start:electron-app:once": "wait-on http://localhost:4200 && electron-forge start",
"package": "npm run package:angular-app && npm run package:electron-app",
- "package:angular-app": "cd workspaces/angular-app && npm run package",
- "package:electron-app": "electron-forge package",
+ "package:shared-lib": "tsc -b workspaces/shared-lib",
+ "package:angular-app": "npm run package:shared-lib && cd workspaces/angular-app && npm run package",
+ "package:electron-app": "npm run package:shared-lib && electron-forge package",
"make": "npm run package:angular-app && electron-forge make",
"publish": "electron-forge publish",
- "lint": "eslint --ext .ts .",
+ "lint": "npm run package:shared-lib && eslint --ext .ts .",
"test:e2e": "npm run test:angular-e2e && npm run test:electron-e2",
- "test:angular-e2e": "npm-run-all -p -r start:angular-app start:angular-e2e",
+ "test:angular-e2e": "npm-run-all -p -r start start:angular-e2e",
"start:angular-e2e": "wait-on http://localhost:4200 && cd workspaces/angular-app && npm run cypress:run",
"test:electron-e2e": "npm run package && cross-env X_NODE_ENV=e2e-test node workspaces/electron-e2e/jasmine.js",
"clean": "shx rm -rf .webpack out node_modules workspaces/shared-lib/.dist workspaces/angular-app/node_modules workspaces/angular-app/.dist",
@@ -49,7 +50,8 @@
"config": {
"forge": {
"packagerConfig": {
- "name": "electron-angular",
+ "name": "Electron Angular App",
+ "executableName": "electron-angular-app",
"icon": "./workspaces/electron-app/main/assets/icons/icon"
},
"makers": [
@@ -62,7 +64,8 @@
"config": {}
},
{
- "name": "@electron-forge/maker-squirrel"
+ "name": "@electron-forge/maker-squirrel",
+ "config": {}
}
],
"plugins": [
diff --git a/workspaces/electron-e2e/jasmine.js b/workspaces/electron-e2e/jasmine.js
index 91643a5..e80f45b 100644
--- a/workspaces/electron-e2e/jasmine.js
+++ b/workspaces/electron-e2e/jasmine.js
@@ -4,7 +4,6 @@ const { SpecReporter } = require('jasmine-spec-reporter');
const jasmine = new Jasmine();
jasmine.loadConfig({
showColors: true,
- defaultTimeoutInterval: 15000,
spec_dir: 'workspaces/electron-e2e',
spec_files: ['./**/*-spec.ts'],
helpers: ['./**/*-helper.ts'],
diff --git a/workspaces/electron-e2e/src/_hooks.ts b/workspaces/electron-e2e/src/_hooks.ts
new file mode 100644
index 0000000..49acad3
--- /dev/null
+++ b/workspaces/electron-e2e/src/_hooks.ts
@@ -0,0 +1,32 @@
+import * as path from 'path';
+import { Application } from 'spectron';
+
+export async function startApp(): Promise {
+ // Path to local electron binary
+ let electronPath = path.join(
+ __dirname,
+ '../../../node_modules/.bin/electron'
+ );
+ if (process.platform === 'win32') {
+ electronPath += '.cmd';
+ }
+
+ // Init local packaged app
+ const app = new Application({
+ path: electronPath,
+ args: ['.webpack/main/index.js'],
+ });
+
+ // Init local app and wait until window loaded
+ await app.start();
+ await app.client.waitUntilWindowLoaded();
+ return app;
+}
+
+export async function stopApp(app: Application): Promise {
+ if (app && app.isRunning()) {
+ // Wait 1 second and then stop local app
+ await new Promise((resolve) => setTimeout(resolve, 1000));
+ await app.stop();
+ }
+}
diff --git a/workspaces/electron-e2e/src/app.e2e-spec.ts b/workspaces/electron-e2e/src/app.e2e-spec.ts
index e66d994..2c37499 100644
--- a/workspaces/electron-e2e/src/app.e2e-spec.ts
+++ b/workspaces/electron-e2e/src/app.e2e-spec.ts
@@ -1,25 +1,15 @@
-import * as path from 'path';
import { Application } from 'spectron';
+import { startApp, stopApp } from './_hooks';
describe('A simple test to verify a visible window is opened with a title', () => {
- // Init local app
- const app = new Application({
- path: path.join(__dirname, '../../../node_modules/.bin/electron'),
- args: [path.join(__dirname, '../../../.webpack/main/index.js')],
- });
+ let app: Application;
beforeAll(async () => {
- // Init local app and wait until window loaded
- await app.start();
- await app.client.waitUntilWindowLoaded();
+ app = await startApp();
});
afterAll(async () => {
- if (app && app.isRunning()) {
- // Wait 1 second and then stop local app
- await new Promise((resolve) => setTimeout(resolve, 1000));
- await app.stop();
- }
+ await stopApp(app);
});
it('shows an initial window', async () => {