Skip to content

Commit 275b837

Browse files
committed
make updates for alot of stuff
0 parents  commit 275b837

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+28131
-0
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["react-hot-loader/babel"]
3+
}

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = false
9+
insert_final_newline = true
10+
indent_style = tab
11+
12+
[{*.yml,*.json}]
13+
indent_style = space
14+
indent_size = 2

.env-template

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
COOKIE_SECRET=3b3544e514e3540211354562945ef27a51297bb2879ead5d95902
2+
CLOUDINARY_URL=
3+
4+
MAILGUN_API_KEY=key-8c206ef630f5d2c87d6cb9696139b971
5+
MAILGUN_DOMAIN=sandboxfde84b58c4d34f408f30e0a41aefcdd9.mailgun.org
6+
7+
RWKB_MONGO_URI=mongodb://localhost/react-redux-keystone-webpack-boilerplate
8+
9+
# If set to not 'true' then the keystone server won't start
10+
# This is like this in case you want to use with vhost or something
11+
# that will start the server
12+
13+
USE_KEYSTONE_SERVER=true
14+
NODE_ENV=development
15+
16+
# AMAZON CREDENTIALS FOR S3
17+
S3_KEY=
18+
S3_SECRET=
19+
S3_BUCKET=
20+
S3_REGION=
21+
22+
AWS_ACCESS_KEY_ID=
23+
AWS_SECRET_ACCESS_KEY=
24+
25+
# This should probably be HOST but it is for the URL for the reset password email
26+
BASE_URL=localhost:3000

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
public/js/bootstrap
2+
public/js/jquery

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "keystone"
3+
}

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# Compiled binary addons (http://nodejs.org/api/addons.html)
20+
build/Release
21+
22+
# Dependency directory
23+
# Deployed apps should consider commenting this line out:
24+
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
25+
node_modules
26+
27+
# Ignore .env configuration files
28+
.env
29+
30+
# Ignore .DS_Store files on OS X
31+
.DS_Store

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Steven Kaspar
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: node keystone.js

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
### React-Redux-Webpack-KeystoneJS Boilerplate
2+
3+
---
4+
5+
### Usage
6+
7+
npm install
8+
gulp
9+
10+
> make sure your mongo process is running
11+
12+
> make sure you have setup the .env file (template provided .env-template)
13+
14+
### Requirements
15+
16+
- NodeJS
17+
- MongoDB
18+
19+
### Features
20+
21+
- **gulp**
22+
23+
gulp default task that...
24+
25+
- starts the KeystoneJS app
26+
- watches KeystoneJS app files and restarts the KeystoneJS app whenever a file changes
27+
- watches `public/styles` and compiles sass on file change
28+
- watches `public/js` and compiles a `bundle.js` file using webpack
29+
30+
- **webpack**
31+
32+
webpack is called by the gulp task using `webpack.config.js` to compile one static `bundle.js` file
33+
34+
- **sass**
35+
36+
**gulp-sass** compiles `public/styles/scss` directory to one `public/styles/site.css` file
37+
38+
- **bootstrap**
39+
40+
bootstrap 4 (beta) is included and is ready to go with any custom component by using `import 'bootstrap'`
41+
42+
- **react**
43+
44+
React with Redux

gulpfile.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
'use strict';
2+
const gulp = require('gulp');
3+
const watch = require('gulp-watch');
4+
const shell = require('gulp-shell')
5+
const sass = require('gulp-sass');
6+
const concat = require('gulp-concat');
7+
const sourcemaps = require('gulp-sourcemaps');
8+
const spawn = require('child_process').spawn;
9+
10+
11+
const paths = {
12+
/**
13+
* paths to files that should restart app
14+
*/
15+
server_files: [
16+
'models/**/*.js',
17+
'routes/**/*.js',
18+
'keystone.js',
19+
'package.json'
20+
],
21+
/**
22+
* gulp-sass configuration
23+
*/
24+
style: {
25+
watch_files: 'public/styles/src/**/*.scss',
26+
src: './public/styles/src/**/*.scss',
27+
dist: './public/styles/dist',
28+
sourcemap_root: '../src'
29+
},
30+
/**
31+
* webpack config and files to watch
32+
*/
33+
webpack: {
34+
config: 'webpack.config.js',
35+
watch_files: [
36+
'public/js/src/**/*',
37+
'webpack.config.js'
38+
]
39+
}
40+
};
41+
42+
/** starting and restarting keystone app **/
43+
gulp.task('watch-app', done => {
44+
45+
// node process
46+
let node_process;
47+
//
48+
const dest_path = `.`;
49+
50+
let restartServer = () => {
51+
node_process.kill();
52+
node_process = startServer();
53+
}
54+
55+
let startServer = () => {
56+
var local_node_process = spawn('node', ['keystone'], {cwd: dest_path});
57+
local_node_process.on('close', (code, signal) => {
58+
console.log(`-- Server process closed --`);
59+
});
60+
local_node_process.stdout.on('data', (data) => {
61+
console.log(`${data}`);
62+
});
63+
local_node_process.stderr.on('data', (data) => {
64+
console.log(`Error: ${data}`);
65+
});
66+
return local_node_process;
67+
}
68+
69+
const watcher = gulp.watch(paths.server_files);
70+
watcher.on('change', () => restartServer() )
71+
72+
// start the server process
73+
node_process = startServer();
74+
75+
done();
76+
});
77+
78+
/** sass **/
79+
gulp.task('watch-sass', () => {
80+
gulp.watch(paths.style.watch_files, ['sass']);
81+
});
82+
gulp.task('sass', () => {
83+
gulp.src(paths.style.src)
84+
.pipe(sourcemaps.init())
85+
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
86+
.pipe(sourcemaps.write('.', {
87+
sourceRoot: paths.style.sourcemap_root
88+
}))
89+
.pipe(gulp.dest(paths.style.dist));
90+
});
91+
92+
/** webpack **/
93+
gulp.task('watch-webpack', () => {
94+
gulp.watch(paths.webpack.watch_files, ['webpack']);
95+
});
96+
gulp.task('webpack', done => {
97+
var webpack_process = spawn('./node_modules/.bin/webpack', [
98+
'--config',
99+
paths.webpack.config
100+
]);
101+
webpack_process.on('close', (code, signal) => {
102+
done();
103+
});
104+
webpack_process.stdout.on('data', (data) => {
105+
console.log(`${data}`);
106+
});
107+
webpack_process.stderr.on('data', (data) => {
108+
console.log(`Error: ${data}`);
109+
});
110+
return webpack_process;
111+
});
112+
113+
114+
/** gulp task setup **/
115+
gulp.task('default', ['watch-app', 'watch-sass']);//, 'watch-webpack']);

keystone.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Simulate config options from your production environment by
2+
// customising the .env file in your project's root folder.
3+
require('dotenv').config({
4+
path: __dirname+'/.env'
5+
});
6+
7+
// Require keystone
8+
var keystone = require('keystone');
9+
10+
// Initialise Keystone with your project's configuration.
11+
// See http://keystonejs.com/guide/config for available options
12+
// and documentation.
13+
14+
keystone.init({
15+
'name': 'keystone-template',
16+
'brand': 'keystone-template',
17+
18+
'sass': 'public',
19+
'static': 'public',
20+
'favicon': 'public/favicon.ico',
21+
'views': 'templates/views',
22+
'view engine': 'pug',
23+
24+
'emails': 'templates/emails',
25+
26+
'auto update': true,
27+
'session': true,
28+
'session store': process.env.SESSION_STORE || 'mongo',
29+
'auth': true,
30+
'user model': 'User',
31+
'cookie secret': process.env.COOKIE_SECRET || 'SOjsda823thpp9asv89ahfiag8r79aenpg',
32+
'mongo': process.env.RWKB_MONGO_URI || "mongodb://localhost/react-redux-keystone-boilerplate"
33+
});
34+
35+
// Load your project's Models
36+
keystone.import('models');
37+
38+
// Setup common locals for your templates. The following are required for the
39+
// bundled templates and layouts. Any runtime locals (that should be set uniquely
40+
// for each request) should be added to ./routes/middleware.js
41+
keystone.set('locals', {
42+
_: require('lodash'),
43+
env: keystone.get('env'),
44+
utils: keystone.utils,
45+
editable: keystone.content.editable,
46+
});
47+
48+
// Load your project's Routes
49+
keystone.set('routes', require('./routes'));
50+
51+
52+
// Configure the navigation bar in Keystone's Admin UI
53+
keystone.set('nav', {
54+
enquiries: 'enquiries',
55+
users: 'users',
56+
documents: 'documents',
57+
});
58+
59+
// Start Keystone to connect to your database and initialise the web server
60+
61+
62+
if (!process.env.MAILGUN_API_KEY || !process.env.MAILGUN_DOMAIN) {
63+
console.log('----------------------------------------'
64+
+ '\nWARNING: MISSING MAILGUN CREDENTIALS'
65+
+ '\n----------------------------------------'
66+
+ '\nYou have opted into email sending but have not provided'
67+
+ '\nmailgun credentials. Attempts to send will fail.'
68+
+ '\n\nCreate a mailgun account and add the credentials to the .env file to'
69+
+ '\nset up your mailgun integration');
70+
}
71+
72+
73+
74+
if(process.env.USE_KEYSTONE_SERVER === 'true'){
75+
keystone.start();
76+
}
77+
else {
78+
console.log(`
79+
/**
80+
* STARTING
81+
*
82+
* keystone.openDatabaseConnection();
83+
*
84+
*/
85+
`);
86+
keystone.openDatabaseConnection();
87+
console.log(`
88+
/**
89+
* STARTING
90+
*
91+
* keystone.initExpressApp();
92+
*
93+
*/
94+
`);
95+
keystone.initExpressApp();
96+
console.log(`
97+
/**
98+
* EXPORTING
99+
*
100+
* module.exports = keystone;
101+
*
102+
*/
103+
`);
104+
105+
console.log(`
106+
/**
107+
* env=${keystone.get('env')}
108+
*/
109+
`);
110+
}
111+
112+
module.exports = keystone;

0 commit comments

Comments
 (0)