Skip to content

Commit

Permalink
start of ep 3 bot 2
Browse files Browse the repository at this point in the history
  • Loading branch information
CreativeBuilds committed Sep 4, 2019
1 parent e9c3f87 commit 8e4f1dc
Show file tree
Hide file tree
Showing 21 changed files with 7,989 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"env": {
"browser": true,
"node": true
},
"extends": "airbnb",
"rules": {
"no-unused-vars": "warn",
"max-len": [
"error",
{
"ignoreUrls": true
}
],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": [
"webpack.*.js",
"test/**/*.js"
]
}
],
"sort-imports": 2,
"import/prefer-default-export": 0,
"import/no-default-export": 2,
"import/no-named-default": 0,
"react/jsx-no-bind": false
},
"plugins": [
"import"
],
"settings": {
"import/resolver": "webpack"
}
}
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.vscode/
dist/
node_modules/
out/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Yarn Integrity file
.yarn-integrity

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Windows thumbnail cache files
Thumbs.db

# OS X files
.DS_Store
._*
70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.1] - 2018-02-05
`v2.0.1` is a minor hotfix release patched the `NODE_ENV` not set on Windows
issue.

### Added
- Package `cross-env` as `devDependencies`.
- README section "Author".

### Fixed
- NPM scripts won't set environment variables on Windows issue.

## 2.0.0 - 2018-02-04
`v2.0.0` is a major release that most part of the boilerplate has been rewritten.

### Added
- ESLint for code checking on Javascript files.
- Airbnb's extensible `.eslintrc` package & its' peer dependencies.
- `.eslintrc` that extends Airbnb's config and has customised rules configured.
- _Rule `no-default-export` is set for JavaScript files to align with
TypeScript._
- ESLint plugin `eslint-import-resolver-webpack` for ESLint to resolve path
aliases set in Webpack config.
- Webpack plugin `copy-pkg-json-webpack-plugin` to generate a `package.json`
file and pack into Webpack's bundled package for production.
- Build commands `build:mac` & `build:win` to package & build the installer of
your Electron app for macOS & Windows using `electron-builder`.
- README section "Building the installer for your Electron app" & sub-section
"Extra options".

### Changed
- Refactored Webpack config file to have `mainConfig` & `rendererConfig`
cleaned up, and set mode by environment variable.
- `.gitignore` to ignore folder `out/` which will be auto-generated during the
build process.
- README section "How does it work?" is now renamed to "Getting started" &
completed the documentation of this section.
- README section "Folder structure" to reflect the changes in `v2.0.0`.

### Fixed
- CSS files fail to inject into views issue by setting Webpack to use
`style-loader` alongside with `css-loader` to bundle the files in Webpack
config file.
- `baseUrl` in `tsconfig.json` points to root directory incorrectly issue.
Corrected to current directory so VSCode can resolves the path aliases
correctly.

### Removed
- Redux & React-Redux related settings, including packages listed on
`devDependencies`, path aliases & folders listed in folder structure.
- Since Electron's built-in IPC & basic React states should be enough to get
the works done, and most Electron apps which have their application logic
runs on Electron's `main` process rather then `renderer` process actually
don't need React-Redux, `redux` & `react-redux` are no longer included in
this boilerplate.
- Redux & React-Redux can still be used on this boilerplate by installing the
package yourself. For details, please refer to the corresponding library's
documents, there's no different than working on any other project which
isn't based on this boilerplate.
- Separated Webpack config files for `development` & `production` mode.

[Unreleased]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/compare/v2.0.1...HEAD
[2.0.1]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/compare/v2.0.0...v2.0.1
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Devtography

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
120 changes: 120 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Electron-React-TypeScript-Webpack-Boilerplate
Pre-configured Electron.js + React.js + TypeScript boilerplate with
Webpack v4 & linters config predefined.

This boilerplate currently works on macOS and Windows. If something doesn't
work, please [file and issue](https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/issues/new).

## Getting started
```bash
// execute
git clone https://github.com/iamWing/electron-react-typescript-base-proj.git
```

```json
// edit the following fields in package.json for your own project
{
"name": your-project-name,
"version": whatever-you-like,
"description": your-own-description,
"build": {
"appId": your-app-id,
"productName": your-product-name,
"buildVersion": whatever-you-like
},
"author": who's-the-author?,
"license": if-you-don't-want-to-use-MIT,
"repository": type-and-link-of-your-repo,
"keywords": keywords-of-your-project,
"bugs": issue-page-of-your-repo,
"homepage": homepage-of-your-repo
}
```

Then install all the `node_modules` needed by executing the following command:
```bash
cd folder-containing-the-cloned-boilerplate
npm run install
```

Finally execute the following command to start Webpack in development mode and
watch the changes on source files.
```bash
npm run dev
```

## Building the installer for your Electron app
The boilerplate is currently configured to package & build the installer of
your app for macOS & Windows using `electron-builder`.

For macOS, execute:
```bash
npm run build:mac
```

For Windows, execute:
```bash
npm run build:win
```
_** `asar` archiving is disabled by default in Windows build as it can cause
errors while running the installed Electron app based on pervious experiences,
whereas the macOS build with `asar` enabled works just fine. You can turn it
back on by removing line 23 (`"asar": false`) in `package.json`. **_

### Extra options
The build scripts are pre-configured to build 64 bit installers since 64 bit
should be the standard for a modern applications. 32 bit builds are still
possible by changing the build scripts in `package.json` as below:
```json
// from
"scripts": {
...
"build:win": "electron-builder build --win --x64",
"build:mac": "electron-builder build --mac --x64"
},

// to
"scripts": {
...
"build:win": "electron-builder build --win --ia32",
"build:mac": "electron-builder build --mac --ia32"
},
```

Builds for Linux, armv71, and arm64 can also be configured by modifying the
build scripts in `package.json`, but those aren't tested yet. For details,
please refer to [documents of `electron-builder`](https://www.electron.build/cli).

## Folder structure
```
electron-react-typescript-base-proj/
| - dist/ //- Generated by Webpack automatically
| - node_modules/
| - out/ //- Generated by build script automatically
| - public/ //- Global static assets
| | - index.html
| | - style.css
| - src/
| | - main/ //- Backend modules for the Electron app
| | | - main.ts //- Entry point of 'electron-main'
| | - models/
| | - renderer/ //- Frontend React components for the Electron app
| | | - renderer.tsx //- Entry point of 'electron-renderer'
| | - utils/ //- Common utilities
| - test/ //- Unit tests
| - .eslintrc //- ESLint config
| - .gitignore
| - package-lock.json
| - package.json
| - tsconfig.json //- TypeScript config
| - tslint.json //- TSLint config
| - webpack.config.js //- Webpack config
```

## Author

[Wing Chau](https://github.com/iamWing) [@Devtography](https://github.com/Devtography)

## License
Electron React TypeScript Webpack Boilerplate is open source software
[licensed as MIT](LICENSE).
91 changes: 91 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"name": "creative-bot-2",
"version": "1.0.0",
"description": "New version of CreativeBot",
"main": "./dist/main.bundle.js",
"scripts": {
"start": "electron ./dist/main.bundle.js",
"dev": "rimraf dist && cross-env NODE_ENV=development webpack --watch --progress --colors",
"prod": "rimraf dist && cross-env NODE_ENV=production webpack --progress --colors",
"test": "mocha -r ts-node/register -r tsconfig-paths/register \"test/**/*.ts\"",
"build:win": "electron-builder build --win --x64",
"build:mac": "electron-builder build --mac --x64"
},
"build": {
"appId": "com.creativebuilds.creativebot",
"productName": "CreativeBot 2",
"directories": {
"app": "./dist/",
"output": "./out/"
},
"win": {
"target": "nsis",
"asar": false
},
"buildVersion": "1.0.0"
},
"author": "CreativeBuilds",
"license": "MIT",
"dependencies": {
"email-validator": "^2.0.4",
"firebase": "^6.5.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-router": "^5.0.1",
"react-router-dom": "^5.0.1",
"rxjs": "^6.5.2",
"styled-components": "^4.3.2"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
"@types/react": "^16.5.2",
"@types/react-dom": "^16.5.2",
"@types/react-router-dom": "^4.3.1",
"@types/styled-components": "^4.1.18",
"acorn": "^6.0.5",
"ajv": "^6.6.2",
"copy-pkg-json-webpack-plugin": "0.0.38",
"cross-env": "^5.2.0",
"css-loader": "^1.0.1",
"electron": "^3.1.2",
"electron-builder": "^20.38.5",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-import-resolver-webpack": "^0.11.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^2.0.1",
"file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0",
"lodash": "^4.17.11",
"mocha": "^5.2.0",
"rimraf": "^2.6.3",
"source-map-loader": "^0.2.4",
"spectron": "^5.0.0",
"style-loader": "^0.23.1",
"ts-loader": "^5.3.3",
"ts-node": "^7.0.1",
"tsconfig-paths": "^3.7.0",
"tslint": "^5.12.0",
"tslint-microsoft-contrib": "^5.2.1",
"typescript": "^3.2.2",
"webpack": "^4.28.1",
"webpack-cli": "^3.2.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Devtography/electron-react-typescript-webpack-boilerplate"
},
"keywords": [
"boilerplate",
"Electron",
"React",
"Typescript",
"Webpack"
],
"bugs": {
"url": "https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/issues"
},
"homepage": "https://github.com/Devtography/electron-react-typescript-webpack-boilerplate#readme"
}
21 changes: 21 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hello World!</title>
<link
href="https://fonts.googleapis.com/css?family=Nunito|Open+Sans&display=swap"
rel="stylesheet"
/>
<style>
* {
font-family: 'Open Sans', sans-serif;
font-family: 'Nunito', sans-serif;
}
</style>
</head>

<body>
<div id="app" class="app"></div>
</body>
</html>
Loading

0 comments on commit 8e4f1dc

Please sign in to comment.