gov-ui-core 0.1.0

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 (101) hide show
  1. package/.storybook/main.ts +32 -0
  2. package/.storybook/preview.tsx +22 -0
  3. package/@types/custom.d.ts +43 -0
  4. package/@types/styles.d.ts +3 -0
  5. package/README.md +46 -0
  6. package/build/253ac843d9cff70a5ac5.eot +1 -0
  7. package/build/3d3eb30384470a0a5f6d.gif +1 -0
  8. package/build/650c6c71d75bb6fca50d.svg +1 -0
  9. package/build/App.d.ts +3 -0
  10. package/build/Main.d.ts +5 -0
  11. package/build/ad0c1b9dc2d8ec4e2fa0.ttf +1 -0
  12. package/build/components/Button/DropdownButton.d.ts +13 -0
  13. package/build/components/Button/SwitchButton.d.ts +7 -0
  14. package/build/components/Button/index.d.ts +11 -0
  15. package/build/components/Button/styled.d.ts +10 -0
  16. package/build/components/Calendar/CalendarNavigation.d.ts +9 -0
  17. package/build/components/Calendar/constants.d.ts +2 -0
  18. package/build/components/Calendar/index.d.ts +11 -0
  19. package/build/components/Calendar/styled.d.ts +2 -0
  20. package/build/components/Carousel/ArrowButton.d.ts +7 -0
  21. package/build/components/Carousel/index.d.ts +13 -0
  22. package/build/components/Carousel/styled.d.ts +2 -0
  23. package/build/components/Directory/index.d.ts +32 -0
  24. package/build/components/Directory/styled.d.ts +6 -0
  25. package/build/components/EmptyBox/index.d.ts +8 -0
  26. package/build/components/EmptyBox/styled.d.ts +4 -0
  27. package/build/components/Form/Form.d.ts +18 -0
  28. package/build/components/Form/Group.d.ts +6 -0
  29. package/build/components/Form/Item.d.ts +22 -0
  30. package/build/components/Form/index.d.ts +14 -0
  31. package/build/components/Form/styled.d.ts +7 -0
  32. package/build/components/Header/ContentHeader.d.ts +15 -0
  33. package/build/components/Header/styled.d.ts +5 -0
  34. package/build/components/Icons/index.d.ts +14 -0
  35. package/build/components/Input/Checkbox.d.ts +19 -0
  36. package/build/components/Input/ErrorMessage.d.ts +8 -0
  37. package/build/components/Input/Input.d.ts +23 -0
  38. package/build/components/Input/InputNumber.d.ts +8 -0
  39. package/build/components/Input/Radio.d.ts +16 -0
  40. package/build/components/Input/Search.d.ts +13 -0
  41. package/build/components/Input/Select.d.ts +42 -0
  42. package/build/components/Input/TextArea.d.ts +15 -0
  43. package/build/components/Input/index.d.ts +19 -0
  44. package/build/components/Input/styled.d.ts +22 -0
  45. package/build/components/IntlText/index.d.ts +5 -0
  46. package/build/components/Loading/OverlayLoading.d.ts +10 -0
  47. package/build/components/Loading/Spinner.d.ts +9 -0
  48. package/build/components/Loading/styled.d.ts +10 -0
  49. package/build/components/Styled/mixins.d.ts +13 -0
  50. package/build/components/Styled/variable.d.ts +6 -0
  51. package/build/components/Table/AppendTable.d.ts +26 -0
  52. package/build/components/Table/AutoTooltip.d.ts +8 -0
  53. package/build/components/Table/TableBase.d.ts +16 -0
  54. package/build/components/Table/TableLoading.d.ts +9 -0
  55. package/build/components/Table/components/Pagination.d.ts +18 -0
  56. package/build/components/Table/components/PaginationItem.d.ts +9 -0
  57. package/build/components/Table/index.d.ts +27 -0
  58. package/build/components/Table/styled.d.ts +25 -0
  59. package/build/components/ThemeProvider.d.ts +10 -0
  60. package/build/f7f1e7911cd4fe275e29.woff +1 -0
  61. package/build/globalStyle.d.ts +5 -0
  62. package/build/index.d.ts +1 -0
  63. package/build/index.js +2 -0
  64. package/build/index.js.LICENSE.txt +69 -0
  65. package/build/modules.d.ts +29 -0
  66. package/build/pages/CreateTable.d.ts +26 -0
  67. package/build/pages/FormSample.d.ts +5 -0
  68. package/build/pages/Sample.d.ts +5 -0
  69. package/build/pages/Sample2.d.ts +5 -0
  70. package/build/pages/Sample3.d.ts +5 -0
  71. package/build/pages/Sample4.d.ts +5 -0
  72. package/build/pages/TableSample.d.ts +5 -0
  73. package/build/pages/sampleData.d.ts +59 -0
  74. package/build/reportWebVitals.d.ts +3 -0
  75. package/build/theme.d.ts +45 -0
  76. package/build/utils/customState.d.ts +28 -0
  77. package/build/utils/hookUtils.d.ts +4 -0
  78. package/build/utils/utils.d.ts +27 -0
  79. package/config/env.js +104 -0
  80. package/config/getHttpsConfig.js +66 -0
  81. package/config/jest/babelTransform.js +29 -0
  82. package/config/jest/cssTransform.js +14 -0
  83. package/config/jest/fileTransform.js +40 -0
  84. package/config/modules.js +134 -0
  85. package/config/paths.js +77 -0
  86. package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
  87. package/config/webpack.config.js +756 -0
  88. package/config/webpack.prod.config.js +91 -0
  89. package/config/webpackDevServer.config.js +127 -0
  90. package/doctor-storybook.log +18 -0
  91. package/package.json +212 -0
  92. package/public/favicon.ico +0 -0
  93. package/public/index.html +43 -0
  94. package/public/logo192.png +0 -0
  95. package/public/logo512.png +0 -0
  96. package/public/manifest.json +25 -0
  97. package/public/robots.txt +3 -0
  98. package/scripts/build.js +217 -0
  99. package/scripts/start.js +154 -0
  100. package/scripts/test.js +52 -0
  101. package/tsconfig.json +33 -0
@@ -0,0 +1,69 @@
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
7
+ /*!
8
+ Copyright (c) 2018 Jed Watson.
9
+ Licensed under the MIT License (MIT), see
10
+ http://jedwatson.github.io/classnames
11
+ */
12
+
13
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
14
+
15
+ /**
16
+ * @license
17
+ * Lodash <https://lodash.com/>
18
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
19
+ * Released under MIT license <https://lodash.com/license>
20
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
21
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
22
+ */
23
+
24
+ /**
25
+ * @license React
26
+ * react-is.production.min.js
27
+ *
28
+ * Copyright (c) Facebook, Inc. and its affiliates.
29
+ *
30
+ * This source code is licensed under the MIT license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ */
33
+
34
+ /**
35
+ * @license React
36
+ * react-jsx-runtime.production.min.js
37
+ *
38
+ * Copyright (c) Facebook, Inc. and its affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */
43
+
44
+ /** @license React v16.13.1
45
+ * react-is.production.min.js
46
+ *
47
+ * Copyright (c) Facebook, Inc. and its affiliates.
48
+ *
49
+ * This source code is licensed under the MIT license found in the
50
+ * LICENSE file in the root directory of this source tree.
51
+ */
52
+
53
+ /** @license React v16.8.6
54
+ * react.production.min.js
55
+ *
56
+ * Copyright (c) Facebook, Inc. and its affiliates.
57
+ *
58
+ * This source code is licensed under the MIT license found in the
59
+ * LICENSE file in the root directory of this source tree.
60
+ */
61
+
62
+ /** @license React v17.0.2
63
+ * react-is.production.min.js
64
+ *
65
+ * Copyright (c) Facebook, Inc. and its affiliates.
66
+ *
67
+ * This source code is licensed under the MIT license found in the
68
+ * LICENSE file in the root directory of this source tree.
69
+ */
@@ -0,0 +1,29 @@
1
+ import Button from './components/Button';
2
+ import Carousel from './components/Carousel';
3
+ import ContentHeader from './components/Header/ContentHeader';
4
+ import Directory from './components/Directory';
5
+ import DropdownButton from './components/Button/DropdownButton';
6
+ import EmptyBox from './components/EmptyBox';
7
+ import Form from './components/Form';
8
+ import Icons from './components/Icons';
9
+ import Input from './components/Input';
10
+ import ErrorMessage from './components/Input/ErrorMessage';
11
+ import AutoTooltip from './components/Table/AutoTooltip';
12
+ import OverlayLoading from './components/Loading/OverlayLoading';
13
+ import SwitchButton from './components/Button/SwitchButton';
14
+ import Table from './components/Table';
15
+ import TableBase from './components/Table/TableBase';
16
+ import Calendar from './components/Calendar';
17
+ import IntlText from './components/IntlText';
18
+ import AppendTable from './components/Table/AppendTable';
19
+ import ThemeProvider from './components/ThemeProvider';
20
+ import { Methods } from './components/Form';
21
+ import defaultTheme from './theme';
22
+ import 'antd/lib/table/style/index.css';
23
+ import 'antd/lib/dropdown/style/index.css';
24
+ import 'antd/lib/style/index.css';
25
+ import 'antd/lib/switch/style/index.css';
26
+ import 'antd/lib/spin/style/index.css';
27
+ import 'antd/lib/tooltip/style/index.css';
28
+ export { AppendTable, Button, Calendar, Carousel, ContentHeader, Directory, DropdownButton, EmptyBox, Form, Icons, Input, ErrorMessage, OverlayLoading, SwitchButton, Table, TableBase, ThemeProvider, AutoTooltip, IntlText, defaultTheme, };
29
+ export type { Methods, };
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ interface ICreateTableProps {
3
+ }
4
+ export declare const FormItemBox: import("styled-components").StyledComponent<"div", any, {
5
+ width?: number | undefined;
6
+ gap?: number | undefined;
7
+ fullHeight?: boolean | undefined;
8
+ }, never>;
9
+ export declare const DATASOURCE_TYPE: {
10
+ ICEBERG: string;
11
+ JDBC: string;
12
+ ORC: string;
13
+ PARQUET: string;
14
+ };
15
+ export declare const DATASOURCE_TYPE_OPTIONS: {
16
+ label: string;
17
+ value: string;
18
+ }[];
19
+ export declare const setColumnOption: (columns: Record<string, any>[], options?: Record<string, any>, padding?: number) => {
20
+ width: any;
21
+ ellipsis: {
22
+ showTitle: boolean;
23
+ };
24
+ }[];
25
+ declare const CreateTable: React.FC<ICreateTableProps>;
26
+ export default CreateTable;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface IFormSampleProps {
3
+ }
4
+ declare const FormSample: React.FC<IFormSampleProps>;
5
+ export default FormSample;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface ISampleProps {
3
+ }
4
+ declare const Sample: React.FC<ISampleProps>;
5
+ export default Sample;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface ISample2Props {
3
+ }
4
+ declare const Sample2: React.FC<ISample2Props>;
5
+ export default Sample2;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface ISample3Props {
3
+ }
4
+ declare const Sample3: React.FC<ISample3Props>;
5
+ export default Sample3;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface ISample4Props {
3
+ }
4
+ declare const Sample4: React.FC<ISample4Props>;
5
+ export default Sample4;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface ITableSampleProps {
3
+ }
4
+ declare const TableSample: React.FC<ITableSampleProps>;
5
+ export default TableSample;
@@ -0,0 +1,59 @@
1
+ export declare const treeData: {
2
+ title: string;
3
+ key: string;
4
+ isLeaf: boolean;
5
+ customType: string;
6
+ children: ({
7
+ title: string;
8
+ key: string;
9
+ customType: string;
10
+ isLeaf: boolean;
11
+ children?: undefined;
12
+ } | {
13
+ title: string;
14
+ key: string;
15
+ isLeaf: boolean;
16
+ children: ({
17
+ title: string;
18
+ key: string;
19
+ isLeaf: boolean;
20
+ children: {
21
+ title: string;
22
+ key: string;
23
+ isLeaf: boolean;
24
+ children: ({
25
+ title: string;
26
+ key: string;
27
+ isLeaf: boolean;
28
+ children: {
29
+ title: string;
30
+ key: string;
31
+ isLeaf: boolean;
32
+ children: {
33
+ title: string;
34
+ key: string;
35
+ isLeaf: boolean;
36
+ }[];
37
+ }[];
38
+ } | {
39
+ title: string;
40
+ key: string;
41
+ isLeaf: boolean;
42
+ children?: undefined;
43
+ })[];
44
+ }[];
45
+ } | {
46
+ title: string;
47
+ key: string;
48
+ isLeaf: boolean;
49
+ children?: undefined;
50
+ })[];
51
+ customType?: undefined;
52
+ } | {
53
+ title: string;
54
+ key: string;
55
+ isLeaf: boolean;
56
+ customType?: undefined;
57
+ children?: undefined;
58
+ })[];
59
+ }[];
@@ -0,0 +1,3 @@
1
+ import { ReportHandler } from 'web-vitals';
2
+ declare const reportWebVitals: (onPerfEntry?: ReportHandler) => void;
3
+ export default reportWebVitals;
@@ -0,0 +1,45 @@
1
+ export type ThemeType = {
2
+ info?: string;
3
+ info10?: string;
4
+ info20?: string;
5
+ success?: string;
6
+ warning?: string;
7
+ error?: string;
8
+ errortooltip?: string;
9
+ transparent?: string;
10
+ black100?: string;
11
+ black80?: string;
12
+ black70?: string;
13
+ black60?: string;
14
+ black50?: string;
15
+ black40?: string;
16
+ black30?: string;
17
+ black20?: string;
18
+ black15?: string;
19
+ black10?: string;
20
+ black05?: string;
21
+ black03?: string;
22
+ white?: string;
23
+ white90?: string;
24
+ white80?: string;
25
+ white70?: string;
26
+ white60?: string;
27
+ white50?: string;
28
+ white40?: string;
29
+ white30?: string;
30
+ white20?: string;
31
+ white10?: string;
32
+ line?: string;
33
+ primary?: string;
34
+ primary90?: string;
35
+ primary60?: string;
36
+ primary50?: string;
37
+ primary40?: string;
38
+ primary20?: string;
39
+ primary10?: string;
40
+ primarystop1?: string;
41
+ primarystop2?: string;
42
+ emptyLogo?: string;
43
+ };
44
+ declare const theme: ThemeType;
45
+ export default theme;
@@ -0,0 +1,28 @@
1
+ type ModalState = {
2
+ open: boolean;
3
+ data?: any;
4
+ };
5
+ /**
6
+ * modal state
7
+ * @param defaultValue
8
+ */
9
+ export declare function useModalState(defaultValue?: ModalState): readonly [ModalState, (value?: ModalState) => void];
10
+ /**
11
+ * pagination state
12
+ * @param defaultValue
13
+ */
14
+ export declare function usePaginationState(defaultValue?: PaginationType): readonly [PaginationType | undefined, (value?: PaginationType) => void];
15
+ export declare const useDebounce: (obj?: any, wait?: number) => any[];
16
+ export type DataInfoState = {
17
+ dataSource?: Record<string, any>[];
18
+ totalSize?: number;
19
+ };
20
+ /**
21
+ * Table datasource loading 처리를 위한 state
22
+ * @param defaultValue
23
+ */
24
+ export declare function useDataInfoState(defaultValue?: {
25
+ dataSource: undefined;
26
+ totalSize: number;
27
+ }): readonly [DataInfoState, (value?: DataInfoState) => void];
28
+ export {};
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const subscribe: (fn: any, values: any[]) => void;
3
+ export declare const usePrevious: (fn: any, values: any[]) => void;
4
+ export declare function useOutsideClick(callback: () => void): import("react").MutableRefObject<any>;
@@ -0,0 +1,27 @@
1
+ import queryString from 'query-string';
2
+ export declare const getOption: (options: any, value: any) => any;
3
+ /**
4
+ * 페이지네이션 계산 함수
5
+ * 현재값을 기준으로 앞뒤 페이지 range를 생성한다.
6
+ * @param current
7
+ * @param min
8
+ * @param total
9
+ * @param length
10
+ */
11
+ export declare const getPagingRange: (current: any, { min, total, length }?: {
12
+ min?: number | undefined;
13
+ total?: number | undefined;
14
+ length?: number | undefined;
15
+ }) => number[];
16
+ export declare const getSortOption: (option: any) => string | undefined;
17
+ export declare function escapeRegExp(string: any): any;
18
+ export declare const getPageQuery: () => queryString.ParsedQuery<string>;
19
+ export declare const getQuery: (key: any) => string | (string | null)[] | null;
20
+ export declare const getStringAttribute: (titleNode: any) => string | undefined;
21
+ /**
22
+ * object 공백 요소를 삭제하기 위한 용도
23
+ * @param obj 기본 object
24
+ * @param values values
25
+ * @param prefixTID prefix id
26
+ */
27
+ export declare const cleanEmptyObj: (obj: any, values: Record<string, any>[], prefixTID?: any) => any;
package/config/env.js ADDED
@@ -0,0 +1,104 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const paths = require('./paths');
6
+
7
+ // Make sure that including paths.js after env.js will read .env variables.
8
+ delete require.cache[require.resolve('./paths')];
9
+
10
+ const NODE_ENV = process.env.NODE_ENV;
11
+ if (!NODE_ENV) {
12
+ throw new Error(
13
+ 'The NODE_ENV environment variable is required but was not specified.'
14
+ );
15
+ }
16
+
17
+ // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18
+ const dotenvFiles = [
19
+ `${paths.dotenv}.${NODE_ENV}.local`,
20
+ // Don't include `.env.local` for `test` environment
21
+ // since normally you expect tests to produce the same
22
+ // results for everyone
23
+ NODE_ENV !== 'test' && `${paths.dotenv}.local`,
24
+ `${paths.dotenv}.${NODE_ENV}`,
25
+ paths.dotenv,
26
+ ].filter(Boolean);
27
+
28
+ // Load environment variables from .env* files. Suppress warnings using silent
29
+ // if this file is missing. dotenv will never modify any environment variables
30
+ // that have already been set. Variable expansion is supported in .env files.
31
+ // https://github.com/motdotla/dotenv
32
+ // https://github.com/motdotla/dotenv-expand
33
+ dotenvFiles.forEach(dotenvFile => {
34
+ if (fs.existsSync(dotenvFile)) {
35
+ require('dotenv-expand')(
36
+ require('dotenv').config({
37
+ path: dotenvFile,
38
+ })
39
+ );
40
+ }
41
+ });
42
+
43
+ // We support resolving modules according to `NODE_PATH`.
44
+ // This lets you use absolute paths in imports inside large monorepos:
45
+ // https://github.com/facebook/create-react-app/issues/253.
46
+ // It works similar to `NODE_PATH` in Node itself:
47
+ // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
48
+ // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
49
+ // Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
50
+ // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
51
+ // We also resolve them to make sure all tools using them work consistently.
52
+ const appDirectory = fs.realpathSync(process.cwd());
53
+ process.env.NODE_PATH = (process.env.NODE_PATH || '')
54
+ .split(path.delimiter)
55
+ .filter(folder => folder && !path.isAbsolute(folder))
56
+ .map(folder => path.resolve(appDirectory, folder))
57
+ .join(path.delimiter);
58
+
59
+ // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
60
+ // injected into the application via DefinePlugin in webpack configuration.
61
+ const REACT_APP = /^REACT_APP_/i;
62
+
63
+ function getClientEnvironment(publicUrl) {
64
+ const raw = Object.keys(process.env)
65
+ .filter(key => REACT_APP.test(key))
66
+ .reduce(
67
+ (env, key) => {
68
+ env[key] = process.env[key];
69
+ return env;
70
+ },
71
+ {
72
+ // Useful for determining whether we’re running in production mode.
73
+ // Most importantly, it switches React into the correct mode.
74
+ NODE_ENV: process.env.NODE_ENV || 'development',
75
+ // Useful for resolving the correct path to static assets in `public`.
76
+ // For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
77
+ // This should only be used as an escape hatch. Normally you would put
78
+ // images into the `src` and `import` them in code to get their paths.
79
+ PUBLIC_URL: publicUrl,
80
+ // We support configuring the sockjs pathname during development.
81
+ // These settings let a developer run multiple simultaneous projects.
82
+ // They are used as the connection `hostname`, `pathname` and `port`
83
+ // in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
84
+ // and `sockPort` options in webpack-dev-server.
85
+ WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
86
+ WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
87
+ WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
88
+ // Whether or not react-refresh is enabled.
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;
@@ -0,0 +1,66 @@
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;
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const babelJest = require('babel-jest').default;
4
+
5
+ const hasJsxRuntime = (() => {
6
+ if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
7
+ return false;
8
+ }
9
+
10
+ try {
11
+ require.resolve('react/jsx-runtime');
12
+ return true;
13
+ } catch (e) {
14
+ return false;
15
+ }
16
+ })();
17
+
18
+ module.exports = babelJest.createTransformer({
19
+ presets: [
20
+ [
21
+ require.resolve('babel-preset-react-app'),
22
+ {
23
+ runtime: hasJsxRuntime ? 'automatic' : 'classic',
24
+ },
25
+ ],
26
+ ],
27
+ babelrc: false,
28
+ configFile: false,
29
+ });
@@ -0,0 +1,14 @@
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
+ };
@@ -0,0 +1,40 @@
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
+ };