Skip to content

Commit

Permalink
windows compatible npm scripts (keystonejs#1299)
Browse files Browse the repository at this point in the history
Fix path manipulation in wysiwyg-tinymce, standardize scripts across demo projects
  • Loading branch information
jesstelford authored and timleslie committed Jun 13, 2019
1 parent 5c28c14 commit b3e561e
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 83 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: yarn start blog
web: yarn demo blog dev
80 changes: 23 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,23 @@ Keystone 5 introduces first-class GraphQL support, a new extensible architecture

It is currently in alpha and under intensive development by [Thinkmill](https://www.thinkmill.com.au) and contributors around the world.

### What's new?
## What's new?

Keystone 5 is a complete re-imagining of KeystoneJS for the future. It builds on the lessons we learned over the last 5 years of the Keystone's history and focuses on the things we believe are the most powerful features for modern web and mobile applications.

This means less focus on hand-holding Node.js template-driven websites and more focus on flexible architecture, a powerful GraphQL API with deep access control features, an extensible Admin UI and plugins for rich field types, file and database adapters, and session management.

We believe it's the ideal back-end for rich React / Vue / Angular applications, Gatsby and Next.js websites, Mobile applications and more. It also makes a great Headless CMS.

## WARNING
🚨🚨🚨

This project is currently very much in the **alpha** phase of development. There are known bugs, missing features, and limited documentation. APIs have not been finalised and may change with each release.

To make this clear, we're currently publishing all packages to the `@keystone-alpha` scope on npm.

## Getting Started

If you're interested in checking out our progress, the simplest way to do so is to clone this repo and run one of the demo projects.

_NOTE: You must have a [working version of `mongo`
installed](https://docs.mongodb.com/manual/installation/#mongodb-community-edition)._

### Demo Projects

Minimum requirements for the Demo Projects:

- [Node.js](https://nodejs.org/) >= 10.x
- [MongoDB](https://v5.keystonejs.com/quick-start/mongodb) >= 4.x

Download a copy of the Keystone 5 repo, and check out the latest release:

```bash
git clone https://github.com/keystonejs/keystone-5.git
cd keystone-5
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
```

Pick which demo project you want to run:

- `todo`: A Todo app showcasing the AdminUI and how to create a minimal List
- `blog`: A starting point for a blog including a WYSIWYG editor
- `meetup`: A local community event website with speakers and sponsors

Then move into the directory for that demo, for example:

```bash
cd demo-projects/todo
```

Now install and run the project:
🚨🚨🚨

```bash
yarn
yarn start
```
## Getting Started

### Quick start

Expand All @@ -74,13 +37,24 @@ To get up and running with a basic project template, run the following commands.
```bash
yarn create keystone-app my-app
cd my-app
yarn start
yarn dev
```

For more details and system requirements, check out the [5 Minute Quick Start
Guide](https://v5.keystonejs.com/quick-start/).

### Demo Projects

These projects are designed to show off different aspects of KeystoneJS features
at a range of complexities (from a simple Todo App to a complex Meetup Site).

See the [`demo-projects/README.md`](./demo-projects/README.md) docs to get
started.

### Manual Setup

```bash
npm install --save @keystone-alpha/keystone @keystone-alpha/fields @keystone-alpha/adapter-mongoose @keystone-alpha/app-graphql @keystone-alpha/app-admin-ui
yarn add @keystone-alpha/keystone @keystone-alpha/fields @keystone-alpha/adapter-mongoose @keystone-alpha/app-graphql @keystone-alpha/app-admin-ui
```

Add a script to your `package.json`:
Expand Down Expand Up @@ -128,7 +102,7 @@ module.exports = {
Now you have everything you need to run a Keystone instance:

```bash
npm run dev
yarn dev
```

Keystone will automatically detect your `index.js` and start the server for you:
Expand Down Expand Up @@ -198,7 +172,7 @@ Add these scripts to your `package.json`:
}
```

Run `npm run build` to generate the following outputs(this output could change in the future):
Run `yarn build` to generate the following outputs(this output could change in the future):

```
.
Expand All @@ -209,7 +183,7 @@ Run `npm run build` to generate the following outputs(this output could change i
To run your keystone instance, run the start script.

```
npm run start
yarn start
```

#### Production Build Artifacts
Expand Down Expand Up @@ -323,23 +297,15 @@ brew install mongodb
brew services start mongodb
```

Create an environment variable in the test project `.env`. This will run project locally on port 3000

```sh
# CLOUDINARY_CLOUD_NAME=abc123
# CLOUDINARY_KEY=abc123
# CLOUDINARY_SECRET=abc123
PORT=3000
```

Then install the dependencies and start the test project:

```sh
bolt
bolt start {name of project folder}
bolt dev
```

_(Running `bolt start` will start the project located in `demo-projects/todo` by default)_
See [`demo-projects/README.md`](./demo-projects/README.md) for more details on
the available demo projects.

### Testing

Expand Down
45 changes: 45 additions & 0 deletions demo-projects/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# KeystoneJS Demo Projects

These projects are designed to show off different aspects of KeystoneJS features
at a range of complexities (from a simple Todo App to a complex Meetup Site).

- `todo`: A Todo app showcasing the AdminUI and how to create a minimal List
- `blog`: A starting point for a blog including a WYSIWYG editor
- `meetup`: A local community event website with speakers and sponsors

## Requirements

Minimum requirements for the Demo Projects:

- [Node.js](https://nodejs.org/) >= 10.x
- [Bolt](http://boltpkg.com/)
- [MongoDB](https://v5.keystonejs.com/quick-start/mongodb) >= 4.x

Download a copy of the Keystone 5 repo, and check out the latest release:

```bash
git clone https://github.com/keystonejs/keystone-5.git
cd keystone-5
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
bolt
```

To run the default demo project (`todo`):

```
bolt dev
```

To run a specific demo project (eg; `blog`):

```
bolt demo blog dev
```

To create & start a production build, use the `build` command followed by `start`:


```
bolt demo blog build
bolt demo blog start
```
4 changes: 2 additions & 2 deletions demo-projects/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"scripts": {
"dev": "cross-env NODE_ENV=development DISABLE_LOGGING=true node -r dotenv-safe/config `yarn bin`/keystone dev",
"build": "cross-env node -r dotenv-safe/config `yarn bin`/keystone build",
"build": "cross-env NODE_ENV=production node -r dotenv-safe/config `yarn bin`/keystone build",
"start": "cross-env NODE_ENV=production node -r dotenv-safe/config `yarn bin`/keystone start"
},
"dependencies": {
Expand Down Expand Up @@ -41,4 +41,4 @@
"react": "^16.8.6",
"react-apollo": "2.4.0"
}
}
}
7 changes: 4 additions & 3 deletions demo-projects/meetup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"node": ">=8.4.0"
},
"scripts": {
"start": "cross-env NODE_ENV=development DISABLE_LOGGING=true keystone",
"build": "cross-env NODE_ENV=production next build"
"dev": "cross-env NODE_ENV=development DISABLE_LOGGING=true keystone dev",
"build": "cross-env NODE_ENV=production keystone build",
"start": "cross-env NODE_ENV=production keystone start"
},
"dependencies": {
"@emotion/core": "^10.0.10",
Expand Down Expand Up @@ -48,4 +49,4 @@
"react-use-form-state": "^0.10.0",
"uuid": "^3.3.2"
}
}
}
9 changes: 9 additions & 0 deletions demo-projects/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"scripts": {
"start": "yarn todo dev",
"blog": "yarn --cwd blog",
"meetup": "yarn --cwd meetup",
"todo": "yarn --cwd todo"
},
"license": "MIT"
}
6 changes: 4 additions & 2 deletions demo-projects/todo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"node": ">=8.4.0"
},
"scripts": {
"start": "cross-env NODE_ENV=development DISABLE_LOGGING=true keystone"
"dev": "cross-env NODE_ENV=development DISABLE_LOGGING=true keystone dev",
"build": "cross-env NODE_ENV=production keystone build",
"start": "cross-env NODE_ENV=production keystone start"
},
"dependencies": {
"@keystone-alpha/adapter-mongoose": "^2.0.1",
Expand All @@ -20,4 +22,4 @@
"@keystone-alpha/app-static": "^1.0.0",
"cross-env": "^5.2.0"
}
}
}
2 changes: 1 addition & 1 deletion docs/quick-start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To create a new KeystoneJS application, ensure [mongodb is running](../quick-sta
```sh
yarn create keystone-app my-app
cd my-app
npm start
yarn dev
```

Congratulations, you are now running your very own KeystoneJS application!
Expand Down
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build]
command = "yarn bolt && yarn website:build"
command = "yarn bolt && yarn website build"
publish = "website/public"
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,30 @@
"author": "The KeystoneJS Development Team",
"license": "MIT",
"scripts": {
"coverage": "DISABLE_LOGGING=true NODE_ENV=test jest --maxWorkers=1 --coverage",
"dev": "yarn demo todo dev",
"demo": "yarn --cwd ./demo-projects",
"website": "yarn --cwd ./website",
"coverage": "cross-env DISABLE_LOGGING=true NODE_ENV=test jest --maxWorkers=1 --coverage",
"cypress:run": "status=0; bolt w @keystone-alpha/cypress-project-basic run cypress:run || status=$?; bolt w @keystone-alpha/cypress-project-login run cypress:run || status=$?; bolt w @keystone-alpha/cypress-project-twitter-login run cypress:run || status=$?; bolt w @keystone-alpha/cypress-project-access-control run cypress:run || status=$?; bolt w @keystone-alpha/cypress-project-client-validation run cypress:run || status=$?; exit $status",
"format:file": "prettier --write",
"format": "prettier --write \"**/*.js{,on}\" \"**/*.md\" && remark . --output",
"fresh": "yarn clean && bolt",
"clean": "bolt ws exec -- rm -rf node_modules && rm -rf node_modules && rm -rf website/.cache",
"clean": "bolt ws exec -- rimraf node_modules website/.cache",
"lint:eslint": "eslint .",
"lint:prettier": "prettier --list-different \"**/*.js\"",
"lint:flow": "flow check",
"lint:markdown": "remark . --frail --quiet",
"lint": "yarn lint:prettier && yarn lint:eslint && yarn lint:flow && yarn lint:markdown",
"start": "yarn start:demo",
"start:demo": "/bin/sh -c 'cd demo-projects/${1:-$0} && yarn start' todo",
"start:test": "/bin/sh -c 'cd test-projects/${1:-$0} && yarn start' basic",
"website:start": "cd website && yarn start",
"website:build": "cd website && yarn build",
"test": "yarn lint && yarn test:unit && yarn cypress:run",
"test:unit": "DISABLE_LOGGING=true NODE_ENV=test jest --maxWorkers=1",
"test:unit:debug": "NODE_ENV=test node --inspect-brk `which jest` --runInBand",
"test:unit": "cross-env DISABLE_LOGGING=true NODE_ENV=test jest --maxWorkers=1",
"test:unit:debug": "cross-env NODE_ENV=test node --inspect-brk `which jest` --runInBand",
"changeset": "changeset",
"version-packages": "changeset bump",
"publish-changed": "yarn build && changeset release --public",
"build:build-field-types": "rimraf packages/build-field-types/lib && babel packages/build-field-types/src --out-dir packages/build-field-types/dist --ignore '**/__tests__/**/*','**/__mocks__/**/*'",
"build": "preconstruct build && bolt w @keystone-alpha/build-field-types build && node ./packages/build-field-types/bin.js build",
"prepare": "yarn build:build-field-types && preconstruct dev && node ./packages/build-field-types/bin.js dev && yarn run --silent contributing-guide",
"contributing-guide": "is-ci && exit 0 || chalk -t \"\n\n{bold 📝 Contributing to KeystoneJS?}\n\" && link '🔗 Read the full Contributing Guide' 'https://github.com/keystonejs/keystone-5/blob/master/CONTRIBUTING.md' && echo \"\n\"",
"contributing-guide": "is-ci && exit 0 || chalk -t \"{bold 📝 Contributing to KeystoneJS?}\" && link \"🔗 Read the full Contributing Guide\" \"https://github.com/keystonejs/keystone-5/blob/master/CONTRIBUTING.md\"",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate",
"heroku-postbuild": "bolt && yarn build && bolt w @keystone-alpha/demo-project-blog build"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-keystone-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ title: Create Keystone App
```sh
yarn create keystone-app my-app
cd my-app
yarn start
yarn dev
```
11 changes: 9 additions & 2 deletions packages/create-keystone-app/templates/todo/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Starter Project - Todo List

This is the todo list - the simplest implementation of Keystone. The todo list allows you to see what the minimum requirements are for running Keystone. It has no fancy extras and only one list - easy peasy!
This is the todo list - the simplest implementation of Keystone. The todo list allows you to see what the minimum requirements are for running Keystone. It has no fancy extras and only one list.

**[Read the Keystone Docs](https://v5.keystonejs.com)**

## Running the Project.

```
yarn start
yarn dev
```

Then visit:
Expand All @@ -16,6 +16,13 @@ Then visit:
- The KeystoneJS Admin UI at [`http://localhost:3000/admin`](http://localhost:3000/admin)
- The GraphQL Playground at [`http://localhost:3000/admin/graphiql`](http://localhost:3000/admin/graphiql)

## Production Build

```
yarn build
yarn start
```

## React App

The one 'extra' that this project includes is an example React App that consumes the data from Keystone via GraphQl. The app uses React's UMD build and is housed within the `/public` directory. It allows you to see how easy it is to create an app that can use Keystone's GraphQL APIs.
4 changes: 3 additions & 1 deletion packages/create-keystone-app/templates/todo/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "<%= appName%>",
"version": "0.0.0",
"scripts": {
"start": "cross-env NODE_ENV=development DISABLE_LOGGING=true keystone"
"dev": "cross-env NODE_ENV=development DISABLE_LOGGING=true keystone dev",
"build": "cross-env NODE_ENV=production keystone build",
"start": "cross-env NODE_ENV=production keystone start"
},
"private": true,
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/fields-wysiwyg-tinymce/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { dirname } from 'path';
import express from 'express';
import { Text } from '@keystone-alpha/fields';
import { importView } from '@keystone-alpha/build-field-types';

function prepareMiddleware() {
const tinymce = require.resolve('tinymce');
const tinymcePath = tinymce.substr(0, tinymce.lastIndexOf('/'));
const tinymcePath = dirname(require.resolve('tinymce'));
const app = express();
app.use('/tinymce-assets', express.static(tinymcePath));
return app;
Expand Down
10 changes: 10 additions & 0 deletions test-projects/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scripts": {
"start": "yarn basic start",
"access-control": "yarn --cwd access-control",
"basic": "yarn --cwd basic",
"login": "yarn --cwd login",
"social-login": "yarn --cwd social-login"
},
"license": "MIT"
}

0 comments on commit b3e561e

Please sign in to comment.