Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/graasp/graasp-desktop int…
Browse files Browse the repository at this point in the history
…o 323/implement-a-tour-guide
  • Loading branch information
hasanagh committed Oct 15, 2020
2 parents 1ce1c7e + 0a40f92 commit 940e452
Show file tree
Hide file tree
Showing 25 changed files with 664 additions and 541 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,22 @@ Following the `electron-log` defaults, logs are written to the following locatio
- Linux: `~/.config/{app name}/logs/{process type}.log`
- macOS: `~/Library/Logs/{app name}/{process type}.log`
- Windows: `%USERPROFILE%\AppData\Roaming\{app name}\logs\{process type}.log`

## Deploy and Publish

**Note**: MacOS can compile the desktop application for every other platforms. Windows OS can only compile Windows executable files.

### Requirements

- You should try to update all dependencies, particularly any dependencies related to `electron` and `electron-builder` as this dependency will create the executable files for every OS.
- Make sure your `.env` and `.env.test` files contain the correct values. Use your own github token `GH_TOKEN` in order to release the new version with your github account.
- **Sign Apple executable files**: In order to sign the application and publish it on the mac store, you will need a corresponding **Developer ID** certificate installed on your apple computer. You need to be part of the apple developer team on the [Apple Developers Website](https://developer.apple.com/) as well as use the certificate containing the private key. [Here](https://help.apple.com/xcode/mac/current/#/dev154b28f09) you can find some indications to help you install this certificate. Once added to _Xcode_ (the should also be available in _My Certificates_ in Keychain), this certificate will be automatically be used during the creation of the executable files. You will also need the `assets/embedded.provisionprofile` file.
This command will tell you if your app was correctly signed: `codesign --display --verbose=2 dist/mac/Graasp.app`

### Steps

1. Run `yarn dist`. This command will first build the repository and compile it into multiple executable files. All the configuration is set in `package.json`.

2. Run `yarn release`. This command will prepare the new release tag and push it on github.

3. Sign in on Github and go to the **Tags** page. Here your release will be waiting for your approval. The release should contain every compiled files for Windows, Mac and Linux platforms (these might be only visible when the user is signed in). As `CHANGELOG.md` was automatically filled in with the release's changes, copy and paste the corresponding changes in the release's description. You can approve the release.
81 changes: 40 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"prebuild": "env-cmd -f ./.env node scripts/setup.js",
"predist": "yarn build",
"predist:win": "yarn build",
"predist:mac": "yarn build",
"predist:linux": "yarn build",
"predist:posix": "yarn build",
"prerelease": "yarn test:once && yarn build",
Expand Down Expand Up @@ -71,95 +70,95 @@
"dependencies": {
"@material-ui/core": "4.11.0",
"@material-ui/icons": "4.9.1",
"@sentry/browser": "5.19.2",
"@sentry/electron": "1.4.0",
"@sentry/browser": "5.24.2",
"@sentry/electron": "2.0.1",
"about-window": "1.13.4",
"archiver": "3.1.1",
"archiver": "5.0.2",
"bson-objectid": "1.3.1",
"chai": "4.2.0",
"cheerio": "1.0.0-rc.3",
"classnames": "2.2.6",
"clsx": "1.1.1",
"connected-react-router": "6.8.0",
"download": "7.1.0",
"electron-devtools-installer": "2.2.4",
"download": "8.0.0",
"electron-devtools-installer": "3.1.1",
"electron-is-dev": "1.2.0",
"electron-log": "4.2.2",
"electron-log": "4.2.4",
"electron-publisher-s3": "20.17.2",
"electron-updater": "4.3.1",
"electron-updater": "4.3.5",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.2",
"extract-zip": "1.6.7",
"enzyme-adapter-react-16": "1.15.5",
"extract-zip": "2.0.1",
"fs-extra": "9.0.1",
"history": "4.10.1",
"i18next": "19.6.2",
"history": "5.0.0",
"i18next": "19.7.0",
"immutable": "4.0.0-rc.12",
"is-online": "8.4.0",
"katex": "0.11.1",
"lodash": "4.17.19",
"katex": "0.12.0",
"lodash": "4.17.20",
"lowdb": "1.0.0",
"md5": "2.2.1",
"md5": "2.3.0",
"mime-types": "2.1.27",
"mkdirp": "1.0.4",
"mocha": "7.1.0",
"mocha": "8.1.3",
"node-machine-id": "1.1.12",
"prop-types": "15.7.2",
"qs": "6.9.4",
"re-resizable": "6.5.4",
"re-resizable": "6.6.1",
"react": "16.13.1",
"react-countup": "4.3.3",
"react-detect-offline": "2.4.0",
"react-dev-utils": "10.2.1",
"react-diff-viewer": "3.1.1",
"react-dom": "16.13.1",
"react-i18next": "11.7.0",
"react-i18next": "11.7.3",
"react-immutable-proptypes": "2.2.0",
"react-joyride": "2.2.1",
"react-json-view": "1.19.1",
"react-loading": "2.0.3",
"react-quill": "1.3.5",
"react-redux": "7.2.0",
"react-redux": "7.2.1",
"react-redux-toastr": "7.6.5",
"react-router": "5.2.0",
"react-router-dom": "5.2.0",
"react-select": "3.1.0",
"react-split-pane": "0.1.91",
"react-split-pane": "0.1.92",
"recharts": "1.8.5",
"redux": "4.0.5",
"redux-devtools-extension": "2.13.8",
"redux-promise": "0.6.0",
"redux-thunk": "2.3.0",
"request-promise": "4.2.5",
"request-promise": "4.2.6",
"rimraf": "3.0.2",
"universal-analytics": "0.4.23"
},
"devDependencies": {
"@babel/cli": "7.10.5",
"@babel/core": "7.10.5",
"@babel/plugin-transform-runtime": "7.10.5",
"@babel/preset-env": "7.10.4",
"@babel/register": "7.10.5",
"@commitlint/cli": "9.1.1",
"@commitlint/config-conventional": "9.1.1",
"@babel/cli": "7.11.6",
"@babel/core": "7.11.6",
"@babel/plugin-transform-runtime": "7.11.5",
"@babel/preset-env": "7.11.5",
"@babel/register": "7.11.5",
"@commitlint/cli": "11.0.0",
"@commitlint/config-conventional": "11.0.0",
"codacy-coverage": "3.4.0",
"concurrently": "5.2.0",
"concurrently": "5.3.0",
"cross-env": "7.0.2",
"electron": "8.2.4",
"electron-builder": "22.7.0",
"electron": "10.1.3",
"electron-builder": "22.8.1",
"env-cmd": "10.1.0",
"enzyme-to-json": "3.5.0",
"enzyme-to-json": "3.6.1",
"eslint-config-airbnb": "18.2.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-mocha": "6.3.0",
"husky": "4.2.5",
"eslint-config-prettier": "6.12.0",
"eslint-plugin-mocha": "8.0.0",
"husky": "4.3.0",
"npm-run-all": "4.1.5",
"prettier": "1.19.1",
"pretty-quick": "2.0.1",
"react-scripts": "3.4.1",
"prettier": "2.1.2",
"pretty-quick": "3.0.2",
"react-scripts": "3.4.3",
"redux-mock-store": "1.5.4",
"spectron": "10.0.1",
"standard-version": "8.0.2",
"wait-on": "4.0.1"
"spectron": "12.0.0",
"standard-version": "9.0.0",
"wait-on": "5.2.0"
},
"build": {
"appId": "com.graasp",
Expand Down
15 changes: 6 additions & 9 deletions public/app/listeners/loadSpace.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const extract = require('extract-zip');
const _ = require('lodash');
const { promisify } = require('util');
const fs = require('fs');
const ObjectId = require('bson-objectid');
const { VAR_FOLDER } = require('../config/config');
Expand Down Expand Up @@ -54,7 +53,7 @@ const renameSpaceFolder = async (prevPath, newPath) => {
return wasRenamed;
};

const extractFileToLoadSpace = mainWindow => async (
const extractFileToLoadSpace = (mainWindow) => async (
event,
{ fileLocation }
) => {
Expand All @@ -63,7 +62,7 @@ const extractFileToLoadSpace = mainWindow => async (
// make temporary folder hidden
const extractPath = `${VAR_FOLDER}/.${tmpId}`;
try {
await promisify(extract)(fileLocation, { dir: extractPath });
await extract(fileLocation, { dir: extractPath });

// get basic information from manifest
const manifestPath = `${extractPath}/manifest.json`;
Expand Down Expand Up @@ -102,7 +101,7 @@ const extractFileToLoadSpace = mainWindow => async (
}
};

const clearLoadSpace = mainWindow => async (event, { extractPath }) => {
const clearLoadSpace = (mainWindow) => async (event, { extractPath }) => {
const isCleanSuccessful = clean(extractPath);
mainWindow.webContents.send(CLEAR_LOAD_SPACE_CHANNEL);
return isCleanSuccessful;
Expand Down Expand Up @@ -158,9 +157,7 @@ const loadSpace = (mainWindow, db) => async (
deleteSpaceAndResources(db, id, tmpPath);

// add new space in database
db.get(SPACES_COLLECTION)
.push(space)
.write();
db.get(SPACES_COLLECTION).push(space).write();
} else {
// clean temp space folder
clean(extractPath);
Expand All @@ -181,7 +178,7 @@ const loadSpace = (mainWindow, db) => async (
// keep only non-duplicate resources
.filter(({ id }) => !savedResources.find({ id }).value())
// change user id by current user id
.map(resource => ({
.map((resource) => ({
...resource,
user: userId,
}));
Expand All @@ -202,7 +199,7 @@ const loadSpace = (mainWindow, db) => async (
// keep only non-duplicate actions
.filter(({ id }) => !savedActions.find({ id }).value())
// change user id by current user id
.map(action => ({ ...action, user: userId }));
.map((action) => ({ ...action, user: userId }));

savedActions.push(...newActions).write();
}
Expand Down
28 changes: 19 additions & 9 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {
ipcMain,
Menu,
dialog,
protocol,
// eslint-disable-next-line import/no-extraneous-dependencies
} = require('electron');
const path = require('path');
Expand Down Expand Up @@ -139,7 +140,7 @@ const {
const isMac = require('./app/utils/isMac');

// add keys to process
Object.keys(env).forEach(key => {
Object.keys(env).forEach((key) => {
process.env[key] = env[key];
});

Expand Down Expand Up @@ -201,25 +202,25 @@ const createWindow = () => {

if (isDev) {
const {
default: installExtension,
default: loadExtension,
REACT_DEVELOPER_TOOLS,
REDUX_DEVTOOLS,
// eslint-disable-next-line global-require
} = require('electron-devtools-installer');

installExtension(REACT_DEVELOPER_TOOLS)
.then(name => {
loadExtension(REACT_DEVELOPER_TOOLS)
.then((name) => {
logger.info(`added extension: ${name}`);
})
.catch(err => {
.catch((err) => {
logger.error(err);
});

installExtension(REDUX_DEVTOOLS)
.then(name => {
loadExtension(REDUX_DEVTOOLS)
.then((name) => {
logger.info(`added extension: ${name}`);
})
.catch(err => {
.catch((err) => {
logger.error(err);
});
}
Expand Down Expand Up @@ -375,7 +376,7 @@ app.on('ready', async () => {
autoUpdater
.checkForUpdatesAndNotify()
.then()
.catch(err => logger.error(err));
.catch((err) => logger.error(err));

await ensureDatabaseExists(DATABASE_PATH);
const db = bootstrapDatabase(DATABASE_PATH);
Expand Down Expand Up @@ -637,3 +638,12 @@ app.on('activate', () => {
ipcMain.on('load-page', (event, arg) => {
mainWindow.loadURL(arg);
});

// enable file:// url scheme
// solution from https://github.com/electron/electron/issues/23757
app.whenReady().then(() => {
protocol.registerFileProtocol('file', (request, callback) => {
const pathname = decodeURI(request.url.replace('file:///', ''));
callback(pathname);
});
});
Loading

0 comments on commit 940e452

Please sign in to comment.