@authing/react-ui-components 3.1.1 → 3.1.3

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 (144) hide show
  1. package/lib/index.d.ts +2573 -201
  2. package/lib/index.min.css +2 -1
  3. package/lib/index.min.js +1 -1
  4. package/lib/index.min.js.LICENSE.txt +42 -0
  5. package/lib/static/media/loading.4a67a5f3.svg +29 -0
  6. package/package.json +54 -18
  7. package/.eslintignore +0 -6
  8. package/.eslintrc.js +0 -7
  9. package/.prettierrc +0 -5
  10. package/.vscode/settings.json +0 -31
  11. package/LICENSE +0 -21
  12. package/config/antdReplacer.js +0 -51
  13. package/config/env.js +0 -106
  14. package/config/getHttpsConfig.js +0 -66
  15. package/config/jest/cssTransform.js +0 -14
  16. package/config/jest/fileTransform.js +0 -40
  17. package/config/modules.js +0 -134
  18. package/config/paths.js +0 -71
  19. package/config/pnpTs.js +0 -35
  20. package/config/webpack.config.js +0 -857
  21. package/config/webpackDevServer.config.js +0 -130
  22. package/public/favicon.ico +0 -0
  23. package/public/index.html +0 -43
  24. package/public/logo192.png +0 -0
  25. package/public/logo512.png +0 -0
  26. package/public/manifest.json +0 -25
  27. package/public/robots.txt +0 -3
  28. package/scripts/build.js +0 -212
  29. package/scripts/lib.js +0 -200
  30. package/scripts/start.js +0 -166
  31. package/scripts/test.js +0 -53
  32. package/src/common/AuthingDropdown/index.tsx +0 -52
  33. package/src/common/AuthingDropdown/style.less +0 -43
  34. package/src/common/AuthingTabs/index.tsx +0 -98
  35. package/src/common/AuthingTabs/style.less +0 -135
  36. package/src/common/CopyAbleText/index.tsx +0 -54
  37. package/src/common/CopyAbleText/style.less +0 -13
  38. package/src/common/VerifyCodeInput/index.tsx +0 -76
  39. package/src/common/VerifyCodeInput/style.less +0 -24
  40. package/src/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  41. package/src/components/AuthingGuard/AppMFALayout/style.less +0 -12
  42. package/src/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  43. package/src/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  44. package/src/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  45. package/src/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  46. package/src/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  47. package/src/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  48. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -86
  49. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  50. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  51. package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  52. package/src/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  53. package/src/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  54. package/src/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -161
  55. package/src/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  56. package/src/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  57. package/src/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  58. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  59. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  60. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  61. package/src/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  62. package/src/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  63. package/src/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  64. package/src/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  65. package/src/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  66. package/src/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  67. package/src/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -61
  68. package/src/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  69. package/src/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  70. package/src/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  71. package/src/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  72. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  73. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  74. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  75. package/src/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  76. package/src/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  77. package/src/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  78. package/src/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  79. package/src/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  80. package/src/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  81. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  82. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  83. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  84. package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  85. package/src/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  86. package/src/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  87. package/src/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  88. package/src/components/AuthingGuard/Forms/index.ts +0 -13
  89. package/src/components/AuthingGuard/GuardLayout/index.tsx +0 -488
  90. package/src/components/AuthingGuard/GuardLayout/style.less +0 -111
  91. package/src/components/AuthingGuard/Header/index.tsx +0 -28
  92. package/src/components/AuthingGuard/Header/style.less +0 -64
  93. package/src/components/AuthingGuard/IconFont/iconfont.js +0 -74
  94. package/src/components/AuthingGuard/IconFont/index.tsx +0 -19
  95. package/src/components/AuthingGuard/IconFont/style.less +0 -6
  96. package/src/components/AuthingGuard/IconFont/svg.js +0 -2
  97. package/src/components/AuthingGuard/LoginLayout/index.tsx +0 -205
  98. package/src/components/AuthingGuard/LoginLayout/style.less +0 -0
  99. package/src/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  100. package/src/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  101. package/src/components/AuthingGuard/MfaLayout/style.less +0 -3
  102. package/src/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  103. package/src/components/AuthingGuard/RegisterLayout/style.less +0 -0
  104. package/src/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  105. package/src/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  106. package/src/components/AuthingGuard/api/appConfig.ts +0 -154
  107. package/src/components/AuthingGuard/api/http.ts +0 -88
  108. package/src/components/AuthingGuard/api/index.ts +0 -3
  109. package/src/components/AuthingGuard/api/sso.ts +0 -29
  110. package/src/components/AuthingGuard/api/userPoolConfig.ts +0 -112
  111. package/src/components/AuthingGuard/constants.ts +0 -107
  112. package/src/components/AuthingGuard/hooks/index.tsx +0 -70
  113. package/src/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  114. package/src/components/AuthingGuard/index.tsx +0 -134
  115. package/src/components/AuthingGuard/locales/en/common.json +0 -185
  116. package/src/components/AuthingGuard/locales/en/index.ts +0 -6
  117. package/src/components/AuthingGuard/locales/en/login.json +0 -94
  118. package/src/components/AuthingGuard/locales/en/map.json +0 -4
  119. package/src/components/AuthingGuard/locales/en/user.json +0 -81
  120. package/src/components/AuthingGuard/locales/index.ts +0 -45
  121. package/src/components/AuthingGuard/locales/zh/common.json +0 -185
  122. package/src/components/AuthingGuard/locales/zh/index.ts +0 -6
  123. package/src/components/AuthingGuard/locales/zh/login.json +0 -94
  124. package/src/components/AuthingGuard/locales/zh/map.json +0 -4
  125. package/src/components/AuthingGuard/locales/zh/user.json +0 -81
  126. package/src/components/AuthingGuard/style.less +0 -104
  127. package/src/components/AuthingGuard/types/Forms.ts +0 -95
  128. package/src/components/AuthingGuard/types/GuardConfig.ts +0 -424
  129. package/src/components/AuthingGuard/types/GuardState.ts +0 -7
  130. package/src/components/AuthingGuard/types/Locales.ts +0 -12
  131. package/src/components/AuthingGuard/types/index.ts +0 -4
  132. package/src/components/index.ts +0 -7
  133. package/src/context/base.tsx +0 -28
  134. package/src/context/global/context.tsx +0 -39
  135. package/src/context/global/reducer.tsx +0 -56
  136. package/src/index.tsx +0 -142
  137. package/src/logo.svg +0 -7
  138. package/src/react-app-env.d.ts +0 -71
  139. package/src/reportWebVitals.ts +0 -15
  140. package/src/setupTests.ts +0 -5
  141. package/src/utils/clipboard.ts +0 -27
  142. package/src/utils/index.ts +0 -180
  143. package/src/utils/popupCenter.ts +0 -48
  144. package/tsconfig.json +0 -24
@@ -1,130 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
5
- const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
6
- const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
7
- const ignoredFiles = require('react-dev-utils/ignoredFiles');
8
- const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
9
- const paths = require('./paths');
10
- const getHttpsConfig = require('./getHttpsConfig');
11
-
12
- const host = process.env.HOST || '0.0.0.0';
13
- const sockHost = process.env.WDS_SOCKET_HOST;
14
- const sockPath = process.env.WDS_SOCKET_PATH; // default: '/sockjs-node'
15
- const sockPort = process.env.WDS_SOCKET_PORT;
16
-
17
- module.exports = function (proxy, allowedHost) {
18
- return {
19
- // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
20
- // websites from potentially accessing local content through DNS rebinding:
21
- // https://github.com/webpack/webpack-dev-server/issues/887
22
- // https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
23
- // However, it made several existing use cases such as development in cloud
24
- // environment or subdomains in development significantly more complicated:
25
- // https://github.com/facebook/create-react-app/issues/2271
26
- // https://github.com/facebook/create-react-app/issues/2233
27
- // While we're investigating better solutions, for now we will take a
28
- // compromise. Since our WDS configuration only serves files in the `public`
29
- // folder we won't consider accessing them a vulnerability. However, if you
30
- // use the `proxy` feature, it gets more dangerous because it can expose
31
- // remote code execution vulnerabilities in backends like Django and Rails.
32
- // So we will disable the host check normally, but enable it if you have
33
- // specified the `proxy` setting. Finally, we let you override it if you
34
- // really know what you're doing with a special environment variable.
35
- disableHostCheck:
36
- !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
37
- // Enable gzip compression of generated files.
38
- compress: true,
39
- // Silence WebpackDevServer's own logs since they're generally not useful.
40
- // It will still show compile warnings and errors with this setting.
41
- clientLogLevel: 'none',
42
- // By default WebpackDevServer serves physical files from current directory
43
- // in addition to all the virtual build products that it serves from memory.
44
- // This is confusing because those files won’t automatically be available in
45
- // production build folder unless we copy them. However, copying the whole
46
- // project directory is dangerous because we may expose sensitive files.
47
- // Instead, we establish a convention that only files in `public` directory
48
- // get served. Our build script will copy `public` into the `build` folder.
49
- // In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
50
- // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
51
- // In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
52
- // Note that we only recommend to use `public` folder as an escape hatch
53
- // for files like `favicon.ico`, `manifest.json`, and libraries that are
54
- // for some reason broken when imported through webpack. If you just want to
55
- // use an image, put it in `src` and `import` it from JavaScript instead.
56
- contentBase: paths.appPublic,
57
- contentBasePublicPath: paths.publicUrlOrPath,
58
- // By default files from `contentBase` will not trigger a page reload.
59
- watchContentBase: true,
60
- // Enable hot reloading server. It will provide WDS_SOCKET_PATH endpoint
61
- // for the WebpackDevServer client so it can learn when the files were
62
- // updated. The WebpackDevServer client is included as an entry point
63
- // in the webpack development configuration. Note that only changes
64
- // to CSS are currently hot reloaded. JS changes will refresh the browser.
65
- hot: true,
66
- // Use 'ws' instead of 'sockjs-node' on server since we're using native
67
- // websockets in `webpackHotDevClient`.
68
- transportMode: 'ws',
69
- // Prevent a WS client from getting injected as we're already including
70
- // `webpackHotDevClient`.
71
- injectClient: false,
72
- // Enable custom sockjs pathname for websocket connection to hot reloading server.
73
- // Enable custom sockjs hostname, pathname and port for websocket connection
74
- // to hot reloading server.
75
- sockHost,
76
- sockPath,
77
- sockPort,
78
- // It is important to tell WebpackDevServer to use the same "publicPath" path as
79
- // we specified in the webpack config. When homepage is '.', default to serving
80
- // from the root.
81
- // remove last slash so user can land on `/test` instead of `/test/`
82
- publicPath: paths.publicUrlOrPath.slice(0, -1),
83
- // WebpackDevServer is noisy by default so we emit custom message instead
84
- // by listening to the compiler events with `compiler.hooks[...].tap` calls above.
85
- quiet: true,
86
- // Reportedly, this avoids CPU overload on some systems.
87
- // https://github.com/facebook/create-react-app/issues/293
88
- // src/node_modules is not ignored to support absolute imports
89
- // https://github.com/facebook/create-react-app/issues/1065
90
- watchOptions: {
91
- ignored: ignoredFiles(paths.appSrc),
92
- },
93
- https: getHttpsConfig(),
94
- host,
95
- overlay: false,
96
- historyApiFallback: {
97
- // Paths with dots should still use the history fallback.
98
- // See https://github.com/facebook/create-react-app/issues/387.
99
- disableDotRule: true,
100
- index: paths.publicUrlOrPath,
101
- },
102
- public: allowedHost,
103
- // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
104
- proxy,
105
- before(app, server) {
106
- // Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`
107
- // middlewares before `redirectServedPath` otherwise will not have any effect
108
- // This lets us fetch source contents from webpack for the error overlay
109
- app.use(evalSourceMapMiddleware(server));
110
- // This lets us open files from the runtime error overlay.
111
- app.use(errorOverlayMiddleware());
112
-
113
- if (fs.existsSync(paths.proxySetup)) {
114
- // This registers user provided middleware for proxy reasons
115
- require(paths.proxySetup)(app);
116
- }
117
- },
118
- after(app) {
119
- // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
120
- app.use(redirectServedPath(paths.publicUrlOrPath));
121
-
122
- // This service worker file is effectively a 'no-op' that will reset any
123
- // previous service worker registered for the same host:port combination.
124
- // We do this in development to avoid hitting the production cache if
125
- // it used the same host and port.
126
- // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
127
- app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
128
- },
129
- };
130
- };
Binary file
package/public/index.html DELETED
@@ -1,43 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="theme-color" content="#000000" />
8
- <meta
9
- name="description"
10
- content="Web site created using create-react-app"
11
- />
12
- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
- <!--
14
- manifest.json provides metadata used when your web app is installed on a
15
- user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
- -->
17
- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
- <!--
19
- Notice the use of %PUBLIC_URL% in the tags above.
20
- It will be replaced with the URL of the `public` folder during the build.
21
- Only files inside the `public` folder can be referenced from the HTML.
22
-
23
- Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
- work correctly both with client-side routing and a non-root public URL.
25
- Learn how to configure a non-root public URL by running `npm run build`.
26
- -->
27
- <title>React App</title>
28
- </head>
29
- <body>
30
- <noscript>You need to enable JavaScript to run this app.</noscript>
31
- <div id="root"></div>
32
- <!--
33
- This HTML file is a template.
34
- If you open it directly in the browser, you will see an empty page.
35
-
36
- You can add webfonts, meta tags, or analytics to this file.
37
- The build step will place the bundled scripts into the <body> tag.
38
-
39
- To begin the development, run `npm start` or `yarn start`.
40
- To create a production bundle, use `npm run build` or `yarn build`.
41
- -->
42
- </body>
43
- </html>
Binary file
Binary file
@@ -1,25 +0,0 @@
1
- {
2
- "short_name": "React App",
3
- "name": "Create React App Sample",
4
- "icons": [
5
- {
6
- "src": "favicon.ico",
7
- "sizes": "64x64 32x32 24x24 16x16",
8
- "type": "image/x-icon"
9
- },
10
- {
11
- "src": "logo192.png",
12
- "type": "image/png",
13
- "sizes": "192x192"
14
- },
15
- {
16
- "src": "logo512.png",
17
- "type": "image/png",
18
- "sizes": "512x512"
19
- }
20
- ],
21
- "start_url": ".",
22
- "display": "standalone",
23
- "theme_color": "#000000",
24
- "background_color": "#ffffff"
25
- }
package/public/robots.txt DELETED
@@ -1,3 +0,0 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow:
package/scripts/build.js DELETED
@@ -1,212 +0,0 @@
1
- 'use strict';
2
-
3
- // Do this as the first thing so that any code reading it knows the right env.
4
- process.env.BABEL_ENV = 'production';
5
- process.env.NODE_ENV = 'production';
6
-
7
- // Makes the script crash on unhandled rejections instead of silently
8
- // ignoring them. In the future, promise rejections that are not handled will
9
- // terminate the Node.js process with a non-zero exit code.
10
- process.on('unhandledRejection', err => {
11
- throw err;
12
- });
13
-
14
- // Ensure environment variables are read.
15
- require('../config/env');
16
-
17
-
18
- const path = require('path');
19
- const chalk = require('react-dev-utils/chalk');
20
- const fs = require('fs-extra');
21
- const bfj = require('bfj');
22
- const webpack = require('webpack');
23
- const configFactory = require('../config/webpack.config');
24
- const paths = require('../config/paths');
25
- const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
26
- const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
27
- const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
28
- const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
29
- const printBuildError = require('react-dev-utils/printBuildError');
30
-
31
- const measureFileSizesBeforeBuild =
32
- FileSizeReporter.measureFileSizesBeforeBuild;
33
- const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
34
- const useYarn = fs.existsSync(paths.yarnLockFile);
35
-
36
- // These sizes are pretty large. We'll warn for bundles exceeding them.
37
- const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
38
- const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
39
-
40
- const isInteractive = process.stdout.isTTY;
41
-
42
- // Warn and crash if required files are missing
43
- if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
44
- process.exit(1);
45
- }
46
-
47
- const argv = process.argv.slice(2);
48
- const writeStatsJson = argv.indexOf('--stats') !== -1;
49
-
50
- // Generate configuration
51
- const config = configFactory('production');
52
-
53
- // We require that you explicitly set browsers and do not fall back to
54
- // browserslist defaults.
55
- const { checkBrowsers } = require('react-dev-utils/browsersHelper');
56
- checkBrowsers(paths.appPath, isInteractive)
57
- .then(() => {
58
- // First, read the current file sizes in build directory.
59
- // This lets us display how much they changed later.
60
- return measureFileSizesBeforeBuild(paths.appBuild);
61
- })
62
- .then(previousFileSizes => {
63
- // Remove all content but keep the directory so that
64
- // if you're in it, you don't end up in Trash
65
- fs.emptyDirSync(paths.appBuild);
66
- // Merge with the public folder
67
- copyPublicFolder();
68
- // Start the webpack build
69
- return build(previousFileSizes);
70
- })
71
- .then(
72
- ({ stats, previousFileSizes, warnings }) => {
73
- if (warnings.length) {
74
- console.log(chalk.yellow('Compiled with warnings.\n'));
75
- console.log(warnings.join('\n\n'));
76
- console.log(
77
- '\nSearch for the ' +
78
- chalk.underline(chalk.yellow('keywords')) +
79
- ' to learn more about each warning.'
80
- );
81
- console.log(
82
- 'To ignore, add ' +
83
- chalk.cyan('// eslint-disable-next-line') +
84
- ' to the line before.\n'
85
- );
86
- } else {
87
- console.log(chalk.green('Compiled successfully.\n'));
88
- }
89
-
90
- console.log('File sizes after gzip:\n');
91
- printFileSizesAfterBuild(
92
- stats,
93
- previousFileSizes,
94
- paths.appBuild,
95
- WARN_AFTER_BUNDLE_GZIP_SIZE,
96
- WARN_AFTER_CHUNK_GZIP_SIZE
97
- );
98
- console.log();
99
-
100
- const appPackage = require(paths.appPackageJson);
101
- const publicUrl = paths.publicUrlOrPath;
102
- const publicPath = config.output.publicPath;
103
- const buildFolder = path.relative(process.cwd(), paths.appBuild);
104
- printHostingInstructions(
105
- appPackage,
106
- publicUrl,
107
- publicPath,
108
- buildFolder,
109
- useYarn
110
- );
111
- },
112
- err => {
113
- const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
114
- if (tscCompileOnError) {
115
- console.log(
116
- chalk.yellow(
117
- 'Compiled with the following type errors (you may want to check these before deploying your app):\n'
118
- )
119
- );
120
- printBuildError(err);
121
- } else {
122
- console.log(chalk.red('Failed to compile.\n'));
123
- printBuildError(err);
124
- process.exit(1);
125
- }
126
- }
127
- )
128
- .catch(err => {
129
- if (err && err.message) {
130
- console.log(err.message);
131
- }
132
- process.exit(1);
133
- });
134
-
135
- // Create the production build and print the deployment instructions.
136
- function build(previousFileSizes) {
137
- console.log('Creating an optimized production build...');
138
-
139
- const compiler = webpack(config);
140
- return new Promise((resolve, reject) => {
141
- compiler.run((err, stats) => {
142
- let messages;
143
- if (err) {
144
- if (!err.message) {
145
- return reject(err);
146
- }
147
-
148
- let errMessage = err.message;
149
-
150
- // Add additional information for postcss errors
151
- if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
152
- errMessage +=
153
- '\nCompileError: Begins at CSS selector ' +
154
- err['postcssNode'].selector;
155
- }
156
-
157
- messages = formatWebpackMessages({
158
- errors: [errMessage],
159
- warnings: [],
160
- });
161
- } else {
162
- messages = formatWebpackMessages(
163
- stats.toJson({ all: false, warnings: true, errors: true })
164
- );
165
- }
166
- if (messages.errors.length) {
167
- // Only keep the first error. Others are often indicative
168
- // of the same problem, but confuse the reader with noise.
169
- if (messages.errors.length > 1) {
170
- messages.errors.length = 1;
171
- }
172
- return reject(new Error(messages.errors.join('\n\n')));
173
- }
174
- if (
175
- process.env.CI &&
176
- (typeof process.env.CI !== 'string' ||
177
- process.env.CI.toLowerCase() !== 'false') &&
178
- messages.warnings.length
179
- ) {
180
- console.log(
181
- chalk.yellow(
182
- '\nTreating warnings as errors because process.env.CI = true.\n' +
183
- 'Most CI servers set it automatically.\n'
184
- )
185
- );
186
- return reject(new Error(messages.warnings.join('\n\n')));
187
- }
188
-
189
- const resolveArgs = {
190
- stats,
191
- previousFileSizes,
192
- warnings: messages.warnings,
193
- };
194
-
195
- if (writeStatsJson) {
196
- return bfj
197
- .write(paths.appBuild + '/bundle-stats.json', stats.toJson())
198
- .then(() => resolve(resolveArgs))
199
- .catch(error => reject(new Error(error)));
200
- }
201
-
202
- return resolve(resolveArgs);
203
- });
204
- });
205
- }
206
-
207
- function copyPublicFolder() {
208
- fs.copySync(paths.appPublic, paths.appBuild, {
209
- dereference: true,
210
- filter: file => file !== paths.appHtml,
211
- });
212
- }
package/scripts/lib.js DELETED
@@ -1,200 +0,0 @@
1
- // Do this as the first thing so that any code reading it knows the right env.
2
- process.env.BABEL_ENV = 'production'
3
- process.env.NODE_ENV = 'production'
4
-
5
- // Makes the script crash on unhandled rejections instead of silently
6
- // ignoring them. In the future, promise rejections that are not handled will
7
- // terminate the Node.js process with a non-zero exit code.
8
- process.on('unhandledRejection', (err) => {
9
- throw err
10
- })
11
-
12
- // Ensure environment variables are read.
13
- require('../config/env')
14
-
15
- const path = require('path')
16
- const chalk = require('react-dev-utils/chalk')
17
- const fs = require('fs-extra')
18
- const bfj = require('bfj')
19
- const webpack = require('webpack')
20
- const configFactory = require('../config/webpack.config')
21
- const paths = require('../config/paths')
22
- const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles')
23
- const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages')
24
- const printHostingInstructions = require('react-dev-utils/printHostingInstructions')
25
- const FileSizeReporter = require('react-dev-utils/FileSizeReporter')
26
- const printBuildError = require('react-dev-utils/printBuildError')
27
-
28
- const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild
29
- const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild
30
- const useYarn = fs.existsSync(paths.yarnLockFile)
31
-
32
- // These sizes are pretty large. We'll warn for bundles exceeding them.
33
- const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024
34
- const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024
35
-
36
- const isInteractive = process.stdout.isTTY
37
-
38
- // Warn and crash if required files are missing
39
- if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
40
- process.exit(1)
41
- }
42
-
43
- const argv = process.argv.slice(2)
44
- const writeStatsJson = argv.indexOf('--stats') !== -1
45
-
46
- // Generate configuration
47
- const config = configFactory('lib')
48
-
49
- // We require that you explicitly set browsers and do not fall back to
50
- // browserslist defaults.
51
- const { checkBrowsers } = require('react-dev-utils/browsersHelper')
52
- checkBrowsers(paths.appPath, isInteractive)
53
- .then(() => {
54
- // First, read the current file sizes in build directory.
55
- // This lets us display how much they changed later.
56
- return measureFileSizesBeforeBuild(paths.libBuild)
57
- })
58
- .then((previousFileSizes) => {
59
- // Remove all content but keep the directory so that
60
- // if you're in it, you don't end up in Trash
61
- fs.emptyDirSync(paths.libBuild)
62
- // Merge with the public folder
63
- // Start the webpack build
64
- return build(previousFileSizes)
65
- })
66
- .then(
67
- ({ stats, previousFileSizes, warnings }) => {
68
- if (warnings.length) {
69
- console.log(chalk.yellow('Compiled with warnings.\n'))
70
- console.log(warnings.join('\n\n'))
71
- console.log(
72
- '\nSearch for the ' +
73
- chalk.underline(chalk.yellow('keywords')) +
74
- ' to learn more about each warning.'
75
- )
76
- console.log(
77
- 'To ignore, add ' +
78
- chalk.cyan('// eslint-disable-next-line') +
79
- ' to the line before.\n'
80
- )
81
- } else {
82
- console.log(chalk.green('Compiled successfully.\n'))
83
- }
84
-
85
- console.log('File sizes after gzip:\n')
86
- printFileSizesAfterBuild(
87
- stats,
88
- previousFileSizes,
89
- paths.libBuild,
90
- WARN_AFTER_BUNDLE_GZIP_SIZE,
91
- WARN_AFTER_CHUNK_GZIP_SIZE
92
- )
93
- console.log()
94
-
95
- const appPackage = require(paths.appPackageJson)
96
- const publicUrl = paths.publicUrlOrPath
97
- const publicPath = config.output.publicPath
98
- const buildFolder = path.relative(process.cwd(), paths.libBuild)
99
- printHostingInstructions(
100
- appPackage,
101
- publicUrl,
102
- publicPath,
103
- buildFolder,
104
- useYarn
105
- )
106
- },
107
- (err) => {
108
- const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true'
109
- if (tscCompileOnError) {
110
- console.log(
111
- chalk.yellow(
112
- 'Compiled with the following type errors (you may want to check these before deploying your app):\n'
113
- )
114
- )
115
- printBuildError(err)
116
- } else {
117
- console.log(chalk.red('Failed to compile.\n'))
118
- printBuildError(err)
119
- process.exit(1)
120
- }
121
- }
122
- )
123
- .catch((err) => {
124
- if (err && err.message) {
125
- console.log(err.message)
126
- }
127
- process.exit(1)
128
- })
129
-
130
- // Create the production build and print the deployment instructions.
131
- function build(previousFileSizes) {
132
- console.log('Creating an optimized production build...')
133
-
134
- const compiler = webpack(config)
135
- return new Promise((resolve, reject) => {
136
- compiler.run((err, stats) => {
137
- let messages
138
- if (err) {
139
- if (!err.message) {
140
- return reject(err)
141
- }
142
-
143
- let errMessage = err.message
144
-
145
- // Add additional information for postcss errors
146
- if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
147
- errMessage +=
148
- '\nCompileError: Begins at CSS selector ' +
149
- err['postcssNode'].selector
150
- }
151
-
152
- messages = formatWebpackMessages({
153
- errors: [errMessage],
154
- warnings: [],
155
- })
156
- } else {
157
- messages = formatWebpackMessages(
158
- stats.toJson({ all: false, warnings: true, errors: true })
159
- )
160
- }
161
- if (messages.errors.length) {
162
- // Only keep the first error. Others are often indicative
163
- // of the same problem, but confuse the reader with noise.
164
- if (messages.errors.length > 1) {
165
- messages.errors.length = 1
166
- }
167
- return reject(new Error(messages.errors.join('\n\n')))
168
- }
169
- if (
170
- process.env.CI &&
171
- (typeof process.env.CI !== 'string' ||
172
- process.env.CI.toLowerCase() !== 'false') &&
173
- messages.warnings.length
174
- ) {
175
- console.log(
176
- chalk.yellow(
177
- '\nTreating warnings as errors because process.env.CI = true.\n' +
178
- 'Most CI servers set it automatically.\n'
179
- )
180
- )
181
- return reject(new Error(messages.warnings.join('\n\n')))
182
- }
183
-
184
- const resolveArgs = {
185
- stats,
186
- previousFileSizes,
187
- warnings: messages.warnings,
188
- }
189
-
190
- if (writeStatsJson) {
191
- return bfj
192
- .write(paths.libBuild + '/bundle-stats.json', stats.toJson())
193
- .then(() => resolve(resolveArgs))
194
- .catch((error) => reject(new Error(error)))
195
- }
196
-
197
- return resolve(resolveArgs)
198
- })
199
- })
200
- }