Move GUI code into lib/gui (#358)

This refactoring will be useful on future changes, where there will be
a single application entry point that will execute the CLI or the GUI
version depending on the environment.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
Juan Cruz Viotti 2016-04-25 12:08:19 -04:00
parent 0ac79fa251
commit afeba11424
78 changed files with 69 additions and 69 deletions

View File

@ -29,9 +29,9 @@ const paths = {
'gulpfile.js' 'gulpfile.js'
], ],
sass: [ sass: [
'./lib/**/*.scss' './lib/gui/**/*.scss'
], ],
sassMain: './lib/scss/main.scss' sassMain: './lib/gui/scss/main.scss'
}; };
gulp.task('sass', function() { gulp.task('sass', function() {

View File

@ -23,40 +23,40 @@
var angular = require('angular'); var angular = require('angular');
const _ = require('lodash'); const _ = require('lodash');
const electron = require('electron'); const electron = require('electron');
const dialog = electron.remote.require('./src/dialog'); const dialog = electron.remote.require('./dialog');
const app = angular.module('Etcher', [ const app = angular.module('Etcher', [
require('angular-ui-router'), require('angular-ui-router'),
// Etcher modules // Etcher modules
require('./browser/modules/drive-scanner'), require('./modules/drive-scanner'),
require('./browser/modules/image-writer'), require('./modules/image-writer'),
require('./browser/modules/analytics'), require('./modules/analytics'),
// Models // Models
require('./browser/models/selection-state'), require('./models/selection-state'),
require('./browser/models/settings'), require('./models/settings'),
// Components // Components
require('./browser/components/progress-button/progress-button'), require('./components/progress-button/progress-button'),
require('./browser/components/drive-selector/drive-selector'), require('./components/drive-selector/drive-selector'),
require('./browser/components/svg-icon/svg-icon'), require('./components/svg-icon/svg-icon'),
// Pages // Pages
require('./browser/pages/finish/finish'), require('./pages/finish/finish'),
require('./browser/pages/settings/settings'), require('./pages/settings/settings'),
// OS // OS
require('./browser/os/notification/notification'), require('./os/notification/notification'),
require('./browser/os/window-progress/window-progress'), require('./os/window-progress/window-progress'),
require('./browser/os/open-external/open-external'), require('./os/open-external/open-external'),
require('./browser/os/dropzone/dropzone'), require('./os/dropzone/dropzone'),
// Utils // Utils
require('./browser/utils/if-state/if-state'), require('./utils/if-state/if-state'),
require('./browser/utils/notifier/notifier'), require('./utils/notifier/notifier'),
require('./browser/utils/path/path'), require('./utils/path/path'),
require('./browser/utils/manifest-bind/manifest-bind') require('./utils/manifest-bind/manifest-bind')
]); ]);
app.run(function(AnalyticsService) { app.run(function(AnalyticsService) {

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -24,8 +24,8 @@ const angular = require('angular');
const MODULE_NAME = 'Etcher.Components.DriveSelector'; const MODULE_NAME = 'Etcher.Components.DriveSelector';
const DriveSelector = angular.module(MODULE_NAME, [ const DriveSelector = angular.module(MODULE_NAME, [
require('angular-ui-bootstrap'), require('angular-ui-bootstrap'),
require('../../../browser/modules/drive-scanner'), require('../../modules/drive-scanner'),
require('../../../browser/models/selection-state') require('../../models/selection-state')
]); ]);
DriveSelector.controller('DriveSelectorController', require('./controllers/drive-selector')); DriveSelector.controller('DriveSelectorController', require('./controllers/drive-selector'));

View File

@ -36,7 +36,7 @@ module.exports = function($uibModal, $q) {
this.open = function() { this.open = function() {
modal = $uibModal.open({ modal = $uibModal.open({
animation: true, animation: true,
templateUrl: './browser/components/drive-selector/templates/drive-selector-modal.tpl.html', templateUrl: './components/drive-selector/templates/drive-selector-modal.tpl.html',
controller: 'DriveSelectorController as modal', controller: 'DriveSelectorController as modal',
size: 'sm' size: 'sm'
}); });

View File

@ -32,7 +32,7 @@
*/ */
module.exports = function() { module.exports = function() {
return { return {
templateUrl: './browser/components/progress-button/templates/progress-button.tpl.html', templateUrl: './components/progress-button/templates/progress-button.tpl.html',
restrict: 'E', restrict: 'E',
replace: true, replace: true,
transclude: true, transclude: true,

View File

@ -34,7 +34,7 @@ const fs = require('fs');
*/ */
module.exports = function() { module.exports = function() {
return { return {
templateUrl: './browser/components/svg-icon/templates/svg-icon.tpl.html', templateUrl: './components/svg-icon/templates/svg-icon.tpl.html',
replace: true, replace: true,
restrict: 'E', restrict: 'E',
scope: { scope: {

View File

@ -19,8 +19,8 @@
const electron = require('electron'); const electron = require('electron');
const globalShortcut = require('global-shortcut'); const globalShortcut = require('global-shortcut');
const path = require('path'); const path = require('path');
const elevate = require('./elevate'); const elevate = require('../src/elevate');
const packageJSON = require('../package.json'); const packageJSON = require('../../package.json');
let mainWindow = null; let mainWindow = null;
electron.app.on('window-all-closed', electron.app.quit); electron.app.on('window-all-closed', electron.app.quit);
@ -45,7 +45,7 @@ electron.app.on('ready', function() {
resizable: false, resizable: false,
fullscreen: false, fullscreen: false,
titleBarStyle: 'hidden-inset', titleBarStyle: 'hidden-inset',
icon: path.join(__dirname, '..', 'assets', 'icon.png') icon: path.join(__dirname, '..', '..', 'assets', 'icon.png')
}); });
// Prevent flash of white when starting the application // Prevent flash of white when starting the application

View File

@ -2,8 +2,8 @@
<html> <html>
<head> <head>
<title>Etcher</title> <title>Etcher</title>
<link rel="stylesheet" type="text/css" href="../node_modules/flexboxgrid/dist/flexboxgrid.css"> <link rel="stylesheet" type="text/css" href="../../node_modules/flexboxgrid/dist/flexboxgrid.css">
<link rel="stylesheet" type="text/css" href="../build/css/main.css"> <link rel="stylesheet" type="text/css" href="../../build/css/main.css">
<link rel="stylesheet" type="text/css" href="css/desktop.css"> <link rel="stylesheet" type="text/css" href="css/desktop.css">
<link rel="stylesheet" type="text/css" href="css/angular.css"> <link rel="stylesheet" type="text/css" href="css/angular.css">
@ -13,9 +13,9 @@
application: 'etcher' application: 'etcher'
}; };
</script> </script>
<script src="../node_modules/trackjs/tracker.js"></script> <script src="../../node_modules/trackjs/tracker.js"></script>
<script src="./browser/app.js"></script> <script src="./app.js"></script>
</head> </head>
<body ng-app="Etcher" style="display: none"> <body ng-app="Etcher" style="display: none">
<header class="section-header"> <header class="section-header">
@ -35,7 +35,7 @@
<main class="wrapper" ui-view></main> <main class="wrapper" ui-view></main>
<footer class="section-footer"> <footer class="section-footer">
<svg-icon path="../../../../../assets/images/etcher.svg" <svg-icon path="../../../assets/etcher.svg"
width="83px" width="83px"
height="13px" height="13px"
os-open-external="http://etcher.io"></svg-icon> os-open-external="http://etcher.io"></svg-icon>
@ -44,7 +44,7 @@
IS <span class="caption" os-open-external="https://github.com/resin-io/etcher">AN OPEN SOURCE PROJECT</span> BY IS <span class="caption" os-open-external="https://github.com/resin-io/etcher">AN OPEN SOURCE PROJECT</span> BY
</span> </span>
<svg-icon path="../../../../../assets/images/resin.svg" <svg-icon path="../../../assets/resin.svg"
width="79px" width="79px"
height="23px" height="23px"
os-open-external="https://resin.io"></svg-icon> os-open-external="https://resin.io"></svg-icon>

View File

@ -28,7 +28,7 @@ const packageJSON = require('../../../package.json');
// Force Mixpanel snippet to load Mixpanel locally // Force Mixpanel snippet to load Mixpanel locally
// instead of using a CDN for performance reasons // instead of using a CDN for performance reasons
window.MIXPANEL_CUSTOM_LIB_URL = '../bower_components/mixpanel/mixpanel.js'; window.MIXPANEL_CUSTOM_LIB_URL = '../../bower_components/mixpanel/mixpanel.js';
require('../../../bower_components/mixpanel/mixpanel-jslib-snippet.js'); require('../../../bower_components/mixpanel/mixpanel-jslib-snippet.js');
require('../../../bower_components/angular-mixpanel/src/angular-mixpanel'); require('../../../bower_components/angular-mixpanel/src/angular-mixpanel');

View File

@ -26,7 +26,7 @@ const electron = require('electron');
if (window.mocha) { if (window.mocha) {
var writer = electron.remote.require(require('path').join(__dirname, '..', '..', 'src', 'writer')); var writer = electron.remote.require(require('path').join(__dirname, '..', '..', 'src', 'writer'));
} else { } else {
var writer = electron.remote.require('./src/writer'); var writer = electron.remote.require('../src/writer');
} }
const MODULE_NAME = 'Etcher.image-writer'; const MODULE_NAME = 'Etcher.image-writer';

View File

@ -43,7 +43,7 @@ FinishPage.config(function($stateProvider) {
.state('success', { .state('success', {
url: '/success', url: '/success',
controller: 'FinishController as finish', controller: 'FinishController as finish',
templateUrl: './browser/pages/finish/templates/success.tpl.html' templateUrl: './pages/finish/templates/success.tpl.html'
}); });
}); });

View File

@ -34,7 +34,7 @@ SettingsPage.config(function($stateProvider) {
.state('settings', { .state('settings', {
url: '/settings', url: '/settings',
controller: 'SettingsController as settings', controller: 'SettingsController as settings',
templateUrl: './browser/pages/settings/templates/settings.tpl.html' templateUrl: './pages/settings/templates/settings.tpl.html'
}); });
}); });

View File

@ -1,7 +1,7 @@
<div class="row around-xs"> <div class="row around-xs">
<div class="col-xs"> <div class="col-xs">
<div class="box text-center" os-dropzone="app.selectImage($file)"> <div class="box text-center" os-dropzone="app.selectImage($file)">
<svg-icon class="center-block" path="../../../../../assets/images/image.svg"></svg-icon> <svg-icon class="center-block" path="../../../assets/image.svg"></svg-icon>
<span class="icon-caption">SELECT IMAGE</span> <span class="icon-caption">SELECT IMAGE</span>
<span class="badge space-top-medium">1</span> <span class="badge space-top-medium">1</span>
@ -27,7 +27,7 @@
<div class="step-border-right" ng-disabled="!app.selection.hasImage() || !app.selection.hasDrive()"></div> <div class="step-border-right" ng-disabled="!app.selection.hasImage() || !app.selection.hasDrive()"></div>
<svg-icon class="center-block" <svg-icon class="center-block"
path="../../../../../assets/images/drive.svg" path="../../../assets/drive.svg"
ng-disabled="!app.selection.hasImage()"></svg-icon> ng-disabled="!app.selection.hasImage()"></svg-icon>
<span class="icon-caption" <span class="icon-caption"
ng-disabled="!app.selection.hasImage()">SELECT DRIVE</span> ng-disabled="!app.selection.hasImage()">SELECT DRIVE</span>
@ -62,7 +62,7 @@
<div class="col-xs"> <div class="col-xs">
<div class="box text-center"> <div class="box text-center">
<svg-icon class="center-block" <svg-icon class="center-block"
path="../../../../../assets/images/flash.svg" path="../../../assets/flash.svg"
ng-disabled="!app.selection.hasImage() || !app.selection.hasDrive()"></svg-icon> ng-disabled="!app.selection.hasImage() || !app.selection.hasDrive()"></svg-icon>
<span class="icon-caption" <span class="icon-caption"
ng-disabled="!app.selection.hasImage() || !app.selection.hasDrive()">FLASH IMAGE</span> ng-disabled="!app.selection.hasImage() || !app.selection.hasDrive()">FLASH IMAGE</span>

View File

@ -33,7 +33,7 @@ $alert-warning-bg: $brand-warning;
$alert-warning-text: #fff; $alert-warning-text: #fff;
$alert-padding: 13px; $alert-padding: 13px;
@import "../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; @import "../../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
@import "./modules/bootstrap"; @import "./modules/bootstrap";
@import "./modules/space"; @import "./modules/space";
@ -41,8 +41,8 @@ $alert-padding: 13px;
@import "./components/caption"; @import "./components/caption";
@import "./components/button"; @import "./components/button";
@import "./components/tick"; @import "./components/tick";
@import "../browser/components/progress-button/styles/progress-button"; @import "../components/progress-button/styles/progress-button";
@import "../browser/components/svg-icon/styles/svg-icon"; @import "../components/svg-icon/styles/svg-icon";
@import "./components/modal"; @import "./components/modal";
@import "./components/alert-ribbon"; @import "./components/alert-ribbon";

View File

@ -2,7 +2,7 @@
"name": "etcher", "name": "etcher",
"displayName": "Etcher", "displayName": "Etcher",
"version": "1.0.0-beta.4", "version": "1.0.0-beta.4",
"main": "lib/etcher.js", "main": "lib/gui/etcher.js",
"description": "An image flasher with support for Windows, OS X and GNU/Linux.", "description": "An image flasher with support for Windows, OS X and GNU/Linux.",
"homepage": "https://github.com/resin-io/etcher", "homepage": "https://github.com/resin-io/etcher",
"repository": { "repository": {
@ -11,9 +11,9 @@
}, },
"scripts": { "scripts": {
"test:main": "electron-mocha --recursive tests/src -R progress", "test:main": "electron-mocha --recursive tests/src -R progress",
"test:browser": "electron-mocha --recursive --renderer tests/browser -R progress", "test:gui": "electron-mocha --recursive --renderer tests/gui -R progress",
"test": "npm run-script test:main && npm run-script test:browser", "test": "npm run-script test:main && npm run-script test:gui",
"start": "electron lib/etcher.js" "start": "electron lib/gui/etcher.js"
}, },
"author": "Juan Cruz Viotti <juan@resin.io>", "author": "Juan Cruz Viotti <juan@resin.io>",
"license": "Apache-2.0", "license": "Apache-2.0",

View File

@ -7,7 +7,7 @@ require('angular-mocks');
describe('Browser: DriveSelector', function() { describe('Browser: DriveSelector', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/components/drive-selector/drive-selector') require('../../../lib/gui/components/drive-selector/drive-selector')
)); ));
describe('DriveSelectorStateService', function() { describe('DriveSelectorStateService', function() {

View File

@ -9,7 +9,7 @@ require('angular-mocks');
describe('Browser: SVGIcon', function() { describe('Browser: SVGIcon', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/components/svg-icon/svg-icon') require('../../../lib/gui/components/svg-icon/svg-icon')
)); ));
describe('svgIcon', function() { describe('svgIcon', function() {
@ -23,8 +23,8 @@ describe('Browser: SVGIcon', function() {
// Workaround `Unexpected request: GET template.html. No more request expected` error. // Workaround `Unexpected request: GET template.html. No more request expected` error.
// See http://stackoverflow.com/a/29437480/1641422 // See http://stackoverflow.com/a/29437480/1641422
const templatePath = './browser/components/svg-icon/templates/svg-icon.tpl.html'; const templatePath = './components/svg-icon/templates/svg-icon.tpl.html';
const template = fs.readFileSync(path.resolve('lib', templatePath), { const template = fs.readFileSync(path.resolve('lib', 'gui', templatePath), {
encoding: 'utf8' encoding: 'utf8'
}); });
$templateCache.put(templatePath, template); $templateCache.put(templatePath, template);
@ -32,8 +32,8 @@ describe('Browser: SVGIcon', function() {
})); }));
it('should inline the svg contents in the element', function() { it('should inline the svg contents in the element', function() {
const icon = '../../../../../assets/images/etcher.svg'; const icon = '../../../../../lib/gui/assets/etcher.svg';
let iconContents = fs.readFileSync(path.join(__dirname, '../../../assets/images/etcher.svg'), { let iconContents = fs.readFileSync(path.join(__dirname, '../../../lib/gui/assets/etcher.svg'), {
encoding: 'utf8' encoding: 'utf8'
}).split('\n'); }).split('\n');
@ -48,7 +48,7 @@ describe('Browser: SVGIcon', function() {
}); });
it('should default the size to 40x40 pixels', function() { it('should default the size to 40x40 pixels', function() {
const icon = '../../../../../assets/images/etcher.svg'; const icon = '../../../../../lib/gui/assets/etcher.svg';
const element = $compile(`<svg-icon path="${icon}">Resin.io</svg-icon>`)($rootScope); const element = $compile(`<svg-icon path="${icon}">Resin.io</svg-icon>`)($rootScope);
$rootScope.$digest(); $rootScope.$digest();
m.chai.expect(element.css('width')).to.equal('40px'); m.chai.expect(element.css('width')).to.equal('40px');
@ -56,7 +56,7 @@ describe('Browser: SVGIcon', function() {
}); });
it('should be able to set a custom height', function() { it('should be able to set a custom height', function() {
const icon = '../../../../../assets/images/etcher.svg'; const icon = '../../../../../lib/gui/assets/etcher.svg';
const element = $compile(`<svg-icon path="${icon}" width="20px">Resin.io</svg-icon>`)($rootScope); const element = $compile(`<svg-icon path="${icon}" width="20px">Resin.io</svg-icon>`)($rootScope);
$rootScope.$digest(); $rootScope.$digest();
m.chai.expect(element.css('width')).to.equal('20px'); m.chai.expect(element.css('width')).to.equal('20px');
@ -64,7 +64,7 @@ describe('Browser: SVGIcon', function() {
}); });
it('should be able to set a custom height', function() { it('should be able to set a custom height', function() {
const icon = '../../../../../assets/images/etcher.svg'; const icon = '../../../../../lib/gui/assets/etcher.svg';
const element = $compile(`<svg-icon path="${icon}" height="20px">Resin.io</svg-icon>`)($rootScope); const element = $compile(`<svg-icon path="${icon}" height="20px">Resin.io</svg-icon>`)($rootScope);
$rootScope.$digest(); $rootScope.$digest();
m.chai.expect(element.css('width')).to.equal('40px'); m.chai.expect(element.css('width')).to.equal('40px');

View File

@ -7,7 +7,7 @@ require('angular-mocks');
describe('Browser: SelectionState', function() { describe('Browser: SelectionState', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/models/selection-state') require('../../../lib/gui/models/selection-state')
)); ));
describe('SelectionStateModel', function() { describe('SelectionStateModel', function() {

View File

@ -8,7 +8,7 @@ require('angular-mocks');
describe('Browser: DriveScanner', function() { describe('Browser: DriveScanner', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/modules/drive-scanner') require('../../../lib/gui/modules/drive-scanner')
)); ));
describe('DriveScannerService', function() { describe('DriveScannerService', function() {

View File

@ -7,7 +7,7 @@ require('angular-mocks');
describe('Browser: ImageWriter', function() { describe('Browser: ImageWriter', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/modules/image-writer') require('../../../lib/gui/modules/image-writer')
)); ));
describe('ImageWriterService', function() { describe('ImageWriterService', function() {

View File

@ -23,7 +23,7 @@ require('angular-mocks');
describe('Browser: OSDropzone', function() { describe('Browser: OSDropzone', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/os/dropzone/dropzone') require('../../../lib/gui/os/dropzone/dropzone')
)); ));
describe('osDropzone', function() { describe('osDropzone', function() {

View File

@ -25,7 +25,7 @@ require('angular-mocks');
describe('Browser: OSOpenExternal', function() { describe('Browser: OSOpenExternal', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/os/open-external/open-external') require('../../../lib/gui/os/open-external/open-external')
)); ));
describe('osOpenExternal', function() { describe('osOpenExternal', function() {

View File

@ -23,7 +23,7 @@ require('angular-mocks');
describe('Browser: OSWindowProgress', function() { describe('Browser: OSWindowProgress', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/os/window-progress/window-progress') require('../../../lib/gui/os/window-progress/window-progress')
)); ));
describe('OSWindowProgressService', function() { describe('OSWindowProgressService', function() {

View File

@ -23,7 +23,7 @@ require('angular-mocks');
describe('Browser: IfState', function() { describe('Browser: IfState', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/utils/if-state/if-state') require('../../../lib/gui/utils/if-state/if-state')
)); ));
let $compile; let $compile;

View File

@ -24,7 +24,7 @@ require('angular-mocks');
describe('Browser: ManifestBind', function() { describe('Browser: ManifestBind', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/utils/manifest-bind/manifest-bind') require('../../../lib/gui/utils/manifest-bind/manifest-bind')
)); ));
let $compile; let $compile;

View File

@ -7,7 +7,7 @@ require('angular-mocks');
describe('Browser: Notifier', function() { describe('Browser: Notifier', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/utils/notifier/notifier') require('../../../lib/gui/utils/notifier/notifier')
)); ));
describe('NotifierService', function() { describe('NotifierService', function() {

View File

@ -8,7 +8,7 @@ require('angular-mocks');
describe('Browser: Path', function() { describe('Browser: Path', function() {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(
require('../../../lib/browser/utils/path/path') require('../../../lib/gui/utils/path/path')
)); ));
describe('BasenameFilter', function() { describe('BasenameFilter', function() {

View File

@ -2,7 +2,7 @@
const m = require('mochainon'); const m = require('mochainon');
const electron = require('electron'); const electron = require('electron');
const dialog = require('../../lib/src/dialog'); const dialog = require('../../lib/gui/dialog');
describe('Dialog:', function() { describe('Dialog:', function() {