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

Add template support #7716

Merged
merged 4 commits into from
Oct 24, 2019
Merged

Add template support #7716

merged 4 commits into from
Oct 24, 2019

Conversation

mrmckeb
Copy link
Contributor

@mrmckeb mrmckeb commented Sep 22, 2019

This is an updated version of #6514.

TODO:

  • Revert .gitignore change, as this is likely to cause confusion in future.
  • Improve support for old and forked react-scripts packages.
  • Fix failing tests.
  • Add documentation for this feature.

@mrmckeb mrmckeb force-pushed the feature/templates branch 4 times, most recently from 75c0ac7 to eda43e2 Compare September 22, 2019 18:09
@mrmckeb mrmckeb marked this pull request as ready for review September 22, 2019 18:36
@mrmckeb mrmckeb requested review from iansu and removed request for iansu and petetnt September 22, 2019 18:36
@mrmckeb
Copy link
Contributor Author

mrmckeb commented Sep 22, 2019

@ianschmitz @iansu This PR is working locally, but I have a handful of tests to fix.

It is ready for you to take a look at though, and you can test locally:

node ../create-react-app/packages/create-react-app template-test \
  --template file:../create-react-app/packages/cra-template-typescript/ \
  --scripts-version file:../create-react-app/packages/react-scripts/

e2e-kitchensink-eject was failing on Windows, as we use Git bash and $PWD. I've fixed that here.

e2e-installs targets --scripts-version=1.0.17. This is failing due to the new template being incompatible with our internal testing template. The fix for this will also cover the real case the someone could use the latest create-react-app and a forked or outdated `react-scripts package.

@mrmckeb mrmckeb force-pushed the feature/templates branch 4 times, most recently from fbdd34c to 3964653 Compare September 23, 2019 10:24
tasks/e2e-installs.sh Outdated Show resolved Hide resolved
packages/create-react-app-template-typescript/package.json Outdated Show resolved Hide resolved
@ianschmitz ianschmitz added this to the 3.2 milestone Sep 24, 2019
Copy link
Contributor

@iansu iansu left a comment

Choose a reason for hiding this comment

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

Looks good! I left a few specific comments and also have a few more general thoughts:

  1. This should be behind a flag in 3.x
  2. Naming conventions
    1. create-react-app-template-* is super long. I don't like using cra but maybe cra-template-* is better?
    2. Having to include typescript in the name of a TypeScript template seems not feasible. Maybe check for typescript in the template dependencies?

I'm going to attempt to use your branch to create a custom template next and will probably have more feedback then.

packages/create-react-app-template-typescript/package.json Outdated Show resolved Hide resolved
"url": "https://github.com/facebook/create-react-app/issues"
},
"files": [
"template",
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems a bit weird to have a directory named template inside the template package. Can we put files at the root or maybe in src?

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 tried agree, and I did try that, but this made more sense to me as for whitelisting files to publish. It also means that the project can have a separate README for the published package, vs what's installed with the template.

packages/create-react-app-template-typescript/package.json Outdated Show resolved Hide resolved
packages/create-react-app/createReactApp.js Outdated Show resolved Hide resolved
packages/create-react-app/createReactApp.js Outdated Show resolved Hide resolved
packages/create-react-app/createReactApp.js Show resolved Hide resolved
packages/react-scripts/config/paths.js Outdated Show resolved Hide resolved
packages/react-scripts/scripts/init.js Show resolved Hide resolved
packages/react-scripts/scripts/init.js Show resolved Hide resolved
Copy link
Contributor

@ianschmitz ianschmitz left a comment

Choose a reason for hiding this comment

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

Just to confirm - --scripts-version will still work by itself until v4, correct?

packages/react-scripts/scripts/init.js Show resolved Hide resolved
@mrmckeb
Copy link
Contributor Author

mrmckeb commented Oct 22, 2019

@ianschmitz Correct, everything works without a template for now. A custom script would need to accept the template though, otherwise it would just use the template it has.

@andriijas
Copy link
Contributor

First of all, awesome work! this will be a sweet addition to let others Kickstart apps even faster.

I share the concern of @iansu - the project officially don't use the cra prefix anywhere (?) but on the other hand. Almost everyone just calls the project cra for short.

Is "react-app-" to generic? (Clashes with react-app-rewired which is not a template)

@mrmckeb
Copy link
Contributor Author

mrmckeb commented Oct 23, 2019

@andriijas, we could use a different prefix, but I know a lot of the community use the CRA acronym. I think it's safe to use... create-react-app is very long, react-app is likely to conflict with existing packages, like react-app-template.

This is the best we have I think...

@mrmckeb mrmckeb force-pushed the feature/templates branch 2 times, most recently from 80e40df to b2a869e Compare October 23, 2019 08:25
@andriijas
Copy link
Contributor

@mrmckeb you are right. Let's just acknowledge the community acronym. Excellent work with this! Can't wait to see what kinds of templates the community will bring. Bootstrapping new react apps in 2020 will literally get you productive in seconds!

@petetnt petetnt self-requested a review October 24, 2019 08:07
Copy link
Contributor

@petetnt petetnt left a comment

Choose a reason for hiding this comment

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

Few small comments :)

packages/cra-template-typescript/package.json Outdated Show resolved Hide resolved
if (useTypeScript) {
console.log(
chalk.yellow(
'The --typescript option has been deprecated and will be removed in a future release.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could do, but I can't create short links. @iansu?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have our new shortlinks domain name set up yet. Maybe just make a TODO and we'll add it before the final release.

docusaurus/docs/adding-typescript.md Show resolved Hide resolved
if (useTypeScript) {
console.log(
chalk.yellow(
'The --typescript option has been deprecated and will be removed in a future release.'
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have our new shortlinks domain name set up yet. Maybe just make a TODO and we'll add it before the final release.

@@ -0,0 +1,13 @@
body {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this file for? Was it in the original template?

@@ -1,78 +1,79 @@
#
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole file shows as changed because it previously had windows line endings. 😞

@iansu iansu closed this Oct 24, 2019
@iansu iansu reopened this Oct 24, 2019
@iansu
Copy link
Contributor

iansu commented Oct 24, 2019

Something has gone horribly wrong with our CI here. Appveyor is in the list of checks and we got rid of that like a year ago.

@iansu iansu merged commit 4c0c819 into master Oct 24, 2019
@iansu
Copy link
Contributor

iansu commented Oct 24, 2019

Thanks! ❤️

@ianschmitz ianschmitz deleted the feature/templates branch October 24, 2019 22:33
@lock lock bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants