-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Add template support #7716
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,79 @@ | ||
# | ||
# Azure Pipelines configuration for building and testing create-react-app on Linux, Windows, and macOS. | ||
# | ||
|
||
trigger: | ||
- master | ||
|
||
variables: | ||
CI: true | ||
# Overrides the Yarn and NPM cache directories so they are on the same drive as the source. This helps improve build performance on Windows hosted agents. | ||
YARN_CACHE_FOLDER: $(Build.SourcesDirectory)/../yarn-cache | ||
NPM_CONFIG_CACHE: $(Build.SourcesDirectory)/../npm-cache | ||
# Sets TEMP to be on the same drive as the cloned source on Windows. This avoids test scripts that "cd" into a directory under TEMP from failing because this directory is on a different drive from the current directory. | ||
VSTS_OVERWRITE_TEMP: True | ||
# Override Verdaccio package to use. This is temporary and is needed to avoid socket timeouts on hosted Windows agent (on Azure). This also changes Verdaccio to return a 503 (service unavailable) instead of a 404 (not found) when the connection to the uplink timesout. | ||
VERDACCIO_PACKAGE: https://github.com/willsmythe/verdaccio/releases/download/create-react-app/verdaccio-4.0.0-alpha.8.tgz | ||
|
||
# ****************************************************************************** | ||
# Simple test suite | ||
# ****************************************************************************** | ||
jobs: | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: Simple | ||
testScript: tasks/e2e-simple.sh | ||
|
||
# ****************************************************************************** | ||
# Installs test suite | ||
# ****************************************************************************** | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: Installs | ||
testScript: tasks/e2e-installs.sh | ||
|
||
# ****************************************************************************** | ||
# Kitchensink test suite | ||
# ****************************************************************************** | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: Kitchensink | ||
testScript: tasks/e2e-kitchensink.sh | ||
|
||
# ****************************************************************************** | ||
# Kitchensink Eject test suite | ||
# ****************************************************************************** | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: KitchensinkEject | ||
testScript: tasks/e2e-kitchensink-eject.sh | ||
|
||
# ****************************************************************************** | ||
# Behavior test suite | ||
# ****************************************************************************** | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: Behavior | ||
testScript: tasks/e2e-behavior.sh | ||
configurations: | ||
LinuxNode8: { vmImage: 'ubuntu-16.04', nodeVersion: 8.x } | ||
LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x } | ||
# WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x } | ||
# WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x } | ||
MacNode8: { vmImage: 'macOS-10.13', nodeVersion: 8.x } | ||
MacNode10: { vmImage: 'macOS-10.13', nodeVersion: 10.x } | ||
|
||
# ****************************************************************************** | ||
# Old Node test suite | ||
# ****************************************************************************** | ||
- job: OldNode | ||
pool: | ||
vmImage: ubuntu-16.04 | ||
steps: | ||
- task: NodeTool@0 | ||
inputs: | ||
versionSpec: 6.x | ||
displayName: 'Install Node.js 6.x' | ||
- bash: tasks/e2e-old-node.sh | ||
displayName: 'Run tests' | ||
# | ||
# Azure Pipelines configuration for building and testing create-react-app on Linux, Windows, and macOS. | ||
# | ||
|
||
trigger: | ||
- master | ||
|
||
variables: | ||
CI: true | ||
# Overrides the Yarn and NPM cache directories so they are on the same drive as the source. This helps improve build performance on Windows hosted agents. | ||
YARN_CACHE_FOLDER: $(Build.SourcesDirectory)/../yarn-cache | ||
NPM_CONFIG_CACHE: $(Build.SourcesDirectory)/../npm-cache | ||
# Sets TEMP to be on the same drive as the cloned source on Windows. This avoids test scripts that "cd" into a directory under TEMP from failing because this directory is on a different drive from the current directory. | ||
VSTS_OVERWRITE_TEMP: True | ||
# Override Verdaccio package to use. This is temporary and is needed to avoid socket timeouts on hosted Windows agent (on Azure). This also changes Verdaccio to return a 503 (service unavailable) instead of a 404 (not found) when the connection to the uplink timesout. | ||
VERDACCIO_PACKAGE: https://github.com/willsmythe/verdaccio/releases/download/create-react-app/verdaccio-4.0.0-alpha.8.tgz | ||
CRA_INTERNAL_TEST: true | ||
|
||
# ****************************************************************************** | ||
# Simple test suite | ||
# ****************************************************************************** | ||
jobs: | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: Simple | ||
testScript: tasks/e2e-simple.sh | ||
|
||
# ****************************************************************************** | ||
# Installs test suite | ||
# ****************************************************************************** | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: Installs | ||
testScript: tasks/e2e-installs.sh | ||
|
||
# ****************************************************************************** | ||
# Kitchensink test suite | ||
# ****************************************************************************** | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: Kitchensink | ||
testScript: tasks/e2e-kitchensink.sh | ||
|
||
# ****************************************************************************** | ||
# Kitchensink Eject test suite | ||
# ****************************************************************************** | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: KitchensinkEject | ||
testScript: tasks/e2e-kitchensink-eject.sh | ||
|
||
# ****************************************************************************** | ||
# Behavior test suite | ||
# ****************************************************************************** | ||
- template: azure-pipelines-test-job.yml | ||
parameters: | ||
name: Behavior | ||
testScript: tasks/e2e-behavior.sh | ||
configurations: | ||
LinuxNode8: { vmImage: 'ubuntu-16.04', nodeVersion: 8.x } | ||
LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x } | ||
# WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x } | ||
# WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x } | ||
MacNode8: { vmImage: 'macOS-10.13', nodeVersion: 8.x } | ||
MacNode10: { vmImage: 'macOS-10.13', nodeVersion: 10.x } | ||
|
||
# ****************************************************************************** | ||
# Old Node test suite | ||
# ****************************************************************************** | ||
- job: OldNode | ||
pool: | ||
vmImage: ubuntu-16.04 | ||
steps: | ||
- task: NodeTool@0 | ||
inputs: | ||
versionSpec: 6.x | ||
displayName: 'Install Node.js 6.x' | ||
- bash: tasks/e2e-old-node.sh | ||
displayName: 'Run tests' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,13 +62,33 @@ yarn create react-app my-app | |
|
||
_`yarn create` is available in Yarn 0.25+_ | ||
|
||
### Creating a TypeScript app | ||
### Selecting a template | ||
|
||
Follow our [Adding TypeScript](adding-typescript.md) documentation to create a TypeScript app. | ||
You can now optionally start a new app from a template by appending `--template [template-name]` to the creation command. | ||
|
||
If you don't select a template, we'll create your project with our base template. | ||
|
||
Templates are always named in the format `cra-template-[template-name]`, however you only need to provide the `[template-name]` to the creation command. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to decide on this prefix because it will be hard to change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about tweaking the docs to encourage the base template if the user is new to react? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, we should encourage one of the base templates (JS or TS) for new users. But we can do this during the beta I think, and we'll also talk to other projects to get more templates created. |
||
|
||
```sh | ||
npx create-react-app my-app --template [template-name] | ||
``` | ||
|
||
> You can find a a list of available templates by searching for ["cra-template-\*"](https://www.npmjs.com/search?q=cra-template-*) on npm. | ||
|
||
#### Creating a TypeScript app | ||
|
||
You can start a new TypeScript app using templates. To use our provided TypeScript template, append `--template typescript` to the creation command. | ||
|
||
```sh | ||
npx create-react-app my-app --template typescript | ||
``` | ||
|
||
If you already have a project and would like to add TypeScript, see our [Adding TypeScript](adding-typescript.md) documentation. | ||
|
||
### Selecting a package manager | ||
|
||
When you create a new app, the CLI will use [Yarn](https://yarnpkg.com/) to install dependencies (when available). If you have Yarn installed, but would prefer to use npm, you can append --use-npm to the creation command. For example: | ||
When you create a new app, the CLI will use [Yarn](https://yarnpkg.com/) to install dependencies (when available). If you have Yarn installed, but would prefer to use npm, you can append `--use-npm` to the creation command. For example: | ||
|
||
```sh | ||
npx create-react-app my-app --use-npm | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# cra-template-typescript | ||
|
||
This is the official TypeScript template for [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
To use this template, add `--template typescript` when creating a new app. | ||
|
||
For example: | ||
|
||
```sh | ||
npx create-react-app my-app --template typescript | ||
|
||
# or | ||
|
||
yarn create react-app my-app --template typescript | ||
``` | ||
|
||
For more information, please refer to: | ||
|
||
- [Getting Started](https://create-react-app.dev/docs/getting-started) – How to create a new app. | ||
- [User Guide](https://create-react-app.dev) – How to develop apps bootstrapped with Create React App. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "cra-template-typescript", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
"react", | ||
"create-react-app", | ||
"template", | ||
"typescript" | ||
], | ||
"description": "The base TypeScript template for Create React App.", | ||
"main": "template.json", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/create-react-app.git", | ||
"directory": "packages/cra-template-typescript" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=8.10" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/facebook/create-react-app/issues" | ||
}, | ||
"files": [ | ||
"template", | ||
"template.json" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"dependencies": { | ||
"@types/node": "^12.0.0", | ||
"@types/react": "^16.9.0", | ||
"@types/react-dom": "^16.9.0", | ||
"@types/jest": "^24.0.0", | ||
"typescript": "^3.6.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# cra-template | ||
|
||
This is the official base template for [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
If you don't specify a template (for example, `--template typescript`), this template will be used by default. | ||
|
||
For more information, please refer to: | ||
|
||
- [Getting Started](https://create-react-app.dev/docs/getting-started) – How to create a new app. | ||
- [User Guide](https://create-react-app.dev) – How to develop apps bootstrapped with Create React App. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "cra-template", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
"react", | ||
"create-react-app", | ||
"template" | ||
], | ||
"description": "The base template for Create React App.", | ||
"main": "template.json", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/create-react-app.git", | ||
"directory": "packages/cra-template" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/facebook/create-react-app/issues" | ||
}, | ||
"files": [ | ||
"template", | ||
"template.json" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"dependencies": {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
body { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this file for? Was it in the original template? |
||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
monospace; | ||
} |
There was a problem hiding this comment.
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. 😞