1
0
mirror of synced 2026-02-03 18:01:02 -05:00

Compare commits

...

294 Commits

Author SHA1 Message Date
Brandon Bayer
192f79e064 v0.7.0 2020-04-27 19:13:51 +07:00
Brandon Bayer
a8d152ba87 Fix some HMR bugs by upgrading next to 9.3.6-canary.13 (#291)
(patch)
2020-04-27 19:06:19 +07:00
Brandon Bayer
875f99a20c update links on homepage of store example
(example)
2020-04-27 18:51:54 +07:00
allcontributors[bot]
c73bdc7487 docs: add eliasjohansson as a contributor (#290) 2020-04-27 18:44:50 +07:00
Elias Johansson
040deeed32 Add useQuery pagination & add pagination to store example (#278)
(minor)
2020-04-27 18:44:00 +07:00
allcontributors[bot]
9c670ef77d docs: add LoriKarikari as a contributor (#288)
(meta)
2020-04-27 17:23:42 +07:00
Lori Karikari
7db98c3636 changed btliz to blitz in fork script (#285)
(ignore)
2020-04-27 17:22:45 +07:00
allcontributors[bot]
08195b04e6 docs: add kandros as a contributor (#287)
(ignore)
2020-04-27 17:05:18 +07:00
Brandon Bayer
cdf8cc4a9f Fix types for second argument of useQuery and ssrQuery (#286)
(patch)
2020-04-27 17:04:14 +07:00
Brandon Bayer
0c3b8dd17a Update PULL_REQUEST_TEMPLATE.md 2020-04-27 17:03:30 +07:00
Brandon Bayer
fd624213b3 chore: remove double jest usage - tests now fixed 2020-04-27 13:07:18 +07:00
allcontributors[bot]
9d91117b97 docs: add skn0tt as a contributor (#273)
(ignore)
2020-04-27 12:39:57 +07:00
Brandon Bayer
8cd670296e Change default DB to SQLite instead of postgres (#283)
(patch)
2020-04-27 12:39:02 +07:00
Jaga Santagostino
14df845e16 Add start script to new app template package.json (#270)
(patch)
2020-04-27 12:38:38 +07:00
Brandon Bayer
7b6b024388 v0.6.6 2020-04-26 19:27:56 +07:00
Rudi Yardley
d736ea11f3 Fix relative imports (#271)
(patch)
2020-04-26 19:27:01 +07:00
Brandon Bayer
9a67da5993 v0.6.5 2020-04-26 14:36:54 +07:00
Brandon Bayer
ba981694ad Fix HMR, Enable Fast Refresh, Upgrade next to 9.3.6-canary.11 (#268) 2020-04-26 14:31:12 +07:00
Rudi Yardley
1eebdb54c6 Fix UnhandledPromiseRejectionWarning error during blitz start (#266)
(patch)
2020-04-26 14:14:19 +07:00
Brandon Bayer
fe1f4b0785 Clean and upgrade dependencies (#267)
(ignore)
2020-04-26 14:10:01 +07:00
Justin Hall
63921f3e23 refactor(cli): rename generator template files for compatibility (#249)
Co-authored-by: Brandon Bayer <b@bayer.ws> (ignore)
2020-04-26 12:29:05 +07:00
allcontributors[bot]
69b02ffb54 docs: add Zeko369 as a contributor (#265)
(ignore)
2020-04-26 12:23:39 +07:00
Fran Zekan
86eec51d24 Update Contributing.md and add script for syncing fork (#248)
(ignore)
2020-04-26 12:23:21 +07:00
Brandon Bayer
d59c0a4fd3 Add Tailwind CSS example app (#264) 2020-04-26 12:04:59 +07:00
Brandon Bayer
852e32a484 Revert "Add Tailwind CSS example app"
This reverts commit 052300f09d.
2020-04-26 11:57:11 +07:00
Brandon Bayer
052300f09d Add Tailwind CSS example app 2020-04-26 11:55:13 +07:00
Brandon Bayer
d2f94ff0cb update issue templates
(ignore)
2020-04-26 11:05:02 +07:00
Brandon Bayer
262a228cd9 update feature issue template 2020-04-26 10:55:49 +07:00
Brandon Bayer
9bf36b0421 update PR template 2020-04-26 10:50:40 +07:00
Brandon Bayer
73d2251168 update issue_template 2020-04-26 10:43:49 +07:00
Brandon Bayer
2d52ceec7f v0.6.4 2020-04-26 10:35:53 +07:00
Brandon Bayer
c8527d93f9 remove the slow warning message 2020-04-26 10:31:51 +07:00
Brandon Bayer
5a69c49976 change new app template Prisma model to be the same as the user guide 2020-04-26 10:31:51 +07:00
allcontributors[bot]
49044611eb docs: add ntgussoni as a contributor (#258)
(ignore)
2020-04-26 10:31:21 +07:00
allcontributors[bot]
2997fcc17d docs: add jclancy93 as a contributor (#256)
(ignore)
2020-04-26 08:54:03 +07:00
Jack Clancy
6f1900c5e6 Make blitz h print the help menu (#252)
(patch)
2020-04-26 08:53:43 +07:00
allcontributors[bot]
a342d62cb5 docs: add DevanB as a contributor (#255)
(ignore)
2020-04-26 08:41:51 +07:00
Devan
5c89d7feb9 Correct Prisma schema name in USER_GUIDE.md (#250)
(ignore)
2020-04-26 08:41:31 +07:00
Jim Cummins
92cf7b599f Fix super slow CLI startup when used in a folder with many files (#254)
(patch)
2020-04-26 08:38:27 +07:00
Brandon Bayer
47d16202c3 Update README.md 2020-04-26 01:15:37 +07:00
allcontributors[bot]
5fb24faa1a docs: add mikeattara as a contributor (#247) 2020-04-25 22:32:30 +07:00
Mike Perry Y Attara
815b351f4a fix typo (#244)
(ignore)
2020-04-25 22:32:02 +07:00
Brandon Bayer
b7528b2058 v0.6.3 2020-04-25 14:07:35 +07:00
Brandon Bayer
6af0eb7ea5 Fix Linux & Remove top level await support in console, temporarily (#231)
(patch)
2020-04-25 14:06:39 +07:00
Brandon Bayer
dcc9c4ddc9 Change email field to be optional in new app template schema 2020-04-25 09:01:00 +07:00
allcontributors[bot]
e7982a1132 docs: add janbaykara as a contributor (#222)
(ignore)
2020-04-24 22:13:15 +07:00
Jan Baykara
64eccf8bb4 Fix reference to id in README (#221)
(ignore)
2020-04-24 22:12:41 +07:00
Brandon Bayer
caad5b44f1 v0.6.2 2020-04-24 22:07:23 +07:00
Brandon Bayer
4b4d65cb7e v0.6.2-canary.0 2020-04-24 21:43:28 +07:00
Brandon Bayer
55fdaa0530 attempt fix for cli package detection 2020-04-24 21:41:14 +07:00
Brandon Bayer
fb3893a8d4 update blitz pkg description 2020-04-24 21:29:29 +07:00
Brandon Bayer
ca5d6ee0aa v0.6.1 2020-04-24 19:18:09 +07:00
Brandon Bayer
f17820f81d Add needed blitz db migrate command to the blitz new template app page 2020-04-24 19:17:19 +07:00
Brandon Bayer
ab6f60571a v0.6.0 2020-04-24 18:25:15 +07:00
Brandon Bayer
5f3d5dd7a3 change pkg script 2020-04-24 18:24:37 +07:00
Brandon Bayer
8b8143d2c2 v0.6.0-alpha 2020-04-24 18:15:41 +07:00
Brandon Bayer
8b6a51f8f1 Update readme for pending alpha release (#219)
* Update readme for pending alpha release

* Fix some language stuff 😄
(ignore)
Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
2020-04-24 18:14:30 +07:00
Brandon Bayer
0c23a7873c v0.6.0-canary.4 2020-04-24 17:50:00 +07:00
Brandon Bayer
0fa28d20c4 Remove oops debug log from blitz generator 2020-04-24 17:47:35 +07:00
Brandon Bayer
97132996b8 Add more useful instructions to the blitz new index page (#217)
* add more useful instructions to the `blitz new` index page

* fix (patch)
2020-04-24 17:41:27 +07:00
Brandon Bayer
96ac63d3a4 Update USER_GUIDE.md 2020-04-24 17:11:59 +07:00
Brandon Bayer
132601f0c2 Update USER_GUIDE.md 2020-04-24 16:59:46 +07:00
Brandon Bayer
c47d15a09f v0.6.0-canary.3 2020-04-24 16:38:59 +07:00
Brandon Bayer
0892137370 🎉 Add full working CRUD actions to pages generator! + fix RPC b… (#214)
minor
2020-04-24 16:36:56 +07:00
Brandon Bayer
797060c068 v0.6.0-canary.2 2020-04-24 15:32:28 +07:00
Adam Markon
1c7134c272 feat(cli): generate command (#187)
* initial scaffolding for generate command and validation in place

* page generator

* mutation generator

* add query and crud generator

* move to server logger

* update docs with most recent API changes

* undo logging changes in new command

* rename a few things, clean up early returns

* use path context relative to the root

* lots of cleanup, changes, fixes

* fix test

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-24 15:28:40 +07:00
Rudi Yardley
2638ec73b3 Speed up blitz start/build by parallelizing prisma generation (#212)
* Parallelize Prisma generation

* Provide resolving promise to fix failing tests (patch)
2020-04-24 15:15:17 +07:00
Brandon Bayer
3c4db0453e v0.6.0-canary.1 2020-04-24 13:59:45 +07:00
Brandon Bayer
d824459190 Add alpha msg to CLI and add OS version with blitz -v (#211)
(patch)
2020-04-24 13:22:58 +07:00
Brandon Bayer
5da2eae6e1 Fix some type issues
(patch)
2020-04-24 13:02:41 +07:00
Brandon Bayer
73f6be0814 Disable jsx-a11y/anchor-is-valid because it doesn't plan will with Blitz/Next links
(patch)
2020-04-24 13:02:02 +07:00
Dylan Brookes
2dfa86556d Beautify query/mutation logging and Refactor logger (#199)
* Refactor logger and beautify rpc logging

* Resolve conflicts and make requested changes

* move rpcHandler into server package where it belongs

* improve logging even more

* fix dependency issue
(patch)
Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-24 12:36:10 +07:00
Fran Zekan
7097150c2d Fix possible race condition during blitz new (#198)
* Refactor dependecy upgrader to mitigate the race condition

* Refactor reduce -> for loop
(patch)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-24 11:18:06 +07:00
Rudi Yardley
84a8ac7512 Maybe fix one issue on windows by removing node-pty (#210)
* Remove node-pty

* Use next instead of process.stdout
(patch)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-24 11:13:09 +07:00
Brandon Bayer
ef48721625 set up release notes (ignore) 2020-04-24 11:07:03 +07:00
Brandon Bayer
a54b48190c Update issue templates 2020-04-24 10:53:48 +07:00
Justin Hall
ff5cab07fc refactor(server): simplify resolveBinAsync (#208)
(patch)
2020-04-24 10:45:17 +07:00
Justin Hall
02ccc7db0e fix(cli): populate new apps with latest version of deps in range (#206) 2020-04-24 00:04:09 +07:00
Brandon Bayer
9de79ba621 v0.6.0-canary.0 2020-04-23 22:26:42 +07:00
allcontributors[bot]
dfac941a80 docs: add Zeko369 as a contributor (#201)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
(ignore)
2020-04-23 22:14:10 +07:00
Brandon Bayer
f3f17a2452 Add spinner to blitz new and blitz start/build (#200)
(patch)
2020-04-23 22:10:10 +07:00
Brandon Bayer
aa6d0e0dc0 update console in user guide 2020-04-23 21:16:21 +07:00
Dylan Brookes
4b0b1b8c66 Change blitz new install to cli version (#195)
* Change blitz new install to cli version

* Update replace-blitz-dependency.ts

* Simplify

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
2020-04-23 20:44:53 +07:00
Brandon Bayer
7e72dd3ccd Merge branch 'master' into canary 2020-04-23 15:29:05 +07:00
Brandon Bayer
0aa16e25ae update publish script 2020-04-23 15:10:20 +07:00
Brandon Bayer
9e5d58ddbd v0.5.2-alpha 2020-04-23 15:06:17 +07:00
Brandon Bayer
edd673f54c publish script change 2020-04-23 15:04:45 +07:00
Brandon Bayer
6cccbe3487 publish script 2020-04-23 15:03:33 +07:00
Brandon Bayer
92069cfef8 v0.5.0-canary.10 2020-04-23 14:56:30 +07:00
Brandon Bayer
b16424592f run reset on publish 2020-04-23 14:56:08 +07:00
Brandon Bayer
92c4a4bfc8 auto rerun CLI test if fails first time & some dx scripts 2020-04-23 14:54:12 +07:00
Brandon Bayer
ffd87a80af v0.5.0-canary.9 2020-04-23 14:40:52 +07:00
Brandon Bayer
9c54cfaef1 v0.5.0-canary.8 2020-04-23 14:37:44 +07:00
Brandon Bayer
fd2e9d2988 fix blitz console again... 2020-04-23 14:33:58 +07:00
Brandon Bayer
3cc4476a98 v0.5.0-canary.7 2020-04-23 13:03:01 +07:00
Brandon Bayer
1a45b2d394 Fix CLI on windows (#192) 2020-04-23 13:00:26 +07:00
Beata Obrok
bac7f21295 fix(cli): console crashing when importing ts files (#185)
* fix(cli): console crashing when importing ts files

* fixes

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-23 10:17:17 +07:00
Brandon Bayer
9755466f9b Update bug_report.md 2020-04-23 09:43:56 +07:00
Justin Hall
3a85e83b56 fix(server): make synchronizer pages rule cross-platform (#186)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-23 09:37:30 +07:00
Justin Hall
4e49239f53 test(server): make dev tests cross-platform (#184) 2020-04-23 09:30:55 +07:00
Camilo Gonzalez
f0a56ff2fe refactor: replaceDependencies to run in parallel (#183) 2020-04-22 22:54:08 +07:00
Brandon Bayer
2a71e3441d fix tsconfig-paths being registered for all commands 2020-04-22 22:16:36 +07:00
Brandon Bayer
63cacbb73c tweak readme 2020-04-22 22:03:16 +07:00
Brandon Bayer
219d12aaa2 update issue templates 2020-04-22 21:57:58 +07:00
Brandon Bayer
b1321c77e1 v0.5.0-canary.6 2020-04-22 21:04:43 +07:00
Brandon Bayer
f7685b4abb fix typo 2020-04-22 21:03:43 +07:00
Brandon Bayer
cf215b4a12 Update USER_GUIDE.md 2020-04-22 20:52:00 +07:00
Rudi Yardley
32f0a76b18 Refactor synchronizer (#146)
* Refactor Synchronizer

* Add api routes functionality

* Add functions to test files

* Update docs

* Added view rendering and error section

* Move devdeps to root

* Add VERCEL_BUILDER env var check

* Update file writer reporter to clear the line and wait less for the ready event

* Alter types

* Update docs add image files

* Update README.md

* Update README.md

* Add params to log docs

* Update README.md

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
2020-04-22 21:08:15 +10:00
Brandon Bayer
e9e8841f07 Implement the blitz console command (#176)
* wip

* working

* add default blitz files to store example

* finish up

* fix tests
2020-04-22 17:43:14 +07:00
Dylan Brookes
d6b29a2f71 Use latest versions for app template (#170)
* Use latest versions for app template

* Make dependency swapping more robust

* Make it faster

* Only upgrade as far as the current major version

* Use dep replace for devDependencies as well

* pretty print json and add .npmrc

* Clean up fetching

* Fail on a case-by-case basis

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-22 15:15:57 +07:00
Brandon Bayer
af338d99e4 Fix yarn test by also running the build (#174) 2020-04-21 21:36:54 +07:00
allcontributors[bot]
bd63e4cab0 docs: add sonnypgs as a contributor (#172)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-21 19:46:18 +07:00
Brandon Bayer
e387936cb0 Update README.md 2020-04-21 19:42:07 +07:00
Dylan Brookes
0650252c53 Print help message for unsupported commands (#153)
* Print help message for unsupported commands

* Fix not found hook

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
2020-04-21 15:22:04 +07:00
Brandon Bayer
76cfb8c076 Fix store example static pages (#168)
* fix revalidate for latest Next version

* also single product page
2020-04-21 14:34:03 +07:00
Brandon Bayer
6273ffd255 fix PR template 2020-04-21 14:32:07 +07:00
Brandon Bayer
6e447f1f44 fix blitz -v when globally linked but using it outside monorepo 2020-04-21 14:12:12 +07:00
Corey Brown
4c4721250a Branded Welcome Template (#158)
* adds blitz branding to welcome template screen

* add dynamic name tag back in

* updates and new logo

* adds dynamic title

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-21 13:54:47 +07:00
Brandon Bayer
6852cfc208 Update issue templates 2020-04-21 13:47:09 +07:00
Brandon Bayer
da488ccf33 update issue template feature_request 2020-04-21 13:14:28 +07:00
Brandon Bayer
36d0ae8587 update PR template 2020-04-21 13:11:07 +07:00
Brandon Bayer
8bcaf62641 Update issue templates 2020-04-21 13:10:55 +07:00
Brandon Bayer
820d191a63 Upgrade and organize dependencies (#165)
* monorepo dependency maintenance

* update dependencies
2020-04-21 13:08:15 +07:00
Brandon Bayer
45842d48ad Add issue templates 2020-04-21 13:02:25 +07:00
Brandon Bayer
67ed16429d fix eslint react warning 2020-04-21 11:22:44 +07:00
allcontributors[bot]
45cb96f9f1 docs: add hew as a contributor (#164)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-21 10:50:33 +07:00
Matt
9063758292 Fix: typo in install instructions (#156) 2020-04-21 10:49:48 +07:00
allcontributors[bot]
2a892ba4d0 docs: add mattleff as a contributor (#163)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-21 10:48:54 +07:00
Matthew Leffler
73b3920a53 Fix typo (#155) 2020-04-21 10:48:36 +07:00
Brandon Bayer
fae90065df add logging util to PULL_REQUEST_TEMPLATE 2020-04-21 10:42:24 +07:00
allcontributors[bot]
fc762c15fc docs: add ETLopes as a contributor (#162)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-21 10:42:01 +07:00
Eduardo Lopes
cc10b71f9d chore(prtemplate): create a PR Template for the project. (#4)
* feat(prtemplate): create a PR Template for the project.

* Update PULL_REQUEST_TEMPLATE.md

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-21 10:39:43 +07:00
Brandon Bayer
998d227832 fix all_contributors 2020-04-21 10:39:04 +07:00
Dylan Brookes
35c150a46a Add logging util (#154)
* Add a logging util file and use for synchronizer

* Delete stray file

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
2020-04-21 10:27:32 +07:00
Brandon Bayer
920716a0d8 move README back to root so github mobile readme view works correctly 2020-04-21 10:11:27 +07:00
Brandon Bayer
39675d1da8 Update USER_GUIDE.md 2020-04-21 10:00:28 +07:00
Brandon Bayer
dd20c0ac6c fix readme 2020-04-20 21:28:38 +07:00
Brandon Bayer
2ea1e7b522 restore buried readme updates 2020-04-20 21:27:02 +07:00
Brandon Bayer
44c3ea22e2 Update README.md 2020-04-20 21:25:42 +07:00
Brandon Bayer
f4760776ee Update readme with benefits and features 2020-04-20 21:25:33 +07:00
Brandon Bayer
65bb7e8e84 add publish-alpha script 2020-04-20 21:23:11 +07:00
Brandon Bayer
8547585cc7 v0.5.1-alpha 2020-04-20 21:20:04 +07:00
Brandon Bayer
16b810e0c3 Merge to master (#152)
* docs: add code of conduct

* Update README.md

* remove broken gh action

* chore: update readme

* Add initial Blitz Core and First Demo 🎉 (#11)

* wip

* chore: fix typings, tweak build config

* update prettier config

* set up husky to run prettier on commit

* add migrate script and update readme

* changes, still broken

* add yarn dev command

* more changes, still broken

* demo working again!

* fix: yarn why do you hate me so much?

* add to gitignore

* trying to get demo dev to work right

* refactor and cleanup

* more cleanup

* update deps

* tweak

* update readme

* fix

* update readme

Co-authored-by: Michael Edelman  <michael@edel.mn>

* Live Demo Deployment (#12)

* add github link to demo

* fix(core): connect to db right away + fix for connection undefined

* changes to demo needed for production deployment

* fix(demo): relax tsconfig

* upgrade prisma & fix core for deployment

* demo updates

* chore(demo): add some comments

* fix(demo): untitled posts

* fix(demo): add content filtering!

* Add Open Collective Sponsor button (#15)

* fix(demo): switch to fruit content filter

* chore: add flybayer as codeowner of everything

* chore: Add Patreon and Paypal to the sponsor button options (#18)

* chore: add sponsor section to readme

* feat(cli): Add initial CLI (#8)

* v0.0.1

Initial PR for oclif CLI

* update prettier config

* chore: repo updates - run prettier on commit

* organize package.json + correct package name

* Add initial app generator

* changes & cleanup

* more tweaks

* Add basic nextjs generation

* #9 Swapping Mocha with Jest for CLI

Swapped Mocha with Jest.

* Swapping Mocha with Jest for CLI

Swapped Mocha with Jest.

* add `yarn b [COMMAND]` for dev convenience

* Formalize path arg

* Make jest work

* Remove empty commands and make tests pass

* Fix path argument

* Revert "target" in tsconfig.json

* Remove `target` from cli package.json

* Fix build command

* Use custom tsconfig for test script

* remove nyc because jest has coverage built in

* little cleanup

Co-authored-by: Mina Abadir <mina@abadir.email>
Co-authored-by: Lorenzo Rapetti <lorenzo.rapetti.94@gmail.com>

* chore(core): Add core tests (#16)

* Add core tests

- Tests cover Form and Controller
- You can check code coverage with "yarn test --coverage"

* A little formatting + form test modifications

* add back console log

Co-authored-by: Yanick Bélanger <yanick.belanger@yahoo.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>

* fix: noop @prisma/client in browser, closes #13 (#19)

Co-authored-by: Brandon Bayer <b@bayer.ws>

* feat(core): Add withBlitz webpack wrapper + fix prisma/client (#31)

* add withBlitz webpack config wrapper

* Move prisma/client noop into withBlitz!

* chore: add pull_request event to github action

* docs: Update CODE_OF_CONDUCT.md (#28)

* feat(cli): Add `blitz console` command (#32)

Co-authored-by: Brandon Bayer <b@bayer.ws>

* feat(cli): Add `blitz test` command (#30)

* add run tests command

* add test command

* add test cmd unit test

* uses project package manager (npm/yarn) to run test script

Co-authored-by: Brandon Bayer <b@bayer.ws>

closes #22

* docs: add dev onboarding blurb to readme

* docs: fix typo

* chore: comment cleanup

* bug(example): Fix Invalid hook call error. (#37)

* fix: Fix jest version incompatability (#43)

* bug(webpack): Create webpack package to avoid context bugs (#42)

* Add new webpack package

* Delete webpack files from core

* Pin dependencies

* feat(cli): use custom REPL in console command (#38)

Co-authored-by: Brandon Bayer <b@bayer.ws>

* feat(core): Return 404 if controller action is not defined (#39)

Co-authored-by: Brandon Bayer <b@bayer.ws>

* fix(core): Add support for multiple attribute types for id (#35)

* Add support for multiple attribute types for id

* Add comment + tests

* test(examples): add cypress tests to first demo (#47)

* [examples] feat: setup cypress in first demo

* [examples] spec: add cypress tests for first demo

closes #44

* feat(cli): Compile to Next (#45)

* Only create a prisma client when it actually needed

* Setup start script for a simple next-project

* Enable "compile to next" on first-demo

* Whitespace

* Fix failing webpack config test

* Testing spawn call

* Neaten up code

* Test tsExtraMock instead of reporter

* Test file deletion

* Better file locations

* Dont need persistent anymore

* Development, Production, Build, Deploy

* Add ts-ignore so we dont get compiler errors

* Remove test on command with flags

* Tidy up typescript config and add test

* Add comment around type issues

* Remove author field

* Tidy up config changs

* quiet core tests

* move es6 from root tsconfig to cli tsconfig

* Rename start -> scripts and tidy up descriptions

* Test build script

* Fix up test description

* Fix bug in build script

Closes #21, #36

Co-authored-by: Brandon Bayer <b@bayer.ws>

* fix(cli): Fix bug in build script (#49)

* Unlink doesnt work on folders

* Mock remove

* feat(cli): Add `blitz test watch` command #23 (#50)

* Add test watch

* Add test:watch

closes #23

Co-authored-by: Brandon Bayer <b@bayer.ws>

* tweak funding

* feat(cli): Add `blitz db` command #24 (#51)

* Add db command

* fixed test

closes #24

Co-authored-by: Brandon Bayer <b@bayer.ws>

* docs: Add the Blitz Manifesto! (#52)

* refactor(server): create server package (#57)

* @blitzjs/webpack -> @blitzjs/server

* Move server code out of cli

* Fix up type and lerna issues

* Prebuild non-cli before test

* Remove noise in PR

* fix: running tests locally after packages have been built

* chore: tweak github actions to remove duplicate builds

* feat: Upgrade next to latest release v9.3.0, closes #60 (#65)

Co-authored-by: Brandon Bayer <b@bayer.ws>

* feat(server): Errors respect file path redirection (#66)

* Expose next-executable

* Redirecting errors correctly with mocked rules

* Add comments about what is waiting

* Remove prepare as it was causing errors when installing dependencies

* Mock outer function instead of call to spawn

* Try using import *

* Remove CI switch as that was not the problem

Co-authored-by: Brandon Bayer <b@bayer.ws>

* docs: add manifesto to readme

* docs: update readme

* chore: add github sponsor link

* feat(server): Transform rules and synchronisation manifest (#69)

* Extract config

* Use gulp pipes to apply tranforms and write manifest.

* Add linting comments to allow import reordering

* Fix manifest bug

* Refactor to pipeline and fix testing method

* Include clean

* Fix up dependencies and tidy up code

* Fix newline issue

* Fix dependencies again

* Fix up testing strategy for file manipulations

* Renaming file because of inconsistency pt1

* Renaming file because of inconsistency pt2

* Update CLI test

* Debug CI build failures not occuring locally

* Include catch for missing unlink

* bug(server): CI pathname errors for readable-stream (#71)

* Try setting normalise to false on tree testing

* Remove debugging log

* feat(cli): load dependencies in blitz console (#68)

* [cli] feat: autoload package dependencies in console

* feat: load Prisma Client into console context

* [cli] spec: fix spec for console command

Co-authored-by: Brandon Bayer <b@bayer.ws>

* Update MANIFESTO.md

* add initial file structure rfc

* Revert "add initial file structure rfc"

This reverts commit f48a776e99.

* Update README.md

* doc: Add All Contributors Spec, Add CONTRIBUTING.md, Update Readme (#77)

* Added financial contributors to the README

* Add @flybayer as a contributor

* Add @medelman17 as a contributor

* Add @ryardley as a contributor

* Add @toddgeist as a contributor

* Add @quirk0o as a contributor

* Add @tsawan as a contributor

* Add @camilo86 as a contributor

* Add @dkempner as a contributor

* Add @gielcobben as a contributor

* Add @MrLeebo as a contributor

* Add @jimthedev as a contributor

* update readme & add CONTRIBUTING.md

* add Kristina

* Add @robdrosenberg as a contributor

* Add @jasonblalock as a contributor

* Add @coreybrown89 as a contributor

* Add @aej11a as a contributor

* update badegs

* tweak

* tweak

* more

Co-authored-by: Jess <jessachandler@gmail.com>

* docs: add lorenzorapetti as a contributor (#80)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* docs: add aem as a contributor (#79)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>

* docs: add rishabhpoddar as a contributor (#78)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>

* docs: add marcoseoane as a contributor (#81)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>

* fix readme

* refactor(cli): CLI refactoring (#25)

* Add base generator class

* change from mem-fs to fs.mkdirSync due to undefined error

* Add base command class

* Add conflict checker

* Add dry run to generator

* Add install via npm or yarn

* Add --no-yarn

* remove unused nyc dependency

Co-authored-by: marcoseoane <marcorseoane@outlook.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>

* chore: fix rishabhpoddar readme link

* Add @merelinguist as a contributor

* chore: tweak readme

* chore: update readme

* Fix dangling chokidar watch and add temporary logging.  (#82)

* Add logging

* Add better commit message

* Ensure will only run if jest is running

* Add manifest to output log

* Update message

* Use specific ignore in build folder

* Add dot ahead of ignored patterns

* Close Watcher

* Remove stray reference

* Neaten up

* chore: add rudi as code owner of packages/server

* chore(deps): bump acorn from 5.7.3 to 5.7.4 (#83)

Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
Co-authored-by: Rudi Yardley <contact@rudiyardley.com>

* docs: Fix website link (#86)

* Fix website link

* regenerate readme

Co-authored-by: Brandon Bayer <b@bayer.ws>

* docs: update readme

* chore: remove all prototype code in prep for new architecture code (#90)

* remove all prototype code and clean up deps

* fixes

* Fix launchEditor bug (#92)

* fix(server): Fix ignorePath (#94)

* Fix up globs

* Revert move as it doesnt really matter because of ignorePaths

* chore: upgrade dependencies (#96)

* feat: Implement the new Architecture! (#95)

* wip

* working rpc mutation

* queries and mutations working!!

* prewarm the lamba

* update withBlitz config wrapper - remove stuff no longer needed

* switch from `pages` to `routes`

* fix a test issue

* fix cli test

* Add file addition and subtraction to transform stream

* Remove comments

* Allow pages and routes

* Allow routes folder without context

* Tidy up build rules

* Fix broken transform test

* Use done callback to ensure all events have passed in stream test

* Fix next build breaking

* File generation RPC works

* Remove commented out code

* Ensure correct jest version so tests run and tidy up

* Fix up linting

* Tidy up synchroniser

* Ensure watcher close is run when watchmode is false

* typo

* update cli readme

* Fix start error

* Downgrade ts-jest to remove warning

* fix build with static pages

* rerun prettier on all files

* yarn workspace: nohoist husky and prisma

* add missing dependency

Co-authored-by: Rudi Yardley <contact@rudiyardley.com>

* chore: change version to 0.0.0

* chore: update lerna config

* v0.0.1-canary.0

* chore: remove version from examples

* v0.0.1-canary.1

* chore: update githead

* fix(examples): Fix Yarn link blitz cli failing (#105)

* Add version to example

* Try using generic versions

* fix(cli): spawn Windows .cmd entrypoints on win32 platform (#109)

Co-authored-by: Brandon Bayer <b@bayer.ws>

* docs: add wKovacs64 as a contributor (#111)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* feat(server): Warning about invalid routes/api structure (#106)

* First pass at warning about duplicate routes

* Move dupe checker to its own function

* Fix some accidental changes

* Revert yarn.lock(?)

* Route > page

* Use pages for store example

* Warn about nested api routes

* Check for duplicate api routes

* Warn api dupe routes

* Remove stray process.exit

* Merge api and pages dupe checkers

* Delete old checkers

* Remove stray line

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>

* docs: add merelinguist as a contributor (#112)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* feat: use `db` folder instead of `prisma` (#114)

* feat: use `db` folder instead of `prisma`

* fix tests

* feat(cli): don't bundle cli (and remove pkg) (#115)

* feat(cli): don't bundle cli with pkg or anything. npm package now working

* fix tests

* chore: update lerna script

* v0.0.1-0.0.1-canary.4.0

* v0.0.2-alpha.0

* chore: update example dependency versions

* fix: build from dependency issues

* chore(examples): Make store work in prod (switch to Postgres) (#117)

* wip

* fix(example): changes for deploying store to Zeit. Switch to postgres

* feat: enable concurrent mode for Blitz apps (#118)

* v0.0.2-canary.0

* build(cli): fix @blitzjs/cli build script on Windows (#120)

* chore: fix all contributors badge generation

* docs: add alpha release note to readme

* docs: readme typo

* Change blitz new template to be a working blitz app (#123)

* change blitz new template to be a working blitz app

* fix tests

* Add the `blitz` package (#125)

* Revert "Add the `blitz` package (#125)"

This reverts commit 9e1ce7dda0.

* fix(cli): leverage cross-spawn for cross-platform compatibility (#122)

* fix(cli): leverage cross-spawn for cross-platform compatibility

* refactor(server): use cross-spawn in next-utils for consistency

* feat(server): `blitz.config.js` config support without `withBlit… (#130)

* Allow blitz config

* Add error message

* Update tests

* Support only blitz.config.js

* Remove blitz.config.js

Co-authored-by: Brandon Bayer <b@bayer.ws>

* give the README a fresh coat of paint!

* Update .all-contributorsrc

* Update README.md

* Update README.md

* automatically read .env for blitz cli commands (#133)

(minor)

* Add `blitz db studio` and `blitz db introspect` (#134)

(minor)

* Implement ssrQuery (#136)

* add medelman17 for code

* Update new app template: favicon, blitz.config.js, .env, fixes (#137)

* Rexport Next stuff from Blitz (#138)

* Update CONTRIBUTING.md

* feat(cli): add help for db commands (#139)

* docs: add sijad as a contributor (#141)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* v0.0.2-canary.1

* tweak readme

* Fix server for deployment to Zeit (#143)

* fix production, but tests still failing

* Fix missing await and avoid changing source folder

Co-authored-by: Rudi Yardley <contact@rudiyardley.com>

* Fix ugly blitz start --production error (#144)

* Automatically run `blitz db migrate` on every `blitz start` (#147)

* Automatically run `blitz db migrate` on every `blitz start`

* Fix test

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>

* Update readme with benefits and features

* Update README.md

* Update MANIFESTO.md

* Add the `blitz` package and proper global/local CLI handling (#128)

* add the `blitz` package (but yarn blitz start not working)

* wip

* working

* updates

* cleanup

* adjustment

* chore: make 'blitz' work (#129)

* chore: make 'blitz' work

* fix: make example work in dev mode with blitz mono-package

* test: skip failing test re patched version of next

* fix: issues re bundling & store example

* fix blitz building in development and some other cleanup

* fixes for CLI usage from blitz

* more changes. blitz build still broken from child_process thing

* remove .yarnrc

* few DX fixes

* fix bug in store example

* fix the build and CLI!

* code comments

* delete vanilla-next

* fix tests

* fix tests

* fix CI tests

* remove server export from `blitz` since end-users don't use it

* move README into the Blitz package

* add link-cli script

* change prisma resolve to use resolveBinAsync

Co-authored-by: Michael Edelman <michael@fabulas.io>

* add register to server package

* add publish script

* v0.5.0-canary.0

* v0.5.0-canary.1

* Many updates to blitz new template, including prettier, eslint,… (#150)

* update template app

* fix `blitz -v`

* v0.5.0-canary.2

* fix cli template files in npm package

* tweak link-cli scripts

* v0.5.0-canary.3

* Back out the auto db migrate, and instead only auto generate pri… (#151)

* change to only generate prisma client on blitz start

* add comment

* v0.5.0-canary.4

* move test mocks to top of file

* v0.5.0-canary.5

* Add the Alpha User Guide (#131)

* Create USER_GUIDE.md

* Update USER_GUIDE.md

* Update USER_GUIDE.md

* Update USER_GUIDE.md

* Update USER_GUIDE.md

* add custom header image

* Update USER_GUIDE.md

* add cli commands

* add blitz db introspect

* Update USER_GUIDE.md

Co-authored-by: Michael Edelman  <michael@edel.mn>
Co-authored-by: Mina Abadir <mina@abadir.email>
Co-authored-by: Lorenzo Rapetti <lorenzo.rapetti.94@gmail.com>
Co-authored-by: Jeremy Liberman <mrleebo@msn.com>
Co-authored-by: Yanick Bélanger <yanick.belanger@yahoo.com>
Co-authored-by: Jim Cummins <jim.for.cy@gmail.com>
Co-authored-by: Beata Obrok <beata.obrok@u2i.com>
Co-authored-by: Camilo Gonzalez <cgs.camilogonzalez@gmail.com>
Co-authored-by: Rudi Yardley <contact@rudiyardley.com>
Co-authored-by: Tahir Awan <tahir.awan@gmail.com>
Co-authored-by: Giel <g.cobben@gmail.com>
Co-authored-by: Jess <jessachandler@gmail.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: marcoseoane <marcorseoane@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dylan Brookes <24858006+merelinguist@users.noreply.github.com>
Co-authored-by: Justin Hall <justin.r.hall@gmail.com>
Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
Co-authored-by: Sajjad Hashemian <sijad@disroot.org>
Co-authored-by: Michael Edelman <michael@fabulas.io>
2020-04-20 21:17:20 +07:00
Brandon Bayer
8d38c6c225 Add the Alpha User Guide (#131)
* Create USER_GUIDE.md

* Update USER_GUIDE.md

* Update USER_GUIDE.md

* Update USER_GUIDE.md

* Update USER_GUIDE.md

* add custom header image

* Update USER_GUIDE.md

* add cli commands

* add blitz db introspect

* Update USER_GUIDE.md
2020-04-20 21:09:15 +07:00
Brandon Bayer
c00e78cbc7 v0.5.0-canary.5 2020-04-20 21:02:53 +07:00
Brandon Bayer
11325ba136 move test mocks to top of file 2020-04-20 21:02:25 +07:00
Brandon Bayer
477094d042 v0.5.0-canary.4 2020-04-20 20:57:31 +07:00
Brandon Bayer
2c91340539 Back out the auto db migrate, and instead only auto generate pri… (#151)
* change to only generate prisma client on blitz start

* add comment
2020-04-20 20:56:26 +07:00
Brandon Bayer
4c42176ec9 v0.5.0-canary.3 2020-04-20 20:08:54 +07:00
Brandon Bayer
6564a268f6 tweak link-cli scripts 2020-04-20 20:08:20 +07:00
Brandon Bayer
9c66a2938e fix cli template files in npm package 2020-04-20 19:29:10 +07:00
Brandon Bayer
27e314821d v0.5.0-canary.2 2020-04-20 17:16:31 +07:00
Brandon Bayer
bf4b90943b Many updates to blitz new template, including prettier, eslint,… (#150)
* update template app

* fix `blitz -v`
2020-04-20 17:12:54 +07:00
Brandon Bayer
3b5f7bc6c8 v0.5.0-canary.1 2020-04-20 12:41:07 +07:00
Brandon Bayer
0659b37d77 v0.5.0-canary.0 2020-04-20 12:32:48 +07:00
Brandon Bayer
67950db948 add publish script 2020-04-20 12:30:31 +07:00
Brandon Bayer
45a09911a4 add register to server package 2020-04-20 12:23:15 +07:00
Brandon Bayer
e89127358f Add the blitz package and proper global/local CLI handling (#128)
* add the `blitz` package (but yarn blitz start not working)

* wip

* working

* updates

* cleanup

* adjustment

* chore: make 'blitz' work (#129)

* chore: make 'blitz' work

* fix: make example work in dev mode with blitz mono-package

* test: skip failing test re patched version of next

* fix: issues re bundling & store example

* fix blitz building in development and some other cleanup

* fixes for CLI usage from blitz

* more changes. blitz build still broken from child_process thing

* remove .yarnrc

* few DX fixes

* fix bug in store example

* fix the build and CLI!

* code comments

* delete vanilla-next

* fix tests

* fix tests

* fix CI tests

* remove server export from `blitz` since end-users don't use it

* move README into the Blitz package

* add link-cli script

* change prisma resolve to use resolveBinAsync

Co-authored-by: Michael Edelman <michael@fabulas.io>
2020-04-20 12:18:20 +07:00
Brandon Bayer
cf94dc866d Update MANIFESTO.md 2020-04-20 11:40:42 +07:00
Brandon Bayer
bd3841b43b Update README.md 2020-04-20 11:32:46 +07:00
Brandon Bayer
50dd2dcc4e Update readme with benefits and features 2020-04-20 11:22:58 +07:00
Dylan Brookes
6443184f0f Automatically run blitz db migrate on every blitz start (#147)
* Automatically run `blitz db migrate` on every `blitz start`

* Fix test

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
2020-04-20 09:17:19 +07:00
Brandon Bayer
9f8a7afd17 Fix ugly blitz start --production error (#144) 2020-04-19 13:04:49 +07:00
Brandon Bayer
5d3afb0230 Fix server for deployment to Zeit (#143)
* fix production, but tests still failing

* Fix missing await and avoid changing source folder

Co-authored-by: Rudi Yardley <contact@rudiyardley.com>
2020-04-19 12:47:16 +07:00
Brandon Bayer
9dfc5c53ed tweak readme 2020-04-19 11:50:10 +07:00
Brandon Bayer
ba540bb546 v0.0.2-canary.1 2020-04-18 14:58:46 +07:00
allcontributors[bot]
b70296a7a2 docs: add sijad as a contributor (#141)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-18 12:52:39 +07:00
Sajjad Hashemian
36c0acdb92 feat(cli): add help for db commands (#139) 2020-04-18 10:21:09 +07:00
Brandon Bayer
549115af97 Update CONTRIBUTING.md 2020-04-17 17:38:30 +07:00
Brandon Bayer
a4d6fe139e Rexport Next stuff from Blitz (#138) 2020-04-17 17:16:19 +07:00
Brandon Bayer
9010566895 Update new app template: favicon, blitz.config.js, .env, fixes (#137) 2020-04-17 16:32:45 +07:00
Brandon Bayer
167fc251fd add medelman17 for code 2020-04-17 15:56:56 +07:00
Brandon Bayer
4bcc2efbec Implement ssrQuery (#136) 2020-04-17 15:50:09 +07:00
Brandon Bayer
4c1eed6248 Add blitz db studio and blitz db introspect (#134)
(minor)
2020-04-17 15:28:08 +07:00
Brandon Bayer
36b4f101f9 automatically read .env for blitz cli commands (#133)
(minor)
2020-04-17 14:43:13 +07:00
Brandon Bayer
9209c934ee Update README.md 2020-04-17 10:59:23 +07:00
Brandon Bayer
ecd1118ce5 Update README.md 2020-04-17 10:54:24 +07:00
Brandon Bayer
29820ac964 Update .all-contributorsrc 2020-04-17 10:53:04 +07:00
Brandon Bayer
93dcd6d884 give the README a fresh coat of paint! 2020-04-17 10:51:57 +07:00
Rudi Yardley
6f66e5bd72 feat(server): blitz.config.js config support without `withBlit… (#130)
* Allow blitz config

* Add error message

* Update tests

* Support only blitz.config.js

* Remove blitz.config.js

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-16 19:07:46 +07:00
Justin Hall
df76a4b2ab fix(cli): leverage cross-spawn for cross-platform compatibility (#122)
* fix(cli): leverage cross-spawn for cross-platform compatibility

* refactor(server): use cross-spawn in next-utils for consistency
2020-04-16 14:06:45 +07:00
Brandon Bayer
b9391305b0 Revert "Add the blitz package (#125)"
This reverts commit 9e1ce7dda0.
2020-04-15 21:03:52 +07:00
Brandon Bayer
9e1ce7dda0 Add the blitz package (#125) 2020-04-15 16:35:47 +07:00
Brandon Bayer
d956da624f Change blitz new template to be a working blitz app (#123)
* change blitz new template to be a working blitz app

* fix tests
2020-04-15 15:04:50 +07:00
Brandon Bayer
4b29564f12 docs: readme typo 2020-04-15 10:55:26 +07:00
Brandon Bayer
227c1204c2 docs: add alpha release note to readme 2020-04-15 10:54:47 +07:00
Brandon Bayer
1ca88afcef chore: fix all contributors badge generation 2020-04-15 10:27:54 +07:00
Justin Hall
bb4272bbe6 build(cli): fix @blitzjs/cli build script on Windows (#120) 2020-04-15 09:37:06 +07:00
Brandon Bayer
b749884ddc v0.0.2-canary.0 2020-04-14 19:32:41 +07:00
Brandon Bayer
0b18df1390 feat: enable concurrent mode for Blitz apps (#118) 2020-04-14 19:30:58 +07:00
Brandon Bayer
256387cbbd chore(examples): Make store work in prod (switch to Postgres) (#117)
* wip

* fix(example): changes for deploying store to Zeit. Switch to postgres
2020-04-14 18:42:24 +07:00
Brandon Bayer
f80071913d fix: build from dependency issues 2020-04-14 17:16:10 +07:00
Brandon Bayer
c05afe8bf6 chore: update example dependency versions 2020-04-14 17:01:04 +07:00
Brandon Bayer
95713e627b v0.0.2-alpha.0 2020-04-14 16:50:21 +07:00
Brandon Bayer
4184a4fe5d v0.0.1-0.0.1-canary.4.0 2020-04-14 16:47:37 +07:00
Brandon Bayer
5933b6189e chore: update lerna script 2020-04-14 16:46:55 +07:00
Brandon Bayer
2d545688cb feat(cli): don't bundle cli (and remove pkg) (#115)
* feat(cli): don't bundle cli with pkg or anything. npm package now working

* fix tests
2020-04-14 16:29:42 +07:00
Brandon Bayer
c3dee2271e feat: use db folder instead of prisma (#114)
* feat: use `db` folder instead of `prisma`

* fix tests
2020-04-14 14:58:44 +07:00
allcontributors[bot]
93865f4431 docs: add merelinguist as a contributor (#112)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-14 12:43:45 +07:00
Dylan Brookes
be1c57b345 feat(server): Warning about invalid routes/api structure (#106)
* First pass at warning about duplicate routes

* Move dupe checker to its own function

* Fix some accidental changes

* Revert yarn.lock(?)

* Route > page

* Use pages for store example

* Warn about nested api routes

* Check for duplicate api routes

* Warn api dupe routes

* Remove stray process.exit

* Merge api and pages dupe checkers

* Delete old checkers

* Remove stray line

Co-authored-by: merelinguist <merelinguist@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-14 12:43:01 +07:00
allcontributors[bot]
5d22f9b2cc docs: add wKovacs64 as a contributor (#111)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-14 11:22:28 +07:00
Justin Hall
1ea4398216 fix(cli): spawn Windows .cmd entrypoints on win32 platform (#109)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-14 11:21:30 +07:00
Rudi Yardley
bb93ed8843 fix(examples): Fix Yarn link blitz cli failing (#105)
* Add version to example

* Try using generic versions
2020-04-14 11:03:11 +07:00
Brandon Bayer
e2eed221e0 chore: update githead 2020-04-13 15:45:10 +07:00
Brandon Bayer
6719104cb3 v0.0.1-canary.1 2020-04-13 15:39:42 +07:00
Brandon Bayer
d103345b77 chore: remove version from examples 2020-04-13 15:38:54 +07:00
Brandon Bayer
ae99dc4a55 v0.0.1-canary.0 2020-04-13 15:35:08 +07:00
Brandon Bayer
4658f616f1 chore: update lerna config 2020-04-13 15:31:44 +07:00
Brandon Bayer
48861cbf25 chore: change version to 0.0.0 2020-04-13 15:27:16 +07:00
Brandon Bayer
c82de5cfd0 feat: Implement the new Architecture! (#95)
* wip

* working rpc mutation

* queries and mutations working!!

* prewarm the lamba

* update withBlitz config wrapper - remove stuff no longer needed

* switch from `pages` to `routes`

* fix a test issue

* fix cli test

* Add file addition and subtraction to transform stream

* Remove comments

* Allow pages and routes

* Allow routes folder without context

* Tidy up build rules

* Fix broken transform test

* Use done callback to ensure all events have passed in stream test

* Fix next build breaking

* File generation RPC works

* Remove commented out code

* Ensure correct jest version so tests run and tidy up

* Fix up linting

* Tidy up synchroniser

* Ensure watcher close is run when watchmode is false

* typo

* update cli readme

* Fix start error

* Downgrade ts-jest to remove warning

* fix build with static pages

* rerun prettier on all files

* yarn workspace: nohoist husky and prisma

* add missing dependency

Co-authored-by: Rudi Yardley <contact@rudiyardley.com>
2020-04-13 13:53:33 +07:00
Brandon Bayer
64185b884d chore: upgrade dependencies (#96) 2020-04-11 21:25:36 +07:00
Rudi Yardley
9bdc4350f9 fix(server): Fix ignorePath (#94)
* Fix up globs

* Revert move as it doesnt really matter because of ignorePaths
2020-04-11 14:17:25 +07:00
Rudi Yardley
81735c4dec Fix launchEditor bug (#92) 2020-04-11 16:37:39 +10:00
Brandon Bayer
53eab985fd chore: remove all prototype code in prep for new architecture code (#90)
* remove all prototype code and clean up deps

* fixes
2020-04-11 10:25:33 +07:00
Brandon Bayer
e16d66a4c5 docs: update readme 2020-04-09 10:20:49 +07:00
Dylan Brookes
bc3aa30929 docs: Fix website link (#86)
* Fix website link

* regenerate readme

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-07 18:18:01 +07:00
dependabot[bot]
9d8edb6ead chore(deps): bump acorn from 5.7.3 to 5.7.4 (#83)
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
Co-authored-by: Rudi Yardley <contact@rudiyardley.com>
2020-04-07 14:47:54 +10:00
Brandon Bayer
25ff55291a chore: add rudi as code owner of packages/server 2020-04-07 09:18:33 +07:00
Rudi Yardley
2a9ac48a72 Fix dangling chokidar watch and add temporary logging. (#82)
* Add logging

* Add better commit message

* Ensure will only run if jest is running

* Add manifest to output log

* Update message

* Use specific ignore in build folder

* Add dot ahead of ignored patterns

* Close Watcher

* Remove stray reference

* Neaten up
2020-04-07 08:42:07 +07:00
Brandon Bayer
925098534f chore: update readme 2020-04-06 20:57:11 +07:00
Brandon Bayer
277c704be8 chore: tweak readme 2020-04-06 20:06:46 +07:00
Brandon Bayer
046b2ed300 Add @merelinguist as a contributor 2020-04-06 20:05:20 +07:00
Brandon Bayer
ef579daf1c chore: fix rishabhpoddar readme link 2020-04-06 20:05:13 +07:00
Lorenzo Rapetti
e44785bcff refactor(cli): CLI refactoring (#25)
* Add base generator class

* change from mem-fs to fs.mkdirSync due to undefined error

* Add base command class

* Add conflict checker

* Add dry run to generator

* Add install via npm or yarn

* Add --no-yarn

* remove unused nyc dependency

Co-authored-by: marcoseoane <marcorseoane@outlook.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-06 18:27:29 +07:00
Brandon Bayer
72697f25f9 fix readme 2020-04-05 17:58:47 +07:00
allcontributors[bot]
fa6067eee7 docs: add marcoseoane as a contributor (#81)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-03 12:05:40 +07:00
allcontributors[bot]
6879be005e docs: add rishabhpoddar as a contributor (#78)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-03 12:04:22 +07:00
allcontributors[bot]
52e93a608b docs: add aem as a contributor (#79)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-04-03 12:02:10 +07:00
allcontributors[bot]
bce5a4bd37 docs: add lorenzorapetti as a contributor (#80)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-03 11:59:58 +07:00
Brandon Bayer
1dad620368 doc: Add All Contributors Spec, Add CONTRIBUTING.md, Update Readme (#77)
* Added financial contributors to the README

* Add @flybayer as a contributor

* Add @medelman17 as a contributor

* Add @ryardley as a contributor

* Add @toddgeist as a contributor

* Add @quirk0o as a contributor

* Add @tsawan as a contributor

* Add @camilo86 as a contributor

* Add @dkempner as a contributor

* Add @gielcobben as a contributor

* Add @MrLeebo as a contributor

* Add @jimthedev as a contributor

* update readme & add CONTRIBUTING.md

* add Kristina

* Add @robdrosenberg as a contributor

* Add @jasonblalock as a contributor

* Add @coreybrown89 as a contributor

* Add @aej11a as a contributor

* update badegs

* tweak

* tweak

* more

Co-authored-by: Jess <jessachandler@gmail.com>
2020-04-03 11:40:31 +07:00
Brandon Bayer
f09b968e27 Update README.md 2020-04-02 20:14:26 +07:00
Brandon Bayer
7f81d6291d Revert "add initial file structure rfc"
This reverts commit f48a776e99.
2020-04-02 19:25:02 +07:00
Brandon Bayer
f48a776e99 add initial file structure rfc 2020-04-02 19:24:07 +07:00
Brandon Bayer
3e63287fa2 Update MANIFESTO.md 2020-04-01 13:13:21 +07:00
Beata Obrok
828c8d2f23 feat(cli): load dependencies in blitz console (#68)
* [cli] feat: autoload package dependencies in console

* feat: load Prisma Client into console context

* [cli] spec: fix spec for console command

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-25 12:13:55 +07:00
Rudi Yardley
d8c2f696b1 bug(server): CI pathname errors for readable-stream (#71)
* Try setting normalise to false on tree testing

* Remove debugging log
2020-03-24 12:57:35 +07:00
Rudi Yardley
4f21628365 feat(server): Transform rules and synchronisation manifest (#69)
* Extract config

* Use gulp pipes to apply tranforms and write manifest.

* Add linting comments to allow import reordering

* Fix manifest bug

* Refactor to pipeline and fix testing method

* Include clean

* Fix up dependencies and tidy up code

* Fix newline issue

* Fix dependencies again

* Fix up testing strategy for file manipulations

* Renaming file because of inconsistency pt1

* Renaming file because of inconsistency pt2

* Update CLI test

* Debug CI build failures not occuring locally

* Include catch for missing unlink
2020-03-20 15:45:24 +07:00
Brandon Bayer
0521b595fe chore: add github sponsor link 2020-03-13 14:16:51 +07:00
Brandon Bayer
f0159a05ae docs: update readme 2020-03-12 19:05:03 +07:00
Brandon Bayer
4a1e7e361f docs: add manifesto to readme 2020-03-11 22:00:20 +07:00
Rudi Yardley
b1f620a579 feat(server): Errors respect file path redirection (#66)
* Expose next-executable

* Redirecting errors correctly with mocked rules

* Add comments about what is waiting

* Remove prepare as it was causing errors when installing dependencies

* Mock outer function instead of call to spawn

* Try using import *

* Remove CI switch as that was not the problem

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-11 21:56:47 +07:00
Giel
dfbcb5bf67 feat: Upgrade next to latest release v9.3.0, closes #60 (#65)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-11 21:45:54 +07:00
Brandon Bayer
0677a16e75 chore: tweak github actions to remove duplicate builds 2020-03-11 21:37:45 +07:00
Brandon Bayer
968b507570 fix: running tests locally after packages have been built 2020-03-11 17:57:15 +07:00
Rudi Yardley
e773b26f5f refactor(server): create server package (#57)
* @blitzjs/webpack -> @blitzjs/server

* Move server code out of cli

* Fix up type and lerna issues

* Prebuild non-cli before test

* Remove noise in PR
2020-03-11 14:02:23 +07:00
Brandon Bayer
54e4759791 docs: Add the Blitz Manifesto! (#52) 2020-03-10 18:06:40 +07:00
Tahir Awan
df0e5d3539 feat(cli): Add blitz db command #24 (#51)
* Add db command

* fixed test

closes #24

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-10 15:51:38 +07:00
Brandon Bayer
32944666f4 tweak funding 2020-03-10 10:48:32 +07:00
Tahir Awan
b5e0d7afed feat(cli): Add blitz test watch command #23 (#50)
* Add test watch

* Add test:watch

closes #23

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-09 15:30:08 +07:00
Rudi Yardley
4bb86dc8b8 fix(cli): Fix bug in build script (#49)
* Unlink doesnt work on folders

* Mock remove
2020-03-09 15:25:42 +07:00
Rudi Yardley
93a5fb057e feat(cli): Compile to Next (#45)
* Only create a prisma client when it actually needed

* Setup start script for a simple next-project

* Enable "compile to next" on first-demo

* Whitespace

* Fix failing webpack config test

* Testing spawn call

* Neaten up code

* Test tsExtraMock instead of reporter

* Test file deletion

* Better file locations

* Dont need persistent anymore

* Development, Production, Build, Deploy

* Add ts-ignore so we dont get compiler errors

* Remove test on command with flags

* Tidy up typescript config and add test

* Add comment around type issues

* Remove author field

* Tidy up config changs

* quiet core tests

* move es6 from root tsconfig to cli tsconfig

* Rename start -> scripts and tidy up descriptions

* Test build script

* Fix up test description

* Fix bug in build script

Closes #21, #36

Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-09 09:37:59 +07:00
Beata Obrok
3c044fd4d0 test(examples): add cypress tests to first demo (#47)
* [examples] feat: setup cypress in first demo

* [examples] spec: add cypress tests for first demo

closes #44
2020-03-08 18:34:21 +07:00
Brandon Bayer
b430c87b65 fix(core): Add support for multiple attribute types for id (#35)
* Add support for multiple attribute types for id

* Add comment + tests
2020-03-05 21:05:22 +07:00
Brandon Bayer
903644b628 feat(core): Return 404 if controller action is not defined (#39)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-05 11:11:39 +07:00
Brandon Bayer
d26be24cb3 feat(cli): use custom REPL in console command (#38)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-05 10:51:06 +07:00
Brandon Bayer
949e7eb83f bug(webpack): Create webpack package to avoid context bugs (#42)
* Add new webpack package

* Delete webpack files from core

* Pin dependencies
2020-03-05 10:40:15 +07:00
Brandon Bayer
97bb455cc4 fix: Fix jest version incompatability (#43) 2020-03-05 08:12:35 +07:00
Brandon Bayer
cdb5ff2133 bug(example): Fix Invalid hook call error. (#37) 2020-03-05 08:11:13 +07:00
Brandon Bayer
b1aee93e2d chore: comment cleanup 2020-03-04 10:24:34 +07:00
Brandon Bayer
667566e341 docs: fix typo 2020-03-04 09:46:24 +07:00
Brandon Bayer
c51443bf5d docs: add dev onboarding blurb to readme 2020-03-04 09:45:26 +07:00
Camilo Gonzalez
ab4a3d2748 feat(cli): Add blitz test command (#30)
* add run tests command

* add test command

* add test cmd unit test

* uses project package manager (npm/yarn) to run test script

Co-authored-by: Brandon Bayer <b@bayer.ws>

closes #22
2020-03-04 09:37:46 +07:00
Beata Obrok
6d6a689557 feat(cli): Add blitz console command (#32)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-04 09:36:22 +07:00
Brandon Bayer
16c2031d2a docs: Update CODE_OF_CONDUCT.md (#28) 2020-03-04 09:33:21 +07:00
Brandon Bayer
590b20f12e chore: add pull_request event to github action 2020-03-04 09:30:02 +07:00
Brandon Bayer
c82c0b3689 feat(core): Add withBlitz webpack wrapper + fix prisma/client (#31)
* add withBlitz webpack config wrapper

* Move prisma/client noop into withBlitz!
2020-03-03 16:16:10 +07:00
Jim Cummins
18d38d79e7 fix: noop @prisma/client in browser, closes #13 (#19)
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-02 21:50:56 +07:00
Jeremy Liberman
4113124ec4 chore(core): Add core tests (#16)
* Add core tests

- Tests cover Form and Controller
- You can check code coverage with "yarn test --coverage"

* A little formatting + form test modifications

* add back console log

Co-authored-by: Yanick Bélanger <yanick.belanger@yahoo.com>
Co-authored-by: Brandon Bayer <b@bayer.ws>
2020-03-02 10:22:08 +07:00
Brandon Bayer
8f6d0e03ac feat(cli): Add initial CLI (#8)
* v0.0.1

Initial PR for oclif CLI

* update prettier config

* chore: repo updates - run prettier on commit

* organize package.json + correct package name

* Add initial app generator

* changes & cleanup

* more tweaks

* Add basic nextjs generation

* #9 Swapping Mocha with Jest for CLI

Swapped Mocha with Jest.

* Swapping Mocha with Jest for CLI

Swapped Mocha with Jest.

* add `yarn b [COMMAND]` for dev convenience

* Formalize path arg

* Make jest work

* Remove empty commands and make tests pass

* Fix path argument

* Revert "target" in tsconfig.json

* Remove `target` from cli package.json

* Fix build command

* Use custom tsconfig for test script

* remove nyc because jest has coverage built in

* little cleanup

Co-authored-by: Mina Abadir <mina@abadir.email>
Co-authored-by: Lorenzo Rapetti <lorenzo.rapetti.94@gmail.com>
2020-03-01 15:46:35 +07:00
Brandon Bayer
c48fd8925b chore: add sponsor section to readme 2020-02-27 18:39:07 -08:00
Brandon Bayer
66af983955 chore: Add Patreon and Paypal to the sponsor button options (#18) 2020-02-27 18:36:11 -08:00
Brandon Bayer
55b735086c chore: add flybayer as codeowner of everything 2020-02-27 18:14:45 -08:00
Brandon Bayer
4e64784749 fix(demo): switch to fruit content filter 2020-02-27 18:13:49 -08:00
Brandon Bayer
3ee2ef0b42 Add Open Collective Sponsor button (#15) 2020-02-26 21:25:33 -08:00
Brandon Bayer
eaa6fc8802 fix(demo): add content filtering! 2020-02-26 17:11:56 -08:00
Brandon Bayer
ef6bf61c5b fix(demo): untitled posts 2020-02-26 16:33:55 -08:00
Brandon Bayer
5f5b589a7f chore(demo): add some comments 2020-02-26 16:07:18 -08:00
Brandon Bayer
82ae27841c Live Demo Deployment (#12)
* add github link to demo

* fix(core): connect to db right away + fix for connection undefined

* changes to demo needed for production deployment

* fix(demo): relax tsconfig

* upgrade prisma & fix core for deployment

* demo updates
2020-02-26 15:56:47 -08:00
Brandon Bayer
8623d5a817 Add initial Blitz Core and First Demo 🎉 (#11)
* wip

* chore: fix typings, tweak build config

* update prettier config

* set up husky to run prettier on commit

* add migrate script and update readme

* changes, still broken

* add yarn dev command

* more changes, still broken

* demo working again!

* fix: yarn why do you hate me so much?

* add to gitignore

* trying to get demo dev to work right

* refactor and cleanup

* more cleanup

* update deps

* tweak

* update readme

* fix

* update readme

Co-authored-by: Michael Edelman  <michael@edel.mn>
2020-02-26 12:46:30 -08:00
Brandon Bayer
250c49c7bd chore: update readme 2020-02-25 16:28:33 -08:00
Brandon Bayer
7739c3e951 remove broken gh action 2020-02-25 16:24:11 -08:00
Brandon Bayer
8a7f7931f4 Update README.md 2020-02-23 13:03:33 -08:00
Brandon Bayer
6579e85a96 docs: add code of conduct 2020-02-23 11:46:21 -08:00
Michael Edelman
1195f5225e chore: shush slack bot, add GH actions badge to README (#6) 2020-02-22 09:29:35 -08:00
Michael Edelman
9b206a9831 Implement Initial Continuous Integration Workflow Using GitHub Actions (#3)
* build: add GH action for CI

* fix: tweak test-related scripts in package.json
2020-02-20 14:12:36 -08:00
Michael Edelman
dae1db73e9 Create GitHub Action for Slack Notice 2020-02-20 16:07:12 -05:00
Michael Edelman
d63f59d2fa tada: bootstrap all the things (#2) 2020-02-19 16:33:26 -08:00
Brandon Bayer
bbf9cb0d2b Update README.md 2020-02-19 10:24:12 -08:00
Brandon Bayer
a44b1d93c1 Update README.md 2020-02-19 10:21:17 -08:00
Brandon Bayer
3dab930a75 Merge pull request #1 from dkempner/patch-1
Bigger click target = higher conversion rate
2020-02-17 14:51:14 -08:00
Daniel Kempner
939fad20f6 Bigger click target = higher conversion rate 2020-02-17 14:44:26 -08:00
Brandon Bayer
2e06ef8637 Update README.md 2020-02-17 14:28:53 -08:00
Brandon Bayer
12ab14bc57 Update README.md 2020-02-17 13:56:53 -08:00
Brandon Bayer
45000493e0 Update README.md 2020-02-17 13:55:13 -08:00
257 changed files with 23604 additions and 2 deletions

359
.all-contributorsrc Normal file
View File

@@ -0,0 +1,359 @@
{
"projectName": "blitz",
"projectOwner": "blitz-js",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"badgeTemplate": "<a aria-label=\"All Contributors\" href=\"#contributors-\"><img alt=\"\" src=\"https://img.shields.io/badge/all_contributors-<%= contributors.length %>-17BB8A.svg?style=for-the-badge&labelColor=000000\"></a>",
"imageSize": 100,
"commit": true,
"commitConvention": "none",
"contributors": [
{
"login": "flybayer",
"name": "Brandon Bayer",
"avatar_url": "https://avatars3.githubusercontent.com/u/8813276?v=4",
"profile": "https://twitter.com/flybayer",
"contributions": [
"code",
"content",
"ideas",
"review"
]
},
{
"login": "medelman17",
"name": "Michael Edelman ",
"avatar_url": "https://avatars1.githubusercontent.com/u/14793389?v=4",
"profile": "https://fabulas.io",
"contributions": [
"infra",
"code"
]
},
{
"login": "merelinguist",
"name": "Dylan Brookes",
"avatar_url": "https://avatars3.githubusercontent.com/u/24858006?v=4",
"profile": "https://merelinguist.now.sh",
"contributions": [
"ideas",
"review",
"code"
]
},
{
"login": "ryardley",
"name": "Rudi Yardley",
"avatar_url": "https://avatars0.githubusercontent.com/u/1256409?v=4",
"profile": "https://medium.com/@ryardley",
"contributions": [
"code",
"ideas"
]
},
{
"login": "toddgeist",
"name": "Todd Geist",
"avatar_url": "https://avatars2.githubusercontent.com/u/316792?v=4",
"profile": "http://www.geistinteractive.com",
"contributions": [
"financial"
]
},
{
"login": "quirk0o",
"name": "Beata Obrok",
"avatar_url": "https://avatars3.githubusercontent.com/u/5123725?v=4",
"profile": "https://github.com/quirk0o",
"contributions": [
"code"
]
},
{
"login": "tsawan",
"name": "Tahir Awan",
"avatar_url": "https://avatars3.githubusercontent.com/u/3263082?v=4",
"profile": "https://github.com/tsawan",
"contributions": [
"code"
]
},
{
"login": "camilo86",
"name": "Camilo Gonzalez",
"avatar_url": "https://avatars1.githubusercontent.com/u/2454632?v=4",
"profile": "https://raluce.com",
"contributions": [
"code"
]
},
{
"login": "dkempner",
"name": "Daniel Kempner",
"avatar_url": "https://avatars3.githubusercontent.com/u/2532112?v=4",
"profile": "http://da.nielkempner.com",
"contributions": [
"code"
]
},
{
"login": "gielcobben",
"name": "Giel",
"avatar_url": "https://avatars0.githubusercontent.com/u/2663212?v=4",
"profile": "http://gielcobben.com",
"contributions": [
"code"
]
},
{
"login": "MrLeebo",
"name": "Jeremy Liberman",
"avatar_url": "https://avatars3.githubusercontent.com/u/2754163?v=4",
"profile": "http://jeremyliberman.com/",
"contributions": [
"code"
]
},
{
"login": "jimthedev",
"name": "Jim Cummins",
"avatar_url": "https://avatars0.githubusercontent.com/u/108938?v=4",
"profile": "https://jimthedev.com",
"contributions": [
"code"
]
},
{
"name": "Kristina Matuška",
"avatar_url": "https://media-exp1.licdn.com/dms/image/C5603AQHVPAjV21gw9g/profile-displayphoto-shrink_200_200/0?e=1591228800&v=beta&t=0MlbmiYhNvGv1xjLD_fOhOFjVDZ7ltNwfGNeJ4DHedQ",
"profile": "http://kristinamatuska.com/",
"contributions": [
"design"
]
},
{
"login": "robdrosenberg",
"name": "Robert Rosenberg",
"avatar_url": "https://avatars0.githubusercontent.com/u/20813991?v=4",
"profile": "http://robdrosenberg.com",
"contributions": [
"code"
]
},
{
"login": "jasonblalock",
"name": "Jason Blalock",
"avatar_url": "https://avatars0.githubusercontent.com/u/5899929?v=4",
"profile": "https://github.com/jasonblalock",
"contributions": [
"code"
]
},
{
"login": "coreybrown89",
"name": "Corey Brown",
"avatar_url": "https://avatars1.githubusercontent.com/u/12791148?v=4",
"profile": "https://corey-brown.com",
"contributions": [
"code"
]
},
{
"login": "aej11a",
"name": "aej11a",
"avatar_url": "https://avatars2.githubusercontent.com/u/10066422?v=4",
"profile": "https://github.com/aej11a",
"contributions": [
"code"
]
},
{
"login": "marcoseoane",
"name": "marcoseoane",
"avatar_url": "https://avatars0.githubusercontent.com/u/28088807?v=4",
"profile": "https://github.com/marcoseoane",
"contributions": [
"ideas"
]
},
{
"login": "rishabhpoddar",
"name": "Rishabh Poddar",
"avatar_url": "https://avatars2.githubusercontent.com/u/2976287?v=4",
"profile": "https://github.com/rishabhpoddar",
"contributions": [
"ideas"
]
},
{
"login": "aem",
"name": "Adam Markon",
"avatar_url": "https://avatars0.githubusercontent.com/u/1909883?v=4",
"profile": "https://github.com/aem",
"contributions": [
"ideas"
]
},
{
"login": "lorenzorapetti",
"name": "Lorenzo Rapetti",
"avatar_url": "https://avatars1.githubusercontent.com/u/2632174?v=4",
"profile": "https://github.com/lorenzorapetti",
"contributions": [
"code"
]
},
{
"login": "wKovacs64",
"name": "Justin Hall",
"avatar_url": "https://avatars1.githubusercontent.com/u/1288694?v=4",
"profile": "https://github.com/wKovacs64",
"contributions": [
"code"
]
},
{
"login": "sijad",
"name": "Sajjad Hashemian",
"avatar_url": "https://avatars3.githubusercontent.com/u/7693001?v=4",
"profile": "https://github.com/sijad",
"contributions": [
"code"
]
},
{
"login": "ETLopes",
"name": "Eduardo Lopes",
"avatar_url": "https://avatars3.githubusercontent.com/u/34959471?v=4",
"profile": "https://github.com/ETLopes",
"contributions": [
"code"
]
},
{
"login": "mattleff",
"name": "Matthew Leffler",
"avatar_url": "https://avatars0.githubusercontent.com/u/120155?v=4",
"profile": "https://github.com/mattleff",
"contributions": [
"doc"
]
},
{
"login": "hew",
"name": "Matt",
"avatar_url": "https://avatars0.githubusercontent.com/u/3103241?v=4",
"profile": "https://hew.tools",
"contributions": [
"doc"
]
},
{
"login": "sonnypgs",
"name": "Sonny",
"avatar_url": "https://avatars3.githubusercontent.com/u/1431300?v=4",
"profile": "https://github.com/sonnypgs",
"contributions": [
"doc"
]
},
{
"login": "Zeko369",
"name": "Fran Zekan",
"avatar_url": "https://avatars3.githubusercontent.com/u/3064377?v=4",
"profile": "https://github.com/Zeko369",
"contributions": [
"code",
"doc"
]
},
{
"login": "janbaykara",
"name": "Jan Baykara",
"avatar_url": "https://avatars2.githubusercontent.com/u/237556?v=4",
"profile": "http://twitter.com/JanBaykara",
"contributions": [
"doc"
]
},
{
"login": "mikeattara",
"name": "Mike Perry Y Attara",
"avatar_url": "https://avatars1.githubusercontent.com/u/31483629?v=4",
"profile": "https://mikeattara.com",
"contributions": [
"doc"
]
},
{
"login": "DevanB",
"name": "Devan",
"avatar_url": "https://avatars0.githubusercontent.com/u/354652?v=4",
"profile": "https://devanthe.dev",
"contributions": [
"doc"
]
},
{
"login": "jclancy93",
"name": "Jack Clancy",
"avatar_url": "https://avatars2.githubusercontent.com/u/7850202?v=4",
"profile": "https://github.com/jclancy93",
"contributions": [
"code"
]
},
{
"login": "ntgussoni",
"name": "Nicolas Torres",
"avatar_url": "https://avatars0.githubusercontent.com/u/10161067?v=4",
"profile": "https://github.com/ntgussoni",
"contributions": [
"test",
"code"
]
},
{
"login": "skn0tt",
"name": "Simon Knott",
"avatar_url": "https://avatars1.githubusercontent.com/u/14912729?v=4",
"profile": "http://simonknott.de",
"contributions": [
"code",
"test"
]
},
{
"login": "kandros",
"name": "Jaga Santagostino",
"avatar_url": "https://avatars0.githubusercontent.com/u/4562878?v=4",
"profile": "http://jagascript.com",
"contributions": [
"code"
]
},
{
"login": "LoriKarikari",
"name": "Lori Karikari",
"avatar_url": "https://avatars1.githubusercontent.com/u/7902980?v=4",
"profile": "https://github.com/LoriKarikari",
"contributions": [
"code"
]
},
{
"login": "eliasjohansson",
"name": "Elias Johansson",
"avatar_url": "https://avatars3.githubusercontent.com/u/22719177?v=4",
"profile": "https://twitter.com/GeggsElias",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
"skipCi": true
}

5
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,5 @@
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
* @flybayer
packages/server/* @ryardley

4
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,4 @@
github: blitz-js
custom: ['https://paypal.me/thebayers']
open_collective: blitzjs
patreon: flybayer

23
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,23 @@
---
name: Bug report
about: Something is not working right. Or error messages are unclear.
title: ''
labels: ''
assignees: ''
---
### What is the problem?
### Steps to Reproduce: <!-- if you can, link to a repo with the failing code -->
1. 2.
### Versions:
```
[Add the output of `blitz --version --verbose` here]
```
### Supporting Documentation
Please include applicable logs and screenshots that show your problem.

View File

@@ -0,0 +1,19 @@
---
name: Feature/change request
about: Something new or better!
title: ''
labels: ''
assignees: ''
---
### What do you want and why?
The more information the better!
### Possible implementation(s)
How might we do this?
### Additional context
Add any other context or screenshots about the feature request here.

22
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,22 @@
### Type: ?? <!-- feature, bug fix, refactor, tests, etc -->
Closes: ??
### What are the changes and their implications? :gear:
??
### Checklist
- [ ] Tests added for changes
- [ ] Any added terminal logging uses `packages/server/src/log.ts`
### Breaking change: ?? <!-- yes or no -->
<!-- If yes, describe the impact and migration path for existing apps-->
### Other information
<!-- Before/after screenshots, etc. -->
<!-- IMPORTANT: Make sure to check the "Allow edits from maintainers" box below this window -->

41
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: Continuous Integration
on:
push:
branches:
- master
- canary
pull_request:
branches:
- master
- canary
jobs:
build_and_test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.16.1'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Node.js modules
id: yarn-cache
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile --silent
env:
CI: true
- name: Test Blitz Packages
run: yarn test
env:
CI: true

24
.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
.log
.DS_Store
.jest-*
lib
node_modules
reports
*.log
.nyc_output
**/coverage
.yarn
.yarnrc
tsconfig.tsbuildinfo
.blitz
.next
dist
.now
# local env files
**/.envrc
**/.env
**/.env.local
**/.env.development.local
**/.env.test.local
**/.env.production.local
.blitz-*

16
.npmignore Normal file
View File

@@ -0,0 +1,16 @@
.DS_Store
.prettierrc
.nyc_output
.travis.yml
coverage
coverage.lcov
bench
docs
src
examples
babel.config.js
test
CONTRIBUTING.md
CODE_OF_CONDUCT.md
*.ts
!*.d.ts

1
.npmrc Normal file
View File

@@ -0,0 +1 @@
save-exact=false

20
.prettierignore Normal file
View File

@@ -0,0 +1,20 @@
**/migrations/**
.blitz
.next
.log
.DS_Store
.jest-*
lib
node_modules
reports
*.log
**/.env*
.nyc_output
**/coverage
.yarn
.yarnrc
tsconfig.tsbuildinfo
dist
bin
packages/cli/templates/**
.github/ISSUE_TEMPLATE/bug_report.md

60
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,60 @@
# The Blitz Community Code of Conduct
The Blitz core members take this CoC very serious. All members, contributors and volunteers in this community are required to act according to the following Code of Conduct to keep Blitz a positive, growing project and community and help us provide and ensure a safe environment for everyone.
The Blitz community
## When Something Happens
If you see a Code of Conduct violation, follow these steps:
1. Let the person know that what they did is not appropriate and ask them to stop and/or edit their message(s).
2. That person should immediately stop the behavior and correct the issue.
3. If this doesnt happen, or if youre uncomfortable speaking up, contact Brandon Bayer ([Twitter](https://twitter.com/flybayer) | [Email](mailto:b@bayer.ws)).
When reporting, please include any relevant details, links, screenshots, context, or other information that may be used to better understand and resolve the situation.
The core members will prioritize the well-being and comfort of the recipients of the violation over the comfort of the violator.
## What We Believe and How We Act
- We are committed to providing a friendly, safe and welcoming environment for everyone, regardless of age, body size, culture, ethnicity, gender expression, gender identity, level of experience, nationality, personal ability or disability, physical appearance, physical or mental difference, race, religion, set of skills, sexual orientation, socio-economic status, and subculture. We welcome people regardless of these or other attributes.
- We are better together. We are more alike than different.
- Our community is based on mutual respect, tolerance, and encouragement.
- We believe that a diverse community where people treat each other with respect is stronger, more vibrant and has more potential contributors and more sources for ideas. We aim for more diversity.
- We are kind, welcoming and courteous to everyone.
- Were respectful of others, their positions, their skills, their commitments and their efforts.
- Were attentive in our communications, whether in person or online, and were tactful when approaching differing views.
- We are aware that language shapes reality. Thus, we use inclusive, gender-neutral language in the documents we provide and when we talk to people. When referring to a group of people, we aim to use gender-neutral terms like “team”, “folks”, “everyone”. (For details, we recommend [this post](https://modelviewculture.com/pieces/gendered-language-feature-or-bug-in-software-documentation)).
- We respect that people have differences of opinion and criticize constructively.
- We value people over code.
## Don'ts
- Dont discriminate against anyone.
- Sexism and racism of any kind (including sexist and racist “jokes”), demeaning or insulting behaviour and harassment are seen as direct violations to this Code of Conduct. Harassment includes offensive verbal comments related to age, body size, culture, ethnicity, gender expression, gender identity, level of experience, nationality, personal ability or disability, physical appearance, physical or mental difference, race, religion, set of skills, sexual orientation, socio-economic status, and subculture. Harassment also includes sexual images in public spaces, deliberate intimidation, stalking, following, harassing photography or recording, inappropriate physical contact, and unwelcome sexual attention.
- On Slack and other online or offline communications channels, don't use overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all.
- Dont be mean or rude.
- Respect that some individuals and cultures consider the casual use of profanity offensive and off-putting.
- Unwelcome / non-consensual sexual advances over Slack or any other channels related with this community are not okay.
- Derailing, tone arguments and otherwise playing on peoples desires to be nice are not welcome, especially in discussions about violations to this Code of Conduct.
- Please avoid unstructured critique.
- Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome.
- Sponsors of Blitz are also subject to this Code of Conduct. In particular, sponsors are required to not use sexualized images, activities, or other material which is not according to this Code of Conduct.
## Consequences for Violations to this Code of Conduct
If a participant engages in any behavior violating this Code of Conduct, the core members of this community will take any action they deem appropriate, starting with a gentle warning and then escalating as needed to expulsion from the community, exclusion from any interaction and loss of all rights in this community.
## Decisions About Consequences of Violations
Decisions about consequences of violations of this Code of Conduct are made by this communitys core members and may not be discussed with the person responsible for the violation.
## For Questions or Feedback
If you have any questions or feedback on this Code of Conduct, were happy to hear from you.
## Thanks for the Inspiration To
- [Hood.ie](http://hood.ie/code-of-conduct/)
- [WeAllJS](https://wealljs.org/code-of-conduct)

121
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,121 @@
![Blitz Contributing Guide](https://files-m3haypbo7.now.sh/contributing.png)
<br>
We're so excited you're interested in helping with Blitz! We happy to help you get started, even if you don't have any previous open-source experience :)
<br>
### Blitz is a Community Project
Blitz is built by and for the community. There's no large company sponsoring development. So all community contributions are very appreciated!
<br>
### Our Codebase is a Garden
The Blitz codebase is like a community garden. There's a lot of beautiful plants and vegetables, but it won't take long until you find some weeds! When you find weeds, please remove them :) Minor refactoring is always encouraged. If you'd like to do some major refactoring, it's best to first either open an issue or check with us in Slack. Most likely we'll agree with you.
<br>
### First Things First
1. Familiarize yourself with the [Blitz Code of Conduct](https://github.com/blitz-js/blitz/blob/canary/CODE_OF_CONDUCT.md)
2. Join the [Blitz Slack Community](https://slack.blitzjs.com)
3. Install the [Zenhub browser extension](https://www.zenhub.com/extension)
4. View open issues and their progress [on the Zenhub repo tab](https://github.com/blitz-js/blitz#zenhub)
<br>
### What to Work On?
Issues with the label [`ready to work on | help wanted`](https://github.com/blitz-js/blitz/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22ready+to+work+on+%7C+help+wanted%22) are the best place to start. If you find one that looks interesting and no one else is already working on it, comment in the issue that you are going to work on it. Please ask as many questions as you need, either directly in the issue or in Slack. We're happy to help!
The Blitzjs.com website and documentation repo also has issues with [`ready to work on | help wanted`](https://github.com/blitz-js/blitzjs.com/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22ready+to+work+on+%7C+help+wanted%22).
#### Things that are ALWAYS welcome
- Improved documentation
- Improved error messages
- Improved logging (i.e. more clear, more beautiful)
- Educational content like blogs, videos, courses
If there's some other way you'd like to contribute, just ask us about it in slack!
After you contribute in any way, please add yourself as a contributor via the [@all-contributors bot](https://allcontributors.org/docs/en/bot/usage)!
<br>
## Development Setup
**1.** Fork this repo
**2.** Clone your fork repo
```sh
# If you didn't fork the repo use blitz-js as the USERNAME
git clone git@github.com:USERNAME/blitz.git
cd blitz
```
**3.** Install dependencies
```
yarn
```
**4.** Start the package server. This must be running for any package development or example development
```
yarn dev
```
**5.** Run tests
```
yarn test
```
#### Sync your fork
```sh
./scripts/fetchRemote.sh
git merge upstream/canary
```
#### Link the Blitz CLI (Optional)
The following will link the development CLI as a local binary so you can use it anywhere for testing.
```
yarn link-cli
// `yarn unlink-cli` will unlink
```
#### Develop a Blitz `package`
**1.** Change to a package directory
```
cd packages/core
```
**2.** Start the test runner
```
yarn test:watch
```
#### Develop a Blitz `example`
**1.** Change to an example directory
```
cd examples/store
```
**2.** Follow instructions in the example's README
## Troubleshooting
If you run into issues that should be documented here, please submit a PR! ❤️

74
MANIFESTO.md Normal file
View File

@@ -0,0 +1,74 @@
# The Blitz.js Manifesto
## Background
Technology follows a repeating cycle of bundling and unbundling. Created in 2005, Ruby on Rails became a major bundling force. It made web application development easier and more accessible than ever before. This benefited everyone, from those learning programming to seniors building production systems.
A major unbundling happened in 2013 with the release of React because it is hyper focused on the rendering layer. As React grew in popularity, so did the choices for all the other parts, leaving developers with hundreds of decisions to make when starting a new app. While this has contributed to JavaScript Fatigue, it's been a powerful driving force for rapid frontend innovation.
Now, in 2020, is the perfect time for another major bundling. Developers are yearning for an easier, simpler way to build web applications. Beginners want a guiding hand for building a robust app. And seniors want a framework that removes mundane tasks and provides a highly scalable architecture.
Hence the creation of Blitz.
## What is Blitz For?
Blitz is for building tiny to large fullstack database-backed applications that have one or more graphical user interfaces like web or mobile apps.
## Foundational Principles
1. Fullstack & Monolithic
2. API Not Required
3. Convention over Configuration
4. Loose Opinions
5. Easy to Start, Easy to Scale
6. Stability
7. Community over Code
### 1. Fullstack & Monolithic
A fullstack, monolithic application is simpler than an application where frontend and backend are developed and deployed separately. Monolithic doesn't mean it will be slow or hard to scale to large teams. Monolithic doesn't mean there isn't separation of concerns. Monolithic means you can reason about your app as a single entity.
### 2. API Not Required
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.
### 3. Convention over Configuration
Starting a new fullstack React app is currently too hard. You have to spend days on things like configuring eslint, prettier, husky, jest, cypress, typescript, deciding on a file structure, setting up a database, adding authentication and authorization, setting up a router, defining routing conventions, and setting up your styling library.
Blitz makes as many decisions and does as much work for you as possible. This makes it lightning fast to start real development. It also greatly benefits the community. Common project structure and architectural patterns make it easy to move from Blitz app to Blitz app and immediately feel at home.
Convention over configuration doesn't mean no configuration. It means configuration is optional. Blitz will provide all the escape hatches you need for bespoke customization.
### 4. Loose Opinions
Blitz is opinionated. The out-of-the-box experience guides you on a path perfect for most applications. However, Blitz isn't arrogant. It understands there are very good reasons for deviating from convention, and it allows you to do so. For example, Blitz has a conventional file structure, but, with few exceptions, doesn't _enforce_ it.
And when there's not community consensus, `blitz new` prompts you to choose.
### 5. Easy to Start, Easy to Scale
A framework that's only easy for one end of an application lifecycle is not a good framework. Both starting and scaling must be easy.
Easy to start includes being easy for beginners and being easy to migrate existing Next.js apps to Blitz.
Scaling is important in all forms: lines of code, number of people working in the codebase, and code execution.
### 6. Stability
In the fast-paced world of Javascript, a stable, predictable release cycle is a breath of fresh air. A stable release cycle ensures minimal breaking changes, and it ensures you know exactly what and when a breaking change will occur. It also minimizes bugs in stable releases by ensuring features are in beta for a minimum amount of time. [Ember is the model citizen](https://emberjs.com/releases/) in this regard.
The exact details of the Blitz release cycle are to be determined, but we'll follow a pattern similar to Ember which strictly follows SemVer with stable releases every 6 weeks and LTS releases every 6 months.
Blitz will follow a public RFC (request for comments) process so all users and companies can participate in proposing and evaluating new features.
If a Blitz API needs to be removed, it will be deprecated in a minor release. Major releases will simply remove APIs already deprecated in a previous release.
### 7. Community over Code
The Blitz community is the most important aspect of the framework, by far.
We have a comprehensive [Code of Conduct](https://github.com/blitz-js/blitz/blob/canary/CODE_OF_CONDUCT.md). LGBTQ+, women, and minorities are especially welcome.
We are all in this together, from the youngest to the oldest. We are all more similar than we are different. We can and should solve problems together. We should learn from other communities, not compete against them.

172
README.md
View File

@@ -1,2 +1,170 @@
# blitz
Framework for building monolithic, full-stack, serverless React apps with zero data-fetching and zero client-side state management
[![Blitz.js](https://raw.githubusercontent.com/blitz-js/art/master/github-cover-photo.png)](https://blitzjs.com)
<!-- prettier-ignore-start -->
<p align="center">
<a aria-label="Join our Slack Community" href="https://slack.blitzjs.com">
<img alt="" src="https://img.shields.io/badge/Join%20our%20community-6700EB.svg?style=for-the-badge&labelColor=000000&logoWidth=20&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQ9SURBVHgB7d3dVdtAEIbhcSpICUoH0IEogQqSVBBSAU4FSSpIOoAORAfQgSghHXzZ1U/YcMD4R9rZmf2ec3y448LyiNf27iLiGIAmPLrweC9Un3DhrzG6EarLNP09nlwJ1SOZ/lQr5N80/S/p2QMVCBf5N17XCfm1Y/rBHqjAG9PPHvBsz+mf9WAP+HLA9M/YA14cOP2payH7jpj+VCtk1wnTP+vj7xCy6cTpn7EHLMLp059iD1iD8eveJbVCNsSLheX1YA/YgOWnf8YeKB3Wmf7Ud6Fy4f/FHmtpxbl3YlC4MJ/Cj0bWdwPnPbARg+L0S54XQHS32WwuxClzd4CM0z9rPfeAuTtA5ulPXYQ7wZ04Y+oOoDD9KZc9YOoOoDj9s4dwFzgXR6w1wIPoOvPWA9buAHEJ173o3gWiy3AnuBUHLEbgmYwvAk1/wuM8vAgexThzbwPDkx7/DHwVXfFOxP2GmsKd4Ab6zPeAyU8CI7AHFmH2BRCBPXAyk18GzUrqAXCTiR4ssyj0VFw/oCU8+e+RZ33AWz6KMaYbIIWxB+JSLs1bsbkeMN0AqakHvoku9oA2sAfqBvbAQdw0QArsgb25aYBUQT3QgT2gB+yBuqGcHij2UCqXDZACe2Anlw2QYg/QAOyBuoE98CL3DZDCuK4/rh/Q7oGL6U+TOvcNkJoijN8X1C48+T+g75eQDrAH/qmqAVJgDwyqaoAUe4AGYA/UDZX3QLUNkEIZPRCd5+6BahsgVUgPROwBTSijB7jpVAvGHriHvmw9wAZ4BpX1ABvgmakHtPcbRuwBTWAPULgAV9D/jKDY9YRvwvgEaurD44uQHvAol7qBW7WKluVtIHiUS7GyvA0s6CiXDnxrpQfsgbqBS7GKk/2jYHCrVlGyfxTMrVo0ALdq1Q3sgSKofh0M9oA61a+D2QM0AHugbmAPqClmSRjK2apVVQ8UsySsoK1aHdgDesCtWnUDeyCrIpeFg1u3sylyWTi3btMA7IG6gT2wuuK3hoE9sKrit4YVslWLPaAN7IG6ocKt2zmY2h4O9sDiTG0PZw/QANy6XTewBxZj9ogYVHy025LMHhEz9cBn0We6B0yfERReBLfhx0/R1YQHPx/QBPbA0VwcEwf2wNFcHBPHHjiem3MC2QPHcXdSaJjA+KfgTPQ8hhfjBzHC40mhlzJ+Xq9lK4a4PCs43AVaGTed5mZq+iOXZwWHi3AnOj2wFWNcnxYe7gTxLtBKHuamP/J+Wnh8a5irB7ZC5Yk9gPX1QuXC+usHWqGyhYvUYR0a7zboUOFCNVhnk0krZAOW7wFOvzXhom2xnEbIHizTA1wEYhWW6YFGyC6c1gOcfg9wfA80Qj7g8B7g9HuCww+haIR8wf49wOn3Cvv9k8tGyC/s7gFOv3fY3QONkH+v9MBWqB7PeqDn9FcIT//kcitUn6kHOu/T/xfWzlQy3dEHhwAAAABJRU5ErkJggg==">
</a>
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-37-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<a aria-label="License" href="https://github.com/blitz-js/blitz/blob/canary/LICENSE">
<img alt="" src="https://img.shields.io/npm/l/blitz.svg?style=for-the-badge&labelColor=000000&color=blue">
</a>
<a aria-label="NPM version" href="https://www.npmjs.com/package/blitz">
<img alt="" src="https://img.shields.io/npm/v/blitz.svg?style=for-the-badge&labelColor=000000&color=E65528">
</a>
</p>
<!-- prettier-ignore-end -->
<br>
<h3 align="center">Blitz is a Rails-like framework for monolithic, full-stack React apps — built on Next.js</h3>
<br>
Blitz brings back the **simplicity and conventions** of server-rendered frameworks like Ruby on Rails while preserving everything we love about React and client-side rendering!
Blitz is the framework for the 99% of us at companies with <100 employees. This means **we don't force you to use advanced technologies like GraphQL**. We let you add advanced technologies on your terms and at your pace.
Blitz **maximizes your productivity** both when starting an app and when scaling it to lots of code and users.
<br>
### :tada: Alpha Release Now Available :tada:
1. `npm i -g blitz`
2. `blitz new myapp`
3. [Read the Alpha User Guide](https://github.com/blitz-js/blitz/blob/canary/USER_GUIDE.md)
<br>
**Features:**<br>
⚡️ Built on Next.js<br>
⚡️ Don't have to build an API for client-side rendering<br>
⚡️ Client-side rendering, Server-side rendering, and fully static pages all in the same app<br>
⚡️ Full Typescript support with static, end-to-end typing (no code generation step needed like with GraphQL)<br>
⚡️ React Concurrent Mode enabled<br>
⚡️ Database/ORM agnostic, but Prisma 2 is default<br>
⚡️ CLI with code scaffolding, Rails-style console REPL, etc<br>
⚡️ GraphQL Ready<br>
⚡️ Deploy serverless or serverful<br>
**Other key features coming:**<br>
⚡️ Highly secure authentication <br>
⚡️ Authorization you can use on both server and client<br>
⚡️ Model validation you can use on both server and client<br>
⚡️ Plugins for easily adding libraries like Tailwind, CSS-in-JS, etc.<br>
⚡️ React native support<br>
⚡️ GUI so you don't have to use the CLI<br>
<br>
### What is Blitz Designed For?
Blitz is designed for tiny to large database-backed applications that have one or more graphical user interfaces.
While we currently only support web, we are pursuing the dream of a single monolithic application that runs on web and mobile with maximum code sharing and minimal boilerplate.
<br>
### What are the Foundational Principles?
1. Fullstack & Monolithic
2. API Not Required
3. Convention over Configuration
4. Loose Opinions
5. Easy to Start, Easy to Scale
6. Stability
7. Community over Code
[The Blitz Manifesto](https://github.com/blitz-js/blitz/blob/canary/MANIFESTO.md) explains these principles in detail.
<br>
## Welcome to the Blitz Community 👋
The Blitz community is warm, safe, diverse, inclusive, and fun! LGBTQ+, women, and minorities are especially welcome. Please read our [Code of Conduct](https://github.com/blitz-js/blitz/blob/canary/CODE_OF_CONDUCT.md).
[Join our Slack Community](https://slack.blitzjs.com) where we help each other build Blitz apps. It's also where we collaborate on building Blitz itself.
There's still a lot of work to do, so you are especially invited to join us in building Blitz! A good place to start is [The Contributing Guide](CONTRIBUTING.md).
<br>
## Sponsors and Donations
- Contribute via [GitHub Sponsors](https://github.com/sponsors/blitz-js)
- Contribute via [PayPal](https://paypal.me/thebayers)
- 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!_
<br>
## Contributors ✨
Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://twitter.com/flybayer"><img src="https://avatars3.githubusercontent.com/u/8813276?v=4" width="100px;" alt=""/><br /><sub><b>Brandon Bayer</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=flybayer" title="Code">💻</a> <a href="#content-flybayer" title="Content">🖋</a> <a href="#ideas-flybayer" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/blitz-js/blitz/pulls?q=is%3Apr+reviewed-by%3Aflybayer" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://fabulas.io"><img src="https://avatars1.githubusercontent.com/u/14793389?v=4" width="100px;" alt=""/><br /><sub><b>Michael Edelman </b></sub></a><br /><a href="#infra-medelman17" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/blitz-js/blitz/commits?author=medelman17" title="Code">💻</a></td>
<td align="center"><a href="https://merelinguist.now.sh"><img src="https://avatars3.githubusercontent.com/u/24858006?v=4" width="100px;" alt=""/><br /><sub><b>Dylan Brookes</b></sub></a><br /><a href="#ideas-merelinguist" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/blitz-js/blitz/pulls?q=is%3Apr+reviewed-by%3Amerelinguist" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/blitz-js/blitz/commits?author=merelinguist" title="Code">💻</a></td>
<td align="center"><a href="https://medium.com/@ryardley"><img src="https://avatars0.githubusercontent.com/u/1256409?v=4" width="100px;" alt=""/><br /><sub><b>Rudi Yardley</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=ryardley" title="Code">💻</a> <a href="#ideas-ryardley" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="http://www.geistinteractive.com"><img src="https://avatars2.githubusercontent.com/u/316792?v=4" width="100px;" alt=""/><br /><sub><b>Todd Geist</b></sub></a><br /><a href="#financial-toddgeist" title="Financial">💵</a></td>
<td align="center"><a href="https://github.com/quirk0o"><img src="https://avatars3.githubusercontent.com/u/5123725?v=4" width="100px;" alt=""/><br /><sub><b>Beata Obrok</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=quirk0o" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/tsawan"><img src="https://avatars3.githubusercontent.com/u/3263082?v=4" width="100px;" alt=""/><br /><sub><b>Tahir Awan</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=tsawan" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://raluce.com"><img src="https://avatars1.githubusercontent.com/u/2454632?v=4" width="100px;" alt=""/><br /><sub><b>Camilo Gonzalez</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=camilo86" title="Code">💻</a></td>
<td align="center"><a href="http://da.nielkempner.com"><img src="https://avatars3.githubusercontent.com/u/2532112?v=4" width="100px;" alt=""/><br /><sub><b>Daniel Kempner</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=dkempner" title="Code">💻</a></td>
<td align="center"><a href="http://gielcobben.com"><img src="https://avatars0.githubusercontent.com/u/2663212?v=4" width="100px;" alt=""/><br /><sub><b>Giel</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=gielcobben" title="Code">💻</a></td>
<td align="center"><a href="http://jeremyliberman.com/"><img src="https://avatars3.githubusercontent.com/u/2754163?v=4" width="100px;" alt=""/><br /><sub><b>Jeremy Liberman</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=MrLeebo" title="Code">💻</a></td>
<td align="center"><a href="https://jimthedev.com"><img src="https://avatars0.githubusercontent.com/u/108938?v=4" width="100px;" alt=""/><br /><sub><b>Jim Cummins</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=jimthedev" title="Code">💻</a></td>
<td align="center"><a href="http://kristinamatuska.com/"><img src="https://media-exp1.licdn.com/dms/image/C5603AQHVPAjV21gw9g/profile-displayphoto-shrink_200_200/0?e=1591228800&v=beta&t=0MlbmiYhNvGv1xjLD_fOhOFjVDZ7ltNwfGNeJ4DHedQ" width="100px;" alt=""/><br /><sub><b>Kristina Matuška</b></sub></a><br /><a href="#design" title="Design">🎨</a></td>
<td align="center"><a href="http://robdrosenberg.com"><img src="https://avatars0.githubusercontent.com/u/20813991?v=4" width="100px;" alt=""/><br /><sub><b>Robert Rosenberg</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=robdrosenberg" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/jasonblalock"><img src="https://avatars0.githubusercontent.com/u/5899929?v=4" width="100px;" alt=""/><br /><sub><b>Jason Blalock</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=jasonblalock" title="Code">💻</a></td>
<td align="center"><a href="https://corey-brown.com"><img src="https://avatars1.githubusercontent.com/u/12791148?v=4" width="100px;" alt=""/><br /><sub><b>Corey Brown</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=coreybrown89" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/aej11a"><img src="https://avatars2.githubusercontent.com/u/10066422?v=4" width="100px;" alt=""/><br /><sub><b>aej11a</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=aej11a" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/marcoseoane"><img src="https://avatars0.githubusercontent.com/u/28088807?v=4" width="100px;" alt=""/><br /><sub><b>marcoseoane</b></sub></a><br /><a href="#ideas-marcoseoane" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/rishabhpoddar"><img src="https://avatars2.githubusercontent.com/u/2976287?v=4" width="100px;" alt=""/><br /><sub><b>Rishabh Poddar</b></sub></a><br /><a href="#ideas-rishabhpoddar" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/aem"><img src="https://avatars0.githubusercontent.com/u/1909883?v=4" width="100px;" alt=""/><br /><sub><b>Adam Markon</b></sub></a><br /><a href="#ideas-aem" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/lorenzorapetti"><img src="https://avatars1.githubusercontent.com/u/2632174?v=4" width="100px;" alt=""/><br /><sub><b>Lorenzo Rapetti</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=lorenzorapetti" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/wKovacs64"><img src="https://avatars1.githubusercontent.com/u/1288694?v=4" width="100px;" alt=""/><br /><sub><b>Justin Hall</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=wKovacs64" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/sijad"><img src="https://avatars3.githubusercontent.com/u/7693001?v=4" width="100px;" alt=""/><br /><sub><b>Sajjad Hashemian</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=sijad" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ETLopes"><img src="https://avatars3.githubusercontent.com/u/34959471?v=4" width="100px;" alt=""/><br /><sub><b>Eduardo Lopes</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=ETLopes" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/mattleff"><img src="https://avatars0.githubusercontent.com/u/120155?v=4" width="100px;" alt=""/><br /><sub><b>Matthew Leffler</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=mattleff" title="Documentation">📖</a></td>
<td align="center"><a href="https://hew.tools"><img src="https://avatars0.githubusercontent.com/u/3103241?v=4" width="100px;" alt=""/><br /><sub><b>Matt</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=hew" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/sonnypgs"><img src="https://avatars3.githubusercontent.com/u/1431300?v=4" width="100px;" alt=""/><br /><sub><b>Sonny</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=sonnypgs" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/Zeko369"><img src="https://avatars3.githubusercontent.com/u/3064377?v=4" width="100px;" alt=""/><br /><sub><b>Fran Zekan</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=Zeko369" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=Zeko369" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="http://twitter.com/JanBaykara"><img src="https://avatars2.githubusercontent.com/u/237556?v=4" width="100px;" alt=""/><br /><sub><b>Jan Baykara</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=janbaykara" title="Documentation">📖</a></td>
<td align="center"><a href="https://mikeattara.com"><img src="https://avatars1.githubusercontent.com/u/31483629?v=4" width="100px;" alt=""/><br /><sub><b>Mike Perry Y Attara</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=mikeattara" title="Documentation">📖</a></td>
<td align="center"><a href="https://devanthe.dev"><img src="https://avatars0.githubusercontent.com/u/354652?v=4" width="100px;" alt=""/><br /><sub><b>Devan</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=DevanB" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/jclancy93"><img src="https://avatars2.githubusercontent.com/u/7850202?v=4" width="100px;" alt=""/><br /><sub><b>Jack Clancy</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=jclancy93" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ntgussoni"><img src="https://avatars0.githubusercontent.com/u/10161067?v=4" width="100px;" alt=""/><br /><sub><b>Nicolas Torres</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=ntgussoni" title="Tests">⚠️</a> <a href="https://github.com/blitz-js/blitz/commits?author=ntgussoni" title="Code">💻</a></td>
<td align="center"><a href="http://simonknott.de"><img src="https://avatars1.githubusercontent.com/u/14912729?v=4" width="100px;" alt=""/><br /><sub><b>Simon Knott</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=skn0tt" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=skn0tt" title="Tests">⚠️</a></td>
<td align="center"><a href="http://jagascript.com"><img src="https://avatars0.githubusercontent.com/u/4562878?v=4" width="100px;" alt=""/><br /><sub><b>Jaga Santagostino</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=kandros" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/LoriKarikari"><img src="https://avatars1.githubusercontent.com/u/7902980?v=4" width="100px;" alt=""/><br /><sub><b>Lori Karikari</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=LoriKarikari" title="Code">💻</a></td>
<td align="center"><a href="https://twitter.com/GeggsElias"><img src="https://avatars3.githubusercontent.com/u/22719177?v=4" width="100px;" alt=""/><br /><sub><b>Elias Johansson</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=eliasjohansson" title="Code">💻</a></td>
</tr>
</table>
<!-- 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!

373
USER_GUIDE.md Normal file
View File

@@ -0,0 +1,373 @@
![Blitz Alpha User Guide](https://files-mgangy3vm.now.sh/alpha-user-guide.png)
<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!
If you have any issues at all, please [open an issue](https://github.com/blitz-js/blitz/issues/new/choose) or join the [Blitz slack](https://slack.blitzjs.com) and talk to 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. But eventually, it will be because this is very important to us.
<br>
## Introduction
Blitz is a Rails-like framework for building monolithic, full-stack React apps. The idea is that Blitz makes you extremely productive by doing as much set up and grunt work for you.
**When building a Blitz app, you dont have to think about “building an API” or “fetching data from your API”**. You only think about writing functions that get and change data. And to use those functions in your component, you simply import and call them like a regular function.
Blitz is built on Next.js, so if you are familiar with that, you will feel right at home.
<br>
## Blitz App Development
### Set Up Your Computer
- [ ] You need Node.js 12 or newer
<br>
### Create Your Blitz App
1. `npm install -g blitz` or `yarn global add blitz`
2. Run `blitz new myAppName` to create a new blitz app in the `myAppName` directory
3. `cd myAppName`
4. `blitz start`
5. View your baby app at [http://localhost:3000](http://localhost:3000)
<br>
### Set Up Your Database
By default, Blitz uses Prisma 2 which is a strongly typed database client. **You probably want to read [the Prisma 2 documentation](https://www.prisma.io/docs/understand-prisma/introduction).** _Note, Prisma 2 is not required for Blitz. The only Prisma-Blitz integration is the `blitz db` cli command. You can use anything you want, such as Mongo, TypeORM, etc._
1. Open `db/schema.prisma` and add the following:
```prisma
model Project {
id Int @default(autoincrement()) @id
name String
tasks Task[]
}
model Task {
id Int @default(autoincrement()) @id
name String
project Project @relation(fields: [projectId], references: [id])
projectId Int
}
```
2. Run `blitz db migrate`
- If this fails, you need to change the `DATABASE_URL` value in `.env` to whatever is required by your Postgres installation.
<br>
### Scaffold out all the files your basic CRUD actions
_CRUD = create, read, update, delete_
1. Run `blitz generate all project` to generate fully working queries, mutations, and pages
2. Open [http://localhost:3000/projects](http://localhost:3000/projects) to see the default project list page
3. Explore the generated pages and view, create, update, and delete projects.
<br>
### Pages
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:
- `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 its 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
Blitz queries and mutations are plain, asynchronous Javascript functions that always run on the server.
We automatically alias the root of your project, so `import db from 'db'` is importing `<project_root>/db/index.ts`
**Example Query:**
```ts
// app/products/queries/getProduct.tsx
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
return product
}
```
**Example Mutation:**
```ts
// app/products/mutations/createProduct.tsx
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
}
```
<br>
### 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.
At build time, the direct function import is swapped out for a function that executes a network call to run the query serverside.
**React Concurrent Mode is enabled by default for Blitz apps.** So the `<Suspense>` component is used for loading states and `<ErrorBoundary>` is used to display errors. If you need, you can read the [React Concurrent Mode Docs](https://reactjs.org/docs/concurrent-mode-intro.html).
```tsx
import {Suspense} from 'react'
import {useRouter, useQuery} from 'blitz'
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}})
return <div>{product.name}</div>
}
export default function () {
return (
<div>
<ErrorBoundary fallback={(error) => <div>Error: {JSON.stringify(error)}</div>}>
<Suspense fallback={<div>Loading...</div>}>
<Product />
</Suspense>
</ErrorBoundary>
</div>
)
}
```
#### On the Server
In `getStaticProps`, a query function can be called directly without `useQuery`
```tsx
import getProduct from '/app/products/queries/getProduct'
export const getStaticProps = async (context) => {
const product = await getProduct({where: {id: context.params?.id}})
return {props: {product}}
}
export default function ({product}) {
return <div>{product.name}</div>
}
```
In `getServerSideProps`, pass a query function to `ssrQuery` which will ensure appropriate middleware is run before/after your query function.
```tsx
import {ssrQuery} from 'blitz'
import getProduct from '/app/products/queries/getProduct'
export const getServerSideProps = async ({params, req, res}) => {
const product = await ssrQuery(getProduct, {where: {id: params.id}}, {req, res}))
return {props: {product}}
}
export default function({product}) {
return <div>{product.name}</div>
}
```
For more details, read the comprehensive [Query & Mutation Usage Issue](https://github.com/blitz-js/blitz/issues/89)
<br>
### Using Mutations
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.
```tsx
import {useQuery} from 'blitz'
import getProduct from '/app/products/queries/getProduct'
import updateProduct from '/app/products/mutations/updateProduct'
function (props) {
const [product] = useQuery(getProduct, {where: {id: props.id}})
return (
<Formik
initialValues={product}
onSubmit={async values => {
try {
const product = await updateProduct(values)
} catch (error) {
alert('Error saving product')
}
}}>
{/* ... */}
</Formik>
)
}
```
For more details, read the comprehensive [Query & Mutation Usage Issue](https://github.com/blitz-js/blitz/issues/89)
<br>
### Custom API Routes
Blitz.js custom API routes are exactly the same as Next.js custom API routes. If you need, read [the Next.js API route documentation](https://nextjs.org/docs/api-routes/introduction)
- Unlike Next.js, your `api/` folder must be a sibling of `pages/` instead of being nested inside.
- All React components inside an `api/` folder are accessible at a URL corresponding to it's path inside `api/`. So `app/projects/api/webhook.tsx` will be at `localhost:3000/api/webhook`.
<br>
### Customize the Webpack Config
Blitz uses the `blitz.config.js` config file at the root of your project. This is exactly the same as `next.config.js`. Read [the Next.js docs on customizing webpack](https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config).
<br>
### Deploy to Production
1. You need a production Postgres database. It's easy to set this up on [Digital Ocean](https://www.digitalocean.com/products/managed-databases-postgresql/?refcode=466ad3d3063d).
2. For deploying serverless, you also need a connection pool. This is also relatively easy to set up on Digital Ocean.
1. [Read the Digitial Ocean docs on setting up your connection pool](https://www.digitalocean.com/docs/databases/postgresql/how-to/manage-connection-pools/#creating-a-connection-pool?refcode=466ad3d3063d)
2. Ensure you set your "Pool Mode" to be "Session" instead of "Transaction" (because of a bug in Prisma)
3. You need your entire database connection string. If you need, [read the Prisma docs on this](https://www.prisma.io/docs/reference/database-connectors/postgresql#connection-details).
1. If deploying to serverless with a connection pool, make sure you get the connection string to your connection pool, not directly to the DB.
4. You need to change the defined datasource in `db/schema.prisma` from SQLite to Postgres
#### Serverless
Assuming you already have a Zeit account and the `now` cli installed, you can do the following:
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": {
"DATABASE_URL": "@database-url"
},
"build": {
"env": {
"DATABASE_URL": "@database-url"
}
}
}
```
3. Run `now`
Once working and deployed to production, your app should be very stable because its running Next.js which is already battle-tested.
#### Traditional, Long-Running Server
You can deploy a Blitz app like a regular Node or Express project.
`blitz start --production` will start your app in production mode. Make sure you provide the `DATABASE_URL` environment variable for your production database.
<br>
## Blitz CLI Commands
#### `blitz new NAME`
Generate a new blitz project at `<current_folder>./NAME`
#### `blitz start`
Start your app in development mode
#### `blitz start --production`
Start your app in production mode
#### `blitz db migrate`
Run any needed migrations via Prisma 2 and generate Prisma Client
#### `blitz db introspect`
Will introspect the database defined in `db/schema.prisma` and automatically generate a complete `schema.prisma` file for you. Lastly, it'll generate Prisma Client.
#### `blitz db studio`
Open the Prisma Studio UI at [http://localhost:5555](http://localhost:5555) so you can easily see and change data in your database.
#### `blitz generate -h`
Generate different types of files for a model. Your model input can be singular or plural, but the generated files will be the same in both cases.
#### `blitz console`
Start a Node.js REPL that's preloaded with your `db` object and all your queries and mutations. This is awesome for quickly trying your code without running the app!
<br>
## More Information
- Read the [Architecture RFC](https://github.com/blitz-js/blitz/pull/73) for more details on the architecture, our decision making, and how queries/mutations work under the hood
- Read the [File Structure & Routing RFC](https://github.com/blitz-js/blitz/pull/74) for more details about the file structure and routing conventions.
- View an example Blitz app at [`examples/store`](https://github.com/blitz-js/blitz/tree/canary/examples/store)
<br>
## What's Next for Blitz.js?
Here's the list of big things that are currently missing from Blitz but are a top priority for us:
- 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
- Authorization (use auth rules both on server and client)
- Model validation (use model validation both on server and client)
- React-Native support
- GUI for folks who prefer that over CLIs
- ... and tons more 🙂
<br>
## FAQ
- **Does Blitz support vanilla Javascript?** Yes, but `blitz new` generates all Typescript files right now. You can add new files with JS and/or convert the generated files to JS. There's an [open issue for generating vanilla JS files](https://github.com/blitz-js/blitz/issues/160) that needs help.
- **Will you support other ESLint configs for the `blitz new` app?** Yes, there's [an issue for this](https://github.com/blitz-js/blitz/issues/161)
<br>
## You are invited to help — lets build the future of web dev together! 🤝
Blitz is just getting started, and it's going to take an entire community to bring it to fruition!
How you can help:
1. Tell others about Blitz
2. Report bugs by opening an issue here on GitHub
3. Send us feedback in the [Blitz slack](https://slack.blitzjs.com).
4. Contribute code. We have a lot of issues that are ready to work on! Start by reading [The Contributing Guide](https://github.com/blitz-js/blitz/blob/canary/CONTRIBUTING.md). Let us know if you need help.
5. Any way you want! We totally appreciate any type of contribution, such as documentation, videos, blog posts, etc. If you have a crazy idea, feel free to run it past us in Slack! :)
6. [Sponsorships & donations](https://github.com/blitz-js/blitz#sponsors-and-donations)
<br>
That's all for now. We hope to see you in the [Blitz slack community](https://slack.blitzjs.com)!

3
__mocks__/fs.js Normal file
View File

@@ -0,0 +1,3 @@
const {fs} = require('memfs')
module.exports = fs

View File

@@ -0,0 +1,4 @@
module.exports = {
presets: ['next/babel'],
plugins: [],
}

View File

@@ -0,0 +1 @@
DATABASE_URL=postgresql://USERNAME@localhost:5432/blitz-example-store

View File

@@ -0,0 +1,9 @@
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
'jsx-a11y/anchor-is-valid': 'off', //Doesn't play well with Blitz/Next <Link> usage
},
}

37
examples/store/.gitignore vendored Normal file
View File

@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
/.blitz/
*.sqlite
.generated-prisma-client
.blitz-console-history
# production
/build
.now
# misc
.DS_Store
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.envrc
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

View File

@@ -0,0 +1,5 @@
.gitkeep
.env
*.ico
*.lock

22
examples/store/README.md Normal file
View File

@@ -0,0 +1,22 @@
## Getting Started
1. Ensure you have Postgres installed locally
2. Set the `DATABASE_URL` environment variable, something like this:
```
DATABASE_URL=postgresql://<your_computer_username>@localhost:5432/blitz-example-store
```
3. DB migrate
```
yarn blitz db migrate
```
4. Start the dev server
```
yarn blitz start
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

View File

@@ -0,0 +1,16 @@
import {Link} from 'blitz'
export default function () {
return (
<div>
<h1>Store Admin</h1>
<div>
<p>
<Link href="/admin/products">
<a>Manage Products</a>
</Link>
</p>
</div>
</div>
)
}

View File

@@ -0,0 +1,30 @@
import {Suspense} from 'react'
import {Link, useRouter, useQuery} from 'blitz'
import getProduct from 'app/products/queries/getProduct'
import ProductForm from 'app/products/components/ProductForm'
function Product() {
const router = useRouter()
const id = parseInt(router?.query.id as string)
const [product] = useQuery(getProduct, {where: {id}})
return <ProductForm product={product} onSuccess={() => router.push('/admin/products')} />
}
export default function () {
return (
<div>
<h1>Edit Product</h1>
<p>
<Link href="/admin/products">
<a>Manage Products</a>
</Link>
</p>
<div>
<Suspense fallback={<div>Loading...</div>}>
<Product />
</Suspense>
</div>
</div>
)
}

View File

@@ -0,0 +1,40 @@
import {Suspense} from 'react'
import {useQuery, Link} from 'blitz'
import getProducts from 'app/products/queries/getProducts'
function ProductsList() {
const [products] = useQuery(getProducts)
return (
<ul>
{products.map((product) => (
<li key={product.id}>
<Link href="/admin/products/[id]" as={`/admin/products/${product.id}`}>
<a>{product.name}</a>
</Link>
</li>
))}
</ul>
)
}
export default function () {
return (
<div>
<h1>Products</h1>
<p>
<Link href="/admin/products/new">
<a>Create Product</a>
</Link>
<Link href="/admin">
<a style={{marginLeft: 16}}>Admin</a>
</Link>
</p>
<Suspense fallback={<div>Loading...</div>}>
<ProductsList />
</Suspense>
</div>
)
}

View File

@@ -0,0 +1,19 @@
import {Link, useRouter} from 'blitz'
import ProductForm from 'app/products/components/ProductForm'
export default function () {
const router = useRouter()
return (
<div>
<h1>Create a New Product</h1>
<p>
<Link href="/admin/products">
<a>Manage Products</a>
</Link>
</p>
<div>
<ProductForm onSuccess={() => router.push('/admin/products')} />
</div>
</div>
)
}

View File

View File

@@ -0,0 +1,19 @@
import React from 'react'
export default class ErrorBoundary extends React.Component<{fallback: (error: any) => React.ReactNode}> {
state = {hasError: false, error: null}
static getDerivedStateFromError(error: any) {
return {
hasError: true,
error,
}
}
render() {
if (this.state.hasError) {
return this.props.fallback(this.state.error)
}
return this.props.children
}
}

View File

View File

@@ -0,0 +1,15 @@
import ErrorBoundary from 'app/components/ErrorBoundary'
export default function MyApp({Component, pageProps}) {
return (
<ErrorBoundary
fallback={(error) => (
<div>
<h1>Unhandled Error</h1>
<pre>{JSON.stringify(error, null, 2)}</pre>
</div>
)}>
<Component {...pageProps} />
</ErrorBoundary>
)
}

View File

@@ -0,0 +1,22 @@
import {Document, Html, DocumentHead, Main, NextScript, DocumentContext} from '@blitzjs/core'
class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx)
return {...initialProps}
}
render() {
return (
<Html lang="en">
<DocumentHead />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument

View File

@@ -0,0 +1,189 @@
import {Head, Link} from 'blitz'
const Home = () => (
<div className="container">
<Head>
<title>Blitz Example Store</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<main>
<h1 className="title" style={{marginBottom: 24}}>
Blitz Store Example
</h1>
<ul>
<li>
<Link href="/products">
<a>Static Product Listings</a>
</Link>
</li>
<li>
<Link href="/products/ssr">
<a>SSR Product Listings</a>
</Link>
</li>
<li>
<Link href="/products/paginated">
<a>Paginated Product Listings (client-rendered)</a>
</Link>
</li>
<li>
<Link href="/admin/products">
<a>Admin Section (client-rendered)</a>
</Link>
</li>
</ul>
</main>
<footer>
<a
href="https://blitzjs.com?utm_source=blitz-new&utm_medium=app-template&utm_campaign=blitz-new"
target="_blank"
rel="noopener noreferrer">
Powered by Blitz.js
</a>
</footer>
<style jsx>{`
.container {
min-height: 100vh;
padding: 0 0.5rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
main {
padding: 5rem 0;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
footer {
width: 100%;
height: 100px;
border-top: 1px solid #eaeaea;
display: flex;
justify-content: center;
align-items: center;
}
footer img {
margin-left: 0.5rem;
}
footer a {
display: flex;
justify-content: center;
align-items: center;
}
a {
color: #0070f3;
text-decoration: none;
}
li + li {
margin-top: 0.5rem;
}
.title a:hover,
.title a:focus,
.title a:active {
text-decoration: underline;
}
.title {
margin: 0;
line-height: 1.15;
font-size: 3rem;
}
.title,
.description {
text-align: center;
}
.description {
line-height: 1.5;
font-size: 1.5rem;
}
code {
background: #fafafa;
border-radius: 5px;
padding: 0.75rem;
font-size: 1.1rem;
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
Bitstream Vera Sans Mono, Courier New, monospace;
}
.grid {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
max-width: 800px;
margin-top: 3rem;
}
.card {
margin: 1rem;
flex-basis: 45%;
padding: 1.5rem;
text-align: left;
color: inherit;
text-decoration: none;
border: 1px solid #eaeaea;
border-radius: 10px;
transition: color 0.15s ease, border-color 0.15s ease;
}
.card:hover,
.card:focus,
.card:active {
color: #0070f3;
border-color: #0070f3;
}
.card h3 {
margin: 0 0 1rem 0;
font-size: 1.5rem;
}
.card p {
margin: 0;
font-size: 1.25rem;
line-height: 1.5;
}
@media (max-width: 600px) {
.grid {
width: 100%;
flex-direction: column;
}
}
`}</style>
<style jsx global>{`
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans,
Droid Sans, Helvetica Neue, sans-serif;
}
* {
box-sizing: border-box;
}
`}</style>
</div>
)
export default Home

View File

@@ -0,0 +1,74 @@
import {Form, Field} from 'react-final-form'
import {Product, ProductCreateInput, ProductUpdateInput} from 'db'
import createProduct from '../mutations/createProduct'
import updateProduct from '../mutations/updateProduct'
type ProductInput = ProductCreateInput | ProductUpdateInput
function isNew(product: ProductInput): product is ProductCreateInput {
return (product as ProductUpdateInput).id === undefined
}
type ProductFormProps = {
product?: ProductUpdateInput
style?: React.CSSProperties
onSuccess: (product: Product) => any
}
export default function ({product, style, onSuccess, ...props}: ProductFormProps) {
return (
<Form
initialValues={product || {name: null, handle: null, description: null, price: null}}
onSubmit={async (data: ProductInput) => {
if (isNew(data)) {
try {
const product = await createProduct({data})
onSuccess(product)
} catch (error) {
alert('Error creating product ' + JSON.stringify(error, null, 2))
}
} else {
try {
const product = await updateProduct({where: {id: data.id}, data})
onSuccess(product)
} catch (error) {
alert('Error updating product ' + JSON.stringify(error, null, 2))
}
}
}}
render={({handleSubmit}) => (
<form onSubmit={handleSubmit} style={{maxWidth: 400, ...style}} {...props}>
<div style={{marginBottom: 16}}>
<label style={{display: 'flex', flexDirection: 'column'}}>
Product Name
<Field name="name" component="input" />
</label>
</div>
<div style={{marginBottom: 16}}>
<label style={{display: 'flex', flexDirection: 'column'}}>
Handle
<Field name="handle" component="input" />
</label>
</div>
<div style={{marginBottom: 16}}>
<label style={{display: 'flex', flexDirection: 'column'}}>
Description
<Field name="description" component="textarea" />
</label>
</div>
<div style={{marginBottom: 16}}>
<label style={{display: 'flex', flexDirection: 'column'}}>
Price
<Field name="price" component="input" parse={(value) => (value ? parseInt(value) : null)} />
</label>
</div>
<button>{product ? 'Update' : 'Create'} Product</button>
</form>
)}
/>
)
}

View File

@@ -0,0 +1,7 @@
import db, {ProductCreateArgs} from 'db'
export default async function createProduct(args: ProductCreateArgs) {
const product = await db.product.create(args)
return product
}

View File

@@ -0,0 +1,7 @@
import db, {ProductDeleteArgs} from 'db'
export default async function deleteProduct(args: ProductDeleteArgs) {
const product = await db.product.delete(args)
return product
}

View File

@@ -0,0 +1,10 @@
import db, {ProductUpdateArgs} from 'db'
export default async function updateProduct(args: ProductUpdateArgs) {
// Don't allow updating ID
delete args.data.id
const product = await db.product.update(args)
return product
}

View File

@@ -0,0 +1,44 @@
import {Link, BlitzPage, GetStaticProps, GetStaticPaths} from 'blitz'
import getProduct from 'app/products/queries/getProduct'
import getProducts from 'app/products/queries/getProducts'
import {Product} from 'db'
type StaticProps = {
product: Product
}
export const getStaticProps: GetStaticProps<StaticProps> = async (ctx) => {
const product = await getProduct({where: {handle: ctx.params.handle as string}})
return {
props: {product},
// Unstable beacuse revalidate is still under RFC: https://nextjs.link/issg
unstable_revalidate: 1,
}
}
export const getStaticPaths: GetStaticPaths = async () => {
const paths = (await getProducts()).map(({handle}) => ({params: {handle}}))
return {
paths,
fallback: true,
}
}
const Page: BlitzPage<StaticProps> = function ({product}) {
if (!product) {
return <div>Building Page...</div>
}
return (
<div>
<h1>{product.name}</h1>
<p>{product.description}</p>
<p>Price: ${product.price}</p>
<Link href="/products">
<a>All Products</a>
</Link>
</div>
)
}
export default Page

View File

@@ -0,0 +1,35 @@
import {Link, BlitzPage, GetStaticProps} from 'blitz'
import getProducts from '../../queries/getProducts'
import {Product} from 'db'
type StaticProps = {
products: Product[]
}
export const getStaticProps: GetStaticProps<StaticProps> = async () => {
const products = await getProducts()
return {
props: {products},
// Unstable beacuse revalidate is still under RFC: https://nextjs.link/issg
unstable_revalidate: 1,
}
}
const Page: BlitzPage<StaticProps> = function ({products}) {
return (
<div>
<h1>Products</h1>
<div>
{products.map((product) => (
<p key={product.id}>
<Link href="/products/[handle]" as={`/products/${product.handle}`}>
<a>{product.name}</a>
</Link>
</p>
))}
</div>
</div>
)
}
export default Page

View File

@@ -0,0 +1,47 @@
import {Suspense, useState} from 'react'
import {Link, BlitzPage, useQuery} from 'blitz'
import getProducts from 'app/products/queries/getProducts'
const ITEMS_PER_PAGE = 3
const Products = () => {
const [page, setPage] = useState(0)
const [products] = useQuery(
getProducts,
{
skip: ITEMS_PER_PAGE * page,
first: ITEMS_PER_PAGE,
},
{paginated: true},
)
return (
<div>
{products.map((product) => (
<p key={product.id}>
<Link href="/products/[handle]" as={`/products/${product.handle}`}>
<a>{product.name}</a>
</Link>
</p>
))}
<button disabled={page === 0} onClick={() => setPage(page - 1)}>
Previous
</button>
<button disabled={products.length !== ITEMS_PER_PAGE} onClick={() => setPage(page + 1)}>
Next
</button>
</div>
)
}
const Page: BlitzPage = function () {
return (
<div>
<h1>Products - Paginated</h1>
<Suspense fallback={<div>Loading...</div>}>
<Products />
</Suspense>
</div>
)
}
export default Page

View File

@@ -0,0 +1,33 @@
import {Link, BlitzPage, GetServerSideProps, ssrQuery} from '@blitzjs/core'
import getProducts from 'app/products/queries/getProducts'
import {Product} from 'db'
type PageProps = {
products: Product[]
}
export const getServerSideProps: GetServerSideProps<PageProps> = async ({req, res}) => {
const products = await ssrQuery(getProducts, undefined, {req, res})
return {
props: {products},
}
}
const Page: BlitzPage<PageProps> = function ({products}) {
return (
<div>
<h1>Products</h1>
<div>
{products.map((product) => (
<p key={product.id}>
<Link href="/products/[handle]" as={`/products/${product.handle}`}>
<a>{product.name}</a>
</Link>
</p>
))}
</div>
</div>
)
}
export default Page

View File

@@ -0,0 +1,7 @@
import db, {FindOneProductArgs} from 'db'
export default async function getProduct(args: FindOneProductArgs) {
const product = await db.product.findOne(args)
return product
}

View File

@@ -0,0 +1,7 @@
import db, {FindManyProductArgs} from 'db'
export default async function getProducts(args?: FindManyProductArgs) {
const products = await db.product.findMany(args)
return products
}

View File

@@ -0,0 +1,13 @@
module.exports = {
webpack: (config, {buildId, dev, isServer, defaultLoaders, webpack}) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
// Important: return the modified config
return config
},
webpackDevMiddleware: (config) => {
// Perform customizations to webpack dev middleware config
// Important: return the modified config
return config
},
}

View File

@@ -0,0 +1,6 @@
import {PrismaClient} from '@prisma/client'
export * from '@prisma/client'
const prisma = new PrismaClient()
export default prisma

View File

View File

@@ -0,0 +1,72 @@
# Migration `20200414170933-init`
This migration has been generated by Brandon Bayer at 4/14/2020, 5:09:33 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TABLE "public"."User" (
"email" text NOT NULL ,
"id" SERIAL,
"name" text ,
"role" text ,
"storeId" integer ,
PRIMARY KEY ("id")
)
CREATE TABLE "public"."Product" (
"description" text ,
"handle" text NOT NULL ,
"id" SERIAL,
"name" text ,
"price" integer ,
PRIMARY KEY ("id")
)
CREATE UNIQUE INDEX "User.email" ON "public"."User"("email")
CREATE UNIQUE INDEX "Product.handle" ON "public"."Product"("handle")
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration ..20200414170933-init
--- datamodel.dml
+++ datamodel.dml
@@ -1,0 +1,30 @@
+// This is your Prisma schema file,
+// learn more about it in the docs: https://pris.ly/d/prisma-schema
+
+datasource postgresql {
+ provider = "postgresql"
+ url = env("DATABASE_URL")
+}
+
+generator client {
+ provider = "prisma-client-js"
+}
+
+
+// --------------------------------------
+
+model User {
+ id Int @default(autoincrement()) @id
+ email String @unique
+ name String?
+ role String?
+ storeId Int?
+}
+
+model Product {
+ id Int @default(autoincrement()) @id
+ handle String @unique
+ name String?
+ description String?
+ price Int?
+}
```

View File

@@ -0,0 +1,30 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource postgresql {
provider = "postgresql"
url = "***"
}
generator client {
provider = "prisma-client-js"
}
// --------------------------------------
model User {
id Int @default(autoincrement()) @id
email String @unique
name String?
role String?
storeId Int?
}
model Product {
id Int @default(autoincrement()) @id
handle String @unique
name String?
description String?
price Int?
}

View File

@@ -0,0 +1,199 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateSource",
"source": "postgresql"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Source",
"source": "postgresql"
},
"argument": "provider",
"value": "\"postgresql\""
},
{
"tag": "CreateArgument",
"location": {
"tag": "Source",
"source": "postgresql"
},
"argument": "url",
"value": "env(\"DATABASE_URL\")"
},
{
"tag": "CreateModel",
"model": "User"
},
{
"tag": "CreateField",
"model": "User",
"field": "id",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "id"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "User",
"field": "id"
},
"directive": "default"
},
"argument": "",
"value": "autoincrement()"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "id"
},
"directive": "id"
}
},
{
"tag": "CreateField",
"model": "User",
"field": "email",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "User",
"field": "email"
},
"directive": "unique"
}
},
{
"tag": "CreateField",
"model": "User",
"field": "name",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "User",
"field": "role",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "User",
"field": "storeId",
"type": "Int",
"arity": "Optional"
},
{
"tag": "CreateModel",
"model": "Product"
},
{
"tag": "CreateField",
"model": "Product",
"field": "id",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Product",
"field": "id"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Product",
"field": "id"
},
"directive": "default"
},
"argument": "",
"value": "autoincrement()"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Product",
"field": "id"
},
"directive": "id"
}
},
{
"tag": "CreateField",
"model": "Product",
"field": "handle",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Product",
"field": "handle"
},
"directive": "unique"
}
},
{
"tag": "CreateField",
"model": "Product",
"field": "name",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "Product",
"field": "description",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "Product",
"field": "price",
"type": "Int",
"arity": "Optional"
}
]
}

View File

@@ -0,0 +1,6 @@
# IF THERE'S A GIT CONFLICT IN THIS FILE, DON'T SOLVE IT MANUALLY!
# INSTEAD EXECUTE `prisma migrate fix`
# Prisma Migrate lockfile v1
# Read more about conflict resolution here: TODO
20200414170933-init

View File

@@ -0,0 +1,30 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource postgresql {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
// --------------------------------------
model User {
id Int @default(autoincrement()) @id
email String @unique
name String?
role String?
storeId Int?
}
model Product {
id Int @default(autoincrement()) @id
handle String @unique
name String?
description String?
price Int?
}

View File

View File

10
examples/store/now.json Normal file
View File

@@ -0,0 +1,10 @@
{
"env": {
"DATABASE_URL": "@store-example-db"
},
"build": {
"env": {
"DATABASE_URL": "@store-example-db"
}
}
}

View File

@@ -0,0 +1,23 @@
{
"name": "store",
"version": "0.7.0",
"private": true,
"scripts": {
"build": "blitz db migrate && blitz build"
},
"dependencies": {
"@prisma/cli": "2.0.0-beta.3",
"@prisma/client": "2.0.0-beta.3",
"blitz": "0.7.0",
"final-form": "4.19.1",
"react": "0.0.0-experimental-e5d06e34b",
"react-dom": "0.0.0-experimental-e5d06e34b",
"react-final-form": "6.4.0",
"typescript": "3.8.3"
},
"NOTE": "Next.js dependency is currently only required for deploying to zeit",
"devDependencies": {
"@types/react": "16.9.34",
"next": "9.3.5"
}
}

BIN
examples/store/public/favicon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,10 @@
<svg width="82" height="16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill="url(#prefix__paint0_linear)" d="M9.018 0l9.019 16H0L9.018 0z"/>
<path fill="#333" fill-rule="evenodd" d="M51.634 12.028h-6.492V2.052h6.492v1.256H46.61v3.007h4.37V7.57h-4.37v3.202h5.024v1.255zm-14.063 0h-7.235v-1.096l5.342-7.624h-5.253V2.052h7.058v1.097l-5.342 7.623h5.43v1.256zm21.88 0h6.333v-1.256h-2.423V3.308h2.423V2.052h-6.332v1.256h2.441v7.465h-2.441v1.255zm18.22 0h-1.468v-8.72h-3.36V2.052h8.225v1.256H77.67v8.72z" clip-rule="evenodd"/>
<defs>
<linearGradient id="prefix__paint0_linear" x1="28.022" x2="16.189" y1="22.991" y2="8.569" gradientUnits="userSpaceOnUse">
<stop stop-color="#fff"/>
<stop offset="1"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 794 B

View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"baseUrl": "./",
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}

View File

View File

@@ -0,0 +1,4 @@
module.exports = {
presets: ["next/babel"],
plugins: [],
}

View File

@@ -0,0 +1,9 @@
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
"jsx-a11y/anchor-is-valid": "off", //Doesn't play well with Blitz/Next <Link> usage
},
}

54
examples/tailwind/.gitignore vendored Normal file
View File

@@ -0,0 +1,54 @@
# dependencies
node_modules
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*
.npm
web_modules/
# blitz
/.blitz/
/.next/
*.sqlite
.now
.blitz-console-history
# misc
.DS_Store
# local env files
.env
.envrc
.env.local
.env.development.local
.env.test.local
.env.production.local
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Testing
coverage
*.lcov
.nyc_output
lib-cov
# Caches
*.tsbuildinfo
.eslintcache
.node_repl_history
.yarn-integrity
# Serverless directories
.serverless/
# Stores VSCode versions used for testing VSCode extensions
.vscode-test

1
examples/tailwind/.npmrc Normal file
View File

@@ -0,0 +1 @@
save-exact=true

View File

@@ -0,0 +1,5 @@
.gitkeep
.env
*.ico
*.lock

View File

@@ -0,0 +1,11 @@
# Blitz Tailwind Example
## Getting Started
1. Start the dev server
```
blitz start
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see Tailwind in use

View File

View File

@@ -0,0 +1,21 @@
import React from "react"
export default class ErrorBoundary extends React.Component<{
fallback: (error: any) => React.ReactNode
}> {
state = { hasError: false, error: null }
static getDerivedStateFromError(error: any) {
return {
hasError: true,
error,
}
}
render() {
if (this.state.hasError) {
return this.props.fallback(this.state.error)
}
return this.props.children
}
}

View File

@@ -0,0 +1,29 @@
import { Link } from "blitz"
const links = [
{ href: "https://github.com/blitz-js/blitz", label: "GitHub" },
{ href: "https://github.com/blitz-js/blitz/blob/canary/USER_GUIDE.md", label: "Docs" },
]
export default function Nav() {
return (
<nav>
<ul className="flex justify-between items-center p-8">
<li>
<Link href="/">
<a className="text-blue-500 no-underline">Home</a>
</Link>
</li>
<ul className="flex justify-between items-center">
{links.map(({ href, label }) => (
<li key={`${href}${label}`} className="ml-4">
<a href={href} className="btn-blue no-underline">
{label}
</a>
</li>
))}
</ul>
</ul>
</nav>
)
}

View File

View File

@@ -0,0 +1,5 @@
import "app/styles/index.css"
export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}

View File

@@ -0,0 +1,23 @@
import { Document, Html, DocumentHead, Main, NextScript /*DocumentContext*/ } from "@blitzjs/core"
class MyDocument extends Document {
// Only uncomment if you need to customize this behaviour
// static async getInitialProps(ctx: DocumentContext) {
// const initialProps = await Document.getInitialProps(ctx)
// return {...initialProps}
// }
render() {
return (
<Html lang="en">
<DocumentHead />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument

View File

@@ -0,0 +1,12 @@
import Nav from "app/components/nav"
export default () => {
return (
<div>
<Nav />
<div className="hero">
<h1 className="title">Blitz.js + Tailwind CSS</h1>
</div>
</div>
)
}

View File

@@ -0,0 +1,3 @@
.btn-blue {
@apply bg-blue-500 text-white font-bold py-2 px-4 rounded;
}

View File

@@ -0,0 +1,25 @@
@import "./button.css";
/* purgecss start ignore */
@tailwind base;
@tailwind components;
/* purgecss end ignore */
@tailwind utilities;
.hero {
width: 100%;
color: #333;
}
.title {
margin: 0;
width: 100%;
padding-top: 80px;
line-height: 1.15;
font-size: 48px;
}
.title,
.description {
text-align: center;
}

View File

@@ -0,0 +1,13 @@
module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
// Important: return the modified config
return config
},
webpackDevMiddleware: (config) => {
// Perform customizations to webpack dev middleware config
// Important: return the modified config
return config
},
}

View File

@@ -0,0 +1,6 @@
import { PrismaClient } from "@prisma/client"
export * from "@prisma/client"
const prisma = new PrismaClient()
export default prisma

View File

View File

@@ -0,0 +1,20 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource postgresql {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
// --------------------------------------
//model Project {
// id Int @default(autoincrement()) @id
// name String
//}

View File

View File

View File

@@ -0,0 +1,59 @@
{
"name": "tailwind",
"version": "0.7.0",
"scripts": {
"build": "blitz db migrate && blitz build",
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
"test": "echo \"No tests yet\""
},
"browserslist": [
"defaults"
],
"prettier": {
"semi": false,
"printWidth": 110
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && pretty-quick --staged",
"pre-push": "blitz test"
}
},
"lint-staged": {
"*.{js,ts,tsx}": [
"eslint --fix",
"git add"
]
},
"dependencies": {
"@prisma/cli": "2.0.0-beta.3",
"@prisma/client": "2.0.0-beta.3",
"blitz": "0.7.0",
"react": "0.0.0-experimental-e5d06e34b",
"react-dom": "0.0.0-experimental-e5d06e34b",
"typescript": "3.8.3"
},
"NOTE": "Next.js dependency is currently only required for deploying to zeit",
"devDependencies": {
"@fullhuman/postcss-purgecss": "2.1.2",
"@types/react": "16.9.34",
"@typescript-eslint/eslint-plugin": "2.29.0",
"@typescript-eslint/parser": "2.29.0",
"babel-eslint": "10.1.0",
"eslint": "6.8.0",
"eslint-config-react-app": "5.2.1",
"eslint-plugin-flowtype": "4.7.0",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "3.0.0",
"husky": "4.2.5",
"lint-staged": "10.1.7",
"next": "9.3.5",
"postcss-preset-env": "6.7.0",
"prettier": "2.0.5",
"pretty-quick": "2.0.1",
"tailwindcss": "1.3.5"
},
"private": true
}

View File

@@ -0,0 +1,17 @@
module.exports = {
plugins: [
"tailwindcss",
...(process.env.NODE_ENV === "production"
? [
[
"@fullhuman/postcss-purgecss",
{
content: ["./pages/**/*.{js,jsx,ts,tsx}", "./components/**/*.{js,jsx,ts,tsx}"],
defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [],
},
],
]
: []),
"postcss-preset-env",
],
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"baseUrl": "./",
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}

View File

16
lerna.json Normal file
View File

@@ -0,0 +1,16 @@
{
"version": "0.7.0",
"packages": ["packages/*"],
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"version": {
"exact": true
},
"publish": {
"npmClient": "npm",
"allowBranch": ["master", "canary"],
"registry": "https://registry.npmjs.org/"
}
}
}

99
package.json Normal file
View File

@@ -0,0 +1,99 @@
{
"name": "root",
"private": true,
"workspaces": {
"packages": [
"packages/*",
"examples/*"
],
"nohoist": [
"**/@prisma",
"**/@prisma/**"
]
},
"engines": {
"yarn": "^1.19.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 && yarn run testonly",
"testonly": "lerna run test --stream --parallel",
"prepublishOnly": "yarn run reset && yarn run test",
"prepack": "cpy README.md packages/blitz/",
"postpack": "rimraf packages/blitz/README.md",
"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 && release --pre",
"publish-latest": "lerna publish ---no-push --force-publish && yarn run danger:push-all && release",
"danger:push-all": "git push --no-verify && git push --no-verify --tags"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.5.0",
"@testing-library/react": "^10.0.3",
"@types/cross-spawn": "^6.0.1",
"@types/debug": "^4.1.5",
"@types/diff": "^4.0.2",
"@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/merge-stream": "^1.1.2",
"@types/node": "^13.13.2",
"@types/node-fetch": "^2.5.7",
"@types/parallel-transform": "^1.1.0",
"@types/path-is-absolute": "^1.0.0",
"@types/pump": "^1.1.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",
"@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",
"husky": "^4.2.3",
"jest": "24.9.0",
"lerna": "^3.20.2",
"lint-staged": "^10.0.8",
"next": "^9.3.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.4",
"pretty-quick": "^2.0.1",
"prompt": "^1.0.0",
"release": "^6.1.0",
"rimraf": "^3.0.2",
"rollup": "^2.7.2",
"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",
"semver": "^7.3.2",
"ts-jest": "24.3.0",
"tsdx": "^0.13.1",
"tslib": "^1.11.1",
"typescript": "^3.8.3",
"wait-on": "^4.0.2"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged",
"pre-push": "yarn test"
}
},
"resolutions": {
"jest": "24.9.0",
"ts-jest": "24.3.0"
}
}

8
packages/blitz/.gitignore vendored Normal file
View File

@@ -0,0 +1,8 @@
*.log
.DS_Store
node_modules
.rts2_cache_cjs
.rts2_cache_esm
.rts2_cache_umd
.rts2_cache_system
dist

3
packages/blitz/bin/blitz Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
require('../dist/cli')

View File

@@ -0,0 +1 @@
require('@testing-library/jest-dom')

View File

@@ -0,0 +1,69 @@
{
"name": "blitz",
"description": "Blitz is a Rails-like framework for monolithic, full-stack React apps — built on Next.js",
"version": "0.7.0",
"license": "MIT",
"scripts": {
"predev": "wait-on -d 500 ../core/dist/packages/core/src/index.d.ts && wait-on ../server/dist/packages/server/src/index.d.ts",
"dev": "rollup -c rollup.config.js --watch",
"build": "rollup -c rollup.config.js"
},
"author": {
"name": "Brandon Bayer",
"email": "b@bayer.ws",
"url": "https://twitter.com/flybayer"
},
"bin": {
"blitz": "./bin/blitz"
},
"main": "dist/index.js",
"module": "dist/blitz.esm.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"husky": {
"hooks": {}
},
"jest": {
"setupFilesAfterEnv": [
"<rootDir>/jest.setup.js"
]
},
"engines": {
"node": ">= 10.13.0"
},
"repository": {
"type": "git",
"url": "https://github.com/blitz-js/blitz"
},
"dependencies": {
"@blitzjs/cli": "0.7.0",
"@blitzjs/core": "0.7.0",
"@blitzjs/server": "0.7.0",
"os-name": "^3.1.0",
"pkg-dir": "^4.2.0",
"resolve-from": "^5.0.0",
"resolve-global": "^1.0.0"
},
"devDependencies": {
"@types/jest": "^25.1.3",
"@types/node": "^13.13.2",
"cross-env": "^7.0.0",
"husky": "^4.2.3",
"lint-staged": "^10.0.8",
"ts-jest": "24.3.0"
},
"keywords": [
"blitz",
"blitzjs",
"blitz.js",
"next",
"next.js",
"react",
"framework",
"fullstack",
"node"
],
"gitHead": "9c54cfaef19b63c30a7e41447541c7cc30b5c6d4"
}

View File

@@ -0,0 +1,56 @@
import pkg from './package.json'
import typescript from '@wessberg/rollup-plugin-ts'
import commonjs from 'rollup-plugin-commonjs'
import external from 'rollup-plugin-peer-deps-external'
import resolve from 'rollup-plugin-node-resolve'
import json from 'rollup-plugin-json'
const common = {
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
'react',
'react-dom',
'next',
'fs',
'path',
],
plugins: [
json(),
external(),
resolve({preferBuiltins: true}),
typescript({
transformers: [],
}),
commonjs({
include: /node_modules/,
namedExports: {},
}),
],
}
const lib = {
input: './src/index.ts',
output: {
file: pkg['main'],
exports: 'named',
sourcemap: 'true',
format: 'cjs',
},
...common,
}
const cli = {
input: './src/bin/cli.ts',
output: {
file: './dist/cli.js',
exports: 'named',
sourcemap: 'true',
format: 'cjs',
},
...common,
}
const builds = [lib, cli]
export default builds

84
packages/blitz/src/bin/cli.ts Executable file
View File

@@ -0,0 +1,84 @@
import * as fs from 'fs'
import * as path from 'path'
const resolveGlobal = require('resolve-global')
const resolveFrom = require('resolve-from')
const pkgDir = require('pkg-dir')
const chalk = require('chalk')
console.log(
chalk.yellow(
`You are using alpha software - if you have any problems, please open an issue here:
https://github.com/blitz-js/blitz/issues/new/choose\n`,
),
)
let usageType: 'local' | 'monorepo' | 'global' | 'global-linked'
const localCLIPkgPath = path.resolve(process.cwd(), 'node_modules', '@blitzjs/cli')
const monorepoCLIPkgPath = path.resolve(process.cwd(), '../..', 'node_modules', '@blitzjs/cli')
const globalCLIPkgPath = resolveFrom(__dirname, '@blitzjs/cli')
const globalLinkedPath = path.resolve(pkgDir.sync(__dirname), '../../lerna.json')
function getBlitzPkgJsonPath() {
switch (usageType) {
case 'local':
return path.join(process.cwd(), 'node_modules/blitz/package.json')
case 'monorepo':
return path.join(process.cwd(), '../../node_modules/blitz/package.json')
case 'global':
return path.join(resolveGlobal.silent('blitz') || '', 'package.json')
case 'global-linked':
return path.join(pkgDir.sync(__dirname), 'package.json')
}
}
let pkgPath
if (fs.existsSync(localCLIPkgPath)) {
usageType = 'local'
pkgPath = localCLIPkgPath
} else if (fs.existsSync(monorepoCLIPkgPath)) {
usageType = 'monorepo'
pkgPath = monorepoCLIPkgPath
} else if (fs.existsSync(globalLinkedPath)) {
usageType = 'global-linked'
pkgPath = path.resolve(pkgDir.sync(__dirname), '../cli')
} else {
usageType = 'global'
pkgPath = globalCLIPkgPath
}
const cli = require(pkgPath as string)
const options = require('minimist')(process.argv.slice(2))
const hasVersionFlag = options._.length === 0 && (options.v || options.version)
const hasVerboseFlag = options._.length === 0 && (options.V || options.verbose)
if (hasVersionFlag) {
if (hasVerboseFlag) {
console.log('debug:', usageType)
console.log('debug: pkgPath:', pkgPath, '\n')
}
try {
const osName = require('os-name')
console.log(`${osName()} | ${process.platform}-${process.arch} | Node: ${process.version}\n`)
let globalInstallPath
let localButGlobalLinked = usageType === 'local' && fs.existsSync(globalLinkedPath)
if (usageType === 'global-linked' || usageType === 'monorepo' || localButGlobalLinked) {
globalInstallPath = pkgDir.sync(__dirname)
} else {
globalInstallPath = pkgDir.sync(resolveFrom(__dirname, 'blitz'))
}
const globalVersion = path.join(globalInstallPath, 'package.json')
console.log(`blitz: ${require(globalVersion).version} (global)`)
if (!usageType.includes('global')) {
console.log(`blitz: ${require(getBlitzPkgJsonPath()).version} (local)`)
}
console.log('') // One last new line
} catch (e) {
console.log('blitz error', e)
}
process.exit(0)
} else {
cli.run()
}

View File

@@ -0,0 +1 @@
export * from '@blitzjs/core'

View File

@@ -0,0 +1 @@
export const isServer = typeof window === 'undefined'

View File

@@ -0,0 +1,3 @@
it('todo', async () => {
expect(true).toBe(true)
})

View File

@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"include": ["src", "types", "test"],
"exclude": ["node_modules"],
"compilerOptions": {
"baseUrl": "./",
"declarationDir": "./dist",
"downlevelIteration": true,
"paths": {
"*": ["src/*", "node_modules/*"]
}
}
}

1
packages/blitz/types/index.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
//

Some files were not shown because too many files have changed in this diff Show More