diff --git a/.gitignore b/.gitignore index a3e7a11d1304bd8e078a121c1b4da5b17e3f6254..bc6d5526099ecb5205e644d603cdd104dc124b79 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ yarn-error.log* /.changelog .npm/ yarn.lock +.eslintcache +packages/cra-template-typescript/template/src/react-app-env.d.ts +packages/cra-template-typescript/template/tsconfig.json \ No newline at end of file diff --git a/package.json b/package.json index e7eaac5d085c6deb3ee634d8c67eb1b3d1eac60f..f26b800c7d501ab5bbd732d7bbc0eb795df0b1fc 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,8 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", + "@types/react": "^17.0.0", + "@types/react-dom": "^17.0.0", "alex": "^8.2.0", "eslint": "^7.11.0", "execa": "1.0.0", @@ -41,6 +43,7 @@ "strip-ansi": "^6.0.0", "svg-term-cli": "^2.1.1", "tempy": "^0.2.1", + "typescript": "^4.1.2", "wait-for-localhost": "^3.3.0", "web-vitals": "^1.0.1" }, diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index 516513081b20619badc031eeb0d5df0608b81870..c08858a391f420ba045abdbd652dee27f8a9bc2a 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -115,7 +115,7 @@ if ( !reactScriptsLinked && __dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1 ) { - const templatePath = '../cra-template/template'; + const templatePath = `../cra-template${process.env.CRA_TEMPLATE_TS_LOCAL ? '-typescript' : ''}/template`; module.exports = { dotenv: resolveOwn(`${templatePath}/.env`), appPath: resolveApp('.'), diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 506df4ff4307470eb961db950d1801827414eabc..f1df52f4ee467edbfc8ea5edd4c1e4225f063eb3 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -138,6 +138,25 @@ CI=true yarn test # Test local start command yarn start --smoke-test +# Run the same tests against with cra-template-typescript +# Test local build command +rm -rf build +CRA_TEMPLATE_TS_LOCAL=true yarn build +# Check for expected output +exists build/*.html +exists build/static/js/*.js +exists build/static/css/*.css +exists build/static/media/*.svg +exists build/favicon.ico + +# Run tests with CI flag +CI=true CRA_TEMPLATE_TS_LOCAL=true yarn test +# Uncomment when snapshot testing is enabled by default: +# exists template/src/__snapshots__/App.test.js.snap + +# Test local start command +CRA_TEMPLATE_TS_LOCAL=true yarn start --smoke-test + # Publish the monorepo publishToLocalRegistry