@authing/react-ui-components 3.0.2-beta.5 → 3.0.3-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/lib/index.d.ts +749 -54
  2. package/lib/index.min.css +2 -2
  3. package/lib/index.min.js +1 -1
  4. package/lib/index.min.js.LICENSE.txt +10 -0
  5. package/package.json +34 -11
  6. package/.eslintignore +0 -6
  7. package/.eslintrc.js +0 -7
  8. package/.prettierrc +0 -5
  9. package/.vscode/settings.json +0 -31
  10. package/build/asset-manifest.json +0 -26
  11. package/build/favicon.ico +0 -0
  12. package/build/index.html +0 -1
  13. package/build/logo192.png +0 -0
  14. package/build/logo512.png +0 -0
  15. package/build/manifest.json +0 -25
  16. package/build/robots.txt +0 -3
  17. package/build/static/css/2.51c07e65.chunk.css +0 -3
  18. package/build/static/css/2.51c07e65.chunk.css.map +0 -1
  19. package/build/static/css/main.779f221a.chunk.css +0 -2
  20. package/build/static/css/main.779f221a.chunk.css.map +0 -1
  21. package/build/static/js/2.bbae9fdb.chunk.js +0 -3
  22. package/build/static/js/2.bbae9fdb.chunk.js.LICENSE.txt +0 -102
  23. package/build/static/js/2.bbae9fdb.chunk.js.map +0 -1
  24. package/build/static/js/3.fd17f196.chunk.js +0 -2
  25. package/build/static/js/3.fd17f196.chunk.js.map +0 -1
  26. package/build/static/js/main.5f341531.chunk.js +0 -2
  27. package/build/static/js/main.5f341531.chunk.js.map +0 -1
  28. package/build/static/js/runtime-main.ef138021.js +0 -2
  29. package/build/static/js/runtime-main.ef138021.js.map +0 -1
  30. package/build/static/media/loading.4a67a5f3.svg +0 -29
  31. package/components/AuthingDropdown/index.tsx +0 -52
  32. package/components/AuthingDropdown/style.less +0 -43
  33. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  34. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  35. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  36. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  37. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  38. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  39. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  40. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  43. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  44. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  45. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  46. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  47. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  48. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  49. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  50. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  53. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  54. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  55. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  56. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  57. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  58. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  59. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  60. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  61. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  62. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  63. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  67. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  68. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  69. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  70. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  71. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  72. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  73. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  76. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  77. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  78. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  79. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  80. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  81. package/components/AuthingGuard/Forms/index.ts +0 -13
  82. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  83. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  84. package/components/AuthingGuard/Header/index.tsx +0 -25
  85. package/components/AuthingGuard/Header/style.less +0 -52
  86. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  87. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  88. package/components/AuthingGuard/IconFont/style.less +0 -6
  89. package/components/AuthingGuard/IconFont/svg.js +0 -2
  90. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  91. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  92. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  93. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  94. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  95. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  96. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  97. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  98. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  99. package/components/AuthingGuard/api/appConfig.ts +0 -146
  100. package/components/AuthingGuard/api/index.ts +0 -3
  101. package/components/AuthingGuard/api/sso.ts +0 -29
  102. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  103. package/components/AuthingGuard/constants.ts +0 -107
  104. package/components/AuthingGuard/hooks/index.tsx +0 -70
  105. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  106. package/components/AuthingGuard/index.tsx +0 -126
  107. package/components/AuthingGuard/style.less +0 -103
  108. package/components/AuthingGuard/types/Forms.ts +0 -94
  109. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  110. package/components/AuthingGuard/types/GuardState.ts +0 -7
  111. package/components/AuthingGuard/types/Locales.ts +0 -12
  112. package/components/AuthingGuard/types/index.ts +0 -4
  113. package/components/AuthingTabs/index.tsx +0 -98
  114. package/components/AuthingTabs/style.less +0 -135
  115. package/components/BindTotp/core/bindSuccess.tsx +0 -72
  116. package/components/BindTotp/core/securityCode.tsx +0 -108
  117. package/components/BindTotp/index.tsx +0 -134
  118. package/components/BindTotp/interface.ts +0 -30
  119. package/components/BindTotp/styles.less +0 -57
  120. package/components/ChangeLanguage/index.tsx +0 -35
  121. package/components/ChangePassword/core/firstLoginReset.tsx +0 -111
  122. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  123. package/components/ChangePassword/index.tsx +0 -72
  124. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  125. package/components/CompleteInfo/index.tsx +0 -45
  126. package/components/CompleteInfo/interface.ts +0 -40
  127. package/components/CompleteInfo/styles.less +0 -7
  128. package/components/CopyAbleText/index.tsx +0 -54
  129. package/components/CopyAbleText/style.less +0 -13
  130. package/components/DownloadAuthenticator/index.tsx +0 -97
  131. package/components/DownloadAuthenticator/interface.ts +0 -22
  132. package/components/DownloadAuthenticator/styles.less +0 -52
  133. package/components/Error/index.tsx +0 -21
  134. package/components/Error/interface.ts +0 -9
  135. package/components/Error/styles.less +0 -12
  136. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  137. package/components/ForgetPassword/index.tsx +0 -78
  138. package/components/ForgetPassword/interface.ts +0 -32
  139. package/components/Guard/Guard.tsx +0 -295
  140. package/components/Guard/authClient.ts +0 -44
  141. package/components/Guard/config.ts +0 -19
  142. package/components/Guard/event.ts +0 -52
  143. package/components/Guard/index.tsx +0 -4
  144. package/components/Guard/module.ts +0 -20
  145. package/components/Guard/stateMachine.ts +0 -152
  146. package/components/Guard/styles.less +0 -461
  147. package/components/IconFont/iconfont.js +0 -74
  148. package/components/IconFont/index.tsx +0 -16
  149. package/components/IconFont/style.less +0 -6
  150. package/components/IconFont/svg.js +0 -2
  151. package/components/ImagePro/index.tsx +0 -53
  152. package/components/ImagePro/styles.less +0 -40
  153. package/components/InputNumber/index.tsx +0 -33
  154. package/components/Login/codemap.ts +0 -49
  155. package/components/Login/core/withAD.tsx +0 -9
  156. package/components/Login/core/withAppQrcode.tsx +0 -49
  157. package/components/Login/core/withLDAP.tsx +0 -146
  158. package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
  159. package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -30
  160. package/components/Login/core/withPassword/InputAccount.tsx +0 -64
  161. package/components/Login/core/withPassword/index.tsx +0 -173
  162. package/components/Login/core/withPhonecode.tsx +0 -122
  163. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  164. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  165. package/components/Login/index.tsx +0 -374
  166. package/components/Login/props.ts +0 -74
  167. package/components/Login/socialLogin/index.tsx +0 -407
  168. package/components/Login/socialLogin/style.less +0 -69
  169. package/components/Login/styles.less +0 -53
  170. package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
  171. package/components/MFA/VerifyCodeInput/index.tsx +0 -145
  172. package/components/MFA/VerifyCodeInput/style.less +0 -35
  173. package/components/MFA/codemap.ts +0 -24
  174. package/components/MFA/core/email.tsx +0 -203
  175. package/components/MFA/core/face.tsx +0 -297
  176. package/components/MFA/core/face_deps.tsx +0 -37
  177. package/components/MFA/core/sms.tsx +0 -203
  178. package/components/MFA/core/totp.tsx +0 -122
  179. package/components/MFA/index.tsx +0 -143
  180. package/components/MFA/mfaMethods/index.tsx +0 -88
  181. package/components/MFA/mfaMethods/style.less +0 -39
  182. package/components/MFA/props.ts +0 -51
  183. package/components/MFA/styles.less +0 -100
  184. package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
  185. package/components/NeedHelpView/index.tsx +0 -47
  186. package/components/RecoveryCode/core/useCode.tsx +0 -71
  187. package/components/RecoveryCode/index.tsx +0 -27
  188. package/components/RecoveryCode/interface.ts +0 -31
  189. package/components/RecoveryCode/style.less +0 -13
  190. package/components/Register/codemap.ts +0 -12
  191. package/components/Register/components/Agreements/index.tsx +0 -81
  192. package/components/Register/components/Agreements/style.less +0 -44
  193. package/components/Register/core/WithEmail.tsx +0 -242
  194. package/components/Register/core/WithPhone.tsx +0 -184
  195. package/components/Register/index.tsx +0 -139
  196. package/components/Register/props.ts +0 -50
  197. package/components/SendCode/SendCodeBtn.tsx +0 -96
  198. package/components/SendCode/index.tsx +0 -94
  199. package/components/SendCode/style.less +0 -31
  200. package/components/ShieldSpin/index.tsx +0 -27
  201. package/components/ShieldSpin/loading.svg +0 -29
  202. package/components/SubmitButton/index.tsx +0 -50
  203. package/components/SubmitSuccess/index.tsx +0 -66
  204. package/components/SubmitSuccess/interface.ts +0 -17
  205. package/components/Type/index.ts +0 -52
  206. package/components/ValidatorRules/ValidatorFormItem.tsx +0 -139
  207. package/components/ValidatorRules/index.ts +0 -20
  208. package/components/VerifyCodeInput/index.tsx +0 -76
  209. package/components/VerifyCodeInput/style.less +0 -24
  210. package/components/_utils/GuardErrorCode.ts +0 -9
  211. package/components/_utils/clipboard.ts +0 -27
  212. package/components/_utils/config.ts +0 -116
  213. package/components/_utils/guradHttp.ts +0 -101
  214. package/components/_utils/hooks/index.ts +0 -64
  215. package/components/_utils/http.ts +0 -85
  216. package/components/_utils/index.ts +0 -326
  217. package/components/_utils/locales/en/common.json +0 -229
  218. package/components/_utils/locales/en/index.ts +0 -6
  219. package/components/_utils/locales/en/login.json +0 -96
  220. package/components/_utils/locales/en/map.json +0 -4
  221. package/components/_utils/locales/en/user.json +0 -82
  222. package/components/_utils/locales/index.ts +0 -45
  223. package/components/_utils/locales/zh/common.json +0 -229
  224. package/components/_utils/locales/zh/index.ts +0 -6
  225. package/components/_utils/locales/zh/login.json +0 -96
  226. package/components/_utils/locales/zh/map.json +0 -4
  227. package/components/_utils/locales/zh/user.json +0 -83
  228. package/components/_utils/popupCenter.ts +0 -48
  229. package/components/assets/images/error.png +0 -0
  230. package/components/context/base.tsx +0 -28
  231. package/components/context/global/context.tsx +0 -39
  232. package/components/context/global/reducer.tsx +0 -56
  233. package/components/context/module/context.tsx +0 -23
  234. package/components/index.ts +0 -12
  235. package/config/antdReplacer.js +0 -51
  236. package/config/env.js +0 -104
  237. package/config/getHttpsConfig.js +0 -66
  238. package/config/jest/cssTransform.js +0 -14
  239. package/config/jest/fileTransform.js +0 -40
  240. package/config/modules.js +0 -134
  241. package/config/paths.js +0 -71
  242. package/config/pnpTs.js +0 -35
  243. package/config/webpack.config.js +0 -835
  244. package/config/webpackDevServer.config.js +0 -130
  245. package/examples.tsx +0 -87
  246. package/index.js +0 -1
  247. package/logo.svg +0 -7
  248. package/public/favicon.ico +0 -0
  249. package/public/index.html +0 -43
  250. package/public/logo192.png +0 -0
  251. package/public/logo512.png +0 -0
  252. package/public/manifest.json +0 -25
  253. package/public/robots.txt +0 -3
  254. package/react-app-env.d.ts +0 -71
  255. package/reportWebVitals.ts +0 -15
  256. package/scripts/build.js +0 -208
  257. package/scripts/lib.js +0 -200
  258. package/scripts/publish.js +0 -57
  259. package/scripts/start.js +0 -162
  260. package/scripts/test.js +0 -49
  261. package/setupTests.ts +0 -5
  262. package/tsconfig.json +0 -30
@@ -1,51 +0,0 @@
1
- /**
2
- * 全面提高 antd 样式优先级
3
- * https://juejin.cn/post/6844904116288749581#heading-8
4
- * https://github.com/fi3ework/postcss-rename-selector/blob/master/src/presets/antd.ts
5
- * */
6
-
7
- const parser = require('postcss-selector-parser')
8
-
9
- function antdScopeReplacerFn(node) {
10
- if (node.type !== 'selector') return
11
-
12
- const firstAntClassNodeIndex = node.nodes.findIndex((n) => {
13
- return n.type === 'class' && n.value.startsWith('authing-')
14
- })
15
- if (firstAntClassNodeIndex < 0) return
16
-
17
- const firstAntClassNode = node.nodes[firstAntClassNodeIndex]
18
- const prevNode = node.nodes[firstAntClassNodeIndex - 1]
19
-
20
- // preserve line break
21
- const spaces = {
22
- before: firstAntClassNode.rawSpaceBefore,
23
- after: firstAntClassNode.rawSpaceAfter,
24
- }
25
-
26
- firstAntClassNode.setPropertyWithoutEscape('rawSpaceBefore', '')
27
- const toInsert = []
28
-
29
- if (firstAntClassNodeIndex === 0 || prevNode.type === 'combinator') {
30
- const universal = parser.universal({
31
- value: '*',
32
- })
33
- toInsert.push(universal)
34
- }
35
-
36
- const attr = parser.attribute({
37
- attribute: 'class',
38
- operator: '*=',
39
- value: `"authing-"`,
40
- raws: {},
41
- })
42
-
43
- toInsert.push(attr)
44
- toInsert[0].spaces = spaces
45
-
46
- firstAntClassNode.parent.nodes.splice(firstAntClassNodeIndex, 0, ...toInsert)
47
- }
48
-
49
- module.exports = {
50
- antdScopeReplacerFn,
51
- }
package/config/env.js DELETED
@@ -1,104 +0,0 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
- const paths = require('./paths')
4
-
5
- // Make sure that including paths.js after env.js will read .env variables.
6
- delete require.cache[require.resolve('./paths')]
7
-
8
- const NODE_ENV = process.env.NODE_ENV
9
- if (!NODE_ENV) {
10
- throw new Error(
11
- 'The NODE_ENV environment variable is required but was not specified.'
12
- )
13
- }
14
-
15
- // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
16
- const dotenvFiles = [
17
- `${paths.dotenv}.${NODE_ENV}.local`,
18
- // Don't include `.env.local` for `test` environment
19
- // since normally you expect tests to produce the same
20
- // results for everyone
21
- NODE_ENV !== 'test' && `${paths.dotenv}.local`,
22
- `${paths.dotenv}.${NODE_ENV}`,
23
- paths.dotenv,
24
- ].filter(Boolean)
25
-
26
- // Load environment variables from .env* files. Suppress warnings using silent
27
- // if this file is missing. dotenv will never modify any environment variables
28
- // that have already been set. Variable expansion is supported in .env files.
29
- // https://github.com/motdotla/dotenv
30
- // https://github.com/motdotla/dotenv-expand
31
- dotenvFiles.forEach((dotenvFile) => {
32
- if (fs.existsSync(dotenvFile)) {
33
- require('dotenv-expand')(
34
- require('dotenv').config({
35
- path: dotenvFile,
36
- })
37
- )
38
- }
39
- })
40
-
41
- // We support resolving modules according to `NODE_PATH`.
42
- // This lets you use absolute paths in imports inside large monorepos:
43
- // https://github.com/facebook/create-react-app/issues/253.
44
- // It works similar to `NODE_PATH` in Node itself:
45
- // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
46
- // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
47
- // Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
48
- // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
49
- // We also resolve them to make sure all tools using them work consistently.
50
- const appDirectory = fs.realpathSync(process.cwd())
51
- process.env.NODE_PATH = (process.env.NODE_PATH || '')
52
- .split(path.delimiter)
53
- .filter((folder) => folder && !path.isAbsolute(folder))
54
- .map((folder) => path.resolve(appDirectory, folder))
55
- .join(path.delimiter)
56
-
57
- // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
58
- // injected into the application via DefinePlugin in webpack configuration.
59
- const REACT_APP = /^REACT_APP_/i
60
-
61
- function getClientEnvironment(publicUrl) {
62
- const raw = Object.keys(process.env)
63
- .filter((key) => REACT_APP.test(key))
64
- .reduce(
65
- (env, key) => {
66
- env[key] = process.env[key]
67
- return env
68
- },
69
- {
70
- // Useful for determining whether we’re running in production mode.
71
- // Most importantly, it switches React into the correct mode.
72
- NODE_ENV: process.env.NODE_ENV || 'development',
73
- // Useful for resolving the correct path to static assets in `public`.
74
- // For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
75
- // This should only be used as an escape hatch. Normally you would put
76
- // images into the `src` and `import` them in code to get their paths.
77
- PUBLIC_URL: publicUrl,
78
- // We support configuring the sockjs pathname during development.
79
- // These settings let a developer run multiple simultaneous projects.
80
- // They are used as the connection `hostname`, `pathname` and `port`
81
- // in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
82
- // and `sockPort` options in webpack-dev-server.
83
- WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
84
- WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
85
- WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
86
- // Whether or not react-refresh is enabled.
87
- // react-refresh is not 100% stable at this time,
88
- // which is why it's disabled by default.
89
- // It is defined here so it is available in the webpackHotDevClient.
90
- FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
91
- }
92
- )
93
- // Stringify all values so we can feed into webpack DefinePlugin
94
- const stringified = {
95
- 'process.env': Object.keys(raw).reduce((env, key) => {
96
- env[key] = JSON.stringify(raw[key])
97
- return env
98
- }, {}),
99
- }
100
-
101
- return { raw, stringified }
102
- }
103
-
104
- module.exports = getClientEnvironment
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const crypto = require('crypto');
6
- const chalk = require('react-dev-utils/chalk');
7
- const paths = require('./paths');
8
-
9
- // Ensure the certificate and key provided are valid and if not
10
- // throw an easy to debug error
11
- function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
12
- let encrypted;
13
- try {
14
- // publicEncrypt will throw an error with an invalid cert
15
- encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
16
- } catch (err) {
17
- throw new Error(
18
- `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
19
- );
20
- }
21
-
22
- try {
23
- // privateDecrypt will throw an error with an invalid key
24
- crypto.privateDecrypt(key, encrypted);
25
- } catch (err) {
26
- throw new Error(
27
- `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
28
- err.message
29
- }`
30
- );
31
- }
32
- }
33
-
34
- // Read file and throw an error if it doesn't exist
35
- function readEnvFile(file, type) {
36
- if (!fs.existsSync(file)) {
37
- throw new Error(
38
- `You specified ${chalk.cyan(
39
- type
40
- )} in your env, but the file "${chalk.yellow(file)}" can't be found.`
41
- );
42
- }
43
- return fs.readFileSync(file);
44
- }
45
-
46
- // Get the https config
47
- // Return cert files if provided in env, otherwise just true or false
48
- function getHttpsConfig() {
49
- const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
50
- const isHttps = HTTPS === 'true';
51
-
52
- if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
53
- const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
54
- const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
55
- const config = {
56
- cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
57
- key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
58
- };
59
-
60
- validateKeyAndCerts({ ...config, keyFile, crtFile });
61
- return config;
62
- }
63
- return isHttps;
64
- }
65
-
66
- module.exports = getHttpsConfig;
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- // This is a custom Jest transformer turning style imports into empty objects.
4
- // http://facebook.github.io/jest/docs/en/webpack.html
5
-
6
- module.exports = {
7
- process() {
8
- return 'module.exports = {};';
9
- },
10
- getCacheKey() {
11
- // The output is always the same.
12
- return 'cssTransform';
13
- },
14
- };
@@ -1,40 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const camelcase = require('camelcase');
5
-
6
- // This is a custom Jest transformer turning file imports into filenames.
7
- // http://facebook.github.io/jest/docs/en/webpack.html
8
-
9
- module.exports = {
10
- process(src, filename) {
11
- const assetFilename = JSON.stringify(path.basename(filename));
12
-
13
- if (filename.match(/\.svg$/)) {
14
- // Based on how SVGR generates a component name:
15
- // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16
- const pascalCaseFilename = camelcase(path.parse(filename).name, {
17
- pascalCase: true,
18
- });
19
- const componentName = `Svg${pascalCaseFilename}`;
20
- return `const React = require('react');
21
- module.exports = {
22
- __esModule: true,
23
- default: ${assetFilename},
24
- ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25
- return {
26
- $$typeof: Symbol.for('react.element'),
27
- type: 'svg',
28
- ref: ref,
29
- key: null,
30
- props: Object.assign({}, props, {
31
- children: ${assetFilename}
32
- })
33
- };
34
- }),
35
- };`;
36
- }
37
-
38
- return `module.exports = ${assetFilename};`;
39
- },
40
- };
package/config/modules.js DELETED
@@ -1,134 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const paths = require('./paths');
6
- const chalk = require('react-dev-utils/chalk');
7
- const resolve = require('resolve');
8
-
9
- /**
10
- * Get additional module paths based on the baseUrl of a compilerOptions object.
11
- *
12
- * @param {Object} options
13
- */
14
- function getAdditionalModulePaths(options = {}) {
15
- const baseUrl = options.baseUrl;
16
-
17
- if (!baseUrl) {
18
- return '';
19
- }
20
-
21
- const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
22
-
23
- // We don't need to do anything if `baseUrl` is set to `node_modules`. This is
24
- // the default behavior.
25
- if (path.relative(paths.appNodeModules, baseUrlResolved) === '') {
26
- return null;
27
- }
28
-
29
- // Allow the user set the `baseUrl` to `appSrc`.
30
- if (path.relative(paths.appSrc, baseUrlResolved) === '') {
31
- return [paths.appSrc];
32
- }
33
-
34
- // If the path is equal to the root directory we ignore it here.
35
- // We don't want to allow importing from the root directly as source files are
36
- // not transpiled outside of `src`. We do allow importing them with the
37
- // absolute path (e.g. `src/Components/Button.js`) but we set that up with
38
- // an alias.
39
- if (path.relative(paths.appPath, baseUrlResolved) === '') {
40
- return null;
41
- }
42
-
43
- // Otherwise, throw an error.
44
- throw new Error(
45
- chalk.red.bold(
46
- "Your project's `baseUrl` can only be set to `src` or `node_modules`." +
47
- ' Create React App does not support other values at this time.'
48
- )
49
- );
50
- }
51
-
52
- /**
53
- * Get webpack aliases based on the baseUrl of a compilerOptions object.
54
- *
55
- * @param {*} options
56
- */
57
- function getWebpackAliases(options = {}) {
58
- const baseUrl = options.baseUrl;
59
-
60
- if (!baseUrl) {
61
- return {};
62
- }
63
-
64
- const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
65
-
66
- if (path.relative(paths.appPath, baseUrlResolved) === '') {
67
- return {
68
- src: paths.appSrc,
69
- };
70
- }
71
- }
72
-
73
- /**
74
- * Get jest aliases based on the baseUrl of a compilerOptions object.
75
- *
76
- * @param {*} options
77
- */
78
- function getJestAliases(options = {}) {
79
- const baseUrl = options.baseUrl;
80
-
81
- if (!baseUrl) {
82
- return {};
83
- }
84
-
85
- const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
86
-
87
- if (path.relative(paths.appPath, baseUrlResolved) === '') {
88
- return {
89
- '^src/(.*)$': '<rootDir>/src/$1',
90
- };
91
- }
92
- }
93
-
94
- function getModules() {
95
- // Check if TypeScript is setup
96
- const hasTsConfig = fs.existsSync(paths.appTsConfig);
97
- const hasJsConfig = fs.existsSync(paths.appJsConfig);
98
-
99
- if (hasTsConfig && hasJsConfig) {
100
- throw new Error(
101
- 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.'
102
- );
103
- }
104
-
105
- let config;
106
-
107
- // If there's a tsconfig.json we assume it's a
108
- // TypeScript project and set up the config
109
- // based on tsconfig.json
110
- if (hasTsConfig) {
111
- const ts = require(resolve.sync('typescript', {
112
- basedir: paths.appNodeModules,
113
- }));
114
- config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config;
115
- // Otherwise we'll check if there is jsconfig.json
116
- // for non TS projects.
117
- } else if (hasJsConfig) {
118
- config = require(paths.appJsConfig);
119
- }
120
-
121
- config = config || {};
122
- const options = config.compilerOptions || {};
123
-
124
- const additionalModulePaths = getAdditionalModulePaths(options);
125
-
126
- return {
127
- additionalModulePaths: additionalModulePaths,
128
- webpackAliases: getWebpackAliases(options),
129
- jestAliases: getJestAliases(options),
130
- hasTsConfig,
131
- };
132
- }
133
-
134
- module.exports = getModules();
package/config/paths.js DELETED
@@ -1,71 +0,0 @@
1
- const path = require('path')
2
- const fs = require('fs')
3
- const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath')
4
-
5
- // Make sure any symlinks in the project folder are resolved:
6
- // https://github.com/facebook/create-react-app/issues/637
7
- const appDirectory = fs.realpathSync(process.cwd())
8
- const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath)
9
-
10
- // We use `PUBLIC_URL` environment variable or "homepage" field to infer
11
- // "public path" at which the app is served.
12
- // webpack needs to know it to put the right <script> hrefs into HTML even in
13
- // single-page apps that may serve index.html for nested URLs like /todos/42.
14
- // We can't use a relative path in HTML because we don't want to load something
15
- // like /todos/42/static/js/bundle.7289d.js. We have to know the root.
16
- const publicUrlOrPath = getPublicUrlOrPath(
17
- process.env.NODE_ENV === 'development',
18
- require(resolveApp('package.json')).homepage,
19
- process.env.PUBLIC_URL
20
- )
21
-
22
- const moduleFileExtensions = [
23
- 'web.mjs',
24
- 'mjs',
25
- 'web.js',
26
- 'js',
27
- 'web.ts',
28
- 'ts',
29
- 'web.tsx',
30
- 'tsx',
31
- 'json',
32
- 'web.jsx',
33
- 'jsx',
34
- ]
35
-
36
- // Resolve file paths in the same order as webpack
37
- const resolveModule = (resolveFn, filePath) => {
38
- const extension = moduleFileExtensions.find((extension) =>
39
- fs.existsSync(resolveFn(`${filePath}.${extension}`))
40
- )
41
-
42
- if (extension) {
43
- return resolveFn(`${filePath}.${extension}`)
44
- }
45
-
46
- return resolveFn(`${filePath}.js`)
47
- }
48
-
49
- // config after eject: we're in ./config/
50
- module.exports = {
51
- dotenv: resolveApp('.env'),
52
- appPath: resolveApp('.'),
53
- appBuild: resolveApp('build'),
54
- appPublic: resolveApp('public'),
55
- appHtml: resolveApp('public/index.html'),
56
- appIndexJs: resolveModule(resolveApp, 'examples'),
57
- appPackageJson: resolveApp('package.json'),
58
- appSrc: resolveApp(''),
59
- appTsConfig: resolveApp('tsconfig.json'),
60
- appJsConfig: resolveApp('jsconfig.json'),
61
- yarnLockFile: resolveApp('yarn.lock'),
62
- testsSetup: resolveModule(resolveApp, 'src/setupTests'),
63
- proxySetup: resolveApp('src/setupProxy.js'),
64
- appNodeModules: resolveApp('node_modules'),
65
- swSrc: resolveModule(resolveApp, 'src/service-worker'),
66
- componentsIndexJs: resolveApp('components/index'),
67
- libBuild: resolveApp('lib'),
68
- publicUrlOrPath,
69
- }
70
-
71
- module.exports.moduleFileExtensions = moduleFileExtensions
package/config/pnpTs.js DELETED
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- const { resolveModuleName } = require('ts-pnp');
4
-
5
- exports.resolveModuleName = (
6
- typescript,
7
- moduleName,
8
- containingFile,
9
- compilerOptions,
10
- resolutionHost
11
- ) => {
12
- return resolveModuleName(
13
- moduleName,
14
- containingFile,
15
- compilerOptions,
16
- resolutionHost,
17
- typescript.resolveModuleName
18
- );
19
- };
20
-
21
- exports.resolveTypeReferenceDirective = (
22
- typescript,
23
- moduleName,
24
- containingFile,
25
- compilerOptions,
26
- resolutionHost
27
- ) => {
28
- return resolveModuleName(
29
- moduleName,
30
- containingFile,
31
- compilerOptions,
32
- resolutionHost,
33
- typescript.resolveTypeReferenceDirective
34
- );
35
- };