Skip to content

Commit

Permalink
Merge branch 'canary' into adam/generate-command-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
flybayer authored Apr 23, 2020
2 parents 6b4868b + 7e72dd3 commit f59c6f7
Show file tree
Hide file tree
Showing 100 changed files with 1,890 additions and 971 deletions.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ about: Something is not working right. Or error messages are unclear.
title: ''
labels: ''
assignees: ''

---

**What is the problem?**


**Steps to Reproduce:**

1.
2.

1. 2.

**Versions:**
- Blitz: [e.g. 0.5.1.-alpha]
- OS: [e.g. macOS]

- Blitz: [e.g. 0.5.1.-alpha]
- OS: [e.g. macOS]

```
[Add the output of `blitz -v` here]
```

**Supporting Documentation**
Please include applicable logs and screenshots that show your problem.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
name: Feature/change request
about: Something new or better!
title: ''
labels: ''
assignees: ''

---

**What do you want and why do you want it?.**
Expand Down
17 changes: 0 additions & 17 deletions .github/ISSUE_TEMPLATE/improvement.md

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dist
**/.env.development.local
**/.env.test.local
**/.env.production.local
.blitz-*
2 changes: 1 addition & 1 deletion MANIFESTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ A fullstack, monolithic application is simpler than an application where fronten

Until now, choosing React for your view layer required you to have a REST or GraphQL API even if it wasn't used by third-parties. This additional complexity is a significant drawback not shared by traditional server rendered apps like Ruby on Rails.

Blitz is a framework for the 99% of us at companies with <100 employees. The vast majority of these apps don't actually need an API, at least not until years down the road when you have the time and resources to build one.
Blitz is a framework for the 99% of us at companies with <100 employees. The vast majority of these apps don't actually need an API, at least not until years down the road when you have the time and resources to build one.

### 3. Convention over Configuration

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ There's still a lot of work to do, so you are especially invited to join us in b
- Contribute via [Open Collective](https://opencollective.com/blitzjs)
- Contribute via [Patreon](https://patreon.com/flybayer)

_Sponsor Blitz and display your logo and hiring status here. This is a great way to get in front of early adopters! [See options on Open Collective](https://opencollective.com/blitzjs)_
_Sponsor Blitz and display your logo and hiring status here. This is a great way to get in front of early adopters!_

<br>

Expand Down Expand Up @@ -148,6 +148,7 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
51 changes: 25 additions & 26 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<br>

Before getting started, you should know **this is alpha software**. Blitz is incomplete. There are rough spots and bugs. APIs may change. But you can build an app and deploy it to production. We're excited to see what you build!
Before getting started, you should know **this is alpha software**. Blitz is incomplete. There are rough spots and bugs. APIs may change. But you can build an app and deploy it to production. We're excited to see what you build!

If you have any issues at all, please join the [Blitz slack](https://slack.blitzjs.com) and tell us in the **#help** channel. If you get stuck and frustrated, please don't blame yourself. This user guide, and Blitz in general, is not yet fine-tuned for those with less experience. Eventually it will be because this is very important to us.

Expand All @@ -24,8 +24,9 @@ Blitz is built on Next.js, so if you are familiar with that, you will feel right

- [ ] You need Node.js 12 or newer
- [ ] You need Postgres installed and running.

- On macOS, you can use `brew install postgres` or install [Postgres.app](https://postgresapp.com/)

<br>

### Create Your Blitz App
Expand Down Expand Up @@ -78,15 +79,14 @@ _CRUD = create, read, update, delete_

Blitz.js pages are exactly the same as Next.js pages. If you need, read [the Next.js Page documentation](https://nextjs.org/docs/basic-features/pages)


- Unlike Next.js, you can have many `pages/` folders nested inside `app/`. This way pages can be organized neatly, especially for larger projects. Like this:
- Unlike Next.js, you can have many `pages/` folders nested inside `app/`. This way pages can be organized neatly, especially for larger projects. Like this:
- `app/pages/about.tsx`
- `app/projects/pages/projects/index.tsx`
- `app/tasks/pages/projects/[projectId]/tasks/[id].tsx`
- All React components inside a `pages/` folder are accessible at a URL corresponding to it's path inside `pages/`. So `pages/about.tsx` will be at `localhost:3000/about`.
- All React components inside a `pages/` folder are accessible at a URL corresponding to it's path inside `pages/`. So `pages/about.tsx` will be at `localhost:3000/about`.

The Next.js router APIs are all exported from the `blitz` package: `useRouter()`, `withRouter()`, and `Router`. If you need, read [the Next.js Router documentation](https://nextjs.org/docs/api-reference/next/router).

<br>

### Writing Queries & Mutations
Expand All @@ -102,7 +102,6 @@ We automatically alias the root of your project, so `import db from 'db'` is imp
import db, {FindOneProductArgs} from 'db'

export default async function getProduct(args: FindOneProductArgs) {

// Can do any pre-processing or event triggers here
const product = await db.product.findOne(args)
// Can do any post-processing or event triggers here
Expand All @@ -118,11 +117,10 @@ export default async function getProduct(args: FindOneProductArgs) {
import db, {ProductCreateArgs} from 'db'

export default async function createProduct(args: ProductCreateArgs) {

// Can do any pre-processing or event triggers here
const product = await db.product.create(args)
// Can do any post-processing or event triggers here

return product
}
```
Expand All @@ -131,7 +129,6 @@ export default async function createProduct(args: ProductCreateArgs) {

### Using Queries


#### In a React Component

Blitz provides a `useQuery` hook, which is built on [`react-query`](https://github.com/tannerlinsley/react-query). The first argument is a query function. The second argument is the input to the query function. The third argument is any valid react-query configuration item.
Expand All @@ -143,27 +140,27 @@ At build time, the direct function import is swapped out for a function that exe
```tsx
import {Suspense} from 'react'
import {useRouter, useQuery} from 'blitz'
import getProduct from '/app/products/queries/getProduct'
import getProduct from 'app/products/queries/getProduct'
import ErrorBoundary from 'app/components/ErrorBoundary'

function Product() {
const router = useRouter()
const id = parseInt(router.query.id as string)
const [product] = useQuery(getProduct, {where: {id: props.query.id}})

return <div>{product.name}</div>
}

export default function() {
export default function () {
return (
<div>
<ErrorBoundary fallback={error => <div>Error: {JSON.stringify(error)}</div>}>
<Suspense fallback={<div>Loading...</div>}>
<Product />
</Suspense>
</ErrorBoundary>
</div>
)
<div>
<ErrorBoundary fallback={(error) => <div>Error: {JSON.stringify(error)}</div>}>
<Suspense fallback={<div>Loading...</div>}>
<Product />
</Suspense>
</ErrorBoundary>
</div>
)
}
```

Expand All @@ -174,12 +171,12 @@ In `getStaticProps`, a query function can be called directly without `useQuery`
```tsx
import getProduct from '/app/products/queries/getProduct'

export const getStaticProps = async context => {
export const getStaticProps = async (context) => {
const product = await getProduct({where: {id: context.params?.id}})
return {props: {product}}
}

export default function({product}) {
export default function ({product}) {
return <div>{product.name}</div>
}
```
Expand All @@ -206,7 +203,7 @@ For more details, read the comprehensive [Query & Mutation Usage Issue](https://

### Using Mutations

Mutations are called directly, like a regular asynchronous function.
Mutations are called directly, like a regular asynchronous function.

At build time, the direct function import is swapped out for a function that executes a network call to run the mutation server-side.

Expand Down Expand Up @@ -268,6 +265,7 @@ Assuming you already have a Zeit account and the `now` cli installed, you can do

1. Add your DB url as a secret environment variable by running `now secrets add @database-url "DATABASE_CONNECTION_STRING"`
2. Add a `now.json` at your project root with

```json
{
"env": {
Expand All @@ -280,9 +278,10 @@ Assuming you already have a Zeit account and the `now` cli installed, you can do
}
}
```

3. Run `now`

Once working and deployed to production, your app should be very stable because it’s running Next.js which is already battle tested.
Once working and deployed to production, your app should be very stable because it’s running Next.js which is already battle tested.

#### Traditional, Long-Running Server

Expand Down Expand Up @@ -342,7 +341,7 @@ Here's the list of big things that are currently missing from Blitz but are top

- A real Blitzjs.com website and documentation
- Translated documentation. If you're interested in helping, [comment in this issue](https://github.com/blitz-js/blitzjs.com/issues/20).
- Authentication
- Authentication
- Authorization (use auth rules both on server and client)
- Model validation (use model validation both on server and client)
- `blitz new` including set up for testing, Prettier, ESLint, styling system (Tailwind, CSS-in-JS, etc)
Expand Down
4 changes: 4 additions & 0 deletions examples/store/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: ['next/babel'],
plugins: [],
}
8 changes: 8 additions & 0 deletions examples/store/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: ['react-app', 'plugin:jsx-a11y/recommended'],
plugins: ['jsx-a11y'],
rules: {
'import/no-webpack-loader-syntax': 'off',
'react/react-in-jsx-scope': 'off', // React is always in scope with Blitz
},
}
1 change: 1 addition & 0 deletions examples/store/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/.blitz/
*.sqlite
.generated-prisma-client
.blitz-console-history

# production
/build
Expand Down
5 changes: 5 additions & 0 deletions examples/store/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitkeep
.env
*.ico
*.lock

Empty file.
Empty file.
Empty file.
Empty file.
Empty file added examples/store/jobs/.keep
Empty file.
4 changes: 2 additions & 2 deletions examples/store/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "store",
"version": "0.5.0-canary.5",
"version": "0.5.2-alpha",
"private": true,
"scripts": {
"build": "blitz db migrate && blitz build"
},
"dependencies": {
"@prisma/cli": "2.0.0-beta.2",
"@prisma/client": "2.0.0-beta.2",
"blitz": "0.5.0-canary.5",
"blitz": "0.5.2-alpha",
"final-form": "4.19.1",
"react": "0.0.0-experimental-e5d06e34b",
"react-dom": "0.0.0-experimental-e5d06e34b",
Expand Down
Binary file added examples/store/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added examples/store/utils/.keep
Empty file.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.5.0-canary.5",
"version": "0.5.2-alpha",
"packages": ["packages/*"],
"npmClient": "yarn",
"useWorkspaces": true,
Expand Down
29 changes: 18 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
},
"engines": {
"yarn": "^1.19.1",
"node": ">=12.16.1"
"node": ">= 10.13.0"
},
"scripts": {
"postinstall": "npm rebuild husky",
"dev": "lerna run dev --no-private --stream --parallel",
"link-cli": "yarn workspace blitz link",
"unlink-cli": "yarn workspace blitz unlink",
"build": "lerna run build --no-private --stream",
"test": "yarn run build && lerna run test --parallel",
"prepublishOnly": "yarn run test",
"test": "yarn run build && yarn run testonly",
"testonly": "lerna run test --parallel",
"prepublishOnly": "yarn run reset && yarn run test",
"prepack": "cpy README.md packages/blitz/",
"postpack": "rimraf packages/blitz/README.md",
"publish-canary": "lerna publish --preid canary --pre-dist-tag canary",
"publish-alpha": "lerna publish --preid alpha"
"reset": "rimraf node_modules && git clean -xfd packages && yarn",
"publish-canary": "lerna publish --preid canary --pre-dist-tag canary --no-push && yarn run danger:push-all",
"publish-alpha": "lerna publish --preid alpha ---no-push --force-publish && yarn run danger:push-all",
"danger:push-all": "git push --no-verify && git push --no-verify --tags"
},
"devDependencies": {
"@testing-library/jest-dom": "5.5.0",
Expand All @@ -35,26 +38,30 @@
"@types/debug": "^4.1.5",
"@types/diff": "^4.0.2",
"@types/find-parent-dir": "0.3.0",
"@types/from2": "^2.3.0",
"@types/fs-extra": "^8.1.0",
"@types/fs-readdir-recursive": "1.0.0",
"@types/gulp-if": "^0.0.33",
"@types/jest": "^25.1.3",
"@types/mem-fs": "^1.1.2",
"@types/mem-fs-editor": "^5.1.1",
"@types/mem-fs": "^1.1.2",
"@types/merge-stream": "^1.1.2",
"@types/node": "^13.7.4",
"@types/node-fetch": "^2.5.6",
"@types/parallel-transform": "^1.1.0",
"@types/path-is-absolute": "^1.0.0",
"@types/pumpify": "^1.4.1",
"@types/react": "16.9.34",
"@types/readable-stream": "^2.3.5",
"@types/through2": "^2.0.34",
"@types/vinyl": "^2.0.4",
"@types/vinyl-fs": "^2.4.11",
"@types/vinyl": "^2.0.4",
"@wessberg/cjs-to-esm-transformer": "^0.0.19",
"@wessberg/rollup-plugin-ts": "^1.2.24",
"cpy-cli": "^3.1.0",
"cross-env": "^7.0.0",
"debug": "^4.1.1",
"directory-tree": "^2.2.4",
"globby": "^11.0.0",
"husky": "^4.2.3",
"jest": "24.9.0",
"lerna": "^3.20.2",
Expand All @@ -65,17 +72,17 @@
"pretty-quick": "2.0.1",
"prompt": "^1.0.0",
"rimraf": "3.0.2",
"rollup": "^2.6.1",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-peer-deps-external": "^2.2.2",
"rollup": "^2.6.1",
"semver": "^7.3.2",
"ts-jest": "24.3.0",
"tsdx": "^0.13.1",
"tslib": "^1.10.0",
"typescript": "^3.7.5",
"tslib": "^1.11.1",
"typescript": "^3.8.3",
"wait-on": "4.0.2"
},
"husky": {
Expand Down
3 changes: 2 additions & 1 deletion packages/blitz/bin/blitz
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env node
#!/usr/bin/env node --experimental-repl-await

require('../dist/cli')
Loading

0 comments on commit f59c6f7

Please sign in to comment.