Skip to content

Commit

Permalink
fixed problems in release-packageing
Browse files Browse the repository at this point in the history
  • Loading branch information
TanninOne committed Sep 14, 2016
1 parent 2dbe5f9 commit 2a49b7a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 23 deletions.
3 changes: 3 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
"bluebird": "^3.4.6",
"electron-squirrel-startup": "^1.0.0",
"fs-extra-promise": "^0.4.0",
"i18next": "^3.4.1",
"i18next-node-fs-backend": "^0.1.2",
"react": "^15.3.0",
"react-addons-update": "^15.3.1",
"react-bootstrap": "^0.30.2",
"react-dom": "^15.3.0",
"react-fontawesome": "^1.1.0",
"react-i18next": "^1.8.0",
"react-layout-pane": "^0.1.16",
"react-redux": "^4.4.5",
"redux": "^3.5.2",
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"_theme_out": "copyup -f node_modules/font-awesome/css/font-awesome.min.css out/assets/css && copyup -f node_modules/font-awesome/fonts/fontawesome-webfont.woff2 out/assets/fonts",
"_theme_app": "copyup -f node_modules/font-awesome/css/font-awesome.min.css app/assets/css && copyup -f node_modules/font-awesome/fonts/fontawesome-webfont.woff2 app/assets/fonts",
"_assets_out": "copyup src/index.html out && copyfiles assets/fonts/* out && copyfiles locales/*/* out && copyfiles assets/images/* out && copyfiles -f extensions/*/dist/*.js out/extensions",
"_assets_app": "copyup src/index.html app && copyfiles assets/fonts/* app && copyfiles locales/*/* app && copyfiles assets/images/* app && copyfiles -f extensions/*/dist/*.js app/extensions",
"_assets_app": "copyup src/index.html app && copyfiles assets/fonts/* app && copyfiles assets/images/* app && copyfiles -f extensions/*/dist/*.js app/extensions",
"_babel_out": "cross-env BABEL_ENV=development babel out -d out",
"_babel_app": "cross-env BABEL_ENV=development babel app -d app --ignore node_modules",
"_less_out": "lessc --clean-css --include-path=node_modules/bootswatch:node_modules/bootstrap-less src/less/index.less out/assets/css/theme.css",
Expand All @@ -37,7 +37,10 @@
"win": {
"target": "squirrel",
"iconUrl": "https://staticdelivery.nexusmods.com/contents/Templates/110/favicon.ico"
}
},
"extraResources": [
"locales"
]
},
"parserOptions": {
"ecmaFeatures": {
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ persistStore(store, {
// auto updater

function setupAutoUpdate() {
autoUpdater.setFeedURL(`http://localhost/download/${app.getVersion()}`);
autoUpdater.setFeedURL(`http://localhost:6000/download/${app.getVersion()}`);
try {
autoUpdater.checkForUpdates();
} catch (e) {
Expand Down Expand Up @@ -140,7 +140,7 @@ function createWindow() {
mainWindow.loadURL(`file://${__dirname}/index.html`);
// opening the devtools automatically can be very useful if the renderer has
// trouble loading the page
// mainWindow.webContents.openDevTools();
mainWindow.webContents.openDevTools();

mainWindow.once('ready-to-show', () => {
log('info', 'ready to show');
Expand Down
3 changes: 3 additions & 0 deletions src/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ let extReducers = getReducers(extensions);

const store: Store<any> = createStore(reducer(extReducers), enhancer);

const { remote } = require('electron');
log('info', 'renderer connected to store');
console.log(`using ${remote.app.getPath('userData')} as the storage directory`);
console.log(`what about ${remote.app.getPath('appData')}`);

const i18n = getI18n(store.getState().settings.interface.language);

Expand Down
4 changes: 2 additions & 2 deletions src/types/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interface IRegisterSettings {
}

interface IRegisterIcon {
(group: string, icon: string, title: string, action: any): void;
(group: string, icon: string, title: string, action: () => void): void;
}

export interface IExtensionContext {

registerSettings: IRegisterSettings;
registerIcon: IRegisterIcon;
registerReducer: any;
registerReducer: (path: string[], Function) => void;

}

Expand Down
6 changes: 3 additions & 3 deletions src/util/ExtensionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ExtensionProvider extends React.Component<IExtensionProps, {}> {
}
}

function emptyContext(): IExtensionContext {
function emptyExtensionContext(): IExtensionContext {
return {
registerSettings: (title: string, component: React.ComponentClass<any>) => undefined,
registerIcon: (group: string, icon: string, title: string, action: any) => undefined,
Expand All @@ -42,7 +42,7 @@ interface IExtensibleProps {
export function getReducers(extensions: IExtensionInit[]) {
let reducers = [];

let context = emptyContext();
let context = emptyExtensionContext();

context.registerReducer = (path: string[], reducer: any) => {
reducers.push({ path, reducer });
Expand Down Expand Up @@ -76,7 +76,7 @@ export function extension(registerFunc: Function) {
public componentWillMount(): void {
this.mExtensions = this.props.staticElements || [];

let extContext = emptyContext();
let extContext = emptyExtensionContext();
extContext[registerFunc.name] = (...args) => {
const res = registerFunc(this, ...args);
if (res !== undefined) {
Expand Down
14 changes: 12 additions & 2 deletions src/util/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import i18n = require('i18next');
import FSBackend = require('i18next-node-fs-backend');

import * as path from 'path';

let dirName = path.dirname(__dirname);
if (dirName.endsWith('.asar')) {
// locales are not packed so users can update/change them
dirName = path.dirname(dirName);
}

const basePath = path.normalize(path.join(dirName, 'locales'));

export default function (language: string): I18next.I18n {
return i18n
.use(FSBackend)
Expand All @@ -20,8 +30,8 @@ export default function (language: string): I18next.I18n {
},

backend: {
loadPath: `${__dirname}/../locales/{{lng}}/{{ns}}.json`,
addPath: `${__dirname}/../locales/{{lng}}/{{ns}}.missing.json`,
loadPath: path.join(basePath, '{{lng}}', '{{ns}}.json'),
addPath: path.join(basePath, '{{lng}}', '{{ns}}.missing.json'),
},
});
}
35 changes: 23 additions & 12 deletions src/views/MainWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { II18NProps } from '../types/II18NProps';
import { IIconDefinition } from '../types/IIconDefinition';
import Developer from './Developer';
import IconBar from './IconBar';
import Settings from './Settings';
import { Button } from './TooltipControls';
Expand All @@ -12,6 +11,11 @@ import { Fixed, Flex, Layout } from 'react-layout-pane';

import update = require('react-addons-update');

let Developer = undefined;
if (process.env.NODE_ENV === 'development') {
Developer = require('./Developer').default;
}

interface IMainWindowProps {
className: string;
}
Expand Down Expand Up @@ -41,7 +45,7 @@ class MainWindow extends React.Component<IMainWindowProps & II18NProps, IMainWin
{ icon: 'gear', title: 'Settings', action: () => this.showLayer('settings') },
];

if (process.env.NODE_ENV === 'development') {
if (Developer !== undefined) {
this.buttonsRight.push(
{ icon: 'wrench', title: 'Developer', action: () => this.showLayer('developer') }
);
Expand All @@ -66,27 +70,21 @@ class MainWindow extends React.Component<IMainWindowProps & II18NProps, IMainWin
</Layout>
<Modal show={this.state.showLayer === 'settings'} onHide={ this.hideLayer }>
<Modal.Header>
<Modal.Title>{t('Settings') }</Modal.Title>
<Modal.Title>{ t('Settings') }</Modal.Title>
</Modal.Header>
<Modal.Body>
<Settings />
</Modal.Body>
<Modal.Footer>
<Button tooltip={t('Close') } id='close' onClick={ this.hideLayer }>
<Button tooltip={ t('Close') } id='close' onClick={ this.hideLayer }>
{t('Close') }
</Button>
</Modal.Footer>
</Modal>
<Modal show={this.state.showLayer === 'developer'} onHide={ this.hideLayer }>
<Modal.Header>
<Modal.Title>{t('Developer')}</Modal.Title>
</Modal.Header>
<Modal.Body>
<Developer />
</Modal.Body>
</Modal>
{ this.renderDeveloperModal() }
</div>
);

}

private showLayer = (layer: string) => this.showLayerImpl(layer);
Expand All @@ -95,6 +93,19 @@ class MainWindow extends React.Component<IMainWindowProps & II18NProps, IMainWin
private showLayerImpl(layer: string): void {
this.setState(update(this.state, { showLayer: { $set: layer } }));
}

private renderDeveloperModal() {
return Developer === undefined ? null : (
<Modal show={this.state.showLayer === 'developer'} onHide={ this.hideLayer }>
<Modal.Header>
<Modal.Title>Developer</Modal.Title>
</Modal.Header>
<Modal.Body>
<Developer />
</Modal.Body>
</Modal>
);
}
}

export default translate(['common'], { wait: true })(MainWindow);

0 comments on commit 2a49b7a

Please sign in to comment.