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.
- package/.storybook/main.ts +32 -0
- package/.storybook/preview.tsx +22 -0
- package/@types/custom.d.ts +43 -0
- package/@types/styles.d.ts +3 -0
- package/README.md +46 -0
- package/build/253ac843d9cff70a5ac5.eot +1 -0
- package/build/3d3eb30384470a0a5f6d.gif +1 -0
- package/build/650c6c71d75bb6fca50d.svg +1 -0
- package/build/App.d.ts +3 -0
- package/build/Main.d.ts +5 -0
- package/build/ad0c1b9dc2d8ec4e2fa0.ttf +1 -0
- package/build/components/Button/DropdownButton.d.ts +13 -0
- package/build/components/Button/SwitchButton.d.ts +7 -0
- package/build/components/Button/index.d.ts +11 -0
- package/build/components/Button/styled.d.ts +10 -0
- package/build/components/Calendar/CalendarNavigation.d.ts +9 -0
- package/build/components/Calendar/constants.d.ts +2 -0
- package/build/components/Calendar/index.d.ts +11 -0
- package/build/components/Calendar/styled.d.ts +2 -0
- package/build/components/Carousel/ArrowButton.d.ts +7 -0
- package/build/components/Carousel/index.d.ts +13 -0
- package/build/components/Carousel/styled.d.ts +2 -0
- package/build/components/Directory/index.d.ts +32 -0
- package/build/components/Directory/styled.d.ts +6 -0
- package/build/components/EmptyBox/index.d.ts +8 -0
- package/build/components/EmptyBox/styled.d.ts +4 -0
- package/build/components/Form/Form.d.ts +18 -0
- package/build/components/Form/Group.d.ts +6 -0
- package/build/components/Form/Item.d.ts +22 -0
- package/build/components/Form/index.d.ts +14 -0
- package/build/components/Form/styled.d.ts +7 -0
- package/build/components/Header/ContentHeader.d.ts +15 -0
- package/build/components/Header/styled.d.ts +5 -0
- package/build/components/Icons/index.d.ts +14 -0
- package/build/components/Input/Checkbox.d.ts +19 -0
- package/build/components/Input/ErrorMessage.d.ts +8 -0
- package/build/components/Input/Input.d.ts +23 -0
- package/build/components/Input/InputNumber.d.ts +8 -0
- package/build/components/Input/Radio.d.ts +16 -0
- package/build/components/Input/Search.d.ts +13 -0
- package/build/components/Input/Select.d.ts +42 -0
- package/build/components/Input/TextArea.d.ts +15 -0
- package/build/components/Input/index.d.ts +19 -0
- package/build/components/Input/styled.d.ts +22 -0
- package/build/components/IntlText/index.d.ts +5 -0
- package/build/components/Loading/OverlayLoading.d.ts +10 -0
- package/build/components/Loading/Spinner.d.ts +9 -0
- package/build/components/Loading/styled.d.ts +10 -0
- package/build/components/Styled/mixins.d.ts +13 -0
- package/build/components/Styled/variable.d.ts +6 -0
- package/build/components/Table/AppendTable.d.ts +26 -0
- package/build/components/Table/AutoTooltip.d.ts +8 -0
- package/build/components/Table/TableBase.d.ts +16 -0
- package/build/components/Table/TableLoading.d.ts +9 -0
- package/build/components/Table/components/Pagination.d.ts +18 -0
- package/build/components/Table/components/PaginationItem.d.ts +9 -0
- package/build/components/Table/index.d.ts +27 -0
- package/build/components/Table/styled.d.ts +25 -0
- package/build/components/ThemeProvider.d.ts +10 -0
- package/build/f7f1e7911cd4fe275e29.woff +1 -0
- package/build/globalStyle.d.ts +5 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +2 -0
- package/build/index.js.LICENSE.txt +69 -0
- package/build/modules.d.ts +29 -0
- package/build/pages/CreateTable.d.ts +26 -0
- package/build/pages/FormSample.d.ts +5 -0
- package/build/pages/Sample.d.ts +5 -0
- package/build/pages/Sample2.d.ts +5 -0
- package/build/pages/Sample3.d.ts +5 -0
- package/build/pages/Sample4.d.ts +5 -0
- package/build/pages/TableSample.d.ts +5 -0
- package/build/pages/sampleData.d.ts +59 -0
- package/build/reportWebVitals.d.ts +3 -0
- package/build/theme.d.ts +45 -0
- package/build/utils/customState.d.ts +28 -0
- package/build/utils/hookUtils.d.ts +4 -0
- package/build/utils/utils.d.ts +27 -0
- package/config/env.js +104 -0
- package/config/getHttpsConfig.js +66 -0
- package/config/jest/babelTransform.js +29 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/modules.js +134 -0
- package/config/paths.js +77 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
- package/config/webpack.config.js +756 -0
- package/config/webpack.prod.config.js +91 -0
- package/config/webpackDevServer.config.js +127 -0
- package/doctor-storybook.log +18 -0
- package/package.json +212 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/scripts/build.js +217 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +52 -0
- package/tsconfig.json +33 -0
package/scripts/build.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
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
|
+
const path = require('path');
|
|
18
|
+
const chalk = require('react-dev-utils/chalk');
|
|
19
|
+
const fs = require('fs-extra');
|
|
20
|
+
const bfj = require('bfj');
|
|
21
|
+
const webpack = require('webpack');
|
|
22
|
+
const configFactory = require('../config/webpack.prod.config');
|
|
23
|
+
const paths = require('../config/paths');
|
|
24
|
+
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
25
|
+
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
26
|
+
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
|
27
|
+
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
28
|
+
const printBuildError = require('react-dev-utils/printBuildError');
|
|
29
|
+
|
|
30
|
+
const measureFileSizesBeforeBuild =
|
|
31
|
+
FileSizeReporter.measureFileSizesBeforeBuild;
|
|
32
|
+
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
33
|
+
const useYarn = fs.existsSync(paths.yarnLockFile);
|
|
34
|
+
|
|
35
|
+
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
36
|
+
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
37
|
+
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
38
|
+
|
|
39
|
+
const isInteractive = process.stdout.isTTY;
|
|
40
|
+
|
|
41
|
+
// Warn and crash if required files are missing
|
|
42
|
+
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const argv = process.argv.slice(2);
|
|
47
|
+
const writeStatsJson = argv.indexOf('--stats') !== -1;
|
|
48
|
+
|
|
49
|
+
// Generate configuration
|
|
50
|
+
const config = configFactory('production');
|
|
51
|
+
|
|
52
|
+
// We require that you explicitly set browsers and do not fall back to
|
|
53
|
+
// browserslist defaults.
|
|
54
|
+
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
|
55
|
+
checkBrowsers(paths.appPath, isInteractive)
|
|
56
|
+
.then(() => {
|
|
57
|
+
// First, read the current file sizes in build directory.
|
|
58
|
+
// This lets us display how much they changed later.
|
|
59
|
+
return measureFileSizesBeforeBuild(paths.appBuild);
|
|
60
|
+
})
|
|
61
|
+
.then(previousFileSizes => {
|
|
62
|
+
// Remove all content but keep the directory so that
|
|
63
|
+
// if you're in it, you don't end up in Trash
|
|
64
|
+
fs.emptyDirSync(paths.appBuild);
|
|
65
|
+
// Merge with the public folder
|
|
66
|
+
copyPublicFolder();
|
|
67
|
+
// Start the webpack build
|
|
68
|
+
return build(previousFileSizes);
|
|
69
|
+
})
|
|
70
|
+
.then(
|
|
71
|
+
({ stats, previousFileSizes, warnings }) => {
|
|
72
|
+
if (warnings.length) {
|
|
73
|
+
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
74
|
+
console.log(warnings.join('\n\n'));
|
|
75
|
+
console.log(
|
|
76
|
+
'\nSearch for the ' +
|
|
77
|
+
chalk.underline(chalk.yellow('keywords')) +
|
|
78
|
+
' to learn more about each warning.'
|
|
79
|
+
);
|
|
80
|
+
console.log(
|
|
81
|
+
'To ignore, add ' +
|
|
82
|
+
chalk.cyan('// eslint-disable-next-line') +
|
|
83
|
+
' to the line before.\n'
|
|
84
|
+
);
|
|
85
|
+
} else {
|
|
86
|
+
console.log(chalk.green('Compiled successfully.\n'));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
console.log('File sizes after gzip:\n');
|
|
90
|
+
printFileSizesAfterBuild(
|
|
91
|
+
stats,
|
|
92
|
+
previousFileSizes,
|
|
93
|
+
paths.appBuild,
|
|
94
|
+
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
|
95
|
+
WARN_AFTER_CHUNK_GZIP_SIZE
|
|
96
|
+
);
|
|
97
|
+
console.log();
|
|
98
|
+
|
|
99
|
+
const appPackage = require(paths.appPackageJson);
|
|
100
|
+
const publicUrl = paths.publicUrlOrPath;
|
|
101
|
+
const publicPath = config.output.publicPath;
|
|
102
|
+
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
|
103
|
+
printHostingInstructions(
|
|
104
|
+
appPackage,
|
|
105
|
+
publicUrl,
|
|
106
|
+
publicPath,
|
|
107
|
+
buildFolder,
|
|
108
|
+
useYarn
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
err => {
|
|
112
|
+
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
|
113
|
+
if (tscCompileOnError) {
|
|
114
|
+
console.log(
|
|
115
|
+
chalk.yellow(
|
|
116
|
+
'Compiled with the following type errors (you may want to check these before deploying your app):\n'
|
|
117
|
+
)
|
|
118
|
+
);
|
|
119
|
+
printBuildError(err);
|
|
120
|
+
} else {
|
|
121
|
+
console.log(chalk.red('Failed to compile.\n'));
|
|
122
|
+
printBuildError(err);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
.catch(err => {
|
|
128
|
+
if (err && err.message) {
|
|
129
|
+
console.log(err.message);
|
|
130
|
+
}
|
|
131
|
+
process.exit(1);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Create the production build and print the deployment instructions.
|
|
135
|
+
function build(previousFileSizes) {
|
|
136
|
+
console.log('Creating an optimized production build...');
|
|
137
|
+
|
|
138
|
+
const compiler = webpack(config);
|
|
139
|
+
return new Promise((resolve, reject) => {
|
|
140
|
+
compiler.run((err, stats) => {
|
|
141
|
+
let messages;
|
|
142
|
+
if (err) {
|
|
143
|
+
if (!err.message) {
|
|
144
|
+
return reject(err);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let errMessage = err.message;
|
|
148
|
+
|
|
149
|
+
// Add additional information for postcss errors
|
|
150
|
+
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
151
|
+
errMessage +=
|
|
152
|
+
'\nCompileError: Begins at CSS selector ' +
|
|
153
|
+
err['postcssNode'].selector;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
messages = formatWebpackMessages({
|
|
157
|
+
errors: [errMessage],
|
|
158
|
+
warnings: [],
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
messages = formatWebpackMessages(
|
|
162
|
+
stats.toJson({ all: false, warnings: true, errors: true })
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
if (messages.errors.length) {
|
|
166
|
+
// Only keep the first error. Others are often indicative
|
|
167
|
+
// of the same problem, but confuse the reader with noise.
|
|
168
|
+
if (messages.errors.length > 1) {
|
|
169
|
+
messages.errors.length = 1;
|
|
170
|
+
}
|
|
171
|
+
return reject(new Error(messages.errors.join('\n\n')));
|
|
172
|
+
}
|
|
173
|
+
if (
|
|
174
|
+
process.env.CI &&
|
|
175
|
+
(typeof process.env.CI !== 'string' ||
|
|
176
|
+
process.env.CI.toLowerCase() !== 'false') &&
|
|
177
|
+
messages.warnings.length
|
|
178
|
+
) {
|
|
179
|
+
// Ignore sourcemap warnings in CI builds. See #8227 for more info.
|
|
180
|
+
const filteredWarnings = messages.warnings.filter(
|
|
181
|
+
w => !/Failed to parse source map/.test(w)
|
|
182
|
+
);
|
|
183
|
+
if (filteredWarnings.length) {
|
|
184
|
+
console.log(
|
|
185
|
+
chalk.yellow(
|
|
186
|
+
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
|
187
|
+
'Most CI servers set it automatically.\n'
|
|
188
|
+
)
|
|
189
|
+
);
|
|
190
|
+
return reject(new Error(filteredWarnings.join('\n\n')));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const resolveArgs = {
|
|
195
|
+
stats,
|
|
196
|
+
previousFileSizes,
|
|
197
|
+
warnings: messages.warnings,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
if (writeStatsJson) {
|
|
201
|
+
return bfj
|
|
202
|
+
.write(paths.appBuild + '/bundle-stats.json', stats.toJson())
|
|
203
|
+
.then(() => resolve(resolveArgs))
|
|
204
|
+
.catch(error => reject(new Error(error)));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return resolve(resolveArgs);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function copyPublicFolder() {
|
|
213
|
+
fs.copySync(paths.appPublic, paths.appBuild, {
|
|
214
|
+
dereference: true,
|
|
215
|
+
filter: file => file !== paths.appHtml,
|
|
216
|
+
});
|
|
217
|
+
}
|
package/scripts/start.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
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 = 'development';
|
|
5
|
+
process.env.NODE_ENV = 'development';
|
|
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
|
+
const fs = require('fs');
|
|
18
|
+
const chalk = require('react-dev-utils/chalk');
|
|
19
|
+
const webpack = require('webpack');
|
|
20
|
+
const WebpackDevServer = require('webpack-dev-server');
|
|
21
|
+
const clearConsole = require('react-dev-utils/clearConsole');
|
|
22
|
+
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
23
|
+
const {
|
|
24
|
+
choosePort,
|
|
25
|
+
createCompiler,
|
|
26
|
+
prepareProxy,
|
|
27
|
+
prepareUrls,
|
|
28
|
+
} = require('react-dev-utils/WebpackDevServerUtils');
|
|
29
|
+
const openBrowser = require('react-dev-utils/openBrowser');
|
|
30
|
+
const semver = require('semver');
|
|
31
|
+
const paths = require('../config/paths');
|
|
32
|
+
const configFactory = require('../config/webpack.config');
|
|
33
|
+
const createDevServerConfig = require('../config/webpackDevServer.config');
|
|
34
|
+
const getClientEnvironment = require('../config/env');
|
|
35
|
+
const react = require(require.resolve('react', { paths: [paths.appPath] }));
|
|
36
|
+
|
|
37
|
+
const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
|
|
38
|
+
const useYarn = fs.existsSync(paths.yarnLockFile);
|
|
39
|
+
const isInteractive = process.stdout.isTTY;
|
|
40
|
+
|
|
41
|
+
// Warn and crash if required files are missing
|
|
42
|
+
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Tools like Cloud9 rely on this.
|
|
47
|
+
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
|
48
|
+
const HOST = process.env.HOST || '0.0.0.0';
|
|
49
|
+
|
|
50
|
+
if (process.env.HOST) {
|
|
51
|
+
console.log(
|
|
52
|
+
chalk.cyan(
|
|
53
|
+
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
|
54
|
+
chalk.bold(process.env.HOST)
|
|
55
|
+
)}`
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
console.log(
|
|
59
|
+
`If this was unintentional, check that you haven't mistakenly set it in your shell.`
|
|
60
|
+
);
|
|
61
|
+
console.log(
|
|
62
|
+
`Learn more here: ${chalk.yellow('https://cra.link/advanced-config')}`
|
|
63
|
+
);
|
|
64
|
+
console.log();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// We require that you explicitly set browsers and do not fall back to
|
|
68
|
+
// browserslist defaults.
|
|
69
|
+
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
|
70
|
+
checkBrowsers(paths.appPath, isInteractive)
|
|
71
|
+
.then(() => {
|
|
72
|
+
// We attempt to use the default port but if it is busy, we offer the user to
|
|
73
|
+
// run on a different port. `choosePort()` Promise resolves to the next free port.
|
|
74
|
+
return choosePort(HOST, DEFAULT_PORT);
|
|
75
|
+
})
|
|
76
|
+
.then(port => {
|
|
77
|
+
if (port == null) {
|
|
78
|
+
// We have not found a port.
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const config = configFactory('development');
|
|
83
|
+
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
|
84
|
+
const appName = require(paths.appPackageJson).name;
|
|
85
|
+
|
|
86
|
+
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
|
87
|
+
const urls = prepareUrls(
|
|
88
|
+
protocol,
|
|
89
|
+
HOST,
|
|
90
|
+
port,
|
|
91
|
+
paths.publicUrlOrPath.slice(0, -1)
|
|
92
|
+
);
|
|
93
|
+
// Create a webpack compiler that is configured with custom messages.
|
|
94
|
+
const compiler = createCompiler({
|
|
95
|
+
appName,
|
|
96
|
+
config,
|
|
97
|
+
urls,
|
|
98
|
+
useYarn,
|
|
99
|
+
useTypeScript,
|
|
100
|
+
webpack,
|
|
101
|
+
});
|
|
102
|
+
// Load proxy config
|
|
103
|
+
const proxySetting = require(paths.appPackageJson).proxy;
|
|
104
|
+
const proxyConfig = prepareProxy(
|
|
105
|
+
proxySetting,
|
|
106
|
+
paths.appPublic,
|
|
107
|
+
paths.publicUrlOrPath
|
|
108
|
+
);
|
|
109
|
+
// Serve webpack assets generated by the compiler over a web server.
|
|
110
|
+
const serverConfig = {
|
|
111
|
+
...createDevServerConfig(proxyConfig, urls.lanUrlForConfig),
|
|
112
|
+
host: HOST,
|
|
113
|
+
port,
|
|
114
|
+
};
|
|
115
|
+
const devServer = new WebpackDevServer(serverConfig, compiler);
|
|
116
|
+
// Launch WebpackDevServer.
|
|
117
|
+
devServer.startCallback(() => {
|
|
118
|
+
if (isInteractive) {
|
|
119
|
+
clearConsole();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (env.raw.FAST_REFRESH && semver.lt(react.version, '16.10.0')) {
|
|
123
|
+
console.log(
|
|
124
|
+
chalk.yellow(
|
|
125
|
+
`Fast Refresh requires React 16.10 or higher. You are using React ${react.version}.`
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
console.log(chalk.cyan('Starting the development server...\n'));
|
|
131
|
+
openBrowser(urls.localUrlForBrowser);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
['SIGINT', 'SIGTERM'].forEach(function (sig) {
|
|
135
|
+
process.on(sig, function () {
|
|
136
|
+
devServer.close();
|
|
137
|
+
process.exit();
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (process.env.CI !== 'true') {
|
|
142
|
+
// Gracefully exit when stdin ends
|
|
143
|
+
process.stdin.on('end', function () {
|
|
144
|
+
devServer.close();
|
|
145
|
+
process.exit();
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
.catch(err => {
|
|
150
|
+
if (err && err.message) {
|
|
151
|
+
console.log(err.message);
|
|
152
|
+
}
|
|
153
|
+
process.exit(1);
|
|
154
|
+
});
|
package/scripts/test.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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 = 'test';
|
|
5
|
+
process.env.NODE_ENV = 'test';
|
|
6
|
+
process.env.PUBLIC_URL = '';
|
|
7
|
+
|
|
8
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
9
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
10
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
11
|
+
process.on('unhandledRejection', err => {
|
|
12
|
+
throw err;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Ensure environment variables are read.
|
|
16
|
+
require('../config/env');
|
|
17
|
+
|
|
18
|
+
const jest = require('jest');
|
|
19
|
+
const execSync = require('child_process').execSync;
|
|
20
|
+
let argv = process.argv.slice(2);
|
|
21
|
+
|
|
22
|
+
function isInGitRepository() {
|
|
23
|
+
try {
|
|
24
|
+
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
|
|
25
|
+
return true;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isInMercurialRepository() {
|
|
32
|
+
try {
|
|
33
|
+
execSync('hg --cwd . root', { stdio: 'ignore' });
|
|
34
|
+
return true;
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Watch unless on CI or explicitly running all tests
|
|
41
|
+
if (
|
|
42
|
+
!process.env.CI &&
|
|
43
|
+
argv.indexOf('--watchAll') === -1 &&
|
|
44
|
+
argv.indexOf('--watchAll=false') === -1
|
|
45
|
+
) {
|
|
46
|
+
// https://github.com/facebook/create-react-app/issues/5210
|
|
47
|
+
const hasSourceControl = isInGitRepository() || isInMercurialRepository();
|
|
48
|
+
argv.push(hasSourceControl ? '--watch' : '--watchAll');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
jest.run(argv);
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"esnext"
|
|
8
|
+
],
|
|
9
|
+
"outDir": "build",
|
|
10
|
+
"allowJs": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"allowSyntheticDefaultImports": true,
|
|
15
|
+
"strict": true,
|
|
16
|
+
"forceConsistentCasingInFileNames": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
"module": "esnext",
|
|
19
|
+
"moduleResolution": "node",
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
"isolatedModules": true,
|
|
22
|
+
"noImplicitAny": false,
|
|
23
|
+
"jsx": "react-jsx",
|
|
24
|
+
"baseUrl": ".",
|
|
25
|
+
"paths": {
|
|
26
|
+
"@/*": ["./src/*"]
|
|
27
|
+
},
|
|
28
|
+
"typeRoots": ["./@types", "../node_modules/@types"],
|
|
29
|
+
"downlevelIteration": true
|
|
30
|
+
},
|
|
31
|
+
"include": ["@types", "src/modules.ts", "src/index.tsx", "src/react-app-env.d.ts"],
|
|
32
|
+
"exclude": ["node_modules"]
|
|
33
|
+
}
|