Skip to content

Commit

Permalink
move all entries to a single file
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Oct 27, 2020
1 parent 0892ee3 commit c9b12c4
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 37 deletions.
12 changes: 0 additions & 12 deletions desktop/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const contextMenu = require('electron-context-menu');
const {autoUpdater} = require('electron-updater');
const log = require('electron-log');
const ELECTRON_EVENTS = require('./ELECTRON_EVENTS');
const checkForUpdates = require('../src/lib/checkForUpdates');
const checkForUpdates = require('../src/libs/checkForUpdates');

/**
* Electron main process that handles wrapping the web application.
Expand Down
6 changes: 2 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/**
* Note: This file is the entry point used by React Native for the native platforms.
* Webpack uses different entry points for web and desktop, located at web/index.js and desktop/index.js, respectively.
*/
/**
* @format
*/

import {AppRegistry} from 'react-native';
import App from './src/App';
import {name as appName} from './app.json';
import additionalAppSetup from './src/setup';

AppRegistry.registerComponent(appName, () => App);
additionalAppSetup();
8 changes: 8 additions & 0 deletions src/setup/index.desktop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {AppRegistry} from 'react-native';
import {name as appName} from '../../app.json';

export default function () {
AppRegistry.runApplication(appName, {
rootTag: document.getElementById('root'),
});
}
4 changes: 4 additions & 0 deletions src/setup/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// No additional setup required for native platforms
export default function () {
return null;
}
36 changes: 17 additions & 19 deletions web/index.js → src/setup/index.website.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import {AppRegistry} from 'react-native';
import Config from 'src/CONFIG';
import App from '../src/App';
import {name as appName} from '../app.json';
import checkForUpdates from '../src/libs/checkForUpdates';
import HttpUtils from '../src/libs/HttpUtils';
import Visibility from '../src/libs/Visibility';

AppRegistry.registerComponent('App', () => App);
AppRegistry.registerComponent(appName, () => App);

AppRegistry.runApplication('App', {
rootTag: document.getElementById('root'),
});
import checkForUpdates from '../libs/checkForUpdates';
import Config from '../CONFIG';
import HttpUtils from '../libs/HttpUtils';
import {name as appName} from '../../app.json';
import Visibility from '../libs/Visibility';

/**
* Download the latest app version from the server, and if it is different than the current one,
Expand Down Expand Up @@ -57,10 +49,16 @@ const webUpdater = currentVersion => ({
update: () => webUpdate(currentVersion),
});

// When app loads, get current version (production only)
if (Config.IS_IN_PRODUCTION) {
HttpUtils.download('version.json')
.then(({version: currentVersion}) => {
checkForUpdates(webUpdater(currentVersion));
});
export default function () {
AppRegistry.runApplication(appName, {
rootTag: document.getElementById('root'),
});

// When app loads, get current version (production only)
if (Config.IS_IN_PRODUCTION) {
HttpUtils.download('version.json')
.then(({version: currentVersion}) => {
checkForUpdates(webUpdater(currentVersion));
});
}
}
2 changes: 1 addition & 1 deletion webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const platformExclude = platform === 'web' ? new RegExp(/\.desktop\.js$/) : new

module.exports = {
entry: {
app: platform === 'web' ? './web/index.js' : './desktop/index.js',
app: './index.js',
},
output: {
filename: '[name]-[hash].bundle.js',
Expand Down

0 comments on commit c9b12c4

Please sign in to comment.