Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup project #1

Merged
merged 12 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build
dist

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
8 changes: 8 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"packages": [
"packages/*"
],
"version": "0.1.0",
"npmClient": "yarn",
"useWorkspaces": true
}
37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "neuron",
"description": "CKB Neuron Wallet",
"version": "0.1.0",
"private": true,
"author": {
"name": "Nervos Core Dev",
"email": "[email protected]",
"url": "https://github.com/nervosnetwork/neuron"
},
"license": "MIT",
"engines": {
"node": ">= 10.15",
"yarn": ">= 1.12"
},
"workspaces": [
"packages/*"
],
"scripts": {
"lint": "lerna run lint",
"test": "lerna run test",
"start:react": "cd packages/react-app && yarn start",
"start:electron": "cd packages/electron-app && yarn start",
"start": "concurrently \"yarn run start:react\" \"wait-on http://localhost:3000 && yarn run start:electron\""
},
"devDependencies": {
"concurrently": "^4.1.0",
"lerna": "^3.10.5",
"tslint": "^5.12.1",
"tslint-config-prettier": "^1.17.0",
"tslint-microsoft-contrib": "^6.0.0",
"tslint-react": "^3.6.0",
"typescript": "^3.2.2",
"typescript-tslint-plugin": "^0.2.1",
"wait-on": "^3.2.0"
}
}
Binary file added packages/electron-app/AppIcon.icns
Binary file not shown.
26 changes: 26 additions & 0 deletions packages/electron-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "neuron",
"description": "CKB Neuron Wallet",
"version": "0.1.0",
"private": true,
"author": {
"name": "Nervos Core Dev",
"email": "[email protected]",
"url": "https://github.com/nervosnetwork/neuron"
},
"license": "MIT",
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"lint": "tslint -p .",
"start": "yarn run build && electron ./dist/main.js"
},
"dependencies": {
"neuron-react-app": "0.1.0"
},
"devDependencies": {
"electron": "^4.0.1",
"typescript": "^3.2.2",
"tslint": "^5.12.1"
}
}
50 changes: 50 additions & 0 deletions packages/electron-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Modules to control application life and create native browser window
import { app, BrowserWindow } from 'electron'

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow: Electron.BrowserWindow

function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
icon: __dirname + '/../AppIcon.icns'
})

mainWindow.loadURL('http://localhost:3000')

// Open the DevTools.
// mainWindow.webContents.openDevTools()

// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})
21 changes: 21 additions & 0 deletions packages/electron-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"noImplicitAny": true,
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"plugins": [
{ "name": "typescript-tslint-plugin" }
],
"paths": {
"*": [
"node_modules/*"
]
}
},
"include": [
"src/**/*"
]
}
18 changes: 18 additions & 0 deletions packages/electron-app/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "tslint-config-prettier",
"rulesDirectory": [
"../../node_modules/tslint-microsoft-contrib/"
],
"rules": {
"max-line-length": {
"options": [120]
},
"semicolon": [true, "never"],
"quotemark": [true, "single"]
},
"jsRules": {
"max-line-length": {
"options": [120]
}
}
}
4 changes: 4 additions & 0 deletions packages/react-app/config-overrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function override(config, env) {
//do stuff with the webpack config...
return config;
}
40 changes: 40 additions & 0 deletions packages/react-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "neuron-react-app",
"version": "0.1.0",
"private": true,
"author": {
"name": "Nervos Core Dev",
"email": "[email protected]",
"url": "https://github.com/nervosnetwork/neuron"
},
"license": "MIT",
"dependencies": {
"@types/jest": "23.3.12",
"@types/node": "10.12.18",
"@types/react": "16.7.18",
"@types/react-dom": "16.0.11",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-scripts": "2.1.3",
"typescript": "3.2.2"
},
"scripts": {
"start": "BROWSER=none react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject",
"lint": "tslint -p ."
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"react-app-rewired": "^2.0.2"
}
}
Binary file added packages/react-app/public/favicon.ico
Binary file not shown.
41 changes: 41 additions & 0 deletions packages/react-app/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Neuron</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions packages/react-app/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "Neuron",
"name": "CKB Neuron Wallet",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
32 changes: 32 additions & 0 deletions packages/react-app/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.App {
text-align: center;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 40vmin;
}

.App-header {
background-color: white;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: black;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
9 changes: 9 additions & 0 deletions packages/react-app/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
ReactDOM.unmountComponentAtNode(div)
})
28 changes: 28 additions & 0 deletions packages/react-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { Component } from 'react'
import logo from './logo.svg'
import './App.css'

class App extends Component {
render() {
return (
<div className='App'>
<header className='App-header'>
<img src={logo} className='App-logo' alt='logo' />
<p>
Neuron is running...
</p>
<a
className='App-link'
href='https://reactjs.org'
target='_blank'
rel='noopener noreferrer'
>
Building with React
</a>
</header>
</div>
)
}
}

export default App
14 changes: 14 additions & 0 deletions packages/react-app/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
12 changes: 12 additions & 0 deletions packages/react-app/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import * as serviceWorker from './serviceWorker'

ReactDOM.render(<App />, document.getElementById('root'))

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister()
Loading