Skip to content

Commit a3cc34a

Browse files
committed
Merge branch 'main' into mutate
2 parents 9339af9 + ee54832 commit a3cc34a

File tree

105 files changed

+2811
-721
lines changed

Some content is hidden

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

105 files changed

+2811
-721
lines changed

.github/workflows/pipeline.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Pipeline
22

33
on:
4-
- push
5-
- pull_request
4+
pull_request:
5+
push:
6+
branches: main
67

78
jobs:
89
build:
@@ -113,7 +114,7 @@ jobs:
113114
- name: Test
114115
run: pnpm test
115116

116-
integration-build:
117+
integration-sveltekit:
117118
runs-on: ${{ matrix.os }}
118119

119120
strategy:
@@ -145,5 +146,41 @@ jobs:
145146
146147
- run: pnpm i
147148

148-
- name: Build Integration
149+
- name: Build SvelteKit Integration
149150
run: pnpm play:build
151+
152+
integration-nextjs:
153+
runs-on: ${{ matrix.os }}
154+
155+
strategy:
156+
matrix:
157+
node-version: [16.x]
158+
os: [ubuntu-latest, windows-latest, macos-latest]
159+
fail-fast: false
160+
161+
steps:
162+
- uses: actions/checkout@v3
163+
164+
- name: Install pnpm
165+
uses: pnpm/action-setup@v2.2.2
166+
with:
167+
version: ^7.3.0
168+
run_install: false
169+
170+
- name: Use Node.js ${{ matrix.node-version }}
171+
uses: actions/setup-node@v3
172+
with:
173+
node-version: ${{ matrix.node-version }}
174+
registry-url: https://registry.npmjs.org/
175+
cache: 'pnpm'
176+
177+
- name: Set an escape hatch exclusive to this monorepo
178+
id: escape_hatch
179+
run: |
180+
echo "FLATBREAD_CI=true" >> $GITHUB_ENV
181+
182+
- run: pnpm i
183+
184+
- name: Build Next.js integration
185+
# TODO: extract the Flatbread build to a separate job that this job can depend on
186+
run: pnpm build && cd examples/nextjs && pnpm build

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# packages & build files
22
**/node_modules
33
**/dist/**
4-
examples
54

65
# temp files
76
**.swp

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ package.json
6060
In reference to that structure, set up a `flatbread.config.js` in the root of your project:
6161

6262
```js
63-
import { defineConfig, markdownTransformer, filesystem } from 'flatbread';
63+
import { defineConfig, transformerMarkdown, sourceFilesystem } from 'flatbread';
6464

6565
const transformerConfig = {
6666
markdown: {
@@ -69,8 +69,8 @@ const transformerConfig = {
6969
},
7070
};
7171
export default defineConfig({
72-
source: filesystem(),
73-
transformer: markdownTransformer(transformerConfig),
72+
source: sourceFilesystem(),
73+
transformer: transformerMarkdown(transformerConfig),
7474

7575
content: [
7676
{
@@ -251,7 +251,7 @@ Limits the number of returned entries to the specified amount. Accepts an intege
251251

252252
## Query within your app ❓❓
253253

254-
[Check out the playground for an example](https://github.com/FlatbreadLabs/flatbread/tree/main/playground) of using Flatbread with SvelteKit to safely shoot off GraphQL queries using a static (or node) adapter.
254+
[Check out the example integrations](https://github.com/FlatbreadLabs/flatbread/tree/main/playground) of using Flatbread with frameworks like SvelteKit and Next.js.
255255

256256
## Field overrides
257257

@@ -306,8 +306,10 @@ Clone the entire monorepo! Once you've installed dependencies with `pnpm -w i`,
306306

307307
This will run a dev server across packages in the monorepo
308308

309+
You may need to seed this with a `pnpm build` first, as there can be a race condition with parallel type generation. After that, you can automatically & incrementally build changes with:
310+
309311
```bash
310-
pnpm -w dev
312+
pnpm dev
311313
```
312314

313315
## **working on a package** ⚒️
@@ -317,13 +319,12 @@ Open another **terminal** tab.
317319
| ☝️ Keep the dev server running in your other tab |
318320
| ------------------------------------------------ |
319321

320-
### Option 1: use the Playground as a demo project
322+
### Option 1: use the SvelteKit example as a demo project
321323

322324
This allows you to work in the full context of a Flatbread instance as an end-user would, except you can tinker with the `packages` internals.
323325

324326
```bash
325-
cd playground
326-
pnpm dev
327+
pnpm play
327328
```
328329

329330
This is a good option when you want to test without creating temporary clutter per-package that you wouldn't want to commit.
@@ -344,14 +345,12 @@ node dist/index.mjs # ya need Node v16+
344345

345346
## **build for production** 📦
346347

347-
This will use `tsup` to build each package linked in the monorepo unless opted out per-package.
348+
This will use `tsup` to build each package linked in the monorepo except the integration examples.
348349

349350
```bash
350351
pnpm build
351352
```
352353

353354
# 📓 Sidenotes
354355

355-
The transpiled TS files in the [`playground`](https://github.com/FlatbreadLabs/flatbread/tree/main/playground) are being tracked in the repo to appease the Vite gods so I can develop quicker. As the project progresses, I'll likely yeet those outta here.
356-
357356
Huge shoutouts to [@antfu](https://github.com/antfu/) and [@sveltejs/kit](https://github.com/sveltejs/kit) for both having invaluable reference points to guide me through learning more advanced Node, Typescript, and monorepo design all in parallel during this project.

examples/nextjs/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

examples/nextjs/.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo

examples/nextjs/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
```
12+
13+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14+
15+
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
16+
17+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
18+
19+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20+
21+
## Learn More
22+
23+
To learn more about Next.js, take a look at the following resources:
24+
25+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27+
28+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29+
30+
## Deploy on Vercel
31+
32+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33+
34+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {
2+
transformerMarkdown,
3+
sourceFilesystem,
4+
type FlatbreadConfig,
5+
} from 'flatbread';
6+
7+
const transformerConfig = {
8+
markdown: {
9+
gfm: true,
10+
externalLinks: true,
11+
},
12+
};
13+
const config = {
14+
source: sourceFilesystem(),
15+
transformer: transformerMarkdown(transformerConfig),
16+
17+
content: [
18+
{
19+
path: '../../packages/flatbread/content/posts',
20+
collection: 'Post',
21+
refs: {
22+
authors: 'Author',
23+
},
24+
},
25+
{
26+
path: '../../packages/flatbread/content/authors',
27+
collection: 'Author',
28+
refs: {
29+
friend: 'Author',
30+
},
31+
},
32+
],
33+
} as FlatbreadConfig;
34+
35+
export default config;

examples/nextjs/next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

examples/nextjs/next.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
3+
reactStrictMode: true,
4+
swcMinify: true,
5+
};
6+
7+
module.exports = nextConfig;

examples/nextjs/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "nextjs",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "flatbread start -- next dev",
7+
"build": "flatbread start -- next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"flatbread": "workspace:*",
13+
"next": "12.2.3",
14+
"react": "18.2.0",
15+
"react-dom": "18.2.0"
16+
},
17+
"devDependencies": {
18+
"@types/node": "16.11.45",
19+
"@types/react": "18.0.15",
20+
"@types/react-dom": "18.0.6",
21+
"eslint": "7.32.0",
22+
"eslint-config-next": "12.2.3",
23+
"typescript": "4.7.4"
24+
}
25+
}

0 commit comments

Comments
 (0)