├── .editorconfig
├── .gitattributes
├── .gitignore
├── .jshintrc
├── .travis.yml
├── .yo-rc.json
├── LICENSE
├── README.md
├── app
├── index.js
└── templates
│ ├── Procfile
│ ├── _package.json
│ ├── client
│ └── scripts
│ │ └── application.js
│ ├── editorconfig
│ ├── gitignore
│ ├── keystone.js
│ ├── models
│ └── User.js
│ ├── public
│ ├── favicon.ico
│ └── styles
│ │ ├── site.less
│ │ └── site.min.css
│ ├── routes
│ └── index.js
│ ├── templates
│ └── views
│ │ └── index.jade
│ └── updates
│ └── 0.0.1-admins.js
├── package.json
└── test
└── test-app.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": true,
3 | "esnext": true,
4 | "bitwise": true,
5 | "camelcase": true,
6 | "curly": true,
7 | "eqeqeq": true,
8 | "immed": true,
9 | "indent": 2,
10 | "latedef": true,
11 | "newcap": true,
12 | "noarg": true,
13 | "quotmark": "single",
14 | "undef": true,
15 | "unused": true,
16 | "strict": true
17 | }
18 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - 'iojs'
5 | - '0.12'
6 | - '0.10'
7 |
--------------------------------------------------------------------------------
/.yo-rc.json:
--------------------------------------------------------------------------------
1 | {
2 | "generator-generator": {}
3 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Jed Watson
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
⚠️ Archived
3 |
This repository is archived and is no longer maintained.
4 |
For the latest Keystone release please visit the Keystone website.
5 |
6 |
7 |
8 |
9 | # generator-keystone-react
10 |
11 | > [Yeoman](http://yeoman.io) generator
12 |
13 | Builds a simple scaffold for a KeystoneJS + React project, using browserify to pull it all together.
14 |
15 |
16 | ## Getting Started
17 |
18 | ```bash
19 | npm install -g yo
20 | ```
21 |
22 | ### Yeoman Generators
23 |
24 |
25 | To install generator-keystone-react from npm, run:
26 |
27 | ```bash
28 | npm install -g generator-keystone-react
29 | ```
30 |
31 | Finally, initiate the generator:
32 |
33 | ```bash
34 | yo keystone-react
35 | ```
36 |
37 | ## License
38 |
39 | [MIT License](http://en.wikipedia.org/wiki/MIT_License). Copyright (c) 2016 Jed Watson.
40 |
--------------------------------------------------------------------------------
/app/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var chalk = require('chalk');
3 | var crypto = require('crypto');
4 | var _ = require('lodash');
5 | var utils = require('keystone-utils');
6 | var yeoman = require('yeoman-generator');
7 |
8 | var KeystoneGenerator = yeoman.generators.Base.extend({
9 |
10 | initializing: function () {
11 | this.pkg = require('../package.json');
12 | },
13 |
14 | prompting: function () {
15 | var done = this.async();
16 |
17 | this.log('\nWelcome to the ' + chalk.green('Keystone React') + ' generator!\n');
18 |
19 | var prompts = [{
20 | type: 'input',
21 | name: 'projectName',
22 | message: 'What is the name of your project?',
23 | default: 'My Site'
24 | }, {
25 | type: 'confirm',
26 | name: 'createDirectory',
27 | message: 'Would you like to create a new directory for your project?',
28 | default: true
29 | }];
30 |
31 | this.prompt(prompts, function (props) {
32 | this.log('\n');
33 | _.extend(this, props);
34 | this.projectKey = utils.slug(this.projectName);
35 | if (props.createDirectory) {
36 | this.destinationRoot(this.projectKey);
37 | }
38 | done();
39 | }.bind(this));
40 | },
41 |
42 | keys: function keys() {
43 | this.cookieSecret = crypto.randomBytes(64).toString('hex');
44 | },
45 |
46 | writing: {
47 | project: function () {
48 | this.copy('keystone.js', 'keystone.js');
49 | this.copy('editorconfig', '.editorconfig');
50 | this.copy('gitignore', '.gitignore');
51 | this.copy('Procfile', 'Procfile');
52 | this.template('_package.json', 'package.json');
53 | },
54 |
55 | clientfiles: function () {
56 | this.copy('client/scripts/application.js', 'client/scripts/application.js');
57 | },
58 |
59 | modelfiles: function () {
60 | this.copy('models/User.js', 'models/User.js');
61 | },
62 |
63 | publicfiles: function () {
64 | this.copy('public/favicon.ico', 'public/favicon.ico');
65 | this.directory('public/styles', 'public/styles');
66 | },
67 |
68 | routesfiles: function () {
69 | this.directory('routes/api', 'routes/api');
70 | this.copy('routes/index.js', 'routes/index.js');
71 | },
72 |
73 | templatefiles: function () {
74 | this.copy('templates/views/index.jade', 'templates/views/index.jade');
75 | },
76 |
77 | updatefiles: function () {
78 | this.copy('updates/0.0.1-admins.js', 'updates/0.0.1-admins.js');
79 | }
80 |
81 | },
82 |
83 | install: function () {
84 | this.log('\n' + chalk.green('Running npm install...') +
85 | '\n'
86 | );
87 | this.npmInstall();
88 | },
89 |
90 | end: function () {
91 | var cmd = (this.createDirectory ? '"cd ' + utils.slug(this.projectName) + '" then ' : '') + '"node keystone"';
92 | this.log(
93 | '\n' + chalk.green.underline('Your new project is ready!') +
94 | '\n' +
95 | '\n\nTo start Keystone, run ' + cmd + '.' +
96 | '\n'
97 | );
98 | }
99 | });
100 |
101 | module.exports = KeystoneGenerator;
102 |
--------------------------------------------------------------------------------
/app/templates/Procfile:
--------------------------------------------------------------------------------
1 | web: node keystone.js
2 |
--------------------------------------------------------------------------------
/app/templates/_package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= projectKey %>",
3 | "version": "0.0.0",
4 | "private": true,
5 | "dependencies": {
6 | "babel-core": "^5.8.21",
7 | "babel-plugin-object-assign": "^1.2.1",
8 | "babelify": "^6.1.3",
9 | "browserify": "^12.0.1",
10 | "browserify-middleware": "^7.0.0",
11 | "keystone": "^0.3.13",
12 | "model-transform": "^2.0.0",
13 | "react": "^0.14.3",
14 | "react-dom": "^0.14.3",
15 | "request": "^2.60.0",
16 | "store-prototype": "^1.1.1",
17 | "underscore": "^1.8.3"
18 | },
19 | "engines": {
20 | "node": ">=0.10.22",
21 | "npm": ">=1.3.14"
22 | },
23 | "scripts": {
24 | "start": "node keystone.js"
25 | },
26 | "main": "keystone.js"
27 | }
28 |
--------------------------------------------------------------------------------
/app/templates/client/scripts/application.js:
--------------------------------------------------------------------------------
1 | var React = require('react');
2 | var ReactDOM = require('react-dom');
3 |
4 | var App = React.createClass({
5 | render: function() {
6 | return (
7 | Hello World
8 | );
9 | }
10 | });
11 |
12 | ReactDOM.render(
13 | ,
14 | document.getElementById('app')
15 | );
16 |
--------------------------------------------------------------------------------
/app/templates/editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = tab
6 | indent_size = 4
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/app/templates/gitignore:
--------------------------------------------------------------------------------
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
32 |
33 | # Ignore built css files
34 | *.min.css
35 |
--------------------------------------------------------------------------------
/app/templates/keystone.js:
--------------------------------------------------------------------------------
1 | var keystone = require('keystone');
2 |
3 | keystone.init({
4 |
5 | 'name': '<%= projectName %>',
6 | 'brand': '<%= projectName %>',
7 |
8 | 'less': 'public',
9 | 'static': 'public',
10 | 'favicon': 'public/favicon.ico',
11 | 'views': 'templates/views',
12 | 'view engine': 'jade',
13 |
14 | 'auto update': true,
15 | 'session': true,
16 | 'auth': true,
17 | 'user model': 'User',
18 | 'cookie secret': '<%= cookieSecret %>',
19 |
20 | });
21 |
22 | keystone.import('models');
23 |
24 | keystone.set('locals', {
25 | _: require('underscore'),
26 | env: keystone.get('env'),
27 | utils: keystone.utils,
28 | editable: keystone.content.editable,
29 | });
30 |
31 | keystone.set('routes', require('./routes'));
32 | keystone.set('nav', {
33 | 'users': 'users',
34 | });
35 |
36 | keystone.start();
37 |
--------------------------------------------------------------------------------
/app/templates/models/User.js:
--------------------------------------------------------------------------------
1 | var keystone = require('keystone');
2 | var transform = require('model-transform');
3 | var Types = keystone.Field.Types;
4 |
5 | var User = new keystone.List('User');
6 |
7 | User.add({
8 | name: { type: Types.Name, required: true, index: true },
9 | email: { type: Types.Email, initial: true, required: true, index: true },
10 | password: { type: Types.Password, initial: true, required: true },
11 | }, 'Permissions', {
12 | isAdmin: { type: Boolean, label: 'Can access Keystone', index: true },
13 | });
14 |
15 | // Provide access to Keystone
16 | User.schema.virtual('canAccessKeystone').get(function() {
17 | return this.isAdmin;
18 | });
19 |
20 | transform.toJSON(User);
21 |
22 | User.defaultColumns = 'name, email, isAdmin';
23 | User.register();
24 |
--------------------------------------------------------------------------------
/app/templates/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keystonejs/generator-keystone-react/a0caec4a6084f8ccf2048804c043ed100cdb0450/app/templates/public/favicon.ico
--------------------------------------------------------------------------------
/app/templates/public/styles/site.less:
--------------------------------------------------------------------------------
1 | // TODO: Add Styles
2 |
--------------------------------------------------------------------------------
/app/templates/public/styles/site.min.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/keystonejs/generator-keystone-react/a0caec4a6084f8ccf2048804c043ed100cdb0450/app/templates/public/styles/site.min.css
--------------------------------------------------------------------------------
/app/templates/routes/index.js:
--------------------------------------------------------------------------------
1 | var babelify = require('babelify');
2 | var browserify = require('browserify-middleware');
3 | var keystone = require('keystone');
4 |
5 | // Setup Route Bindings
6 | exports = module.exports = function (app) {
7 |
8 | app.use('/js', browserify('./client/scripts', {
9 | transform: [babelify.configure({
10 | plugins: ['object-assign'],
11 | })],
12 | }));
13 |
14 | // Views
15 | app.use(function (req, res) {
16 | res.render('index');
17 | });
18 |
19 | };
20 |
--------------------------------------------------------------------------------
/app/templates/templates/views/index.jade:
--------------------------------------------------------------------------------
1 | doctype html
2 | html
3 | //- HTML HEADER
4 | head
5 | meta(charset="utf-8")
6 | meta(name="viewport", content="width=device-width, initial-scale=1.0")
7 | meta(http-equiv="X-UA-Compatible" content="IE=edge")
8 |
9 | title <%= projectName %>
10 | link(rel="shortcut icon", href="/favicon.ico", type="image/x-icon")
11 |
12 | //- Customise the stylesheet for your site by editing /public/styles/site.less
13 | //- All .less files will be automatically compiled and minified in production.
14 | link(href="/styles/site.min.css", rel="stylesheet")
15 |
16 | //- HTML BODY
17 | body
18 | #app
19 | script(src='/js/application.js')
20 |
--------------------------------------------------------------------------------
/app/templates/updates/0.0.1-admins.js:
--------------------------------------------------------------------------------
1 | exports.create = {
2 | User: [
3 | { 'name.full': 'Admin User', email: 'user@keystonejs.com', password: 'admin', isAdmin: true },
4 | ],
5 | };
6 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generator-keystone-react",
3 | "version": "0.0.13",
4 | "description": "KeystoneJS + React Application Generator",
5 | "license": "MIT",
6 | "main": "app/index.js",
7 | "repository": {
8 | "type": "git",
9 | "url": "https://github.com/keystonejs/generator-keystone-react.git"
10 | },
11 | "author": "Jed Watson",
12 | "homepage": "http://keystonejs.com/",
13 | "engines": {
14 | "node": ">=0.10.0"
15 | },
16 | "scripts": {
17 | "test": "mocha"
18 | },
19 | "files": [
20 | "app"
21 | ],
22 | "keywords": [
23 | "keystone",
24 | "keystonejs",
25 | "react",
26 | "reactjs",
27 | "website",
28 | "app",
29 | "cms",
30 | "yeoman",
31 | "yeoman-generator"
32 | ],
33 | "dependencies": {
34 | "chalk": "^1.0.0",
35 | "keystone-utils": "^0.1.13",
36 | "lodash": "^3.9.1",
37 | "yeoman-generator": "^0.20.1"
38 | },
39 | "devDependencies": {
40 | "mocha": "*"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/test/test-app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var assert = require('yeoman-generator').assert;
5 | var helpers = require('yeoman-generator').test;
6 | var os = require('os');
7 |
8 | describe('keystone-react:app', function () {
9 | before(function (done) {
10 | helpers.run(path.join(__dirname, '../app'))
11 | .inDir(path.join(os.tmpdir(), './temp-test'))
12 | .withOptions({ 'skip-install': true })
13 | .withPrompt({
14 | someOption: true
15 | })
16 | .on('end', done);
17 | });
18 |
19 | it('creates files', function () {
20 | assert.file([
21 | 'bower.json',
22 | 'package.json',
23 | '.editorconfig',
24 | '.jshintrc'
25 | ]);
26 | });
27 | });
28 |
--------------------------------------------------------------------------------