Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update buttercms example #35436

Merged
merged 16 commits into from
May 3, 2022

Conversation

ViolanteCodes
Copy link
Contributor

@ViolanteCodes ViolanteCodes commented Mar 18, 2022

Documentation / Examples

  • Make sure the linting passes by running yarn lint

Note: I was having a lot of linting errors on a freshly pulled down copy of the canary branch (see code snippet at bottom). After consulting with my team, I checked out the UPDATE_BUTTERCMS_EXAMPLE branch and ran yarn lint-no-typescript (our project is not typescript), which came back with two errors for my new branch, one of which was easily fixed. The other is this:

/home/maria/Programming/butter/next.js/examples/cms-buttercms/components/author-card.js
  7:8  error  Definition for rule '@next/next/no-img-element' was not found  @next/next/no-img-element

If i remember correctly, this author card component was originally set up with <Image />, but was changed to a <img> because of the need for people to choose author profile images from whatever domain they wanted, as people have the option to set their profile image in butter to any image (e.g., outside of our cms).

If this is not acceptable, please advise how you would like us to address.

Pro:~/Programming/butter/next.js$ yarn lint
yarn run v1.22.17
$ run-p test-types lint-typescript prettier-check lint-eslint lint-language
$ lerna run typescript
$ eslint . --ext js,jsx,ts,tsx --max-warnings=0 --config .eslintrc.json --no-eslintrc
$ alex .
$ prettier --check .
$ yarn tsc
$ /home/maria/Programming/butter/next.js/node_modules/.bin/tsc
lerna notice cli v4.0.0
lerna info Executing command in 2 packages: "yarn run typescript"
Checking formatting...
docs/middleware.mdlerna info run Ran npm script 'typescript' in '@next/react-dev-overlay' in 29.9s:
$ tsec --noEmit -p tsconfig.json
errors/no-unwanted-polyfillio.mdtest/lib/e2e-utils.ts:112:16 - error TS2749: 'NextConfig' refers to a value, but is being used as a type here. Did you mean 'typeof NextConfig'?
112   nextConfig?: NextConfig
                   ~~~~~~~~~~
test/lib/next-modes/base.ts:22:26 - error TS2749: 'NextConfig' refers to a value, but is being used as a type here. Did you mean 'typeof NextConfig'?
22   protected nextConfig?: NextConfig
                            ~~~~~~~~~~
test/lib/next-modes/base.ts:52:18 - error TS2749: 'NextConfig' refers to a value, but is being used as a type here. Did you mean 'typeof NextConfig'?
52     nextConfig?: NextConfig
                    ~~~~~~~~~~
test/lib/next-modes/base.ts:125:18 - error TS2749: 'NextConfig' refers to a value, but is being used as a type here. Did you mean 'typeof NextConfig'?
125             } as NextConfig,
                     ~~~~~~~~~~
test/unit/next-babel-loader-dev.test.ts:47:34 - error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ name: any; parentId: any; attrs: any; startTime: any; }'.
  Type '{ name: string; }' is missing the following properties from type '{ name: any; parentId: any; attrs: any; startTime: any; }': parentId, attrs, startTime
47       currentTraceSpan: new Span({ name: 'test' }),
                                    ~~~~~~~~~~~~~~~~
test/unit/next-babel-loader-prod.test.ts:48:34 - error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type '{ name: any; parentId: any; attrs: any; startTime: any; }'.
  Type '{ name: string; }' is missing the following properties from type '{ name: any; parentId: any; attrs: any; startTime: any; }': parentId, attrs, startTime
48       currentTraceSpan: new Span({ name: 'test' }),
                                    ~~~~~~~~~~~~~~~~
test/unit/web-runtime/body.test.ts:46:15 - error TS2339: Property 'bodyUsed' does not exist on type 'Implementation'.
46   expect(body.bodyUsed).toEqual(false)
                 ~~~~~~~~
test/unit/web-runtime/body.test.ts:48:23 - error TS2339: Property 'body' does not exist on type 'Implementation'.
48   const reader = body.body.getReader()
                         ~~~~
test/unit/web-runtime/body.test.ts:49:15 - error TS2339: Property 'bodyUsed' does not exist on type 'Implementation'.
49   expect(body.bodyUsed).toEqual(false)
                 ~~~~~~~~
test/unit/web-runtime/body.test.ts:57:15 - error TS2339: Property 'bodyUsed' does not exist on type 'Implementation'.
57   expect(body.bodyUsed).toEqual(true)
                 ~~~~~~~~
test/unit/web-runtime/body.test.ts:75:50 - error TS2339: Property 'body' does not exist on type 'Implementation'.
75   for await (const item of streamToIterator(body.body)) {
                                                    ~~~~
test/unit/web-runtime/body.test.ts:80:23 - error TS2339: Property 'body' does not exist on type 'Implementation'.
80   const reader = body.body.getReader()
                         ~~~~
test/unit/web-runtime/body.test.ts:84:28 - error TS2339: Property 'text' does not exist on type 'Implementation'.
84   const error = await body.text().catch((err) => err)
                              ~~~~
test/unit/web-runtime/body.test.ts:104:27 - error TS2339: Property 'text' does not exist on type 'Implementation'.
104   const text = await body.text()
                              ~~~~
test/unit/web-runtime/body.test.ts:107:28 - error TS2339: Property 'text' does not exist on type 'Implementation'.
107   const error = await body.text().catch((err) => err)
                               ~~~~
test/unit/web-runtime/body.test.ts:127:27 - error TS2339: Property 'text' does not exist on type 'Implementation'.
127   const text = await body.text()
                              ~~~~
test/unit/web-runtime/body.test.ts:152:28 - error TS2339: Property 'arrayBuffer' does not exist on type 'Implementation'.
152   const value = await body.arrayBuffer()
                               ~~~~~~~~~~~
test/unit/web-runtime/body.test.ts:161:28 - error TS2339: Property 'arrayBuffer' does not exist on type 'Implementation'.
161   const value = await body.arrayBuffer()
                               ~~~~~~~~~~~
test/unit/web-runtime/body.test.ts:176:28 - error TS2339: Property 'arrayBuffer' does not exist on type 'Implementation'.
176   const value = await body.arrayBuffer()
                               ~~~~~~~~~~~
test/unit/web-runtime/body.test.ts:186:31 - error TS2339: Property 'formData' does not exist on type 'Implementation'.
186   const formData = await body.formData()
                                  ~~~~~~~~
test/unit/web-runtime/body.test.ts:194:27 - error TS2339: Property 'blob' does not exist on type 'Implementation'.
194   const blob = await body.blob()
                              ~~~~
test/unit/web-runtime/body.test.ts:201:28 - error TS2339: Property 'json' does not exist on type 'Implementation'.
201   const value = await body.json()
                               ~~~~
test/unit/web-runtime/body.test.ts:207:28 - error TS2339: Property 'json' does not exist on type 'Implementation'.
207   const error = await body.json().catch((err) => err)
                               ~~~~
Found 23 errors.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
errors/page-without-valid-component.mdERROR: "test-types" exited with 2.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@ijjk ijjk added the examples Issue/PR related to examples label Mar 18, 2022
@ViolanteCodes ViolanteCodes marked this pull request as ready for review March 18, 2022 17:12
@ViolanteCodes
Copy link
Contributor Author

@leerob Hello! Sorry for reaching out directly, but I think Jake mentioned he'd corresponded with you previously about updating our Butter starter project. I just wanted to check on this. We're so excited to get this new starter merged in :). Could you let me know if there's some action I need to take? Thank you :)

examples/cms-buttercms/.eslintrc Outdated Show resolved Hide resolved
examples/cms-buttercms/.gitignore Outdated Show resolved Hide resolved
examples/cms-buttercms/README.md Outdated Show resolved Hide resolved
examples/cms-buttercms/package.json Outdated Show resolved Hide resolved
examples/cms-buttercms/package.json Outdated Show resolved Hide resolved
examples/cms-buttercms/package.json Outdated Show resolved Hide resolved
@ViolanteCodes
Copy link
Contributor Author

@leerob I've made the changes asked for, but have not pushed up yet as I wanted to check - would you like us to squash our commits into one and rebase on top of the most recent canary?

@leerob
Copy link
Member

leerob commented Apr 14, 2022

You don't need to squash 👍 Whatever works for you

@ViolanteCodes
Copy link
Contributor Author

@leerob i believe this is ready for review as the changes requested have been made.

One note: I did run yarn prettier --write in the repo, which fixed a few whitespace issues, but those files are not pulling into git? Are there some pre-commit hooks or something set up to ignore whitespace-only changes?

@ViolanteCodes
Copy link
Contributor Author

@leerob I see that there is a failing test here, however, I don't see anything to fix in the error message? Would it be possible for you to let us know what we need to do from here? Thank you, and sorry for the inconvenience!

Copy link
Member

@leerob leerob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few more comments, looking good! Thanks for making those changes.

@@ -0,0 +1 @@
NEXT_PUBLIC_BUTTER_CMS_API_KEY=your_auth_token
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep this as .env.local.example - any reason it changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted back to .env.local.example

@@ -32,3 +32,6 @@ yarn-error.log*

# vercel
.vercel

# other
.vscode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was failing because of this - all examples need to have the same .gitignore 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've committed this change

examples/cms-buttercms/.gitignore Outdated Show resolved Hide resolved
},
images: {
domains: ['cdn.buttercms.com'],
dangerouslyAllowSVG: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we need the domains specification as the images for the landing page come from the CDN, but I've deleted the dangerously allow SVG key

@@ -1,28 +0,0 @@
import { getPreviewPostBySlug } from '@/lib/api'

export default async function preview(req, res) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this was removed? It'd be great if it used on-demand ISR as well 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that we no longer support the same method for previewing of a draft post, so there's no longer a getPreviewPostBySlug method.

As for the on-demand ISR - that sounds like a very cool feature! Unfortunately, the main next.js developer that we had for creating the starter is not available, and I'm really hesitant to change anything that's going to affect functionality on that level, as I'm not a next.js developer (or even js developer 😅 myself).

We have another version of this starter in our docs and our page that we'd also have to update, as we're trying to keep the two versions (i.e., the one in our docs and the one in the next.js examples) from diverging too greatly. Our main goal with the starter was for someone to be able to set it up super-rapidly using the exact same steps across all stacks that we support, so we'd like to prevent having to set up extra environment variables, etc.

If the on-demand static ISR is an absolute requirement for updating our current example, I can forward that information to my team, but I think our preference at this time would be to not implement it if that's a possibility? It also makes the process of testing/hosting a bit more difficult, due to the need to create a production build and start the production server, and we're trying to keep these starters as easy to drop in as possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries - could be a future improvement!

@ViolanteCodes
Copy link
Contributor Author

@leerob I think I've addressed all the changes from this last batch, save regarding the on-demand ISR; please see my note. Please let me know if there's anything I forgot or need to do, and thank you again.

leerob
leerob previously approved these changes Apr 27, 2022
Copy link
Member

@leerob leerob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for dealing with my changes!

@ViolanteCodes
Copy link
Contributor Author

Thank you so much for dealing with my changes!

Of course - and thank you for your feedback. It was extremely clear and implementable; much appreciated :)

@ViolanteCodes
Copy link
Contributor Author

@leerob I see we have a failing test again, sorry 😢. Please let me know what I can do to fix this, and thanks again for all your help.

@ViolanteCodes
Copy link
Contributor Author

@leerob Oh, awesome! So exciting to see all tests pass! Thank you!

@balazsorban44 balazsorban44 merged commit fec5318 into vercel:canary May 3, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue/PR related to examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants