Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hackingbeauty committed Nov 20, 2017
0 parents commit 5119f48
Show file tree
Hide file tree
Showing 72 changed files with 15,415 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .babelrc
@@ -0,0 +1,11 @@
{
"presets": ["react", "es2015"],
"plugins": [
["transform-class-properties"]
],
"env": {
"start": {
"presets": ["react-hmre"]
}
}
}
3 changes: 3 additions & 0 deletions .eslintignore
@@ -0,0 +1,3 @@
dist
node_modules
bin
49 changes: 49 additions & 0 deletions .eslintrc
@@ -0,0 +1,49 @@
{
"extends": "eslint:recommended",
"ecmaFeatures": {
"modules": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": [
"react"
],
"rules": {
"no-console": 0,
"no-debugger": 2,
"new-cap": 0,
"strict": 0,
"no-underscore-dangle": 0,
"no-use-before-define": 0,
"eol-last": 0,
"quotes": [2, "single"],
"indent": [2, 2],
"jsx-quotes": 1,
"react/jsx-no-undef": 1,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/prop-types": 0,
"react/jsx-closing-bracket-location":0,
"space-infix-ops": 0,
"comma-dangle": [2, "never"],
"prop-types":[0,"never"],
"no-multi-spaces": [1, {
"exceptions": {
"VariableDeclarator": true,
"ImportDeclaration": true,
"Property": true
}
}]
}
}
19 changes: 19 additions & 0 deletions .githooks/pre-push
@@ -0,0 +1,19 @@
#!/bin/bash

npm run lint # Run linter

if [ $? -ne 0 ]; then
echo "[LINT ERROR] Your code has errors."
exit 1
fi


npm run test # Run tests

if [ $? -ne 0 ]; then
echo "[TEST ERROR] Test must pass before pushing to origin."
exit 1
fi


# Add more checks here
17 changes: 17 additions & 0 deletions .gitignore
@@ -0,0 +1,17 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# testing
coverage

# production
build
dist

# misc
.DS_Store
.env
npm-debug.log
.truffle-solidity-loader
46 changes: 46 additions & 0 deletions README.md
@@ -0,0 +1,46 @@
# React, Redux, Truffle, and Material-UI for bootstrapping a Dapp

In addition to Webpack and React, this box adds: React-Router, Redux and Material-UI for easy skinning of a Dapp.

## Installation

1. Install truffle and an ethereum client. For local development, try EthereumJS TestRPC.
```javascript
npm install -g truffle // Version 3.0.5+ required.
npm install -g ethereumjs-testrpc
```

2. Compile and migrate the contracts.
```javascript
truffle compile
truffle migrate
```

3. Run the webpack server for front-end hot reloading. For now, smart contract changes must be manually recompiled and migrated.
```javascript
npm run start
```

4. Jest is included for testing React components and Truffle's own suite is incldued for smart contracts. Be sure you've compile your contracts before running jest, or you'll receive some file not found errors.
```javascript
// Runs Jest for component tests.
npm run test

// Runs Truffle's test suite for smart contract tests.
truffle test
```

5. To build the application for production, use the build command. A production build will be in the /dist folder.
```javascript
npm run build
```

## FAQ

* __Why is there both a truffle.js file and a truffle-config.js file?__

Truffle requires the truffle.js file be named truffle-config on Windows machines. Feel free to delete the file that doesn't correspond to your platform.

* __Where is my production build?__

The production build will be in the /dist folder. This is because Truffle outputs contract compilations to the build folder.
14 changes: 14 additions & 0 deletions bin/server.js
@@ -0,0 +1,14 @@
var fs = require('fs');

var babelrc = fs.readFileSync('./.babelrc');
var config;

try {
config = JSON.parse(babelrc);
} catch (err) {
console.error('==> ERROR: Error parsing your .babelrc.');
console.error(err);
}

require('babel-core/register')(config);
require('../server');
28 changes: 28 additions & 0 deletions config/env.js
@@ -0,0 +1,28 @@
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
// injected into the application via DefinePlugin in Webpack configuration.

var REACT_APP = /^REACT_APP_/i;

function getClientEnvironment(publicUrl) {
var processEnv = Object
.keys(process.env)
.filter(key => REACT_APP.test(key))
.reduce((env, key) => {
env[key] = JSON.stringify(process.env[key]);
return env;
}, {
// Useful for determining whether we’re running in production mode.
// Most importantly, it switches React into the correct mode.
'NODE_ENV': JSON.stringify(
process.env.NODE_ENV || 'development'
),
// Useful for resolving the correct path to static assets in `public`.
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
// This should only be used as an escape hatch. Normally you would put
// images into the `src` and `import` them in code to get their paths.
'PUBLIC_URL': JSON.stringify(publicUrl)
});
return {'process.env': processEnv};
}

module.exports = getClientEnvironment;
12 changes: 12 additions & 0 deletions config/jest/cssTransform.js
@@ -0,0 +1,12 @@
// This is a custom Jest transformer turning style imports into empty objects.
// http://facebook.github.io/jest/docs/tutorial-webpack.html

module.exports = {
process() {
return 'module.exports = {};';
},
getCacheKey(fileData, filename) {
// The output is always the same.
return 'cssTransform';
},
};
10 changes: 10 additions & 0 deletions config/jest/fileTransform.js
@@ -0,0 +1,10 @@
const path = require('path');

// This is a custom Jest transformer turning file imports into filenames.
// http://facebook.github.io/jest/docs/tutorial-webpack.html

module.exports = {
process(src, filename) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
},
};
46 changes: 46 additions & 0 deletions config/paths.js
@@ -0,0 +1,46 @@
var path = require('path');
var fs = require('fs');

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
var appDirectory = fs.realpathSync(process.cwd());
function resolveApp(relativePath) {
return path.resolve(appDirectory, relativePath);
}

// We support resolving modules according to `NODE_PATH`.
// This lets you use absolute paths in imports inside large monorepos:
// https://github.com/facebookincubator/create-react-app/issues/253.

// It works similar to `NODE_PATH` in Node itself:
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders

// We will export `nodePaths` as an array of absolute paths.
// It will then be used by Webpack configs.
// Jest doesn’t need this because it already handles `NODE_PATH` out of the box.

// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421

var nodePaths = (process.env.NODE_PATH || '')
.split(process.platform === 'win32' ? ';' : ':')
.filter(Boolean)
.filter(folder => !path.isAbsolute(folder))
.map(resolveApp);

// config after eject: we're in ./config/
module.exports = {
// Changed from build to build_webpack so smart contract compilations are not overwritten.
appBuild: resolveApp('build_webpack'),
appPublic: resolveApp('public'),
appHtml: resolveApp('public/index.html'),
appIndexJs: resolveApp('src/index.js'),
appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('src'),
yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveApp('src/setupTests.js'),
appNodeModules: resolveApp('node_modules'),
ownNodeModules: resolveApp('node_modules'),
nodePaths: nodePaths
};
14 changes: 14 additions & 0 deletions config/polyfills.js
@@ -0,0 +1,14 @@
if (typeof Promise === 'undefined') {
// Rejection tracking prevents a common issue where React gets into an
// inconsistent state due to an error, but it gets swallowed by a Promise,
// and the user has no idea what causes React's erratic future behavior.
require('promise/lib/rejection-tracking').enable();
window.Promise = require('promise/lib/es6-extensions.js');
}

// fetch() polyfill for making API calls.
require('whatwg-fetch');

// Object.assign() is commonly used with React.
// It will use the native implementation if it's present and isn't buggy.
Object.assign = require('object-assign');
67 changes: 67 additions & 0 deletions config/webpack/common.config.js
@@ -0,0 +1,67 @@
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const autoprefixer = require('autoprefixer');

const development = require('./dev.config.js');
const production = require('./prod.config.js');

require('babel-polyfill');

const TARGET = process.env.npm_lifecycle_event;

const PATHS = {
app: path.join(__dirname, '../../src'),
build: path.join(__dirname, '../../dist'),
};

process.env.BABEL_ENV = TARGET;

const common = {
entry: [
'babel-polyfill',
PATHS.app,
],

output: {
path: PATHS.build,
filename: 'bundle.js',
},

resolve: {
extensions: ['.jsx', '.js', '.json', '.scss'],
modules: ['node_modules', PATHS.app],
},

module: {
rules: [{
test: /\.js$/,
loaders: ['babel-loader'],
exclude: /node_modules/,
},
{
test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$/,
loader: "file-loader"
}],
},

plugins: [
new webpack.LoaderOptionsPlugin({
options: {
context: __dirname,
postcss: [
autoprefixer(),
]
}
})
]

};

if (TARGET === 'start' || !TARGET) {
module.exports = merge(development, common);
}

if (TARGET === 'build' || !TARGET) {
module.exports = merge(production, common);
}

0 comments on commit 5119f48

Please sign in to comment.