Skip to content

Commit

Permalink
fix: fix folder structure
Browse files Browse the repository at this point in the history
closes #64
  • Loading branch information
juancarlosfarah committed May 3, 2019
1 parent 8ea8c53 commit 61844d0
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"license": "MIT",
"homepage": "./",
"main": "app/electron.js",
"main": "public/electron.js",
"keywords": [
"Graasp Desktop",
"React",
Expand Down
20 changes: 20 additions & 0 deletions public/app/config/channels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// this file needs to use module.exports as it is used both by react and electron
// make sure this file is identical in both src/config and public/app/config

module.exports = {
SAVE_SPACE_CHANNEL: 'space:save',
GET_SPACE_CHANNEL: 'space:get',
GET_SPACES_CHANNEL: 'spaces:get',
DELETE_SPACE_CHANNEL: 'space:delete',
DELETED_SPACE_CHANNEL: 'space:deleted',
LOAD_SPACE_CHANNEL: 'space:load',
LOADED_SPACE_CHANNEL: 'space:loaded',
EXPORT_SPACE_CHANNEL: 'space:export',
EXPORTED_SPACE_CHANNEL: 'space:exported',
SHOW_LOAD_SPACE_PROMPT_CHANNEL: 'prompt:space:load:show',
SHOW_EXPORT_SPACE_PROMPT_CHANNEL: 'prompt:space:export:show',
SHOW_DELETE_SPACE_PROMPT_CHANNEL: 'prompt:space:delete:show',
RESPOND_LOAD_SPACE_PROMPT_CHANNEL: 'prompt:space:load:response',
RESPOND_EXPORT_SPACE_PROMPT_CHANNEL: 'prompt:space:export:respond',
RESPOND_DELETE_SPACE_PROMPT_CHANNEL: 'prompt:space:delete:respond',
};
File renamed without changes.
16 changes: 16 additions & 0 deletions public/app/config/errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// this file needs to use module.exports as it is used both by react and electron
// make sure this file is identical in both src/config and app/config

const ERROR_ZIP_CORRUPTED = 'ERROR_ZIP_CORRUPTED';
const ERROR_JSON_CORRUPTED = 'ERROR_JSON_CORRUPTED';
const ERROR_SPACE_ALREADY_AVAILABLE = 'ERROR_SPACE_ALREADY_AVAILABLE';
const ERROR_DOWNLOADING_FILE = 'ERROR_DOWNLOADING_FILE';
const ERROR_GENERAL = 'ERROR_GENERAL';

module.exports = {
ERROR_ZIP_CORRUPTED,
ERROR_JSON_CORRUPTED,
ERROR_SPACE_ALREADY_AVAILABLE,
ERROR_DOWNLOADING_FILE,
ERROR_GENERAL,
};
42 changes: 42 additions & 0 deletions public/app/config/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// this file needs to use module.exports as it is used both by react and electron
// make sure this file is identical in both src/config and public/app/config

const ERROR_DOWNLOADING_MESSAGE = 'There was a problem downloading your files';
const ERROR_LOADING_MESSAGE = 'There was a problem loading your space';
const ERROR_EXPORTING_MESSAGE = 'There was a problem exporting this space';
const SUCCESS_EXPORTING_MESSAGE = 'Space was exported successfully';
const ERROR_DELETING_MESSAGE = 'There was a problem deleting this space';
const SUCCESS_DELETING_MESSAGE = 'Space was deleted successfully';
const ERROR_ZIP_CORRUPTED_MESSAGE =
'The archive provided is not formatted properly';
const ERROR_JSON_CORRUPTED_MESSAGE = "Space's JSON file is corrupted";
const ERROR_SPACE_ALREADY_AVAILABLE_MESSAGE =
'A space with the same id is already available';
const SUCCESS_SPACE_LOADED_MESSAGE = 'Space was loaded successfully';
const UNEXPECTED_ERROR_MESSAGE = 'An unexpected error has occurred';
const ERROR_GETTING_SPACE_MESSAGE = 'There was an error getting that space.';
const OFFLINE_ERROR_MESSAGE = 'This functionality requires online connectivity';
const ERROR_MESSAGE_HEADER = 'Error';
const ERROR_SAVING_SPACE_MESSAGE = 'There was an error saving the space';
const SUCCESS_SAVING_MESSAGE = 'Space was saved successfully';
const SUCCESS_MESSAGE_HEADER = 'Success';

module.exports = {
ERROR_DOWNLOADING_MESSAGE,
ERROR_MESSAGE_HEADER,
ERROR_SAVING_SPACE_MESSAGE,
SUCCESS_SAVING_MESSAGE,
SUCCESS_MESSAGE_HEADER,
ERROR_GETTING_SPACE_MESSAGE,
ERROR_EXPORTING_MESSAGE,
SUCCESS_EXPORTING_MESSAGE,
ERROR_DELETING_MESSAGE,
SUCCESS_DELETING_MESSAGE,
ERROR_ZIP_CORRUPTED_MESSAGE,
ERROR_JSON_CORRUPTED_MESSAGE,
ERROR_SPACE_ALREADY_AVAILABLE_MESSAGE,
SUCCESS_SPACE_LOADED_MESSAGE,
UNEXPECTED_ERROR_MESSAGE,
OFFLINE_ERROR_MESSAGE,
ERROR_LOADING_MESSAGE,
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 21 additions & 21 deletions app/electron.js → public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ const extract = require('extract-zip');
const archiver = require('archiver');
const { autoUpdater } = require('electron-updater');
const Sentry = require('@sentry/electron');
const logger = require('./app/logger');
const {
getExtension,
isDownloadable,
generateHash,
createSpaceDirectory,
} = require('./app/utilities');
const {
ensureDatabaseExists,
bootstrapDatabase,
SPACES_COLLECTION,
} = require('./app/db');
const {
VAR_FOLDER,
DATABASE_PATH,
TEMPORARY_EXTRACT_FOLDER,
} = require('./app/config/config');
const {
LOAD_SPACE_CHANNEL,
LOADED_SPACE_CHANNEL,
Expand All @@ -33,30 +50,13 @@ const {
SHOW_LOAD_SPACE_PROMPT_CHANNEL,
RESPOND_LOAD_SPACE_PROMPT_CHANNEL,
SAVE_SPACE_CHANNEL,
} = require('../src/config/channels');
const {
getExtension,
isDownloadable,
generateHash,
createSpaceDirectory,
} = require('./utilities');
const {
ensureDatabaseExists,
bootstrapDatabase,
SPACES_COLLECTION,
} = require('./db');
} = require('./app/config/channels');
const {
ERROR_SPACE_ALREADY_AVAILABLE,
ERROR_DOWNLOADING_FILE,
ERROR_GENERAL,
ERROR_ZIP_CORRUPTED,
} = require('../src/config/errors');
const logger = require('./logger');
const {
VAR_FOLDER,
DATABASE_PATH,
TEMPORARY_EXTRACT_FOLDER,
} = require('./config/config');
} = require('./app/config/errors');

// use promisified fs
const fsPromises = fs.promises;
Expand All @@ -81,7 +81,7 @@ const createWindow = () => {
movable: true,
webPreferences: {
nodeIntegration: false,
preload: `${__dirname}/preload.js`,
preload: `${__dirname}/app/preload.js`,
webSecurity: false,
},
height: 860,
Expand All @@ -91,7 +91,7 @@ const createWindow = () => {
mainWindow.loadURL(
isDev
? 'http://localhost:3000'
: `file://${path.join(__dirname, '../build/index.html')}`
: `file://${path.join(__dirname, './index.html')}`
);

if (isDev) {
Expand Down
2 changes: 2 additions & 0 deletions src/config/channels.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// this file needs to use module.exports as it is used both by react and electron
// make sure this file is identical in both src/config and public/app/config

module.exports = {
SAVE_SPACE_CHANNEL: 'space:save',
GET_SPACE_CHANNEL: 'space:get',
Expand Down
2 changes: 2 additions & 0 deletions src/config/errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// this file needs to use module.exports as it is used both by react and electron
// make sure this file is identical in both src/config and public/app/config

const ERROR_ZIP_CORRUPTED = 'ERROR_ZIP_CORRUPTED';
const ERROR_JSON_CORRUPTED = 'ERROR_JSON_CORRUPTED';
const ERROR_SPACE_ALREADY_AVAILABLE = 'ERROR_SPACE_ALREADY_AVAILABLE';
Expand Down
1 change: 1 addition & 0 deletions src/config/messages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// this file needs to use module.exports as it is used both by react and electron
// make sure this file is identical in both src/config and public/app/config

const ERROR_DOWNLOADING_MESSAGE = 'There was a problem downloading your files';
const ERROR_LOADING_MESSAGE = 'There was a problem loading your space';
Expand Down

0 comments on commit 61844d0

Please sign in to comment.