orc-scripts 1.2.0-pre.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/LICENSE +19 -0
- package/README.md +76 -0
- package/babel.js +1 -0
- package/eslint.js +1 -0
- package/jest.js +1 -0
- package/package.json +164 -0
- package/prettier.js +1 -0
- package/src/__mocks__/fileMock.js +1 -0
- package/src/config/babel-preset.js +4 -0
- package/src/config/babel-transform.js +4 -0
- package/src/config/babel-whitelist.json +1 -0
- package/src/config/babelrc.js +38 -0
- package/src/config/eslintrc.js +15 -0
- package/src/config/jest-resolver.js +35 -0
- package/src/config/jest.config.js +45 -0
- package/src/config/jestSetupFiles.js +4 -0
- package/src/config/prettier.config.js +9 -0
- package/src/config/setAssetPath.js +1 -0
- package/src/config/unexpected-form.js +317 -0
- package/src/config/unexpected-form.test.js +2397 -0
- package/src/config/unexpected-module.js +112 -0
- package/src/config/unexpected-module.test.js +1106 -0
- package/src/config/unexpected-styles.js +44 -0
- package/src/config/unexpected-styles.test.js +118 -0
- package/src/config/unexpected.js +117 -0
- package/src/config/unexpected.test.js +393 -0
- package/src/config/webpack.config.js +103 -0
- package/src/index.js +19 -0
- package/src/run-script.js +99 -0
- package/src/scripts/build/cli.js +43 -0
- package/src/scripts/build/index.js +9 -0
- package/src/scripts/build/web.js +24 -0
- package/src/scripts/buildDep.js +122 -0
- package/src/scripts/buildIconsSheet.js +50 -0
- package/src/scripts/clean.js +8 -0
- package/src/scripts/extract-messages.js +22 -0
- package/src/scripts/generateApi.js +152 -0
- package/src/scripts/getDist.js +20 -0
- package/src/scripts/mergeTranslations.js +32 -0
- package/src/scripts/prep.js +28 -0
- package/src/scripts/start.js +45 -0
- package/src/scripts/tag.js +76 -0
- package/src/scripts/test.js +26 -0
- package/src/scripts/validateTranslations.js +72 -0
- package/src/utils.js +95 -0
- package/src/utils.test.js +93 -0
- package/webpack.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2018 Orckestra Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Orckestra Client Application Framework toolbox
|
|
2
|
+
|
|
3
|
+
 [](https://coveralls.io/github/Orckestra/orc-scripts?branch=master)
|
|
4
|
+
|
|
5
|
+
This package contains a standard set of dependencies and tooling for web applications. It is based on [`kcd-scripts`](https://github.com/kentcdodds/kcd-scripts) (copyright © 2017 Kent C. Dodds, licensed via MIT License) in both concept and code.
|
|
6
|
+
|
|
7
|
+
## Installation and use
|
|
8
|
+
|
|
9
|
+
Installing this package is done via npm: `npm install orc-scripts`. This will also install the dependency set provided.
|
|
10
|
+
|
|
11
|
+
### Scripts
|
|
12
|
+
|
|
13
|
+
[Several scripts](docs/scripts.md) are provided to users.
|
|
14
|
+
|
|
15
|
+
The easiest way to use these scripts is to add entries to your package.json under "scripts", invoking the `orc-scripts` command. A typical "scripts" section might look like this:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"scripts": {
|
|
20
|
+
"clean": "orc-scripts clean",
|
|
21
|
+
"build": "orc-scripts prep && orc-scripts build",
|
|
22
|
+
"start": "orc-scripts prep && orc-scripts start",
|
|
23
|
+
"test": "orc-scripts test",
|
|
24
|
+
"coverage": "orc-scripts test --coverage"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Code tools
|
|
30
|
+
|
|
31
|
+
The toolbox contains support for `eslint` and `prettier`, both for use with development tools (such as Atom or VS Code) and in git hooks. To integrate with your development tool of choice, ensure the suitable plugin is installed if applicable, and create a config file or `package.json` entry that points to the `orc-scripts` preset for that tool (`orc-scripts/eslint`, resp. `orc-scripts/prettier`).
|
|
32
|
+
|
|
33
|
+
To set up a git commit hook that runs `prettier` on all staged files, add the following section to `package.json`:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"husky": {
|
|
38
|
+
"hooks": {
|
|
39
|
+
"pre-commit": "lint-staged"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This will run the `lint-staged` tool whenever you commit files to git. Configure this tool with a section in your `package.json` as follows:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"lint-staged": {
|
|
50
|
+
"linters": {
|
|
51
|
+
"*.{js,json,md}": ["prettier --write", "git add"]
|
|
52
|
+
},
|
|
53
|
+
"ignore": ["package.json", "package-lock.json", "src/translations/*.json"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This instructs `lint-staged` to run `prettier` on staged files, rewriting the file to specifications, and then re-staging it for the commit. This ensures that all code in the app lives up to the strict standards set by `prettier`. It is recommended to not let it process `package.json`, `package-lock.json` and translation files, as these are automatically processed and changed. Prettier can be told to ignore these by adding a `.prettierignore` file using the same syntax as `.gitignore`.
|
|
59
|
+
|
|
60
|
+
### Testing
|
|
61
|
+
|
|
62
|
+
Testing with Jest and `unexpected` is built into the toolbox, allowing test setup to be as simple as adding a file with a `.test.js` suffix to your file tree. A number of [plugins and custom assertions](docs/assertions.md) are provided as well.
|
|
63
|
+
|
|
64
|
+
### Deploying
|
|
65
|
+
|
|
66
|
+
An application that employs code splitting (resulting in multiple output bundle files) and is to be deployed to a CDN will need to pass the CDN location to the entry bundle to ensure that further bundles are fetched from the right location. To do this, include a script in the header of the `index.html` file which sets `window.ASSET_PATH` to the CDN location (a slash-terminated url, i.e. `"https://foo.cdn.org/my-bundle/"`). This needs to be executed before the entry bundle.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
Copyright © 2018 Orckestra Inc.
|
|
71
|
+
|
|
72
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
73
|
+
|
|
74
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
75
|
+
|
|
76
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/babel.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./src/config/babel-preset");
|
package/eslint.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./src/config/eslintrc");
|
package/jest.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./src/config/jest.config");
|
package/package.json
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "orc-scripts",
|
|
3
|
+
"version": "1.2.0-pre.0",
|
|
4
|
+
"description": "Scripts toolbox for Orckestra",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"orc-scripts": "src/index.js"
|
|
8
|
+
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">= 10",
|
|
11
|
+
"npm": ">= 6.13.4"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"coverage": "node src test --coverage",
|
|
15
|
+
"coveralls": "cat coverage/lcov.info | coveralls",
|
|
16
|
+
"lint": "eslint src",
|
|
17
|
+
"test": "node src test",
|
|
18
|
+
"test:orc-shared": "node src buildDep https://github.com/Orckestra/orc-shared.git",
|
|
19
|
+
"watch": "node src prep && node src build --watch",
|
|
20
|
+
"tag": "node src tag"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"babel.js",
|
|
25
|
+
"webpack.js",
|
|
26
|
+
"jest.js",
|
|
27
|
+
"eslint.js",
|
|
28
|
+
"prettier.js"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/Orckestra/orc-scripts.git"
|
|
33
|
+
},
|
|
34
|
+
"author": "Gert K. Sønderby <gert.sonderby@orckestra.com>",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/Orckestra/orc-scripts/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/Orckestra/orc-scripts#readme",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@babel/cli": "^7.0.0",
|
|
42
|
+
"@babel/core": "^7.0.0",
|
|
43
|
+
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
|
44
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
|
45
|
+
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
|
|
46
|
+
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
|
47
|
+
"@babel/plugin-transform-computed-properties": "^7.0.0",
|
|
48
|
+
"@babel/plugin-transform-destructuring": "^7.8.3",
|
|
49
|
+
"@babel/plugin-transform-react-jsx": "^7.0.0",
|
|
50
|
+
"@babel/plugin-transform-template-literals": "^7.0.0",
|
|
51
|
+
"@babel/preset-env": "^7.0.0",
|
|
52
|
+
"@formatjs/intl-getcanonicallocales": "^1.4.6",
|
|
53
|
+
"@formatjs/intl-pluralrules": "^3.4.10",
|
|
54
|
+
"@gustavnikolaj/async-main-wrap": "^3.0.1",
|
|
55
|
+
"@loadable/babel-plugin": "^5.13.2",
|
|
56
|
+
"@loadable/component": "5.13.1",
|
|
57
|
+
"@material-ui/core": "^4.9.14",
|
|
58
|
+
"@material-ui/lab": "^4.0.0-alpha.57",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
|
60
|
+
"@typescript-eslint/parser": "^2.0.0",
|
|
61
|
+
"@welldone-software/why-did-you-render": "^4.2.5",
|
|
62
|
+
"babel-core": "7.0.0-bridge.0",
|
|
63
|
+
"babel-eslint": "^10.0.1",
|
|
64
|
+
"babel-loader": "^8.0.4",
|
|
65
|
+
"babel-plugin-react-intl-auto": "^3.1.0",
|
|
66
|
+
"babel-plugin-root-import": "^6.5.0",
|
|
67
|
+
"babel-plugin-styled-components": "^1.10.6",
|
|
68
|
+
"classnames": "^2.2.6",
|
|
69
|
+
"connected-react-router": "^6.3.1",
|
|
70
|
+
"core-js": "^3.0.0",
|
|
71
|
+
"coveralls": "^3.0.2",
|
|
72
|
+
"cross-spawn": "^7.0.0",
|
|
73
|
+
"css-loader": "^3.4.2",
|
|
74
|
+
"date-fns": "^2",
|
|
75
|
+
"dotenv": "^8.0.0",
|
|
76
|
+
"enzyme": "^3.11.0",
|
|
77
|
+
"enzyme-adapter-react-16": "^1.15.2",
|
|
78
|
+
"eslint": "^6.1.0",
|
|
79
|
+
"eslint-config-react-app": "^5.1.0",
|
|
80
|
+
"eslint-plugin-flowtype": "^4.7.0",
|
|
81
|
+
"eslint-plugin-import": "^2.14.0",
|
|
82
|
+
"eslint-plugin-jsx-a11y": "^6.1.2",
|
|
83
|
+
"eslint-plugin-react": "^7.11.1",
|
|
84
|
+
"eslint-plugin-react-hooks": "^2.5.1",
|
|
85
|
+
"extract-react-intl-messages": "^4.1.1",
|
|
86
|
+
"file-loader": "^6.0.0",
|
|
87
|
+
"full-icu": "^1.3.1",
|
|
88
|
+
"husky": "^4.0.0",
|
|
89
|
+
"icu4c-data": "^0.64.2",
|
|
90
|
+
"identity-obj-proxy": "^3.0.0",
|
|
91
|
+
"imagemin": "^5.0.0",
|
|
92
|
+
"img-loader": "^3.0.1",
|
|
93
|
+
"immutable": "^3.0.0",
|
|
94
|
+
"immutable4": "npm:immutable@^4.0.0-rc.12",
|
|
95
|
+
"is-ci": "^2.0.0",
|
|
96
|
+
"jest": "^26.1.0",
|
|
97
|
+
"jest-enzyme": "^7.1.2",
|
|
98
|
+
"jest-junit": "^11.0.1",
|
|
99
|
+
"lint-staged": "^10.0.0",
|
|
100
|
+
"moment-timezone": "^0.5.33",
|
|
101
|
+
"ncp": "^2.0.0",
|
|
102
|
+
"normalizr": "^3.3.0",
|
|
103
|
+
"pkg-dir": "^4.0.0",
|
|
104
|
+
"polished": "^3.4.2",
|
|
105
|
+
"prettier": "^2.0.2",
|
|
106
|
+
"react": "^16.12.0",
|
|
107
|
+
"react-big-calendar": "^0.33.2",
|
|
108
|
+
"react-datepicker": "^3.0.0",
|
|
109
|
+
"react-dom": "^16.12.0",
|
|
110
|
+
"react-hot-loader": "^4.12.18",
|
|
111
|
+
"react-intl": "5.6.5",
|
|
112
|
+
"react-measure": "^2.1.2",
|
|
113
|
+
"react-multi-clamp": "^2.0.2",
|
|
114
|
+
"react-redux": "^7.1.3",
|
|
115
|
+
"react-resize-detector": "^5.0.6",
|
|
116
|
+
"react-router": "^5.1.2",
|
|
117
|
+
"react-router-dom": "^5.1.2",
|
|
118
|
+
"react-test-renderer": "^16.12.0",
|
|
119
|
+
"react-transition-group": "^4.3.0",
|
|
120
|
+
"read-pkg-up": "^7.0.0",
|
|
121
|
+
"recompose": "^0.30.0",
|
|
122
|
+
"redux": "^4.0.1",
|
|
123
|
+
"redux-api-middleware": "^3.0.0",
|
|
124
|
+
"redux-immutable": "^4.0.0",
|
|
125
|
+
"reselect": "^4.0.0",
|
|
126
|
+
"resolve": "^1.15.1",
|
|
127
|
+
"rimraf": "^3.0.0",
|
|
128
|
+
"seamless-immutable": "^7.1.3",
|
|
129
|
+
"sinon": "^9.0.0",
|
|
130
|
+
"style-loader": "^1.1.3",
|
|
131
|
+
"styled-components": "5.1.1",
|
|
132
|
+
"styled-transition-group": "^2.0.0",
|
|
133
|
+
"svg-inline-loader": "^0.8.0",
|
|
134
|
+
"ts-jest": "^26.4.0",
|
|
135
|
+
"typeface-open-sans": "^0.0.75",
|
|
136
|
+
"typeface-roboto-condensed": "^0.0.75",
|
|
137
|
+
"unexpected": "^11.1.0",
|
|
138
|
+
"unexpected-dom": "^4.14.3",
|
|
139
|
+
"unexpected-immutable": "^0.5.0",
|
|
140
|
+
"unexpected-reaction": "^2.14.0",
|
|
141
|
+
"unexpected-sinon": "^10.11.1",
|
|
142
|
+
"url-loader": "^4.0.0",
|
|
143
|
+
"url-pattern": "^1.0.3",
|
|
144
|
+
"url-polyfill": "^1.1.0",
|
|
145
|
+
"webpack": "^4.25.1",
|
|
146
|
+
"webpack-bundle-analyzer": "^3.6.0",
|
|
147
|
+
"webpack-dev-server": "^3.1.10",
|
|
148
|
+
"whatwg-fetch": "^3.0.0"
|
|
149
|
+
},
|
|
150
|
+
"sideEffects": false,
|
|
151
|
+
"lint-staged": {
|
|
152
|
+
"*.{js,json,md}": [
|
|
153
|
+
"prettier --write"
|
|
154
|
+
],
|
|
155
|
+
"*.js": [
|
|
156
|
+
"eslint"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"husky": {
|
|
160
|
+
"hooks": {
|
|
161
|
+
"pre-commit": "lint-staged"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
package/prettier.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./src/config/prettier.config");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = "test-file-stub";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["orc-[a-z]+/src", "ansi-regex", "strip-ansi", "connected-react-router", "react-intl", "@formatjs"]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const { parseEnv } = require("../utils");
|
|
2
|
+
|
|
3
|
+
const isTest = process.env.NODE_ENV === "test" || process.env.BABEL_ENV === "test";
|
|
4
|
+
const isWebpack = parseEnv("BUILD_WEBPACK", false);
|
|
5
|
+
const isReact = parseEnv("BUILD_REACT", isWebpack);
|
|
6
|
+
|
|
7
|
+
const envTargets = isTest ? "current node, last 2 chrome version" : isReact ? "defaults, IE 11" : "node 10";
|
|
8
|
+
|
|
9
|
+
console.log("Using targets", envTargets);
|
|
10
|
+
|
|
11
|
+
const envOptions = { loose: true, targets: envTargets };
|
|
12
|
+
module.exports = {
|
|
13
|
+
presets: [[require.resolve("@babel/preset-env"), envOptions]],
|
|
14
|
+
plugins: [
|
|
15
|
+
require.resolve("@babel/plugin-syntax-dynamic-import"),
|
|
16
|
+
isTest || isReact ? require.resolve("babel-plugin-styled-components") : null,
|
|
17
|
+
require.resolve("@babel/plugin-transform-template-literals"),
|
|
18
|
+
require.resolve("@babel/plugin-transform-destructuring"),
|
|
19
|
+
require.resolve("@babel/plugin-proposal-object-rest-spread"),
|
|
20
|
+
require.resolve("@babel/plugin-proposal-class-properties"),
|
|
21
|
+
require.resolve("@babel/plugin-proposal-private-property-in-object"),
|
|
22
|
+
require.resolve("@babel/plugin-proposal-private-methods"),
|
|
23
|
+
[
|
|
24
|
+
"babel-plugin-root-import",
|
|
25
|
+
{
|
|
26
|
+
rootPathSuffix: "./src",
|
|
27
|
+
rootPathPrefix: "~/",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
isTest || isReact ? require.resolve("react-hot-loader/babel") : null,
|
|
31
|
+
isTest || isReact ? require.resolve("@loadable/babel-plugin") : null,
|
|
32
|
+
isTest || isReact ? require.resolve("@babel/plugin-transform-react-jsx") : null,
|
|
33
|
+
isTest || isReact
|
|
34
|
+
? [require.resolve("babel-plugin-react-intl-auto"), { removePrefix: "src", filebase: true }]
|
|
35
|
+
: null,
|
|
36
|
+
require.resolve("@babel/plugin-transform-computed-properties"),
|
|
37
|
+
].filter(x => !!x),
|
|
38
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const eslintrc = {
|
|
2
|
+
extends: ["react-app"],
|
|
3
|
+
rules: {
|
|
4
|
+
"jsx-a11y/href-no-hash": "off",
|
|
5
|
+
},
|
|
6
|
+
globals: {
|
|
7
|
+
SUPPORTED_LOCALES: false,
|
|
8
|
+
OVERTURE_MODULE: false,
|
|
9
|
+
DEPENDENCIES: false,
|
|
10
|
+
BUILD_ID: false,
|
|
11
|
+
BUILD_NUMBER: false,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports = eslintrc;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Created by https://github.com/gcangussu
|
|
2
|
+
// Taken from https://gist.github.com/gcangussu/af52da296aef829eba15ea626453f031
|
|
3
|
+
|
|
4
|
+
const resolve = require("resolve");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {{
|
|
8
|
+
basedir: string;
|
|
9
|
+
browser?: boolean;
|
|
10
|
+
defaultResolver: (request: string, options: ResolverOptions) => string;
|
|
11
|
+
extensions?: readonly string[];
|
|
12
|
+
moduleDirectory?: readonly string[];
|
|
13
|
+
paths?: readonly string[];
|
|
14
|
+
rootDir?: string;
|
|
15
|
+
}} ResolverOptions
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} request
|
|
20
|
+
* @param {ResolverOptions} options
|
|
21
|
+
*/
|
|
22
|
+
module.exports = (request, options) => {
|
|
23
|
+
try {
|
|
24
|
+
return resolve.sync(request, {
|
|
25
|
+
basedir: options.rootDir || options.basedir,
|
|
26
|
+
extensions: options.extensions,
|
|
27
|
+
preserveSymlinks: true,
|
|
28
|
+
});
|
|
29
|
+
} catch (e) {
|
|
30
|
+
if (e.code === "MODULE_NOT_FOUND") {
|
|
31
|
+
return options.defaultResolver(request, options);
|
|
32
|
+
}
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const { fromRoot } = require("../utils");
|
|
3
|
+
|
|
4
|
+
const here = p => path.join(__dirname, p);
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const isCI = require("is-ci") || args.includes("--ci");
|
|
8
|
+
|
|
9
|
+
const ignores = ["/node_modules/"];
|
|
10
|
+
|
|
11
|
+
const jestConfig = {
|
|
12
|
+
roots: [fromRoot("src")],
|
|
13
|
+
testEnvironment: "jsdom",
|
|
14
|
+
resolver: here("jest-resolver.js"),
|
|
15
|
+
moduleNameMapper: {
|
|
16
|
+
"\\.(jpg|jpeg|png|gif)$": here("../__mocks__/fileMock.js"),
|
|
17
|
+
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
|
|
18
|
+
},
|
|
19
|
+
modulePaths: [fromRoot("src"), fromRoot("node_modules")],
|
|
20
|
+
modulePathIgnorePatterns: ["node_modules/orc-[a-z]+/node_modules"],
|
|
21
|
+
moduleFileExtensions: ["js", "json"],
|
|
22
|
+
collectCoverageFrom: ["src/**/*.js"],
|
|
23
|
+
globals: {
|
|
24
|
+
BUILD_ID: "000",
|
|
25
|
+
BUILD_NUMBER: "000",
|
|
26
|
+
OVERTURE_MODULE: "aModule",
|
|
27
|
+
DEPENDENCIES: { someDependant: "1.1.1" },
|
|
28
|
+
},
|
|
29
|
+
setupFiles: [require.resolve("whatwg-fetch")],
|
|
30
|
+
setupFilesAfterEnv: [here("unexpected.js"), here("./jestSetupFiles.js")],
|
|
31
|
+
transform: { "^.+\\.js$": here("./babel-transform") },
|
|
32
|
+
transformIgnorePatterns: ["/node_modules/(?!(?:" + require("./babel-whitelist.json").join("|") + ")/)"],
|
|
33
|
+
testMatch: ["**/*.test.js"],
|
|
34
|
+
testPathIgnorePatterns: [...ignores],
|
|
35
|
+
testURL: "http://localhost:8000/",
|
|
36
|
+
verbose: true,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (!isCI) {
|
|
40
|
+
jestConfig["coverageReporters"] = ["html", "text-summary"];
|
|
41
|
+
} else {
|
|
42
|
+
jestConfig["coverageReporters"] = ["json", "lcov", "text", "clover", "cobertura"];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = jestConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__webpack_public_path__ = window.ASSET_PATH || "/"; // eslint-disable-line
|