Skip to content

Commit 3b78739

Browse files
Merge pull request #103 from electron/local-versions
feat: Add support for local Electron builds (with versions)
2 parents fe81d5c + 4616f12 commit 3b78739

36 files changed

+1187
-200
lines changed

src/interfaces.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
export type ElectronVersionState = 'downloading' | 'ready' | 'unknown';
2-
31
export type WindowNames = 'main';
42

53
export type Files = Map<string, string>;
64

75
export type FileTransform = (files: Files) => Promise<Files>;
86

7+
export enum ElectronVersionState {
8+
ready = 'ready',
9+
downloading = 'downloading',
10+
unknown = 'unknown'
11+
}
12+
13+
export enum ElectronVersionSource {
14+
remote = 'remote',
15+
local = 'local'
16+
}
17+
918
export interface GitHubVersion {
1019
url: string;
1120
assets_url: string;
@@ -28,6 +37,7 @@ export interface EditorValues {
2837

2938
export interface ElectronVersion extends GitHubVersion {
3039
state: ElectronVersionState;
40+
source: ElectronVersionSource;
3141
}
3242

3343
export interface OutputEntry {

src/less/core/button.less

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
button,
22
input[type='button'],
33
input[type='reset'],
4-
input[type='submit'] {
4+
input[type='submit'],
5+
.force-button {
56
background-color: @foreground-2;
67
border: @border;
78
border-radius: .4rem;
@@ -17,6 +18,7 @@ input[type='submit'] {
1718
text-decoration: none;
1819
text-transform: uppercase;
1920
white-space: nowrap;
21+
line-height: 2.95rem;
2022

2123
&:hover {
2224
box-shadow: inset 0 0 100px 100px rgba(255, 255, 255, 0.15);

src/less/core/form.less

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ select {
1717
box-shadow: none;
1818
box-sizing: inherit; // Forced to replace inherit values of the normalize.css
1919
height: 3.8rem;
20-
width: 100%;
20+
width: ~"calc(100% - 1rem)";
21+
padding-left: 1rem;
2122

2223
&:focus {
2324
border-color: @foreground-2;

src/less/dialogs.less

+11-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@
161161
}
162162

163163
input {
164-
width: 100%;
165164
color: rgba(159, 234, 249, 0.5);
166165
height: 28px;
167166
margin-top: 10px;
@@ -207,6 +206,17 @@
207206
opacity: 0.5;
208207
}
209208

209+
.add-version-dialog {
210+
label {
211+
white-space: normal;
212+
height: unset;
213+
}
214+
215+
input[type="file"] {
216+
display: none;
217+
}
218+
}
219+
210220
select {
211221
font-size: 12px;
212222
height: 28px;

src/less/settings.less

+37-18
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@
3535
width: 250px;
3636
}
3737

38+
.electron-versions-table {
39+
button {
40+
margin: 0;
41+
min-width: 250px;
42+
}
43+
44+
.action {
45+
text-align: center;
46+
width: 250px;
47+
}
48+
}
49+
50+
.settings-appearance {
51+
button {
52+
margin-left: 0.5rem;
53+
}
54+
}
55+
3856
.settings-content {
3957
height: 100%;
4058
width: 100%;
@@ -45,8 +63,27 @@
4563
}
4664

4765
.settings-electron {
66+
.advanced-options-buttons {
67+
display: flex;
68+
flex-flow: row wrap;
69+
70+
> div {
71+
margin-right: 1rem;
72+
73+
button {
74+
width: 100%;
75+
}
76+
}
77+
78+
> div:last-of-type {
79+
margin-right: 0;
80+
}
81+
}
82+
4883
.versions-to-show {
4984
margin-bottom: 2rem;
85+
border-bottom: 1px solid @border-color-1;
86+
padding-bottom: 1.5rem;
5087

5188
p {
5289
margin-bottom: 1rem;
@@ -59,18 +96,6 @@
5996
}
6097
}
6198

62-
.electron-versions-table {
63-
button {
64-
margin: 0;
65-
min-width: 250px;
66-
}
67-
68-
.action {
69-
text-align: center;
70-
width: 250px;
71-
}
72-
}
73-
7499
.settings-section {
75100
margin-bottom: 20px;
76101

@@ -163,10 +188,4 @@
163188
}
164189
}
165190
}
166-
167-
.settings-appearance {
168-
button {
169-
margin-left: 0.5rem;
170-
}
171-
}
172191
}

src/renderer/binary.ts

+17-7
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,15 @@ export class BinaryManager {
7979
const zipPath = await eDownload({ version });
8080
const extractPath = this.getDownloadPath(version);
8181
console.log(`BinaryManager: Electron ${version} downloaded, now unpacking`);
82-
const electronFiles = await this.unzip(zipPath, extractPath);
83-
console.log(electronFiles);
82+
83+
try {
84+
const electronFiles = await this.unzip(zipPath, extractPath);
85+
console.log(`Unzipped ${version}`, electronFiles);
86+
} catch (error) {
87+
console.warn(`Failure while unzipping ${version}`, error);
88+
89+
// Todo: Handle this case
90+
}
8491

8592
this.state[version] = 'ready';
8693
}
@@ -89,11 +96,13 @@ export class BinaryManager {
8996
* Gets the expected path for the binary of a given Electron version
9097
*
9198
* @param {string} version
99+
* @param {string} dir
92100
* @returns {string}
93101
*/
94-
public getElectronBinaryPath(version: string): string {
95-
const dir = this.getDownloadPath(version);
96-
102+
public getElectronBinaryPath(
103+
version: string,
104+
dir: string = this.getDownloadPath(version),
105+
): string {
97106
switch (process.platform) {
98107
case 'darwin':
99108
return path.join(dir, 'Electron.app/Contents/MacOS/Electron');
@@ -138,10 +147,11 @@ export class BinaryManager {
138147
* Did we already download a given version?
139148
*
140149
* @param {string} version
150+
* @param {string} dir
141151
* @returns {boolean}
142152
*/
143-
public async getIsDownloaded(version: string): Promise<boolean> {
144-
const expectedPath = this.getElectronBinaryPath(version);
153+
public async getIsDownloaded(version: string, dir?: string): Promise<boolean> {
154+
const expectedPath = this.getElectronBinaryPath(version, dir);
145155
const fs = await fancyImport<typeof fsType>('fs-extra');
146156
return fs.existsSync(expectedPath);
147157
}

0 commit comments

Comments
 (0)