Commit fe7b5c21 authored by Valerii Sorokobatko's avatar Valerii Sorokobatko Committed by Dan Abramov
Browse files

update to modern code style (#1738)

* mv create-react-app/index.js -> create-react-app/creteReactApp.js

* update to modern code style

* var -> cosnt

* set trailing-coma to es5 for prettier
parent 43873dc9
main 3.x add-babel-plugin-optimize-react amyrlam-patch-1 dependabot/npm_and_yarn/follow-redirects-1.14.8 dependabot/npm_and_yarn/nanoid-3.3.1 dependabot/npm_and_yarn/prismjs-1.27.0 feat/audits github-actions-ci github/fork/AMS777/patch-3 github/fork/Aghassi/patch-1 github/fork/AkiJoey/master github/fork/AlexWebLab/patch-1 github/fork/Amila-Rukshan/patch-1 github/fork/AmyShackles/patch-1 github/fork/Andarist/fix/manifest-handle-all-entrypoints github/fork/Andarist/improve-code-comments github/fork/Andarist/patch-2 github/fork/Andarist/remove-babel-core-from-preset-deps github/fork/AriPerkkio/pr/fix-slow-app-creation github/fork/AryaAnish121/patch-1 github/fork/AshmeetSingh987/master github/fork/Ayushparikh-code/patch-1 github/fork/BenBonno/main github/fork/Bluefitdev/master github/fork/Bnaya/webpack-ignore-irrelevant-warnings github/fork/BogdanDor/remove-webpackHotDevClient github/fork/BrainEno/yakai911 github/fork/CarlRibbegaardh/feature/filename github/fork/CarlRibbegaardh/feature/tsconfig-config github/fork/CharlesStover/001 github/fork/ChithurajMsys/patch-1 github/fork/CommanderRoot/refactor/rm-deprecated-substr github/fork/DanielBailey-web/patch-1 github/fork/DavidKessel/website-update github/fork/DemonHa/add-fullySpecified-cofiguration github/fork/Ekwuno/add-cloudflare-pages-to-deploy github/fork/Emanisay/emanisay27-patch-2 github/fork/ErfanMirzapour/master github/fork/FeatherBlack/master github/fork/Ferri0/patch-1 github/fork/FezVrasta/feat/profile-env-variable github/fork/FezVrasta/patch-5 github/fork/FezVrasta/patch-6 github/fork/FezVrasta/wp5-worker-url-plugin github/fork/FloydJohn/fix-browser-env github/fork/FontEndArt/main github/fork/Garciaa94/patch-1 github/fork/GiaKhai/patch-1 github/fork/HAMED-NIYAZI/patch-1 github/fork/Haosik/patch-1 github/fork/HewlettPackard/main github/fork/HollyPony/main github/fork/HugoGEORGET/fix-proxy-middleware-documentation github/fork/HumbertoL/fix/remove-extra-period github/fork/JLHwung/fix-failing-master github/fork/Jarryxin/main github/fork/Jarryxin/wp5 github/fork/JensColman/patch-1 github/fork/Jhinpan/patch-1 github/fork/Jiacheng787/main github/fork/KennethSundqvist/mocking-node-modules github/fork/Kingwl/InlineChunkHtmlPlugin_defer github/fork/KurtGokhan/lint-command github/fork/Lesliemicheal111/patch-1 github/fork/LinusU/disable-tsc-plugin github/fork/M-Usman-Tahir/patch-1 github/fork/M779-star/patch-1 github/fork/Manc/patch github/fork/ManishINN/main github/fork/MarcusMorba/patch-3 github/fork/MartijnHols/fix/12044-dont-install-tailwindcss github/fork/Methuselah96/add-missing-peer-dependencies github/fork/MichaelDeBoey/patch-1 github/fork/MichaelDeBoey/patch-2 github/fork/Mk-Etlinger/patch-2 github/fork/MozhganShafiee/main github/fork/Mrman/core-js-config-change github/fork/Nareshdhori/circleci-project-setup github/fork/NeoLegends/fix/create-element github/fork/NightWalker9/patch-2 github/fork/NoamGaash/patch-1 github/fork/PeteSchuster/patch-1 github/fork/Ph0enixKM/patch-1 github/fork/PranavSenthilnathan/setupProxyTs github/fork/Rahim-Chan/fix/filename github/fork/RakeshPotnuru/patch-1 github/fork/RomainTHD/main github/fork/Seokkitdo/patch-1 github/fork/SiegfriedEhret/patch-1 github/fork/Skyscanner/leop-317-sassfunction github/fork/SyedMuhammedBilal/patch-2 github/fork/SyedMuhammedBilal/patch-4 github/fork/TheAli711/main github/fork/TheLarkInn/feature/organize-config github/fork/TitusEfferian/titusefferian/docs/pre-render github/fork/TrySound/upgrade-svgr-6 github/fork/VNDRMKT/main github/fork/VoloshchenkoAl/babel-plugin-formatjs github/fork/WesCossick/fix-missing-build-error-paths github/fork/YehudaKremer/patch-1 github/fork/YuanXingH/fix/webpack-tsc-compile-on-error github/fork/ace4port/patch-1 github/fork/acusti/template-comment-typo-fix github/fork/adebiyi-al/docs/deployment github/fork/admindivyansh/patch-2 github/fork/adrielcodeco/main github/fork/aixfox/master github/fork/ajbogh/main github/fork/akolade011/dev github/fork/akuji1993/master github/fork/alexandr-g/deps/husky-v5 github/fork/alexkev/running-tests-recommended-wording github/fork/alexxyzeng/main github/fork/allanzi/patch-1 github/fork/amatissart/fix-webpack-config-glob github/fork/amcgee/feat-auto-publicpath github/fork/amehdaly/master github/fork/andrearota/master github/fork/andrzej-erli/patch-1 github/fork/ankitmadhwani24/main github/fork/annie-kat/patch-1 github/fork/antzshrek/master github/fork/anuragarwalkar/patch-1 github/fork/atefBB/patch-1 github/fork/await-ovo/fix-docs-add-typescript github/fork/await-ovo/fix-missing-postcss-plugins github/fork/aymans/patch-1 github/fork/ayush987goyal/pr/chunk-minsize github/fork/barionleg/amyrlam-patch-1 github/fork/barionleg/unpin-babel-loader github/fork/bbrk24/main github/fork/bdenhollander/patch-1 github/fork/behnammodi/total-size github/fork/benjaminr-ps/add-wds-socket-protocol github/fork/benjaminr-ps/patch-1 github/fork/bhardwajhimanshu219/svgr-webpack-version-upgrade github/fork/binary-person/patch-1 github/fork/bkrausz/patch-1 github/fork/bluenote10/bugfix/attempt_to_fix_custom_loader_race_condition github/fork/bmuenzenmeyer/master github/fork/bradjones1/patch-1 github/fork/bradoyler/patch-1 github/fork/breyed/patch-1 github/fork/british-council/fix/yarn-link-lerna github/fork/buuug7/patch-1 github/fork/c-w/remove-style-loader github/fork/camjackson/master github/fork/candrews/dropconsole github/fork/carlosparreno/v5-fix-splitchunks-issue-prod-build github/fork/caub/patch-1 github/fork/ceithir/editorconfig github/fork/chadwithuhc/patch-1 github/fork/challet/patch-launchEditor github/fork/cheesestringer/fix-package-lock-json github/fork/cheesestringer/update-measuring-performance github/fork/christopher-francisco/dart-sass github/fork/chybisov/patch-1 github/fork/cindyledev/issue-7886 github/fork/codybentson2/patch-1 github/fork/cprecioso/no-svgr-url-import github/fork/cszo/homepage-fix github/fork/cybermerlin/hotfix/jest_upgrade github/fork/daceynolan/typescript-ambiet-modules-docs github/fork/dan-valentine/Allow-Proxy-to-be-set-by-environment-variables github/fork/danconnell/react-error-overlay-nonce github/fork/danielmahon/master github/fork/danvc/all_add_multiple_entry_points_1084 github/fork/darthmaim/patch-1 github/fork/daschaa/main github/fork/daylesalmon/patch-1 github/fork/dblazheski96/entry-path-variable github/fork/ddzz/gha-update github/fork/dedo1911/main github/fork/demurgos/fix/12625-ts-node16 github/fork/demurgos/fix/7147-ts-composite github/fork/derbyshire10/main github/fork/devinrhode2/patch-1 github/fork/dilanx/patch-1 github/fork/donnygitsome/main github/fork/draculapile/fix/babel-parser-error github/fork/dtran320/patch-1 github/fork/dylan8902/patch-1 github/fork/easyandme/patch-1 github/fork/eckdanny/docs/add-skip-preflight-check-docs github/fork/elrumordelaluz/patch-1 github/fork/elrumordelaluz/patch-2 github/fork/email2vimalraj/master github/fork/entropitor/fix-no-emit github/fork/etalab/cra-envs github/fork/eventualbuddha/add-@babel/plugin-proposal-private-property-in-object-dependency github/fork/fanny/master github/fork/fivecar/cache_clear_docs github/fork/fkirc/fix_slow_recompile_times github/fork/forana/clear-console github/fork/fupengl/master github/fork/gabrieldejesus/patch-1 github/fork/gaearon/hot-reload-again github/fork/gdethier/main github/fork/geewoo94/config/tailwind github/fork/gergelypap/fix/remove-noopener github/fork/getzelus/patch-1 github/fork/giovannibenussi/loading-indicator github/fork/giovannibenussi/master github/fork/gminova/fix/remove-redundant-imports github/fork/happymonday/master github/fork/hasanayan/module-federation github/fork/herbievine/patch-1 github/fork/hermansje/feat/jsxImportSource github/fork/heygrady/preset-env-modern github/fork/hoangle4/patch-1 github/fork/huyenltnguyen/patch-1 github/fork/iamayushdas/codeblocks github/fork/iamstarkov/patch-1 github/fork/iansu/drop-node-14 github/fork/iansu/node-17-ci github/fork/iansu/worker-loader github/fork/improper/bugfix/version-check-breaks-file-path-usage github/fork/ioloie/enable-write-to-disk github/fork/ivanmcgregor/patch-1 github/fork/izzygld/patch-1 github/fork/jaime-ez/patch-1 github/fork/jakejakeho/patch-1 github/fork/jamescostian/improve-setup-proxy-extension-support github/fork/jamescostian/improve_ts_extension_support github/fork/jameswithers89/patch-1 github/fork/jamidwyer/fix/error-overlay-iframe-axe github/fork/jamirvin/main github/fork/jayeshmann/patch-1 github/fork/jean-smaug/bump-jest-in-react-scripts github/fork/jmgregory/stable-env-var-order github/fork/joeldenning/cjs-support github/fork/joelparkerhenderson/main github/fork/joey-laminar/patch-1 github/fork/johnnyreilly/patch-1 github/fork/jomarquez21/avoid-casting-on-root-element github/fork/jonatanklosko/jk-stdin-close-exit github/fork/joostlubach/joostlubach-open-browser github/fork/judycodes/patch-1 github/fork/jwalton9/main github/fork/karlhorky/patch-1 github/fork/karlhorky/patch-2 github/fork/kavinkuma6/patch-1 github/fork/kaykayehnn/fix-react-error-overlay-ts-errors github/fork/kayuapi/patch-1 github/fork/khalidwaleed0/patch-1 github/fork/kiancross/sass-loader-peer-dep github/fork/kidroca/patch-1 github/fork/kingsmendv/patch-for-pnp github/fork/kitsunekyo/feat/allow-postcss-config-override github/fork/kixxer01/patch-1 github/fork/knopp10000/patch-1 github/fork/kombucha/2378-lint-warning-most-recent-file github/fork/kopyl/patch-1 github/fork/krotovic/master github/fork/krreet/swap-babel-out-with-swc-in-start-build-and-test-2 github/fork/larixer/main github/fork/laxsuryavanshi/main github/fork/ldeninski/bugfix/add-missing-cjs-extension-to-webpack-config github/fork/levrik/editor-detection-wsl github/fork/lfshr/issue-8596/fix-win32-resolve-url-loader github/fork/limal/patch-1 github/fork/llshicc/master github/fork/louy2/patch-1 github/fork/luanorlandi/docs/react-scripts-dependency github/fork/lucabattistini/feat/webpack-svgr-loader github/fork/lucasff/patch-1 github/fork/ludofischer/reduce-noise github/fork/luffy84217/fix-webpack-dev-server-deprecated-option github/fork/luwuer/logo-cannot-be-selected github/fork/luxp/master github/fork/macjabeth/jonathan-picazo github/fork/maksimdegtyarev/remove-react-import github/fork/manavm1990/main github/fork/maoqxxmm/fix/typo github/fork/marcofugaro/cache-directory-jest github/fork/marvelsrp/hotfix-lint-treads github/fork/mcfedr/cjs-support github/fork/mdevils/update-html-entities-with-flow-types github/fork/merceyz/merceyz/fix/missing-dependencies github/fork/milesibastos/patch-1 github/fork/mkarajohn/fix-absolute-paths-in-jest-config-modulePaths github/fork/mmazzarolo/patch-1 github/fork/modernizer-bot/explicit-path-5 github/fork/mohd-akram/add-eslint-context-rule github/fork/morellodev/patch-1 github/fork/mrduguo/main github/fork/mrmckeb/feature/verify-git-package-names github/fork/msaaddev/primary-branch-main github/fork/mwangel/master github/fork/n6g7/custom-host-port github/fork/nategiraudeau/patch-1 github/fork/nattwasm/main github/fork/nfriend/nfriend-add-_redirects-file github/fork/nicgirault/patch-1 github/fork/nickmccurdy/add-prettier-config-to-app github/fork/nickmccurdy/feature/remove-remaining-react-imports github/fork/nickmccurdy/move-e2e-tests-to-github-actions github/fork/nickmccurdy/patch-1 github/fork/nickmccurdy/patch-2 github/fork/nickmccurdy/replace-npx github/fork/nickmccurdy/revert-web-vitals github/fork/nico-martin/manifets-json-to-serviceworker github/fork/nnmax/fix/throwAnUnknowError github/fork/nvh95/file-transform github/fork/omar-bakhsh/patch-1 github/fork/oparaskos/patch-1 github/fork/opencollective/opencollective github/fork/p-avital/patch-2 github/fork/p12tic/fix-dev-server-proxy-broken-origin-header github/fork/pan-alexey/main github/fork/paramt/patch-2 github/fork/pdsouza/patch-1 github/fork/pedr0ni/main github/fork/pedro-demeu/patch-1 github/fork/pedromello/patch-1 github/fork/penx/patch-3 github/fork/ph-fritsche/update-template github/fork/phated/phated/postcss-loader-upgrade github/fork/philn5d-ar/patch-1 github/fork/pnarielwala/patch-1 github/fork/pradhul-dev/patch-1 github/fork/prichodko/feat/modern github/fork/priyankgandhi/patch-1 github/fork/proflayton/brandon/add-no-bin-link-option github/fork/pstrh/pr/increase-css-module-hash-uniqueness github/fork/purelledhand/feat/support-disable-incremental-build github/fork/pushred/resolve-url-loader-v5 github/fork/puxiao/main github/fork/qubbit/patch-1 github/fork/raix/swap-babel-out-with-swc-in-start-build-and-test github/fork/raix/v5-add-back-support-for-node-builtins github/fork/raix/v5-add-react-runtime-aliases github/fork/raix/v5-fix-react-error-overlay-build github/fork/raix/v5-fix-split-chunks-issue-prod-build github/fork/rannn505/patch-1 github/fork/redbmk/full-homepage-url github/fork/revolunet/patch-1 github/fork/rgbutov/patch-2 github/fork/rheh/main github/fork/rluvaton/use-module-ids github/fork/rojo20/react-testing-library-docs github/fork/rpivo/master github/fork/rreckonerr/patch-1 github/fork/rsylvian/patch-1 github/fork/ruckc/websocketurl github/fork/ryo-kagawa/doc-troubleshooting github/fork/ryota-murakami/feat/disableModuleScopePlugin github/fork/ryota-murakami/fix/format github/fork/sashashura/patch-1 github/fork/saurabhjdas786/patch-1 github/fork/saurabhjdas786/patch-2 github/fork/sbindass-deal/patch-1 github/fork/schalkventer/patch-1 github/fork/scottlamb/pr-print-stack github/fork/segheysens/main github/fork/serghei77/patch-1 github/fork/serranom/patch-1 github/fork/sheepsteak/paths github/fork/sheerun/wasm github/fork/shfshanyue/fix-inline-chunk github/fork/shhnjk/main github/fork/shian15810/no-const-enum github/fork/siddhantvirus/master github/fork/siddharthborderwala/patch-1 github/fork/siddtheone/patch-1 github/fork/silvareal/patch-1 github/fork/skoging/patch-2 github/fork/sumanthratna/image-optimization2 github/fork/sunil-sharma-999/main github/fork/svenliebig/master github/fork/swayamTA/test_branch github/fork/tanify/patch-1 github/fork/tanvirstreame/fix-project-directory github/fork/tanvirstreame/update-jest github/fork/tanvirstreame/update-type github/fork/tarikhamilton/patch-1 github/fork/tcope25/patch-1 github/fork/teemezzy/patch-2 github/fork/testower/patch-1 github/fork/tetedacier/patch-1 github/fork/textbook/dont-lint-deps github/fork/th13vn/main github/fork/thexpand/patch-1 github/fork/thisgeek/patch-1 github/fork/tmclo/main github/fork/tobiasbueschel/docs/docusaurus-readme github/fork/tobiasbueschel/master github/fork/tobiasbueschel/refactor/const github/fork/tomvalorsa/patch-1 github/fork/treuherz/main github/fork/trueadm/add-babel-plugin-optimize-react github/fork/unclechu/sandbox/wenzel/customizable-proxy-env-var github/fork/user7564/main github/fork/veltman/unambiguous-sourcetype github/fork/vikr01/fix/babel-env github/fork/viswa84/patch-1 github/fork/vlio20/patch-1 github/fork/webbertakken/patch-1 github/fork/wozzo/master github/fork/wsergent/patch-1 github/fork/xdiegors/patch-2 github/fork/xiaoxiangmoe/master github/fork/xtech-guru/add-less-support github/fork/yamankatby/patch-2 github/fork/yanneves/feature/no-restricted-globals github/fork/yicheny/fix_webpack5_cache_invalidation github/fork/ylemkimon/allowed-hosts github/fork/yvettep321/wp5 github/fork/zalox/master github/fork/zamarawka/feat/css-loacal-ident github/fork/zanemayo/patch-1 github/fork/zenotsai/mr/main/fix_build_cache github/fork/zhaomengfan/main github/fork/zhixiaoqiang/feature/react-dev-utils-export-guessEditor github/fork/zhoujingchao/main github/fork/zingbretsen/mdx-webpack-bugfix github/fork/zjffun/master lk/refactor-tests unpin-babel-loader wp5 v5.0.1 v5.0.0 v4.0.3 v4.0.2 v4.0.1 v4.0.0 v3.4.4 v3.4.3 v3.4.2 v3.4.1 v3.4.0 v3.3.1 v3.3.0 v3.2.0 v3.1.2 v3.1.1 v3.1.0 v3.0.1 v3.0.0 v2.1.8 v2.1.7 v2.1.6 v2.1.5 v2.1.4 v2.1.3 v2.1.2 v2.1.1 v2.1.0 v2.0.5 v2.0.4 v2.0.3 v1.1.5 v1.1.4 v1.1.3 v1.1.2 v1.1.1 v1.1.0 v1.0.17 v1.0.16 v1.0.15 v1.0.13 v1.0.12 v1.0.11 v1.0.10 v1.0.9 v1.0.8 v1.0.7 v1.0.6 v1.0.5 v1.0.4 v1.0.3 v1.0.2 v1.0.1 v1.0.0 reset react-scripts@5.0.1 react-scripts@5.0.0 react-scripts@4.0.3 react-scripts@4.0.2 react-scripts@4.0.1 react-scripts@4.0.0 react-scripts@3.4.1 react-scripts@3.4.0 react-scripts@3.3.1 react-scripts@3.3.0 react-scripts@3.2.0 react-scripts@3.1.2 react-scripts@3.1.1 react-scripts@3.1.0 react-scripts@3.0.1 react-scripts@3.0.0 react-scripts@2.1.8 react-scripts@2.1.7 react-scripts@2.1.6 react-scripts@2.1.5 react-scripts@2.1.4 react-scripts@2.1.3 react-scripts@2.1.2 react-scripts@2.1.1 react-scripts@2.1.0 react-scripts@2.0.4 react-scripts@2.0.3 react-scripts@2.0.2 react-scripts@2.0.1 react-scripts@2.0.0 react-scripts@1.1.4 react-scripts@1.1.3 react-scripts@1.1.2 react-scripts@1.1.1 react-scripts@1.1.0 react-scripts@1.0.17 react-scripts@1.0.16 react-scripts@1.0.15 react-scripts@1.0.14 react-scripts@1.0.13 react-scripts@1.0.12 react-scripts@1.0.11 react-scripts@1.0.10 react-scripts@1.0.9 react-scripts@1.0.8 react-scripts@1.0.7 react-scripts@1.0.6 react-scripts@1.0.5 react-scripts@1.0.4 react-scripts@1.0.3 react-scripts@1.0.2 react-scripts@1.0.1 react-scripts@1.0.0 react-error-overlay@6.0.11 react-error-overlay@6.0.10 react-error-overlay@6.0.9 react-error-overlay@6.0.8 react-error-overlay@6.0.7 react-error-overlay@6.0.6 react-error-overlay@6.0.5 react-error-overlay@6.0.4 react-error-overlay@6.0.3 react-error-overlay@6.0.2 react-error-overlay@6.0.1 react-error-overlay@6.0.0 react-error-overlay@5.1.6 react-error-overlay@5.1.5 react-error-overlay@5.1.4 react-error-overlay@5.1.3 react-error-overlay@5.1.2 react-error-overlay@5.1.1 react-error-overlay@5.1.0 react-error-overlay@5.0.6 react-error-overlay@5.0.4 react-error-overlay@5.0.3 react-error-overlay@5.0.2 react-error-overlay@5.0.1 react-error-overlay@4.0.0 react-error-overlay@3.0.0 react-error-overlay@2.0.2 react-error-overlay@2.0.1 react-error-overlay@2.0.0 react-error-overlay@1.0.10 react-error-overlay@1.0.9 react-error-overlay@1.0.8 react-error-overlay@1.0.7 react-error-overlay@1.0.6 react-error-overlay@1.0.5 react-error-overlay@1.0.4 react-error-overlay@1.0.3 react-error-overlay@1.0.2 react-error-overlay@1.0.1 react-error-overlay@1.0.0 react-dev-utils@12.0.1 react-dev-utils@12.0.0 react-dev-utils@11.0.3 react-dev-utils@11.0.2 react-dev-utils@11.0.1 react-dev-utils@11.0.0 react-dev-utils@10.2.1 react-dev-utils@10.2.0 react-dev-utils@10.1.0 react-dev-utils@10.0.0 react-dev-utils@9.1.0 react-dev-utils@9.0.4 react-dev-utils@9.0.3 react-dev-utils@9.0.2 react-dev-utils@9.0.1 react-dev-utils@9.0.0 react-dev-utils@8.0.0 react-dev-utils@7.0.5 react-dev-utils@7.0.4 react-dev-utils@7.0.3 react-dev-utils@7.0.2 react-dev-utils@7.0.1 react-dev-utils@7.0.0 react-dev-utils@6.1.1 react-dev-utils@6.1.0 react-dev-utils@6.0.4 react-dev-utils@6.0.3 react-dev-utils@6.0.2 react-dev-utils@6.0.1 react-dev-utils@5.0.1 react-dev-utils@5.0.0 react-dev-utils@4.2.1 react-dev-utils@4.2.0 react-dev-utils@4.1.0 react-dev-utils@4.0.1 react-dev-utils@4.0.0 react-dev-utils@3.1.0 react-dev-utils@3.0.2 react-dev-utils@3.0.1 react-dev-utils@3.0.0 react-dev-utils@2.0.1 react-dev-utils@2.0.0 react-dev-utils@1.0.3 react-dev-utils@1.0.2 react-dev-utils@1.0.1 react-dev-utils@1.0.0 react-app-polyfill@3.0.0 react-app-polyfill@2.0.0 react-app-polyfill@1.0.6 react-app-polyfill@1.0.5 react-app-polyfill@1.0.4 react-app-polyfill@1.0.3 react-app-polyfill@1.0.2 react-app-polyfill@1.0.1 react-app-polyfill@1.0.0 react-app-polyfill@0.2.2 react-app-polyfill@0.2.1 react-app-polyfill@0.2.0 react-app-polyfill@0.1.3 react-app-polyfill@0.1.2 react-app-polyfill@0.1.1 eslint-config-react-app@7.0.1 eslint-config-react-app@7.0.0 eslint-config-react-app@6.0.0 eslint-config-react-app@5.2.1 eslint-config-react-app@5.2.0 eslint-config-react-app@5.1.0 eslint-config-react-app@5.0.2 eslint-config-react-app@5.0.1 eslint-config-react-app@5.0.0 eslint-config-react-app@4.0.1 eslint-config-react-app@4.0.0 eslint-config-react-app@3.0.8 eslint-config-react-app@3.0.7 eslint-config-react-app@3.0.6 eslint-config-react-app@3.0.5 eslint-config-react-app@3.0.3 eslint-config-react-app@3.0.2 eslint-config-react-app@3.0.1 eslint-config-react-app@2.1.0 eslint-config-react-app@2.0.1 eslint-config-react-app@2.0.0 eslint-config-react-app@1.0.5 eslint-config-react-app@1.0.4 eslint-config-react-app@1.0.3 eslint-config-react-app@1.0.2 eslint-config-react-app@1.0.1 eslint-config-react-app@1.0.0 create-react-app@5.0.1 create-react-app@5.0.0 create-react-app@4.0.3 create-react-app@4.0.2 create-react-app@4.0.1 create-react-app@4.0.0 create-react-app@3.4.1 create-react-app@3.4.0 create-react-app@3.3.1 create-react-app@3.3.0 create-react-app@3.2.0 create-react-app@3.1.2 create-react-app@3.1.1 create-react-app@3.1.0 create-react-app@3.0.1 create-react-app@3.0.0 create-react-app@2.1.8 create-react-app@2.1.7 create-react-app@2.1.6 create-react-app@2.1.5 create-react-app@2.1.4 create-react-app@2.1.3 create-react-app@2.1.2 create-react-app@2.1.1 create-react-app@2.1.0 create-react-app@2.0.3 create-react-app@2.0.2 create-react-app@2.0.1 create-react-app@1.5.2 create-react-app@1.5.0 create-react-app@1.4.3 create-react-app@1.4.1 create-react-app@1.4.0 create-react-app@1.3.3 create-react-app@1.3.2 create-react-app@1.3.1 cra-template-typescript@1.2.0 cra-template-typescript@1.1.3 cra-template-typescript@1.1.2 cra-template-typescript@1.1.1 cra-template-typescript@1.1.0 cra-template-typescript@1.0.3 cra-template-typescript@1.0.2 cra-template-typescript@1.0.1 cra-template-typescript@1.0.0 cra-template@1.2.0 cra-template@1.1.3 cra-template@1.1.2 cra-template@1.1.1 cra-template@1.1.0 cra-template@1.0.3 cra-template@1.0.2 cra-template@1.0.1 cra-template@1.0.0 confusing-browser-globals@1.0.11 confusing-browser-globals@1.0.10 confusing-browser-globals@1.0.9 confusing-browser-globals@1.0.8 confusing-browser-globals@1.0.7 confusing-browser-globals@1.0.6 confusing-browser-globals@1.0.5 confusing-browser-globals@1.0.3 confusing-browser-globals@1.0.2 babel-preset-react-app@10.0.1 babel-preset-react-app@10.0.0 babel-preset-react-app@9.1.2 babel-preset-react-app@9.1.1 babel-preset-react-app@9.1.0 babel-preset-react-app@9.0.2 babel-preset-react-app@9.0.1 babel-preset-react-app@9.0.0 babel-preset-react-app@8.0.0 babel-preset-react-app@7.0.2 babel-preset-react-app@7.0.1 babel-preset-react-app@7.0.0 babel-preset-react-app@6.1.0 babel-preset-react-app@6.0.0 babel-preset-react-app@5.0.3 babel-preset-react-app@5.0.2 babel-preset-react-app@5.0.1 babel-preset-react-app@5.0.0 babel-preset-react-app@3.1.1 babel-preset-react-app@3.1.0 babel-preset-react-app@3.0.3 babel-preset-react-app@3.0.2 babel-preset-react-app@3.0.1 babel-preset-react-app@3.0.0 babel-plugin-named-asset-import@0.3.8 babel-plugin-named-asset-import@0.3.7 babel-plugin-named-asset-import@0.3.6 babel-plugin-named-asset-import@0.3.5 babel-plugin-named-asset-import@0.3.4 babel-plugin-named-asset-import@0.3.3 babel-plugin-named-asset-import@0.3.2 babel-plugin-named-asset-import@0.3.1 babel-plugin-named-asset-import@0.3.0 babel-plugin-named-asset-import@0.2.3 babel-plugin-named-asset-import@0.2.2 babel-plugin-named-asset-import@0.2.1
4 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file,!1933Add note about installing watchman
Showing with 1063 additions and 860 deletions
+1063 -860
......@@ -8,11 +8,13 @@
"postinstall": "lerna bootstrap",
"publish": "tasks/release.sh",
"start": "node packages/react-scripts/scripts/start.js",
"test": "node packages/react-scripts/scripts/test.js --env=jsdom"
"test": "node packages/react-scripts/scripts/test.js --env=jsdom",
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'"
},
"devDependencies": {
"eslint": "3.16.1",
"lerna": "2.0.0-beta.38",
"lerna-changelog": "^0.2.3"
"lerna-changelog": "^0.2.3",
"prettier": "^0.21.0"
}
}
......@@ -16,21 +16,30 @@ const plugins = [
// The following two plugins use Object.assign directly, instead of Babel's
// extends helper. Note that this assumes `Object.assign` is available.
// { ...todo, completed: true }
[require.resolve('babel-plugin-transform-object-rest-spread'), {
useBuiltIns: true
}],
[
require.resolve('babel-plugin-transform-object-rest-spread'),
{
useBuiltIns: true,
},
],
// Transforms JSX
[require.resolve('babel-plugin-transform-react-jsx'), {
useBuiltIns: true
}],
[
require.resolve('babel-plugin-transform-react-jsx'),
{
useBuiltIns: true,
},
],
// Polyfills the runtime needed for async/await and generators
[require.resolve('babel-plugin-transform-runtime'), {
helpers: false,
polyfill: false,
regenerator: true,
// Resolve the Babel runtime relative to the config.
moduleName: path.dirname(require.resolve('babel-runtime/package'))
}]
[
require.resolve('babel-plugin-transform-runtime'),
{
helpers: false,
polyfill: false,
regenerator: true,
// Resolve the Babel runtime relative to the config.
moduleName: path.dirname(require.resolve('babel-runtime/package')),
},
],
];
// This is similar to how `env` works in Babel:
......@@ -42,9 +51,11 @@ const plugins = [
var env = process.env.BABEL_ENV || process.env.NODE_ENV;
if (env !== 'development' && env !== 'test' && env !== 'production') {
throw new Error(
'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or '+
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' + JSON.stringify(env) + '.'
'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(env) +
'.'
);
}
......@@ -59,7 +70,7 @@ if (env === 'development' || env === 'test') {
// Adds component stack to warning messages
require.resolve('babel-plugin-transform-react-jsx-source'),
// Adds __self attribute to JSX which React will use for some warnings
require.resolve('babel-plugin-transform-react-jsx-self')
require.resolve('babel-plugin-transform-react-jsx-self'),
]);
}
......@@ -67,46 +78,55 @@ if (env === 'test') {
module.exports = {
presets: [
// ES features necessary for user's Node version
[require('babel-preset-env').default, {
targets: {
node: 'current',
[
require('babel-preset-env').default,
{
targets: {
node: 'current',
},
},
}],
],
// JSX, Flow
require.resolve('babel-preset-react')
require.resolve('babel-preset-react'),
],
plugins: plugins.concat([
// Compiles import() to a deferred require()
require.resolve('babel-plugin-dynamic-import-node')
])
require.resolve('babel-plugin-dynamic-import-node'),
]),
};
} else {
module.exports = {
presets: [
// Latest stable ECMAScript features
[require.resolve('babel-preset-env'), {
targets: {
// React parses on ie 9, so we should too
ie: 9,
// We currently minify with uglify
// Remove after https://github.com/mishoo/UglifyJS2/issues/448
uglify: true
[
require.resolve('babel-preset-env'),
{
targets: {
// React parses on ie 9, so we should too
ie: 9,
// We currently minify with uglify
// Remove after https://github.com/mishoo/UglifyJS2/issues/448
uglify: true,
},
// Disable polyfill transforms
useBuiltIns: false,
},
// Disable polyfill transforms
useBuiltIns: false
}],
],
// JSX, Flow
require.resolve('babel-preset-react')
require.resolve('babel-preset-react'),
],
plugins: plugins.concat([
// function* () { yield 42; yield 43; }
[require.resolve('babel-plugin-transform-regenerator'), {
// Async functions are converted to generators by babel-preset-latest
async: false
}],
[
require.resolve('babel-plugin-transform-regenerator'),
{
// Async functions are converted to generators by babel-preset-latest
async: false,
},
],
// Adds syntax support for import()
require.resolve('babel-plugin-syntax-dynamic-import'),
])
]),
};
if (env === 'production') {
......
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
const validateProjectName = require('validate-npm-package-name');
const chalk = require('chalk');
const commander = require('commander');
const fs = require('fs-extra');
const path = require('path');
const execSync = require('child_process').execSync;
const spawn = require('cross-spawn');
const semver = require('semver');
const dns = require('dns');
const tmp = require('tmp');
const unpack = require('tar-pack').unpack;
const hyperquest = require('hyperquest');
let projectName;
const program = commander
.version(require('./package.json').version)
.arguments('<project-directory>')
.usage(`${chalk.green('<project-directory>')} [options]`)
.action(name => {
projectName = name;
})
.option('--verbose', 'print additional logs')
.option(
'--scripts-version <alternative-package>',
'use a non-standard version of react-scripts'
)
.allowUnknownOption()
.on('--help', () => {
console.log(` Only ${chalk.green('<project-directory>')} is required.`);
console.log();
console.log(
` A custom ${chalk.cyan('--scripts-version')} can be one of:`
);
console.log(` - a specific npm version: ${chalk.green('0.8.2')}`);
console.log(
` - a custom fork published on npm: ${chalk.green('my-react-scripts')}`
);
console.log(
` - a .tgz archive: ${chalk.green('https://mysite.com/my-react-scripts-0.8.2.tgz')}`
);
console.log(
` It is not needed unless you specifically want to use a fork.`
);
console.log();
console.log(
` If you have any problems, do not hesitate to file an issue:`
);
console.log(
` ${chalk.cyan('https://github.com/facebookincubator/create-react-app/issues/new')}`
);
console.log();
})
.parse(process.argv);
if (typeof projectName === 'undefined') {
console.error('Please specify the project directory:');
console.log(
` ${chalk.cyan(program.name())} ${chalk.green('<project-directory>')}`
);
console.log();
console.log('For example:');
console.log(` ${chalk.cyan(program.name())} ${chalk.green('my-react-app')}`);
console.log();
console.log(
`Run ${chalk.cyan(`${program.name()} --help`)} to see all options.`
);
process.exit(1);
}
function printValidationResults(results) {
if (typeof results !== 'undefined') {
results.forEach(error => {
console.error(chalk.red(` * ${error}`));
});
}
}
const hiddenProgram = new commander.Command()
.option(
'--internal-testing-template <path-to-template>',
'(internal usage only, DO NOT RELY ON THIS) ' +
'use a non-standard application template'
)
.parse(process.argv);
createApp(
projectName,
program.verbose,
program.scriptsVersion,
hiddenProgram.internalTestingTemplate
);
function createApp(name, verbose, version, template) {
const root = path.resolve(name);
const appName = path.basename(root);
checkAppName(appName);
fs.ensureDirSync(name);
if (!isSafeToCreateProjectIn(root)) {
console.log(
`The directory ${chalk.green(name)} contains files that could conflict.`
);
console.log('Try using a new directory name.');
process.exit(1);
}
console.log(`Creating a new React app in ${chalk.green(root)}.`);
console.log();
const packageJson = {
name: appName,
version: '0.1.0',
private: true,
};
fs.writeFileSync(
path.join(root, 'package.json'),
JSON.stringify(packageJson, null, 2)
);
const originalDirectory = process.cwd();
process.chdir(root);
run(root, appName, version, verbose, originalDirectory, template);
}
function shouldUseYarn() {
try {
execSync('yarnpkg --version', { stdio: 'ignore' });
return true;
} catch (e) {
return false;
}
}
function install(useYarn, dependencies, verbose, isOnline) {
return new Promise((resolve, reject) => {
let command;
let args;
if (useYarn) {
command = 'yarnpkg';
args = ['add', '--exact'];
if (!isOnline) {
args.push('--offline');
}
[].push.apply(args, dependencies);
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'));
console.log(chalk.yellow('Falling back to the local Yarn cache.'));
console.log();
}
} else {
checkNpmVersion();
command = 'npm';
args = ['install', '--save', '--save-exact'].concat(dependencies);
}
if (verbose) {
args.push('--verbose');
}
const child = spawn(command, args, { stdio: 'inherit' });
child.on('close', code => {
if (code !== 0) {
reject({
command: `${command} ${args.join(' ')}`,
});
return;
}
resolve();
});
});
}
function run(root, appName, version, verbose, originalDirectory, template) {
const packageToInstall = getInstallPackage(version);
const allDependencies = ['react', 'react-dom', packageToInstall];
console.log('Installing packages. This might take a couple minutes.');
const useYarn = shouldUseYarn();
getPackageName(packageToInstall)
.then(packageName => checkIfOnline(useYarn).then(isOnline => ({
isOnline: isOnline,
packageName: packageName,
})))
.then(info => {
const isOnline = info.isOnline;
const packageName = info.packageName;
console.log(
`Installing ${chalk.cyan('react')}, ${chalk.cyan('react-dom')}, and ${chalk.cyan(packageName)}...`
);
console.log();
return install(useYarn, allDependencies, verbose, isOnline).then(
() => packageName
);
})
.then(packageName => {
checkNodeVersion(packageName);
// Since react-scripts has been installed with --save
// we need to move it into devDependencies and rewrite package.json
// also ensure react dependencies have caret version range
fixDependencies(packageName);
const scriptsPath = path.resolve(
process.cwd(),
'node_modules',
packageName,
'scripts',
'init.js'
);
const init = require(scriptsPath);
init(root, appName, verbose, originalDirectory, template);
})
.catch(reason => {
console.log();
console.log('Aborting installation.');
if (reason.command) {
console.log(` ${chalk.cyan(reason.command)} has failed.`);
} else {
console.log(chalk.red('Unexpected error. Please report it as a bug:'));
console.log(reason);
}
console.log();
// On 'exit' we will delete these files from target directory.
const knownGeneratedFiles = [
'package.json',
'npm-debug.log',
'yarn-error.log',
'yarn-debug.log',
'node_modules',
];
const currentFiles = fs.readdirSync(path.join(root));
currentFiles.forEach(file => {
knownGeneratedFiles.forEach(fileToMatch => {
// This will catch `(npm-debug|yarn-error|yarn-debug).log*` files
// and the rest of knownGeneratedFiles.
if (
(fileToMatch.match(/.log/g) && file.indexOf(fileToMatch) === 0) ||
file === fileToMatch
) {
console.log(`Deleting generated file... ${chalk.cyan(file)}`);
fs.removeSync(path.join(root, file));
}
});
});
const remainingFiles = fs.readdirSync(path.join(root));
if (!remainingFiles.length) {
// Delete target folder if empty
console.log(
`Deleting ${chalk.cyan(`${appName} /`)} from ${chalk.cyan(path.resolve(root, '..'))}`
);
process.chdir(path.resolve(root, '..'));
fs.removeSync(path.join(root));
}
console.log('Done.');
process.exit(1);
});
}
function getInstallPackage(version) {
let packageToInstall = 'react-scripts';
const validSemver = semver.valid(version);
if (validSemver) {
packageToInstall += `@${validSemver}`;
} else if (version) {
// for tar.gz or alternative paths
packageToInstall = version;
}
return packageToInstall;
}
function getTemporaryDirectory() {
return new Promise((resolve, reject) => {
// Unsafe cleanup lets us recursively delete the directory if it contains
// contents; by default it only allows removal if it's empty
tmp.dir({ unsafeCleanup: true }, (err, tmpdir, callback) => {
if (err) {
reject(err);
} else {
resolve({
tmpdir: tmpdir,
cleanup: () => {
try {
callback();
} catch (ignored) {
// Callback might throw and fail, since it's a temp directory the
// OS will clean it up eventually...
}
},
});
}
});
});
}
function extractStream(stream, dest) {
return new Promise((resolve, reject) => {
stream.pipe(
unpack(dest, err => {
if (err) {
reject(err);
} else {
resolve(dest);
}
})
);
});
}
// Extract package name from tarball url or path.
function getPackageName(installPackage) {
if (installPackage.indexOf('.tgz') > -1) {
return getTemporaryDirectory()
.then(obj => {
let stream;
if (/^http/.test(installPackage)) {
stream = hyperquest(installPackage);
} else {
stream = fs.createReadStream(installPackage);
}
return extractStream(stream, obj.tmpdir).then(() => obj);
})
.then(obj => {
const packageName = require(path.join(obj.tmpdir, 'package.json')).name;
obj.cleanup();
return packageName;
})
.catch(err => {
// The package name could be with or without semver version, e.g. react-scripts-0.2.0-alpha.1.tgz
// However, this function returns package name only without semver version.
console.log(
`Could not extract the package name from the archive: ${err.message}`
);
const assumedProjectName = installPackage.match(
/^.+\/(.+?)(?:-\d+.+)?\.tgz$/
)[1];
console.log(
`Based on the filename, assuming it is "${chalk.cyan(assumedProjectName)}"`
);
return Promise.resolve(assumedProjectName);
});
} else if (installPackage.indexOf('git+') === 0) {
// Pull package name out of git urls e.g:
// git+https://github.com/mycompany/react-scripts.git
// git+ssh://github.com/mycompany/react-scripts.git#v1.2.3
return Promise.resolve(installPackage.match(/([^\/]+)\.git(#.*)?$/)[1]);
} else if (installPackage.indexOf('@') > 0) {
// Do not match @scope/ when stripping off @version or @tag
return Promise.resolve(
installPackage.charAt(0) + installPackage.substr(1).split('@')[0]
);
}
return Promise.resolve(installPackage);
}
function checkNpmVersion() {
let isNpm2 = false;
try {
const npmVersion = execSync('npm --version').toString();
isNpm2 = semver.lt(npmVersion, '3.0.0');
} catch (err) {
return;
}
if (!isNpm2) {
return;
}
console.log(chalk.yellow('It looks like you are using npm 2.'));
console.log(
chalk.yellow(
'We suggest using npm 3 or Yarn for faster install times ' +
'and less disk space usage.'
)
);
console.log();
}
function checkNodeVersion(packageName) {
const packageJsonPath = path.resolve(
process.cwd(),
'node_modules',
packageName,
'package.json'
);
const packageJson = require(packageJsonPath);
if (!packageJson.engines || !packageJson.engines.node) {
return;
}
if (!semver.satisfies(process.version, packageJson.engines.node)) {
console.error(
chalk.red(
'You are running Node %s.\n' +
'Create React App requires Node %s or higher. \n' +
'Please update your version of Node.'
),
process.version,
packageJson.engines.node
);
process.exit(1);
}
}
function checkAppName(appName) {
const validationResult = validateProjectName(appName);
if (!validationResult.validForNewPackages) {
console.error(
`Could not create a project called ${chalk.red(`"${appName}"`)} because of npm naming restrictions:`
);
printValidationResults(validationResult.errors);
printValidationResults(validationResult.warnings);
process.exit(1);
}
// TODO: there should be a single place that holds the dependencies
const dependencies = ['react', 'react-dom'];
const devDependencies = ['react-scripts'];
const allDependencies = dependencies.concat(devDependencies).sort();
if (allDependencies.indexOf(appName) >= 0) {
console.error(
chalk.red(
`We cannot create a project called ${chalk.green(appName)} because a dependency with the same name exists.\n` +
`Due to the way npm works, the following names are not allowed:\n\n`
) +
chalk.cyan(allDependencies.map(depName => ` ${depName}`).join('\n')) +
chalk.red('\n\nPlease choose a different project name.')
);
process.exit(1);
}
}
function makeCaretRange(dependencies, name) {
const version = dependencies[name];
if (typeof version === 'undefined') {
console.error(chalk.red(`Missing ${name} dependency in package.json`));
process.exit(1);
}
let patchedVersion = `^${version}`;
if (!semver.validRange(patchedVersion)) {
console.error(
`Unable to patch ${name} dependency version because version ${chalk.red(version)} will become invalid ${chalk.red(patchedVersion)}`
);
patchedVersion = version;
}
dependencies[name] = patchedVersion;
}
function fixDependencies(packageName) {
const packagePath = path.join(process.cwd(), 'package.json');
const packageJson = require(packagePath);
if (typeof packageJson.dependencies === 'undefined') {
console.error(chalk.red('Missing dependencies in package.json'));
process.exit(1);
}
const packageVersion = packageJson.dependencies[packageName];
if (typeof packageVersion === 'undefined') {
console.error(chalk.red(`Unable to find ${packageName} in package.json`));
process.exit(1);
}
packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies[packageName] = packageVersion;
delete packageJson.dependencies[packageName];
makeCaretRange(packageJson.dependencies, 'react');
makeCaretRange(packageJson.dependencies, 'react-dom');
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
}
// If project only contains files generated by GH, it’s safe.
// We also special case IJ-based products .idea because it integrates with CRA:
// https://github.com/facebookincubator/create-react-app/pull/368#issuecomment-243446094
function isSafeToCreateProjectIn(root) {
const validFiles = [
'.DS_Store',
'Thumbs.db',
'.git',
'.gitignore',
'.idea',
'README.md',
'LICENSE',
'web.iml',
];
return fs.readdirSync(root).every(file => validFiles.indexOf(file) >= 0);
}
function checkIfOnline(useYarn) {
if (!useYarn) {
// Don't ping the Yarn registry.
// We'll just assume the best case.
return Promise.resolve(true);
}
return new Promise(resolve => {
dns.resolve('registry.yarnpkg.com', err => {
resolve(err === null);
});
});
}
......@@ -39,489 +39,19 @@
'use strict';
var chalk = require('chalk');
var validateProjectName = require("validate-npm-package-name");
var currentNodeVersion = process.versions.node;
if (currentNodeVersion.split('.')[0] < 4) {
console.error(
chalk.red(
'You are running Node ' + currentNodeVersion + '.\n' +
'Create React App requires Node 4 or higher. \n' +
'Please update your version of Node.'
'You are running Node ' +
currentNodeVersion +
'.\n' +
'Create React App requires Node 4 or higher. \n' +
'Please update your version of Node.'
)
);
process.exit(1);
}
var commander = require('commander');
var fs = require('fs-extra');
var path = require('path');
var execSync = require('child_process').execSync;
var spawn = require('cross-spawn');
var semver = require('semver');
var dns = require('dns');
var tmp = require('tmp');
var unpack = require('tar-pack').unpack;
var hyperquest = require('hyperquest');
var projectName;
var program = commander
.version(require('./package.json').version)
.arguments('<project-directory>')
.usage(chalk.green('<project-directory>') + ' [options]')
.action(function (name) {
projectName = name;
})
.option('--verbose', 'print additional logs')
.option('--scripts-version <alternative-package>', 'use a non-standard version of react-scripts')
.allowUnknownOption()
.on('--help', function () {
console.log(' Only ' + chalk.green('<project-directory>') + ' is required.');
console.log();
console.log(' A custom ' + chalk.cyan('--scripts-version') + ' can be one of:');
console.log(' - a specific npm version: ' + chalk.green('0.8.2'));
console.log(' - a custom fork published on npm: ' + chalk.green('my-react-scripts'));
console.log(' - a .tgz archive: ' + chalk.green('https://mysite.com/my-react-scripts-0.8.2.tgz'));
console.log(' It is not needed unless you specifically want to use a fork.');
console.log();
console.log(' If you have any problems, do not hesitate to file an issue:');
console.log(' ' + chalk.cyan('https://github.com/facebookincubator/create-react-app/issues/new'));
console.log();
})
.parse(process.argv);
if (typeof projectName === 'undefined') {
console.error('Please specify the project directory:');
console.log(' ' + chalk.cyan(program.name()) + chalk.green(' <project-directory>'));
console.log();
console.log('For example:');
console.log(' ' + chalk.cyan(program.name()) + chalk.green(' my-react-app'));
console.log();
console.log('Run ' + chalk.cyan(program.name() + ' --help') + ' to see all options.');
process.exit(1);
}
function printValidationResults(results) {
if (typeof results !== 'undefined') {
results.forEach(function (error) {
console.error(chalk.red(' * ' + error));
});
}
}
var hiddenProgram = new commander.Command()
.option('--internal-testing-template <path-to-template>', '(internal usage only, DO NOT RELY ON THIS) ' +
'use a non-standard application template')
.parse(process.argv)
createApp(projectName, program.verbose, program.scriptsVersion, hiddenProgram.internalTestingTemplate);
function createApp(name, verbose, version, template) {
var root = path.resolve(name);
var appName = path.basename(root);
checkAppName(appName);
fs.ensureDirSync(name);
if (!isSafeToCreateProjectIn(root)) {
console.log('The directory ' + chalk.green(name) + ' contains files that could conflict.');
console.log('Try using a new directory name.');
process.exit(1);
}
console.log(
'Creating a new React app in ' + chalk.green(root) + '.'
);
console.log();
var packageJson = {
name: appName,
version: '0.1.0',
private: true
};
fs.writeFileSync(
path.join(root, 'package.json'),
JSON.stringify(packageJson, null, 2)
);
var originalDirectory = process.cwd();
process.chdir(root);
run(root, appName, version, verbose, originalDirectory, template);
}
function shouldUseYarn() {
try {
execSync('yarnpkg --version', {stdio: 'ignore'});
return true;
} catch (e) {
return false;
}
}
function install(useYarn, dependencies, verbose, isOnline) {
return new Promise(function(resolve, reject) {
var command;
var args;
if (useYarn) {
command = 'yarnpkg';
args = [
'add',
'--exact',
];
if (!isOnline) {
args.push('--offline');
}
[].push.apply(args, dependencies);
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'));
console.log(chalk.yellow('Falling back to the local Yarn cache.'));
console.log();
}
} else {
checkNpmVersion();
command = 'npm';
args = ['install', '--save', '--save-exact'].concat(dependencies);
}
if (verbose) {
args.push('--verbose');
}
var child = spawn(command, args, {stdio: 'inherit'});
child.on('close', function(code) {
if (code !== 0) {
reject({
command: command + ' ' + args.join(' ')
});
return;
}
resolve();
});
});
}
function run(root, appName, version, verbose, originalDirectory, template) {
var packageToInstall = getInstallPackage(version);
var allDependencies = ['react', 'react-dom', packageToInstall];
console.log('Installing packages. This might take a couple minutes.');
var useYarn = shouldUseYarn();
getPackageName(packageToInstall)
.then(function(packageName) {
return checkIfOnline(useYarn).then(function(isOnline) {
return {
isOnline: isOnline,
packageName: packageName,
};
});
})
.then(function(info) {
var isOnline = info.isOnline;
var packageName = info.packageName;
console.log(
'Installing ' + chalk.cyan('react') + ', ' + chalk.cyan('react-dom') +
', and ' + chalk.cyan(packageName) + '...'
);
console.log();
return install(useYarn, allDependencies, verbose, isOnline).then(function() {
return packageName;
});
})
.then(function(packageName) {
checkNodeVersion(packageName);
// Since react-scripts has been installed with --save
// we need to move it into devDependencies and rewrite package.json
// also ensure react dependencies have caret version range
fixDependencies(packageName);
var scriptsPath = path.resolve(
process.cwd(),
'node_modules',
packageName,
'scripts',
'init.js'
);
var init = require(scriptsPath);
init(root, appName, verbose, originalDirectory, template);
})
.catch(function(reason) {
console.log();
console.log('Aborting installation.');
if (reason.command) {
console.log(' ' + chalk.cyan(reason.command), 'has failed.')
} else {
console.log(chalk.red('Unexpected error. Please report it as a bug:'));
console.log(reason);
}
console.log();
// On 'exit' we will delete these files from target directory.
var knownGeneratedFiles = [
'package.json', 'npm-debug.log', 'yarn-error.log', 'yarn-debug.log', 'node_modules'
];
var currentFiles = fs.readdirSync(path.join(root));
currentFiles.forEach(function (file) {
knownGeneratedFiles.forEach(function (fileToMatch) {
// This will catch `(npm-debug|yarn-error|yarn-debug).log*` files
// and the rest of knownGeneratedFiles.
if ((fileToMatch.match(/.log/g) && file.indexOf(fileToMatch) === 0) || file === fileToMatch) {
console.log('Deleting generated file...', chalk.cyan(file));
fs.removeSync(path.join(root, file));
}
});
});
var remainingFiles = fs.readdirSync(path.join(root));
if (!remainingFiles.length) {
// Delete target folder if empty
console.log('Deleting', chalk.cyan(appName + '/'), 'from', chalk.cyan(path.resolve(root, '..')));
process.chdir(path.resolve(root, '..'));
fs.removeSync(path.join(root));
}
console.log('Done.');
process.exit(1);
});
}
function getInstallPackage(version) {
var packageToInstall = 'react-scripts';
var validSemver = semver.valid(version);
if (validSemver) {
packageToInstall += '@' + validSemver;
} else if (version) {
// for tar.gz or alternative paths
packageToInstall = version;
}
return packageToInstall;
}
function getTemporaryDirectory() {
return new Promise(function(resolve, reject) {
// Unsafe cleanup lets us recursively delete the directory if it contains
// contents; by default it only allows removal if it's empty
tmp.dir({ unsafeCleanup: true }, function(err, tmpdir, callback) {
if (err) {
reject(err);
} else {
resolve({
tmpdir: tmpdir,
cleanup: function() {
try {
callback();
} catch (ignored) {
// Callback might throw and fail, since it's a temp directory the
// OS will clean it up eventually...
}
}
});
}
});
});
}
function extractStream(stream, dest) {
return new Promise(function(resolve, reject) {
stream.pipe(unpack(dest, function(err) {
if (err) {
reject(err);
} else {
resolve(dest);
}
}));
});
}
// Extract package name from tarball url or path.
function getPackageName(installPackage) {
if (installPackage.indexOf('.tgz') > -1) {
return getTemporaryDirectory().then(function(obj) {
var stream;
if (/^http/.test(installPackage)) {
stream = hyperquest(installPackage);
} else {
stream = fs.createReadStream(installPackage);
}
return extractStream(stream, obj.tmpdir).then(function() {
return obj;
});
}).then(function(obj) {
var packageName = require(path.join(obj.tmpdir, 'package.json')).name;
obj.cleanup();
return packageName;
}).catch(function(err) {
// The package name could be with or without semver version, e.g. react-scripts-0.2.0-alpha.1.tgz
// However, this function returns package name only without semver version.
console.log('Could not extract the package name from the archive: ' + err.message);
var assumedProjectName = installPackage.match(/^.+\/(.+?)(?:-\d+.+)?\.tgz$/)[1];
console.log('Based on the filename, assuming it is "' + chalk.cyan(assumedProjectName) + '"');
return Promise.resolve(assumedProjectName);
});
} else if (installPackage.indexOf('git+') === 0) {
// Pull package name out of git urls e.g:
// git+https://github.com/mycompany/react-scripts.git
// git+ssh://github.com/mycompany/react-scripts.git#v1.2.3
return Promise.resolve(installPackage.match(/([^\/]+)\.git(#.*)?$/)[1]);
} else if (installPackage.indexOf('@') > 0) {
// Do not match @scope/ when stripping off @version or @tag
return Promise.resolve(installPackage.charAt(0) + installPackage.substr(1).split('@')[0]);
}
return Promise.resolve(installPackage);
}
function checkNpmVersion() {
var isNpm2 = false;
try {
var npmVersion = execSync('npm --version').toString();
isNpm2 = semver.lt(npmVersion, '3.0.0');
} catch (err) {
return;
}
if (!isNpm2) {
return;
}
console.log(chalk.yellow('It looks like you are using npm 2.'));
console.log(chalk.yellow(
'We suggest using npm 3 or Yarn for faster install times ' +
'and less disk space usage.'
));
console.log();
}
function checkNodeVersion(packageName) {
var packageJsonPath = path.resolve(
process.cwd(),
'node_modules',
packageName,
'package.json'
);
var packageJson = require(packageJsonPath);
if (!packageJson.engines || !packageJson.engines.node) {
return;
}
if (!semver.satisfies(process.version, packageJson.engines.node)) {
console.error(
chalk.red(
'You are running Node %s.\n' +
'Create React App requires Node %s or higher. \n' +
'Please update your version of Node.'
),
process.version,
packageJson.engines.node
);
process.exit(1);
}
}
function checkAppName(appName) {
var validationResult = validateProjectName(appName);
if (!validationResult.validForNewPackages) {
console.error('Could not create a project called ' + chalk.red('"' + appName + '"') + ' because of npm naming restrictions:');
printValidationResults(validationResult.errors);
printValidationResults(validationResult.warnings);
process.exit(1);
}
// TODO: there should be a single place that holds the dependencies
var dependencies = ['react', 'react-dom'];
var devDependencies = ['react-scripts'];
var allDependencies = dependencies.concat(devDependencies).sort();
if (allDependencies.indexOf(appName) >= 0) {
console.error(
chalk.red(
'We cannot create a project called ' + chalk.green(appName) + ' because a dependency with the same name exists.\n' +
'Due to the way npm works, the following names are not allowed:\n\n'
) +
chalk.cyan(
allDependencies.map(function(depName) {
return ' ' + depName;
}).join('\n')
) +
chalk.red('\n\nPlease choose a different project name.')
);
process.exit(1);
}
}
function makeCaretRange(dependencies, name) {
var version = dependencies[name];
if (typeof version === 'undefined') {
console.error(
chalk.red('Missing ' + name + ' dependency in package.json')
);
process.exit(1);
}
var patchedVersion = '^' + version;
if (!semver.validRange(patchedVersion)) {
console.error(
'Unable to patch ' + name + ' dependency version because version ' + chalk.red(version) + ' will become invalid ' + chalk.red(patchedVersion)
);
patchedVersion = version;
}
dependencies[name] = patchedVersion;
}
function fixDependencies(packageName) {
var packagePath = path.join(process.cwd(), 'package.json');
var packageJson = require(packagePath);
if (typeof packageJson.dependencies === 'undefined') {
console.error(
chalk.red('Missing dependencies in package.json')
);
process.exit(1);
}
var packageVersion = packageJson.dependencies[packageName];
if (typeof packageVersion === 'undefined') {
console.error(
chalk.red('Unable to find ' + packageName + ' in package.json')
);
process.exit(1);
}
packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies[packageName] = packageVersion;
delete packageJson.dependencies[packageName];
makeCaretRange(packageJson.dependencies, 'react');
makeCaretRange(packageJson.dependencies, 'react-dom');
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
}
// If project only contains files generated by GH, it’s safe.
// We also special case IJ-based products .idea because it integrates with CRA:
// https://github.com/facebookincubator/create-react-app/pull/368#issuecomment-243446094
function isSafeToCreateProjectIn(root) {
var validFiles = [
'.DS_Store', 'Thumbs.db', '.git', '.gitignore', '.idea', 'README.md', 'LICENSE', 'web.iml'
];
return fs.readdirSync(root)
.every(function(file) {
return validFiles.indexOf(file) >= 0;
});
}
function checkIfOnline(useYarn) {
if (!useYarn) {
// Don't ping the Yarn registry.
// We'll just assume the best case.
return Promise.resolve(true);
}
return new Promise(function(resolve) {
dns.resolve('registry.yarnpkg.com', function(err) {
resolve(err === null);
});
});
}
require('./createReactApp');
......@@ -14,7 +14,8 @@
"url": "https://github.com/facebookincubator/create-react-app/issues"
},
"files": [
"index.js"
"index.js",
"createReactApp.js"
],
"bin": {
"create-react-app": "./index.js"
......
......@@ -30,7 +30,7 @@ module.exports = {
commonjs: true,
es6: true,
jest: true,
node: true
node: true,
},
parserOptions: {
......@@ -39,20 +39,18 @@ module.exports = {
ecmaFeatures: {
jsx: true,
generators: true,
experimentalObjectRestSpread: true
}
experimentalObjectRestSpread: true,
},
},
settings: {
'import/ignore': [
'node_modules'
],
'import/ignore': ['node_modules'],
'import/extensions': ['.js'],
'import/resolver': {
node: {
extensions: ['.js', '.json']
}
}
extensions: ['.js', '.json'],
},
},
},
rules: {
......@@ -89,15 +87,18 @@ module.exports = {
'no-labels': ['warn', { allowLoop: false, allowSwitch: false }],
'no-lone-blocks': 'warn',
'no-loop-func': 'warn',
'no-mixed-operators': ['warn', {
groups: [
['&', '|', '^', '~', '<<', '>>', '>>>'],
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
['&&', '||'],
['in', 'instanceof']
],
allowSamePrecedence: false
}],
'no-mixed-operators': [
'warn',
{
groups: [
['&', '|', '^', '~', '<<', '>>', '>>>'],
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
['&&', '||'],
['in', 'instanceof'],
],
allowSamePrecedence: false,
},
],
'no-multi-str': 'warn',
'no-native-reassign': 'warn',
'no-negated-in-lhs': 'warn',
......@@ -110,11 +111,7 @@ module.exports = {
'no-octal-escape': 'warn',
'no-redeclare': 'warn',
'no-regex-spaces': 'warn',
'no-restricted-syntax': [
'warn',
'LabeledStatement',
'WithStatement',
],
'no-restricted-syntax': ['warn', 'LabeledStatement', 'WithStatement'],
'no-script-url': 'warn',
'no-self-assign': 'warn',
'no-self-compare': 'warn',
......@@ -128,27 +125,36 @@ module.exports = {
'no-restricted-globals': ['error', 'event'],
'no-unexpected-multiline': 'warn',
'no-unreachable': 'warn',
'no-unused-expressions': ['warn', {
'allowShortCircuit': true,
'allowTernary': true
}],
'no-unused-expressions': [
'warn',
{
allowShortCircuit: true,
allowTernary: true,
},
],
'no-unused-labels': 'warn',
'no-unused-vars': ['warn', {
vars: 'local',
varsIgnorePattern: '^_',
args: 'none',
ignoreRestSiblings: true,
}],
'no-unused-vars': [
'warn',
{
vars: 'local',
varsIgnorePattern: '^_',
args: 'none',
ignoreRestSiblings: true,
},
],
'no-use-before-define': ['warn', 'nofunc'],
'no-useless-computed-key': 'warn',
'no-useless-concat': 'warn',
'no-useless-constructor': 'warn',
'no-useless-escape': 'warn',
'no-useless-rename': ['warn', {
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false,
}],
'no-useless-rename': [
'warn',
{
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false,
},
],
'no-with': 'warn',
'no-whitespace-before-property': 'warn',
'operator-assignment': ['warn', 'always'],
......@@ -159,15 +165,19 @@ module.exports = {
'unicode-bom': ['warn', 'never'],
'use-isnan': 'warn',
'valid-typeof': 'warn',
'no-restricted-properties': ['error', {
object: 'require',
property: 'ensure',
message: 'Please use import() instead. More info: https://webpack.js.org/guides/code-splitting-import/#dynamic-import'
}, {
object: 'System',
property: 'import',
message: 'Please use import() instead. More info: https://webpack.js.org/guides/code-splitting-import/#dynamic-import'
}],
'no-restricted-properties': [
'error',
{
object: 'require',
property: 'ensure',
message: 'Please use import() instead. More info: https://webpack.js.org/guides/code-splitting-import/#dynamic-import',
},
{
object: 'System',
property: 'import',
message: 'Please use import() instead. More info: https://webpack.js.org/guides/code-splitting-import/#dynamic-import',
},
],
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/
......@@ -203,10 +213,13 @@ module.exports = {
'react/jsx-equals-spacing': ['warn', 'never'],
'react/jsx-no-duplicate-props': ['warn', { ignoreCase: true }],
'react/jsx-no-undef': 'error',
'react/jsx-pascal-case': ['warn', {
allowAllCaps: true,
ignore: [],
}],
'react/jsx-pascal-case': [
'warn',
{
allowAllCaps: true,
ignore: [],
},
],
'react/jsx-uses-react': 'warn',
'react/jsx-uses-vars': 'warn',
'react/no-danger-with-children': 'warn',
......@@ -226,6 +239,6 @@ module.exports = {
// https://github.com/gajus/eslint-plugin-flowtype
'flowtype/define-flow-type': 'warn',
'flowtype/require-valid-file-annotation': 'warn',
'flowtype/use-flow-type': 'warn'
}
'flowtype/use-flow-type': 'warn',
},
};
......@@ -33,7 +33,7 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap) {
folder: path.join('build', path.dirname(asset.name)),
name: path.basename(asset.name),
size: size,
sizeLabel: filesize(size) + (difference ? ' (' + difference + ')' : '')
sizeLabel: filesize(size) + (difference ? ' (' + difference + ')' : ''),
};
});
assets.sort((a, b) => b.size - a.size);
......@@ -88,12 +88,15 @@ function measureFileSizesBeforeBuild(buildFolder) {
if (!err && fileNames) {
sizes = fileNames
.filter(fileName => /\.(js|css)$/.test(fileName))
.reduce((memo, fileName) => {
var contents = fs.readFileSync(fileName);
var key = removeFileNameHash(buildFolder, fileName);
memo[key] = gzipSize(contents);
return memo;
}, {});
.reduce(
(memo, fileName) => {
var contents = fs.readFileSync(fileName);
var key = removeFileNameHash(buildFolder, fileName);
memo[key] = gzipSize(contents);
return memo;
},
{}
);
}
resolve({
root: buildFolder,
......
......@@ -25,7 +25,8 @@ class InterpolateHtmlPlugin {
apply(compiler) {
compiler.plugin('compilation', compilation => {
compilation.plugin('html-webpack-plugin-before-html-processing',
compilation.plugin(
'html-webpack-plugin-before-html-processing',
(data, callback) => {
// Run HTML through a series of user-specified string replacements.
Object.keys(this.replacements).forEach(key => {
......
......@@ -34,15 +34,15 @@ var base0E = 'a71d5d'; // Keywords, Storage, Selector, Markup Italic, Diff Chang
var colors = {
reset: [base05, 'transparent'],
black: base05,
red: base08, /* marker, bg-invalid */
green: base0B, /* string */
yellow: base08, /* capitalized, jsx_tag, punctuator */
red: base08 /* marker, bg-invalid */,
green: base0B /* string */,
yellow: base08 /* capitalized, jsx_tag, punctuator */,
blue: base0C,
magenta: base0C, /* regex */
cyan: base0E, /* keyword */
gray: base03, /* comment, gutter */
magenta: base0C /* regex */,
cyan: base0E /* keyword */,
gray: base03 /* comment, gutter */,
lightgrey: base01,
darkgrey: base03
darkgrey: base03,
};
var anserMap = {
......@@ -56,20 +56,19 @@ var anserMap = {
'ansi-bright-red': 'red',
'ansi-red': 'red',
'ansi-bright-magenta': 'magenta',
'ansi-magenta': 'magenta'
'ansi-magenta': 'magenta',
};
function ansiHTML(txt) {
var arr = new Anser().ansiToJson(txt, {
use_classes: true
use_classes: true,
});
var result = '';
var open = false;
for (var index = 0; index < arr.length; ++index) {
var c = arr[index];
var content = c.content,
fg = c.fg;
var content = c.content, fg = c.fg;
var contentParts = content.split('\n');
for (var _index = 0; _index < contentParts.length; ++_index) {
......
......@@ -10,7 +10,9 @@
'use strict';
function clearConsole() {
process.stdout.write(process.platform === 'win32' ? '\x1Bc' : '\x1B[2J\x1B[3J\x1B[H');
process.stdout.write(
process.platform === 'win32' ? '\x1Bc' : '\x1B[2J\x1B[3J\x1B[H'
);
}
module.exports = clearConsole;
This diff is collapsed.
......@@ -46,18 +46,15 @@ function formatMessage(message) {
lines = [
lines[0],
// Clean up message because "Module not found: " is descriptive enough.
lines[1].replace(
'Cannot resolve \'file\' or \'directory\' ', ''
).replace(
'Cannot resolve module ', ''
).replace(
'Error: ', ''
),
lines[1]
.replace("Cannot resolve 'file' or 'directory' ", '')
.replace('Cannot resolve module ', '')
.replace('Error: ', ''),
// Skip all irrelevant lines.
// (For some reason they only appear on the client in browser.)
'',
lines[lines.length - 1] // error location is the last line
]
lines[lines.length - 1], // error location is the last line
];
}
// Cleans up syntax error messages.
......@@ -108,7 +105,8 @@ function formatMessage(message) {
// from user code generated by WebPack. For more information see
// https://github.com/facebookincubator/create-react-app/pull/1050
message = message.replace(
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s\)]*(\n|$)/gm, ''
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s\)]*(\n|$)/gm,
''
); // at ... ...:x:y
return message;
......@@ -116,14 +114,14 @@ function formatMessage(message) {
function formatWebpackMessages(json) {
var formattedErrors = json.errors.map(function(message) {
return 'Error in ' + formatMessage(message)
return 'Error in ' + formatMessage(message);
});
var formattedWarnings = json.warnings.map(function(message) {
return 'Warning in ' + formatMessage(message)
return 'Warning in ' + formatMessage(message);
});
var result = {
errors: formattedErrors,
warnings: formattedWarnings
warnings: formattedWarnings,
};
if (result.errors.some(isLikelyASyntaxError)) {
// If there are any syntax errors, show just them.
......
......@@ -18,8 +18,8 @@ var execOptions = {
stdio: [
'pipe', // stdin (default)
'pipe', // stdout (default)
'ignore' //stderr
]
'ignore', //stderr
],
};
function isProcessAReactApp(processCommand) {
......@@ -27,7 +27,10 @@ function isProcessAReactApp(processCommand) {
}
function getProcessIdOnPort(port) {
return execSync('lsof -i:' + port + ' -P -t -sTCP:LISTEN', execOptions).trim();
return execSync(
'lsof -i:' + port + ' -P -t -sTCP:LISTEN',
execOptions
).trim();
}
function getPackageNameInDirectory(directory) {
......@@ -35,26 +38,30 @@ function getPackageNameInDirectory(directory) {
try {
return require(packagePath).name;
} catch(e) {
} catch (e) {
return null;
}
}
function getProcessCommand(processId, processDirectory) {
var command = execSync('ps -o command -p ' + processId + ' | sed -n 2p', execOptions);
var command = execSync(
'ps -o command -p ' + processId + ' | sed -n 2p',
execOptions
);
if (isProcessAReactApp(command)) {
const packageName = getPackageNameInDirectory(processDirectory);
return (packageName) ? packageName + '\n' : command;
return packageName ? packageName + '\n' : command;
} else {
return command;
}
}
function getDirectoryOfProcessById(processId) {
return execSync('lsof -p '+ processId + ' | awk \'$4=="cwd" {print $9}\'', execOptions).trim();
return execSync(
'lsof -p ' + processId + ' | awk \'$4=="cwd" {print $9}\'',
execOptions
).trim();
}
function getProcessForPort(port) {
......@@ -63,10 +70,9 @@ function getProcessForPort(port) {
var directory = getDirectoryOfProcessById(processId);
var command = getProcessCommand(processId, directory);
return chalk.cyan(command) + chalk.blue(' in ') + chalk.cyan(directory);
} catch(e) {
} catch (e) {
return null;
}
}
module.exports = getProcessForPort;
......@@ -30,22 +30,18 @@ function openBrowser(url) {
// requested a different browser, we can try opening
// Chrome with AppleScript. This lets us reuse an
// existing tab when possible instead of creating a new one.
const shouldTryOpenChromeWithAppleScript = (
process.platform === 'darwin' && (
typeof browser !== 'string' ||
browser === OSX_CHROME
)
);
const shouldTryOpenChromeWithAppleScript = process.platform === 'darwin' &&
(typeof browser !== 'string' || browser === OSX_CHROME);
if (shouldTryOpenChromeWithAppleScript) {
try {
// Try our best to reuse existing tab
// on OS X Google Chrome with AppleScript
execSync('ps cax | grep "Google Chrome"');
execSync(
'osascript openChrome.applescript ' + url,
{cwd: __dirname, stdio: 'ignore'}
);
execSync('osascript openChrome.applescript ' + url, {
cwd: __dirname,
stdio: 'ignore',
});
return true;
} catch (err) {
// Ignore errors.
......@@ -59,11 +55,11 @@ function openBrowser(url) {
if (process.platform === 'darwin' && browser === 'open') {
browser = undefined;
}
// Fallback to opn
// (It will always open new tab)
try {
var options = {app: browser};
var options = { app: browser };
opn(url, options).catch(() => {}); // Prevent `unhandledRejection` error.
return true;
} catch (err) {
......
......@@ -16,7 +16,9 @@ var rl = require('readline');
// You can control the behavior on <Enter> with `isYesDefault`.
function prompt(question, isYesDefault) {
if (typeof isYesDefault !== 'boolean') {
throw new Error('Provide explicit boolean isYesDefault as second argument.');
throw new Error(
'Provide explicit boolean isYesDefault as second argument.'
);
}
return new Promise(resolve => {
var rlInterface = rl.createInterface({
......
......@@ -46,7 +46,7 @@ function createOverlayIframe(onIframeLoad) {
}
function addOverlayDivTo(iframe) {
var div = iframe.contentDocument.createElement('div');
var div = iframe.contentDocument.createElement('div');
div.id = 'react-dev-utils-webpack-hot-dev-client-overlay-div';
div.style.position = 'fixed';
div.style.boxSizing = 'border-box';
......@@ -104,8 +104,9 @@ function ensureOverlayDivExists(onOverlayDivReady) {
function showErrorOverlay(message) {
ensureOverlayDivExists(function onOverlayDivReady(overlayDiv) {
// Make it look similar to our terminal.
overlayDiv.innerHTML =
'<span style="color: ' + red + '">Failed to compile.</span><br><br>' +
overlayDiv.innerHTML = '<span style="color: ' +
red +
'">Failed to compile.</span><br><br>' +
ansiHTML(entities.encode(message));
});
}
......@@ -124,13 +125,15 @@ function destroyErrorOverlay() {
}
// Connect to WebpackDevServer via a socket.
var connection = new SockJS(url.format({
protocol: window.location.protocol,
hostname: window.location.hostname,
port: window.location.port,
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node'
}));
var connection = new SockJS(
url.format({
protocol: window.location.protocol,
hostname: window.location.hostname,
port: window.location.port,
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node',
})
);
// Unlike WebpackDevServer client, we won't try to reconnect
// to avoid spamming the console. Disconnect usually happens
......@@ -207,7 +210,7 @@ function handleErrors(errors) {
// "Massage" webpack messages.
var formatted = formatWebpackMessages({
errors: errors,
warnings: []
warnings: [],
});
// Only show the first error.
......@@ -232,27 +235,27 @@ function handleAvailableHash(hash) {
connection.onmessage = function(e) {
var message = JSON.parse(e.data);
switch (message.type) {
case 'hash':
handleAvailableHash(message.data);
break;
case 'still-ok':
case 'ok':
handleSuccess();
break;
case 'content-changed':
// Triggered when a file from `contentBase` changed.
window.location.reload();
break;
case 'warnings':
handleWarnings(message.data);
break;
case 'errors':
handleErrors(message.data);
break;
default:
case 'hash':
handleAvailableHash(message.data);
break;
case 'still-ok':
case 'ok':
handleSuccess();
break;
case 'content-changed':
// Triggered when a file from `contentBase` changed.
window.location.reload();
break;
case 'warnings':
handleWarnings(message.data);
break;
case 'errors':
handleErrors(message.data);
break;
default:
// Do nothing.
}
}
};
// Is there a newer version of this code available?
function isUpdateAvailable() {
......@@ -297,7 +300,7 @@ function tryApplyUpdates(onHotUpdateSuccess) {
}
// https://webpack.github.io/docs/hot-module-replacement.html#check
var result = module.hot.check(/* autoApply */true, handleApplyUpdates);
var result = module.hot.check(/* autoApply */ true, handleApplyUpdates);
// // Webpack 2 returns a Promise instead of invoking a callback
if (result && result.then) {
......
......@@ -15,36 +15,38 @@ var script = process.argv[2];
var args = process.argv.slice(3);
switch (script) {
case 'build':
case 'eject':
case 'start':
case 'test':
var result = spawn.sync(
'node',
[require.resolve('../scripts/' + script)].concat(args),
{stdio: 'inherit'}
);
if (result.signal) {
if (result.signal === 'SIGKILL') {
console.log(
'The build failed because the process exited too early. ' +
'This probably means the system ran out of memory or someone called ' +
'`kill -9` on the process.'
);
} else if (result.signal === 'SIGTERM') {
console.log(
'The build failed because the process exited too early. ' +
'Someone might have called `kill` or `killall`, or the system could ' +
'be shutting down.'
);
case 'build':
case 'eject':
case 'start':
case 'test':
var result = spawn.sync(
'node',
[require.resolve('../scripts/' + script)].concat(args),
{ stdio: 'inherit' }
);
if (result.signal) {
if (result.signal === 'SIGKILL') {
console.log(
'The build failed because the process exited too early. ' +
'This probably means the system ran out of memory or someone called ' +
'`kill -9` on the process.'
);
} else if (result.signal === 'SIGTERM') {
console.log(
'The build failed because the process exited too early. ' +
'Someone might have called `kill` or `killall`, or the system could ' +
'be shutting down.'
);
}
process.exit(1);
}
process.exit(1);
}
process.exit(result.status);
break;
default:
console.log('Unknown script "' + script + '".');
console.log('Perhaps you need to update react-scripts?');
console.log('See: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases');
break;
process.exit(result.status);
break;
default:
console.log('Unknown script "' + script + '".');
console.log('Perhaps you need to update react-scripts?');
console.log(
'See: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases'
);
break;
}
......@@ -12,34 +12,36 @@
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
// injected into the application via DefinePlugin in Webpack configuration.
var REACT_APP = /^REACT_APP_/i;
const REACT_APP = /^REACT_APP_/i;
function getClientEnvironment(publicUrl) {
var raw = Object
.keys(process.env)
const raw = Object.keys(process.env)
.filter(key => REACT_APP.test(key))
.reduce((env, key) => {
env[key] = process.env[key];
return env;
}, {
// Useful for determining whether we’re running in production mode.
// Most importantly, it switches React into the correct mode.
'NODE_ENV': process.env.NODE_ENV || 'development',
// Useful for resolving the correct path to static assets in `public`.
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
// This should only be used as an escape hatch. Normally you would put
// images into the `src` and `import` them in code to get their paths.
'PUBLIC_URL': publicUrl
});
.reduce(
(env, key) => {
env[key] = process.env[key];
return env;
},
{
// Useful for determining whether we’re running in production mode.
// Most importantly, it switches React into the correct mode.
NODE_ENV: process.env.NODE_ENV || 'development',
// Useful for resolving the correct path to static assets in `public`.
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
// This should only be used as an escape hatch. Normally you would put
// images into the `src` and `import` them in code to get their paths.
PUBLIC_URL: publicUrl,
}
);
// Stringify all values so we can feed into Webpack DefinePlugin
var stringified = {
'process.env': Object
.keys(raw)
.reduce((env, key) => {
const stringified = {
'process.env': Object.keys(raw).reduce(
(env, key) => {
env[key] = JSON.stringify(raw[key]);
return env;
}, {})
},
{}
),
};
return { raw, stringified };
......
......@@ -6,12 +6,11 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
const babelJest = require('babel-jest');
module.exports = babelJest.createTransformer({
presets: [require.resolve('babel-preset-react-app')],
babelrc: false
babelrc: false,
});
......@@ -16,6 +16,6 @@ const path = require('path');
module.exports = {
process(src, filename) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
return `module.exports = ${JSON.stringify(path.basename(filename))};`;
},
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment