Skip to content

Support generating typescript cells and pages | Autodetect ts project#2279

Merged
dac09 merged 16 commits intoredwoodjs:mainfrom
dac09:feat/ts-generators-cell-pages-layouts
Apr 21, 2021
Merged

Support generating typescript cells and pages | Autodetect ts project#2279
dac09 merged 16 commits intoredwoodjs:mainfrom
dac09:feat/ts-generators-cell-pages-layouts

Conversation

@dac09
Copy link
Copy Markdown
Contributor

@dac09 dac09 commented Apr 15, 2021

Closes #523

What does it do?

  • Allows generation of cells in typescript
    yarn rw g cell pets --ts

  • Allows generation of pages in typescript
    yarn rw g page kitten --ts

  • Allows generation of scaffolds in typescript

  • Autodetects if your project is typescript, and flags all generators to use typescript. So no need to pass the --ts flag all the time. In your typescript project you can just run yarn rw g page kitten and it'll infer the ts flag

  • Updates all the tests to use toMatchSnapshot, and cleans up their behaviour so all the handlers are consistent.

  • Removes depracated generators (been long enough since Sep 2020!)

What it doesn't do

Statically type cells, or handle typing cells from the outside. This is a separate piece that Peter P is looking at.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 15, 2021

📦 PR Packages

Click to Show Package Download Links

https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/create-redwood-app-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-api-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-api-server-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-auth-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-cli-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-core-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-dev-server-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-eslint-config-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-eslint-plugin-redwood-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-forms-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-internal-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-prerender-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-router-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-structure-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-testing-0.30.1-a694979.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/2279/redwoodjs-web-0.30.1-a694979.tgz

Install this PR by running yarn rw upgrade --pr 2279:0.30.1-a694979

@dac09 dac09 marked this pull request as draft April 15, 2021 13:25
@dac09 dac09 marked this pull request as ready for review April 19, 2021 13:37
@dac09 dac09 force-pushed the feat/ts-generators-cell-pages-layouts branch 2 times, most recently from 2b16e2b to f896c5f Compare April 19, 2021 13:40
])
})

test.only('includes skip link when --skipLink is set to true', () => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Uhoh @jtoar 😆

agg[k] = v.default
return agg
}, {})
return Object.entries(builder).reduce(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just renames the variables to make it more readable

Comment thread packages/cli/src/commands/generate.js
@dac09 dac09 force-pushed the feat/ts-generators-cell-pages-layouts branch from 79d8e07 to cd386b1 Compare April 19, 2021 14:24
@dac09 dac09 force-pushed the feat/ts-generators-cell-pages-layouts branch from ff61cea to cd5bf91 Compare April 20, 2021 09:04
Copy link
Copy Markdown
Member

@peterp peterp left a comment

Choose a reason for hiding this comment

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

This is a monster... Thanks for doing this! 🦾, it looks good to me, but I didn't spend as much time as I would've wanted one this, but given the size and the fact that it's all tested makes me feel more confident.

@dac09
Copy link
Copy Markdown
Contributor Author

dac09 commented Apr 21, 2021

I'll make sure to test these manually before the release with DT's help, but I was fairly careful - made sure all the tests pass first, then moved them to snapshots, then checked each individual snapshot

@dac09 dac09 merged commit adcc6d7 into redwoodjs:main Apr 21, 2021
dac09 added a commit to dac09/redwood that referenced this pull request Apr 21, 2021
…erve-web

* 'main' of github.com:redwoodjs/redwood: (40 commits)
  Support generating typescript cells and pages | Autodetect ts project (redwoodjs#2279)
  create-redwood-app messages: moved app start commands to end (redwoodjs#2278)
  Add import type to configuration files (redwoodjs#2214)
  Bump @reach/skip-nav from 0.13.2 to 0.15.0 (redwoodjs#2237)
  Adding Setup Deploy Render Command (redwoodjs#2099)
  Disable role linting in Routes (redwoodjs#2318)
  v0.30.1 (redwoodjs#2322)
  teardown should attempt to delete dbName table (redwoodjs#2083)
  Restore @storybook/addon-a11y (redwoodjs#2309)
  fix(auth): Implement automatic token refresh on supported providers (redwoodjs#2277)
  fix(cli): move api-server dep from api to cli (redwoodjs#2307)
  Static typing for cells (redwoodjs#2208)
  Recommended Babel package upgrades (dependabot) (redwoodjs#2255)
  v0.30.0 (redwoodjs#2301)
  upgrade Prisma v2.21.0 (redwoodjs#2273)
  Further improvements to CONTRIBUTING.md (redwoodjs#2261)
  Adds better messages for rwt link | Watcher does not exist on build failure | Only remove node_modules after a succesful framework build (redwoodjs#2269)
  Update named param types in router readme (redwoodjs#2262)
  Bump core-js from 3.6.5 to 3.10.1 (redwoodjs#2243)
  Fix: webpack optimizations for JS (redwoodjs#2235)
  ...
@thedavidprice thedavidprice added this to the next-release milestone Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript: Generators and Templates tracking issue

4 participants