Skip to content

Commit b2107ce

Browse files
authored
Merge pull request #118 from imolorhe/add-forge-config-file
Add forge config file
2 parents bad50aa + 566521c commit b2107ce

File tree

7 files changed

+159
-107
lines changed

7 files changed

+159
-107
lines changed

.appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ build: off # We do not intend to build using MS Build
3939

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

4445
deploy:

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ script:
3131
- ng lint
3232
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then karma start karma.conf.js --single-run; fi
3333
before_deploy:
34-
- npm run make
34+
- npm run build-electron
3535
deploy:
3636
provider: releases
3737
api_key:

electron/fix-base-path-windows.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
OLD_BASE='<base href="/">'
4+
NEW_BASE='<base href="./">'
5+
sed -i '' "s|$OLD_BASE|$NEW_BASE|g" .\dist\index.html

electron/main.js

Lines changed: 72 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,68 @@ let win
1010

1111
function createWindow () {
1212

13-
// TODO - Use the altair protocol to replace the file protocol
14-
protocol.registerBufferProtocol('altair', (request, callback) => {
15-
const url = request.url.substr(7);
16-
fs.readFile(path.normalize(`${url}`), 'utf8', function (err, data) {
17-
if (err) {
18-
return console.log('Error loading file to buffer.', err);
19-
}
20-
21-
// Load the data from the file into a buffer and pass it to the callback
22-
// Using the mime package to get the mime type for the file, based on the file name
23-
callback({ mimeType: mime.lookup(url), data: new Buffer(data) });
24-
// console.log(data);
25-
});
26-
// callback({path: path.normalize(`${__dirname}/${url}`)})
27-
}, (error) => {
28-
if (error) console.error('Failed to register protocol')
29-
});
13+
/**
14+
* Using a custom buffer protocol, instead of a file protocol because of restrictions with the file protocol.
15+
*/
16+
protocol.registerBufferProtocol('altair', (request, callback) => {
17+
let url = request.url.substr(7);
18+
19+
// In windows, the url comes as altair://c/Users/Jackie/Documents/projects/altair/dist/index.html
20+
// We also need to strip out the //c from the path
21+
// TODO - Find a better way of handling this
22+
if (process.platform === 'win32') {
23+
url = request.url.substr(10);
24+
}
3025

31-
// Create the browser window.
32-
win = new BrowserWindow({
33-
width: 1280,
34-
height: 800,
35-
titleBarStyle: 'hidden-inset'
36-
});
26+
// Maybe this could work?
27+
// console.log('::>>', path.join(__dirname, '../dist', path.basename(request.url)));
3728

38-
// Populate the application menu
39-
createMenu();
40-
41-
// and load the index.html of the app.
42-
win.loadURL(url.format({
43-
pathname: path.join(__dirname, '../dist/index.html'),
44-
protocol: 'altair:',
45-
slashes: true
46-
}));
47-
// win.loadURL('altair://' + __dirname + '/../dist/index.html')
48-
49-
// Open the DevTools.
50-
// win.webContents.openDevTools()
51-
52-
// Prevent the app from navigating away from the app
53-
win.webContents.on('will-navigate', (e, url) => e.preventDefault());
54-
55-
// Emitted when the window is closed.
56-
win.on('closed', () => {
57-
// Dereference the window object, usually you would store windows
58-
// in an array if your app supports multi windows, this is the time
59-
// when you should delete the corresponding element.
60-
win = null;
61-
})
29+
fs.readFile(path.normalize(`${url}`), 'utf8', function (err, data) {
30+
if (err) {
31+
return console.log('Error loading file to buffer.', err);
32+
}
33+
34+
// Load the data from the file into a buffer and pass it to the callback
35+
// Using the mime package to get the mime type for the file, based on the file name
36+
callback({ mimeType: mime.lookup(url), data: new Buffer(data) });
37+
// console.log(data);
38+
});
39+
// callback({path: path.normalize(`${__dirname}/${url}`)})
40+
}, (error) => {
41+
if (error) console.error('Failed to register protocol')
42+
});
43+
44+
// Create the browser window.
45+
win = new BrowserWindow({
46+
width: 1280,
47+
height: 800,
48+
// titleBarStyle: 'hidden-inset'
49+
});
50+
51+
// Populate the application menu
52+
createMenu();
53+
54+
// and load the index.html of the app.
55+
win.loadURL(url.format({
56+
pathname: path.join(__dirname, '../dist/index.html'),
57+
protocol: 'altair:',
58+
slashes: true
59+
}));
60+
// win.loadURL('altair://' + __dirname + '/../dist/index.html')
61+
62+
// Open the DevTools.
63+
// win.webContents.openDevTools()
64+
65+
// Prevent the app from navigating away from the app
66+
win.webContents.on('will-navigate', (e, url) => e.preventDefault());
67+
68+
// Emitted when the window is closed.
69+
win.on('closed', () => {
70+
// Dereference the window object, usually you would store windows
71+
// in an array if your app supports multi windows, this is the time
72+
// when you should delete the corresponding element.
73+
win = null;
74+
})
6275
}
6376

6477
function createMenu () {
@@ -136,24 +149,24 @@ protocol.registerStandardSchemes(['altair']);
136149
// This method will be called when Electron has finished
137150
// initialization and is ready to create browser windows.
138151
// Some APIs can only be used after this event occurs.
139-
app.on('ready', createWindow)
152+
app.on('ready', createWindow);
140153

141154
// Quit when all windows are closed.
142155
app.on('window-all-closed', () => {
143-
// On macOS it is common for applications and their menu bar
144-
// to stay active until the user quits explicitly with Cmd + Q
145-
if (process.platform !== 'darwin') {
146-
app.quit()
147-
}
156+
// On macOS it is common for applications and their menu bar
157+
// to stay active until the user quits explicitly with Cmd + Q
158+
if (process.platform !== 'darwin') {
159+
app.quit()
160+
}
148161
});
149162

150163
app.on('activate', () => {
151-
// On macOS it's common to re-create a window in the app when the
152-
// dock icon is clicked and there are no other windows open.
153-
if (win === null) {
154-
createWindow()
155-
}
156-
})
164+
// On macOS it's common to re-create a window in the app when the
165+
// dock icon is clicked and there are no other windows open.
166+
if (win === null) {
167+
createWindow()
168+
}
169+
});
157170

158171
// In this file you can include the rest of your app's specific main process
159172
// code. You can also put them in separate files and require them here.

forge.config.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
module.exports = {
2+
make_targets: {
3+
win32: [
4+
'squirrel'
5+
],
6+
darwin: [
7+
'zip'
8+
],
9+
linux: [
10+
'deb',
11+
'rpm'
12+
]
13+
},
14+
electronPackagerConfig: {
15+
asar: true,
16+
quiet: true,
17+
protocol: 'altair://',
18+
protocolName: 'Altair GraphQL Client File',
19+
icon: './electron/logo',
20+
prune: true,
21+
// "ignore": [
22+
// "idea",
23+
// "bin",
24+
// "chrome-ext-files",
25+
// "docs",
26+
// "e2e",
27+
// "src"
28+
// ],
29+
ignore: (path) => {
30+
const tests = [
31+
// Ignore git directory
32+
() => /^\/\.git\/.*/g,
33+
// Ignore idea directory
34+
() => /^\/\.idea\/.*/g,
35+
// Ignore root dev FileDescription
36+
() => /^\/(bin|chrome-ext-files|docs|e2e|src|test|.cert.pfx|.editorconfig|.eslintignore|.eslintrc|.gitignore|.travis.yml|appveyor.yml|circle.yml|CONTRIBUTING.md|Gruntfile.js|gulpfile.js|ISSUE_TEMPLATE.md|LICENSE|README.md)(\/|$)/g, // eslint-disable-line
37+
];
38+
for (let i = 0; i < tests.length; i++) {
39+
if (tests[i]().test(path)) {
40+
return true;
41+
}
42+
}
43+
return false;
44+
},
45+
},
46+
electronWinstallerConfig: {
47+
name: 'Altair',
48+
setupIcon: './electron/logo.ico'
49+
},
50+
electronInstallerDebian: {},
51+
electronInstallerRedhat: {},
52+
github_repository: {
53+
owner: 'imolorhe',
54+
name: 'altair'
55+
},
56+
windowsStoreConfig: {
57+
packageName: 'Altair GraphQL Client'
58+
}
59+
};

package.json

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
"author": "[email protected]",
66
"description": "The best graphQL client you will ever need",
77
"homepage": "https://imolorhe.github.io/altair/",
8-
"keywords": ["graphql", "altair", "wysiwyg", "editor", "client"],
8+
"keywords": [
9+
"graphql",
10+
"altair",
11+
"wysiwyg",
12+
"editor",
13+
"client"
14+
],
915
"main": "electron/main.js",
1016
"scripts": {
1117
"ng": "ng",
@@ -83,48 +89,16 @@
8389
"typescript": "~2.2.0"
8490
},
8591
"config": {
86-
"forge": {
87-
"make_targets": {
88-
"win32": [
89-
"squirrel"
90-
],
91-
"darwin": [
92-
"zip"
93-
],
94-
"linux": [
95-
"deb",
96-
"rpm"
97-
]
98-
},
99-
"electronPackagerConfig": {
100-
"asar": true,
101-
"quiet": true,
102-
"protocol": "altair://",
103-
"protocolName": "Altair GraphQL Client File",
104-
"icon": "./electron/logo",
105-
"prune": true,
106-
"ignore": [
107-
"idea",
108-
"bin",
109-
"chrome-ext-files",
110-
"docs",
111-
"e2e",
112-
"src"
113-
]
114-
},
115-
"electronWinstallerConfig": {
116-
"name": "Altair",
117-
"setupIcon": "./electron/logo.ico"
118-
},
119-
"electronInstallerDebian": {},
120-
"electronInstallerRedhat": {},
121-
"github_repository": {
122-
"owner": "imolorhe",
123-
"name": "altair"
124-
},
125-
"windowsStoreConfig": {
126-
"packageName": "Altair GraphQL Client"
127-
}
128-
}
92+
"forge": "./forge.config.js"
93+
},
94+
"directories": {
95+
"doc": "docs"
96+
},
97+
"repository": {
98+
"type": "git",
99+
"url": "git+https://github.com/imolorhe/altair.git"
100+
},
101+
"bugs": {
102+
"url": "https://github.com/imolorhe/altair/issues"
129103
}
130104
}

src/app/components/window-switcher/window-switcher.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="app-window-switcher-container">
2-
<div class="app-window-switcher-electron-stub" *ngIf="isElectron">
3-
<div class="app-window-switcher-input">&nbsp;</div>
4-
</div>
2+
<!--<div class="app-window-switcher-electron-stub" *ngIf="isElectron">-->
3+
<!--<div class="app-window-switcher-input">&nbsp;</div>-->
4+
<!--</div>-->
55
<!--<div class="app-window-switcher active">
66
window 1
77
</div>-->

0 commit comments

Comments
 (0)