Skip to content

Commit

Permalink
Merge pull request #1 from edrlab/feature/misc-project-setup
Browse files Browse the repository at this point in the history
various project setup improvements
  • Loading branch information
clebeaupin authored Mar 30, 2017
2 parents 999a71d + b657d83 commit 2cb7ded
Show file tree
Hide file tree
Showing 12 changed files with 5,025 additions and 60 deletions.
20 changes: 10 additions & 10 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# top-most EditorConfig file
root=true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,ts}]
charset = utf-8
[*.{md}]
indent_style = ignore
indent_size = ignore

# 4 space indentation
[*.{scss,css,py}]
[*.{js,ts,jsx,tsx}]
indent_style = space
indent_size = 4

# 2 space indentation
[*.{html,yml,json,ejs}]
[*.{yml,json}]
indent_style = space
indent_size = 2

[*.{html,ejs,css,scss}]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
node_modules
.DS_Store
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.DS_Store
25 changes: 17 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
esudo: false
branches:
only:
- master
language: node_js
node_js:
- 6

- '6'
before_install:
- 'pwd && ls -als'
install:
- npm install
- npm run lint

- 'pwd && ls -als'
before_script:
- npm run lint

- 'pwd && ls -als'
- 'yarn install'
script:
- npm run build
- 'yarn run lint'
- 'yarn run build'
after_success:
- 'pwd && ls -als'
- 'ls dist'
after_failure:
- 'pwd && ls -als'
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# Readium Desktop

Desktop application for ebooks
## Build status

## Status
TravisCI, `develop` branch:

[![Build Status](https://travis-ci.org/edrlab/readium-desktop.svg?branch=master)](https://travis-ci.org/edrlab/readium-desktop)

## Prerequisites

1) https://nodejs.org NodeJS >= 6, NPM >= 3 (check with `node --version` and `npm --version` from the command line)
2) https://yarnpkg.com Yarn >= 0.21 (check with `yarn --version` from the command line)

## Quick start

Command line steps:

1) `cd readium-desktop`
2) `npm update --global` (sync NPM global packages)
3) `yarn global upgrade` (sync Yarn global packages)
4) `yarn install` (initialize local `node_modules` packages from dependencies declared in `package.json`)
5) `yarn upgrade` (sync local packages)
6) `yarn run lint` (code linting)
7) `yarn start` (runs the app)
8) `yarn start:dev` (runs the app in dev mode)

## Technologies

* typescript
Expand All @@ -19,21 +37,21 @@ Desktop application for ebooks
Install all dependencies

```
npm install
yarn install
```

## Getting started

### Production

```
npm start
yarn start
```

### Development

```
npm run start:dev
yarn run start:dev
```

This environment provides a hot loader.
Expand Down
35 changes: 29 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
{
"name": "readium-desktop",
"version": "0.1.0",
"version": "0.0.1-alpha1",
"description": "Desktop application to read ebooks",
"main": "index.js",
"keywords": [
"readium",
"epub"
],
"engines": {
"node": ">=6",
"npm": ">=3",
"yarn": ">= 0.21"
},
"main": "dist/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "cross-env BUILD_ENV=PROD webpack -p",
"start": "npm run build && cross-env BUILD_ENV=PROD electron ./dist/main.js",
"lint:ts": "tslint './src/**/*.ts'",
"lint:editorconfig": "editorconfig-tools check .* * src/* src/*/*",
"lint:editorconfig": "eclint check '**/*' '[!].git/**/*' '[!]node_modules/**/*' '[!]dist/**/*' '[!]**/.DS_Store'",
"lint": "npm run lint:editorconfig && npm run lint:ts",
"start:dev:renderer": "webpack-dev-server",
"start:dev:main": "webpack -d && electron ./dist/main.js",
Expand All @@ -18,8 +27,22 @@
"type": "git",
"url": "[email protected]:edrlab/readium-desktop.git"
},
"author": "EDRLab",
"license": "Copyright @EDRLab",
"author": {
"name": "EDRLab developers",
"organization": "EDRLab",
"url": "http://github.com/edrlab/"
},
"license": "BSD-3-Clause",
"licenses": [
{
"type": "BSD-3-Clause",
"url": "http://opensource.org/licenses/BSD-3-Clause"
}
],
"bugs": {
"url": "https://github.com/edrlab/readium-desktop/issues"
},
"homepage": "https://github.com/edrlab/readium-desktop",
"dependencies": {
"@types/electron": "^1.4.34",
"@types/i18next": "^2.3.35",
Expand Down Expand Up @@ -50,7 +73,7 @@
"concurrently": "^3.4.0",
"cross-env": "^3.2.4",
"css-loader": "^0.28.0",
"editorconfig-tools": "^0.1.1",
"eclint": "^2.0.1",
"electron": "^1.6.2",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.10.1",
Expand Down
2 changes: 1 addition & 1 deletion src/actions/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Action } from "redux";
export const SET_LOCALE = "SET_LOCALE";

export interface ILocaleAction extends Action {
locale: string;
locale: string;
}

export function setLocale(locale: string): ILocaleAction {
Expand Down
18 changes: 18 additions & 0 deletions src/components/Library.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,29 @@ import { lazyInject } from "../di";
import { Translator } from "../i18n/translator";
import { IAppState } from "../reducers/app";

// DANIEL - IPC test
import { ipcRenderer } from "electron";

interface ILibraryState {
locale: string;
}

export default class Library extends React.Component<undefined, ILibraryState> {
public state: ILibraryState;

// DANIEL - IPC test
public _handleClick() {
console.log("CLICK");

// let response = ipcRenderer.sendSync('synchronous-message', 'RENDERER SYNC');
// console.log(response);

ipcRenderer.on('asynchronous-reply', (event, arg) => {
console.log(arg);
})
ipcRenderer.send('asynchronous-message', 'RENDERER ASYNC')
}

@lazyInject(Translator)
private translator: Translator;

Expand Down Expand Up @@ -80,6 +96,8 @@ export default class Library extends React.Component<undefined, ILibraryState> {
</ToolbarGroup>
</Toolbar>
<h1>{__("library.heading")}</h1>

<RaisedButton label="DANIEL - IPC test" onClick={this._handleClick} />
</div>
);
}
Expand Down
29 changes: 21 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as path from "path";

import { app, BrowserWindow, dialog } from "electron";

import { ipcMain } from "electron";

// Preprocessing directive
declare var __RENDERER_BASE_URL__: string;

Expand All @@ -11,7 +13,18 @@ let mainWindow: Electron.BrowserWindow = null;

// Opens the main window, with a native menu bar.
function createWindow() {
mainWindow = new BrowserWindow({width: 800, height: 600});

ipcMain.on("asynchronous-message", (event, arg) => {
console.log(arg);
event.sender.send("asynchronous-reply", arg + "__PONG");
});

// ipcMain.on("synchronous-message", (event, arg) => {
// console.log(arg);
// event.returnValue = arg + "__PONG";
// });

mainWindow = new BrowserWindow({ width: 800, height: 600 });
let rendererBaseUrl = __RENDERER_BASE_URL__;

if (rendererBaseUrl === "file://") {
Expand All @@ -32,10 +45,10 @@ function createWindow() {

// Quit when all windows are closed.
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
},
if (process.platform !== "darwin") {
app.quit();
}
},
);

// Call 'createWindow()' on startup.
Expand All @@ -46,7 +59,7 @@ app.on("ready", () => {
// On OS X it's common to re-create a window in the app when the dock icon is clicked and there are no other
// windows open.
app.on("activate", () => {
if (mainWindow === null) {
createWindow();
}
if (mainWindow === null) {
createWindow();
}
});
4 changes: 2 additions & 2 deletions src/reducers/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { combineReducers } from "redux";
import { i18n, I18NState } from "./i18n";

export interface IAppState {
i18n: I18NState;
i18n: I18NState;
}

export const app = combineReducers({
i18n,
i18n,
});
23 changes: 3 additions & 20 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
{
/*
* Possible values:
* - the name of a built-in config
* - a string that can be resolved as a module that exports the config object, e.g.:
* - an npm package name
* - an npm package name followed by the path to a file inside
* - a relative path to a JSON file
*/
"extends": "tslint:recommended",
"rules": {
/*
* Any rules specified here will override those from the base config we are extending.
*/
"ordered-imports": [
true,
{
"import-sources-order": "case-insensitive",
"named-imports-order": "case-insensitive"
}
]
],
"no-console": false
},
"jsRules": {
/*
* Any rules specified here will override those from the base config we are extending.
*/
"ordered-imports": [
"ordered-imports": [
true,
{
"import-sources-order": "case-insensitive",
Expand All @@ -33,9 +20,5 @@
]
},
"rulesDirectory": [
/*
* A list of relative or absolute paths to directories that contain custom rules.
* See the Custom Rules documentation below for more details.
*/
]
}
Loading

0 comments on commit 2cb7ded

Please sign in to comment.