Skip to content

Commit

Permalink
Moved electron into altair-electron package.
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Oct 11, 2019
1 parent 6e5f5d5 commit b6206f8
Show file tree
Hide file tree
Showing 54 changed files with 6,017 additions and 92 deletions.
14 changes: 7 additions & 7 deletions .appveyor.yml
Expand Up @@ -9,16 +9,16 @@ cache:
- '%USERPROFILE%\.electron'
skip_non_tags: true
artifacts:
- path: 'out\make\**\*'
- path: 'packages\altair-electron\out\make\**\*'
name: altairAll

- path: 'out\altair-win32-x64\altair.exe'
- path: 'packages\altair-electron\out\altair-win32-x64\altair.exe'
name: altairWin

- path: 'out\make\**/*.exe'
- path: 'packages\altair-electron\out\make\**/*.exe'
name: altairExe

- path: 'out\make\**/*.nupkg'
- path: 'packages\altair-electron\out\make\**/*.nupkg'
name: altairNuget

install:
Expand All @@ -30,7 +30,7 @@ install:
before_test:
- yarn global add @angular/cli@1.6.3
- yarn global add karma
- yarn global add electron-forge
# - yarn global add electron-forge
- yarn
# - npm install -g @angular/cli
# - npm install -g karma
Expand All @@ -49,9 +49,9 @@ build: off # We do not intend to build using MS Build

# Run build in after_test to generate artifacts
after_test:
- ps: (Get-Content .\dist\index.html) | ForEach-Object { $_ -replace '<base href="/">', '<base href="./">' } | Set-Content .\dist\index.html
# - ps: (Get-Content .\dist\index.html) | ForEach-Object { $_ -replace '<base href="/">', '<base href="./">' } | Set-Content .\dist\index.html
# - npm run make
- yarn dist-electron
- yarn build-electron
# - npm run dist-electron

deploy:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -9,7 +9,7 @@
/docs/.sass-cache
/docs/.jekyll-metadata
altair.zip
/out
out/
/web-ext-artifacts
/firebase-sample-dist
*.nex
Expand Down
10 changes: 4 additions & 6 deletions .travis.yml
Expand Up @@ -7,8 +7,6 @@ os:
osx_image: xcode11
node_js:
- 10
env:
- DEBUG=electron-forge:*
addons:
apt:
sources:
Expand All @@ -27,7 +25,7 @@ before_install:
- export DISPLAY=:99.0
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then google-chrome --version; fi
before_script:
- yarn global add @angular/cli karma electron-forge lerna surge
- yarn global add @angular/cli karma lerna surge
- yarn
- yarn build
- npm config set //registry.npmjs.org/:_authToken=${NPM_TOKEN}
Expand All @@ -37,7 +35,7 @@ script:
- ng lint
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then yarn test-single-run; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then yarn webdriver-update-ci; ng e2e --webdriver-update=false; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then bin/start_ci_test_server.sh; yarn test-electron; bin/stop_ci_test_server.sh; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then bin/start_ci_test_server.sh; yarn test-all; bin/stop_ci_test_server.sh; fi
- if [ ! -z "$TRAVIS_TAG" ]; then yarn build-electron; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then yarn build; fi # Need to generate files for deployment
after_success:
Expand All @@ -49,7 +47,7 @@ deploy:
secure: Raef82s/PIkWThnr5vxHsxZX7FI6LKB3dbUkHzEs/S88hhibQCLuUIrvtbPwEJ/nxj0tpnD93elRQWpYsFRa38omv11g0o5eSUy7WwEHEum6g6se1fH3DqhBJsnIJFtfNXwdysMuvzWeJQ4P4j37jSg3wuCs9oJn0I+GrtS/wrE8EyxGKjtd68lVZo5rNCllUiHeizl8oIcRTUREKexxpsLEapBqgxmkFDn7lbgLDgt4/VwtaCZVN6bAnjknJS9DMynOJS0S1uyl6Gqd1paHVvEPrJv/UpeGKsp+OyoU7qbt/0ZXqXd1Yyym5jp0NAdb2IVNUAiyAAMUjy0qYDIZJMLAOhoO/GlJjvr+Sun81Fgv3fTDPzdUkHLUOVAFqsAmqhkupdZ3PnbiPExk3M3vTIEYI6v2CdxEglZyuZ1GNZ1551CT2hddHuoGue3JGaeq/V8n7QGZUGdplw9NHr7YOkuGpbbxGDjJM/RQXXEdAj1YXTSe225NNEOjoY5AuaVnIW76pfzhjEZtAHCpiYDfqECjtQ9dNuV5K58qElfPmDlBjYv1/G46OiEb/wpFiXtNZel+pvYaV7EK0RNA5IYSUn/S5v2MHEd8XVS90KV2L+CFv++9M46le3Nx6Qr4Lbu7VeY3va7JA/FCN+6HWpoupCg4N98rNOgfjay6FO/d56c=
file_glob: true
file:
- out/make/*
- packages/altair-electron/out/make/*
skip_cleanup: true
on:
tags: true
Expand All @@ -68,7 +66,7 @@ deploy:
branch: staging
- provider: snap
file_glob: true
snap: out/**/*.snap
snap: packages/altair-electron/out/**/*.snap
channel: stable
skip_cleanup: true
on:
Expand Down
15 changes: 10 additions & 5 deletions bin/package_electron_app.sh
@@ -1,24 +1,29 @@
#!/bin/bash

# !!! TODO: Remove as deprecated
# Remove any electron-builds directory
rm -rf electron-builds
# rm -rf electron-builds

# Create a new electron-builds directory
mkdir electron-builds
# mkdir electron-builds

# Build the angular app
npm run build
# npm run build

# Fix the base href path for the electron app
./electron/fix-base-path.sh
# ./electron/fix-base-path.sh

# Make the electron apps
# npm run make
npm run dist-electron
# npm run dist-electron

# Package the electron app
# ./node_modules/electron-packager/cli.js . Altair --out=electron-builds --overwrite --icon=electron/logo.icns

./node_modules/.bin/lerna bootstrap

./node_modules/.bin/lerna run --scope altair-electron build

# Snippet:
# Remove git tags
# git push --delete origin add-compilerc.11 add-compilerc.12 && git tag -d add-compilerc.11 add-compilerc.12
2 changes: 1 addition & 1 deletion chrome-ext-files/manifest.json
Expand Up @@ -3,7 +3,7 @@
"name": "Altair GraphQL Client",
"short_name": "Altair",
"description": "The only graphQL client you'll ever need.",
"version": "2.3.4",
"version": "2.3.5",
"icons": {
"16": "assets/img/altair_logo_128.png",
"48": "assets/img/altair_logo_128.png",
Expand Down
5 changes: 0 additions & 5 deletions electron/preload/xt.js

This file was deleted.

2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "2.3.4",
"version": "2.3.5",
"registry": "https://registry.npmjs.org/",
"npmClient": "yarn"
}
34 changes: 3 additions & 31 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "altair",
"productName": "Altair GraphQL Client",
"version": "2.3.4",
"version": "2.3.5",
"license": "MIT",
"author": "Samuel Imolorhe <samuelimolo4real@gmail.com> (https://sirmuel.design/)",
"description": "The best graphQL client you will ever need",
Expand All @@ -13,7 +13,6 @@
"editor",
"client"
],
"main": "electron/main.js",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -23,18 +22,13 @@
"test": "ng test",
"test-single-run": "ng test --watch=false --code-coverage",
"test-build": "ng lint && npm run build && npm run test-single-run",
"test-all": "npm run build && lerna bootstrap && lerna run test",
"local-verify": "ng test --single-run && ng lint && ng e2e && yarn build && lerna bootstrap",
"lint": "ng lint",
"e2e": "ng e2e",
"heroku-postbuild": "npm run build",
"electron": "npm run build && ./electron/fix-base-path.sh && ./node_modules/.bin/electron .",
"build-electron": "./bin/package_electron_app.sh",
"build-electron": "npm run build && lerna bootstrap && lerna run --scope altair-electron build --stream",
"build-ext": "npm run build && ./bin/chrome_ext.sh",
"package": "electron-forge package",
"make": "electron-forge make",
"dist-electron": "electron-builder",
"test-electron": "npm run build && ./electron/fix-base-path.sh && npm run test-electron:simple",
"test-electron:simple": "./node_modules/.bin/mocha --full-trace electron/__tests__",
"postinstall": "npm run generate-settings-schema-validator && opencollective postinstall",
"lerna-publish": "lerna publish from-git --force-publish=* --yes",
"publish-packages": "npm run build && lerna bootstrap && npm run lerna-publish",
Expand Down Expand Up @@ -83,13 +77,6 @@
"core-js": "^3.1.4",
"curlup": "^1.0.0",
"dexie": "^2.0.4",
"electron-debug": "^3.0.1",
"electron-is-dev": "^1.1.0",
"electron-log": "^3.0.6",
"electron-squirrel-startup": "^1.0.0",
"electron-updater": "^4.1.2",
"electron-util": "^0.12.1",
"electron-window-state": "^5.0.3",
"express": "^4.17.1",
"file-dialog": "^0.0.7",
"file-saver": "^2.0.2",
Expand Down Expand Up @@ -138,15 +125,6 @@
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"codelyzer": "^5.1.0",
"devtron": "^1.4.0",
"dotenv": "^8.1.0",
"electron": "4.2.9",
"electron-builder": "^21.1.1",
"electron-chromedriver": "^6.0.0-beta.3",
"electron-compile": "^6.4.4",
"electron-notarize": "^0.1.1",
"electron-prebuilt-compile": "^4.0.0",
"electron-reloader": "^0.3.0",
"jasmine-core": "^3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.2.0",
Expand All @@ -156,23 +134,17 @@
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "1.4.2",
"lerna": "^3.16.0",
"mime-types": "^2.1.24",
"mocha": "^6.2.0",
"ncp": "^2.0.0",
"ngrx-store-freeze": "^0.2.0",
"protractor": "^5.4.2",
"rxjs-tslint-rules": "^4.24.3",
"spectron": "6.0.0",
"start-server-and-test": "^1.9.1",
"ts-node": "^8.3.0",
"tslint": "^5.18.0",
"typescript": "^3.4.5",
"typescript-json-schema": "^0.40.0",
"web-ext": "^3.1.1"
},
"config": {
"forge": "./forge.config.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/imolorhe/altair.git"
Expand Down
Expand Up @@ -4,8 +4,8 @@ const chaiAsPromised = require('chai-as-promised');
const assert = chai.assert;
const path = require('path');

let electronPath = path.join(__dirname, '../../node_modules', '.bin', 'electron');
const appPath = path.join(__dirname, '../main');
let electronPath = path.join(__dirname, '../node_modules', '.bin', 'electron');
const appPath = path.join(__dirname, '../');
if (process.platform === 'win32') {
electronPath += '.cmd';
}
Expand Down
@@ -1,32 +1,24 @@
appId: com.xkoji.altair
productName: Altair GraphQL Client
directories:
buildResources: electron
buildResources: resources
output: out
files:
- '**/*'
- 'electron/**/*'
- '!src/**/*'
- '!out/**/*'
- '!packages/**/*'
- '!web-ext-artifacts/**/*'
- '!coverage/**/*'
- '!docs/**/*'
- '!chrome-extension/**/*'
afterSign: electron/scripts/notarize.js
afterSign: scripts/notarize.js
mac:
category: public.app-category.developer-tools
icon: electron/icon.png
icon: resources/icon.png
artifactName: ${name}_${version}_${arch}_mac.${ext}
hardenedRuntime: true
entitlements: electron/entitlements.mac.plist
entitlementsInherit: electron/entitlements.mac.plist
entitlements: resources/entitlements.mac.plist
entitlementsInherit: resources/entitlements.mac.plist
# gatekeeperAssess: false
dmg:
icon: electron/icon.png
icon: resources/icon.png
linux:
artifactName: ${name}_${version}_${arch}_linux.${ext}
icon: electron/icons
icon: resources/icons
snap:
publish: github
win:
Expand Down
1 change: 1 addition & 0 deletions packages/altair-electron/index.js
@@ -0,0 +1 @@
require('./src/main');
49 changes: 49 additions & 0 deletions packages/altair-electron/package.json
@@ -0,0 +1,49 @@
{
"name": "altair-electron",
"version": "2.3.5",
"description": "Electron wrapper for Altair",
"main": "index.js",
"author": "Samuel Imolorhe <samuelimolo4real@gmail.com> (https://sirmuel.design/)",
"license": "MIT",
"scripts": {
"test": "mocha --full-trace __tests__",
"build": "electron-builder",
"dev": "electron ."
},
"dependencies": {
"altair-static": "^2.3.5",
"electron-debug": "^3.0.1",
"electron-is-dev": "^1.1.0",
"electron-log": "^3.0.6",
"electron-squirrel-startup": "^1.0.0",
"electron-updater": "^4.1.2",
"electron-util": "^0.12.1",
"electron-window-state": "^5.0.3",
"mime-types": "^2.1.24"
},
"devDependencies": {
"devtron": "^1.4.0",
"dotenv": "^8.1.0",
"electron": "4.2.9",
"electron-builder": "^21.1.1",
"electron-chromedriver": "^6.0.0-beta.3",
"electron-compile": "^6.4.4",
"electron-notarize": "^0.1.1",
"electron-prebuilt-compile": "^4.0.0",
"electron-reloader": "^0.3.0",
"mocha": "^6.2.0",
"spectron": "6.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/imolorhe/altair.git"
},
"bugs": {
"url": "https://github.com/imolorhe/altair/issues"
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/altair",
"logo": "https://opencollective.com/altair/logo.txt"
}
}
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 12 additions & 7 deletions electron/window.js → packages/altair-electron/src/window.js
Expand Up @@ -5,6 +5,8 @@ const fs = require('fs');
const mime = require('mime-types');
const windowStateKeeper = require('electron-window-state');

const { getDistDirectory } = require('altair-static');

const { getStore } = require('./store');
const { createMenu } = require('./menu');
const { createTouchBar } = require('./touchbar');
Expand Down Expand Up @@ -71,7 +73,7 @@ const createWindow = () => {
*/
protocol.registerBufferProtocol('altair', (request, callback) => {

const requestDirectory = path.resolve(app.getAppPath(), 'dist');
const requestDirectory = getDistDirectory();
const filePath = path.join(requestDirectory, new url.URL(request.url).pathname);
const indexPath = path.join(requestDirectory, 'index.html');

Expand All @@ -91,7 +93,7 @@ const createWindow = () => {
});
});
}, (error) => {
if (error) console.error('Failed to register protocol')
if (error) console.error('Failed to register protocol');
});

// Load the previous state with fallback to defaults
Expand Down Expand Up @@ -172,11 +174,14 @@ const createWindow = () => {
// Doesn't seem to be called. Might be because of buffer protocol.
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
callback({
responseHeaders: {
...details.responseHeaders,
// Setting CSP
'Content-Security-Policy': [`script-src 'self' 'sha256-1Sj1x3xsk3UVwnakQHbO0yQ3Xm904avQIfGThrdrjcc='; object-src 'self';`]
}
responseHeaders: Object.assign(
{},
details.responseHeaders,
{
// Setting CSP
'Content-Security-Policy': [`script-src 'self' 'sha256-1Sj1x3xsk3UVwnakQHbO0yQ3Xm904avQIfGThrdrjcc='; object-src 'self';`]
}
)
});
});
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
Expand Down

0 comments on commit b6206f8

Please sign in to comment.