@xfe-repo/web-app 1.1.6 → 1.2.2
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/.eslintrc.js +1 -2
- package/bin/index.js +1 -20
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +163 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +84 -0
- package/package.json +17 -4
- package/config/webpack/webpack.config.ssr.js +0 -336
- package/scripts/config.js +0 -52
- package/scripts/devSSR.js +0 -78
- package/scripts/test.js +0 -52
package/.eslintrc.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** @type {import("eslint").Linter.Config} */
|
|
2
2
|
module.exports = {
|
|
3
|
-
root: true,
|
|
4
3
|
extends: ["@xfe-repo/eslint-config/react.js"],
|
|
5
4
|
env: {
|
|
6
5
|
node: true,
|
|
@@ -9,6 +8,6 @@ module.exports = {
|
|
|
9
8
|
project: "./tsconfig.json",
|
|
10
9
|
},
|
|
11
10
|
ignorePatterns: [
|
|
12
|
-
'
|
|
11
|
+
'*.js',
|
|
13
12
|
],
|
|
14
13
|
};
|
package/bin/index.js
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const minimist = require('minimist')
|
|
4
|
-
|
|
5
|
-
const argv = minimist(process.argv.slice(2))
|
|
6
|
-
|
|
7
|
-
const { _: commands } = argv
|
|
8
|
-
|
|
9
|
-
const [command] = commands
|
|
10
|
-
|
|
11
|
-
if(command === 'dev') {
|
|
12
|
-
require('../scripts/dev')
|
|
13
|
-
} else if(command === 'build') {
|
|
14
|
-
require('../scripts/build')
|
|
15
|
-
} else if(command === 'config') {
|
|
16
|
-
require('../scripts/config')
|
|
17
|
-
} else if(command === 'test') {
|
|
18
|
-
require('../scripts/test')
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
require('../dist/cli.js');
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _iterable_to_array_limit(arr, i) {
|
|
11
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
12
|
+
if (_i == null) return;
|
|
13
|
+
var _arr = [];
|
|
14
|
+
var _n = true;
|
|
15
|
+
var _d = false;
|
|
16
|
+
var _s, _e;
|
|
17
|
+
try {
|
|
18
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
19
|
+
_arr.push(_s.value);
|
|
20
|
+
if (i && _arr.length === i) break;
|
|
21
|
+
}
|
|
22
|
+
} catch (err) {
|
|
23
|
+
_d = true;
|
|
24
|
+
_e = err;
|
|
25
|
+
} finally{
|
|
26
|
+
try {
|
|
27
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
28
|
+
} finally{
|
|
29
|
+
if (_d) throw _e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return _arr;
|
|
33
|
+
}
|
|
34
|
+
function _non_iterable_rest() {
|
|
35
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
36
|
+
}
|
|
37
|
+
function _sliced_to_array(arr, i) {
|
|
38
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
39
|
+
}
|
|
40
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
41
|
+
if (!o) return;
|
|
42
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
43
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
44
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
45
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
46
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
47
|
+
}
|
|
48
|
+
var __create = Object.create;
|
|
49
|
+
var __defProp = Object.defineProperty;
|
|
50
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
51
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
52
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
53
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
54
|
+
var __esm = function(fn, res) {
|
|
55
|
+
return function __init() {
|
|
56
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
var __copyProps = function(to, from, except, desc) {
|
|
60
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
61
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
62
|
+
try {
|
|
63
|
+
var _loop = function() {
|
|
64
|
+
var key = _step.value;
|
|
65
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
66
|
+
get: function() {
|
|
67
|
+
return from[key];
|
|
68
|
+
},
|
|
69
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
73
|
+
} catch (err) {
|
|
74
|
+
_didIteratorError = true;
|
|
75
|
+
_iteratorError = err;
|
|
76
|
+
} finally{
|
|
77
|
+
try {
|
|
78
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
79
|
+
_iterator.return();
|
|
80
|
+
}
|
|
81
|
+
} finally{
|
|
82
|
+
if (_didIteratorError) {
|
|
83
|
+
throw _iteratorError;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return to;
|
|
89
|
+
};
|
|
90
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
91
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
92
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
93
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
94
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
95
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
96
|
+
value: mod,
|
|
97
|
+
enumerable: true
|
|
98
|
+
}) : target, mod);
|
|
99
|
+
};
|
|
100
|
+
// src/config.ts
|
|
101
|
+
var config_exports = {};
|
|
102
|
+
var import_path, import_fs, import_yaml, configDeploy;
|
|
103
|
+
var init_config = __esm({
|
|
104
|
+
"src/config.ts": function() {
|
|
105
|
+
"use strict";
|
|
106
|
+
import_path = __toESM(require("path"));
|
|
107
|
+
import_fs = __toESM(require("fs"));
|
|
108
|
+
import_yaml = __toESM(require("yaml"));
|
|
109
|
+
configDeploy = function() {
|
|
110
|
+
var xfeConfig = JSON.parse(import_fs.default.readFileSync("./xfe.json", "utf8"));
|
|
111
|
+
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.deploy)) return;
|
|
112
|
+
var droneConfigFilePath = import_path.default.resolve(__dirname, "../deploy/.drone.yml");
|
|
113
|
+
import_fs.default.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
114
|
+
var valuesYamlFilePath = import_path.default.resolve(__dirname, "../deploy/helm/values.yaml");
|
|
115
|
+
var valuesYamlFile = import_fs.default.readFileSync(valuesYamlFilePath, "utf8");
|
|
116
|
+
var valuesYaml = import_yaml.default.parse(valuesYamlFile);
|
|
117
|
+
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
118
|
+
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = {
|
|
119
|
+
test: [],
|
|
120
|
+
stage: [],
|
|
121
|
+
prod: []
|
|
122
|
+
};
|
|
123
|
+
var _xfeConfig_deploy = xfeConfig.deploy, _xfeConfig_deploy_virtualServiceEnabled = _xfeConfig_deploy.virtualServiceEnabled, virtualServiceEnabled = _xfeConfig_deploy_virtualServiceEnabled === void 0 ? true : _xfeConfig_deploy_virtualServiceEnabled, _xfeConfig_deploy_hostsProd = _xfeConfig_deploy.hostsProd, hostsProd = _xfeConfig_deploy_hostsProd === void 0 ? [] : _xfeConfig_deploy_hostsProd, _xfeConfig_deploy_hostsStage = _xfeConfig_deploy.hostsStage, hostsStage = _xfeConfig_deploy_hostsStage === void 0 ? [] : _xfeConfig_deploy_hostsStage, _xfeConfig_deploy_hostsTest = _xfeConfig_deploy.hostsTest, hostsTest = _xfeConfig_deploy_hostsTest === void 0 ? [] : _xfeConfig_deploy_hostsTest, _xfeConfig_deploy_gateways = _xfeConfig_deploy.gateways, gateways = _xfeConfig_deploy_gateways === void 0 ? [
|
|
124
|
+
"common-gateway-eshetang"
|
|
125
|
+
] : _xfeConfig_deploy_gateways;
|
|
126
|
+
var _xfeConfig_deploy1 = xfeConfig.deploy, _xfeConfig_deploy_targetK8s = _xfeConfig_deploy1.targetK8s, targetK8s = _xfeConfig_deploy_targetK8s === void 0 ? "saas" : _xfeConfig_deploy_targetK8s, _xfeConfig_deploy_targetNamespace = _xfeConfig_deploy1.targetNamespace, targetNamespace = _xfeConfig_deploy_targetNamespace === void 0 ? "" : _xfeConfig_deploy_targetNamespace;
|
|
127
|
+
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
128
|
+
valuesYaml.virtualService.gateways = gateways;
|
|
129
|
+
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
130
|
+
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
131
|
+
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
132
|
+
valuesYaml.targetK8s = targetK8s;
|
|
133
|
+
valuesYaml.namespace = targetNamespace;
|
|
134
|
+
var valuesYamlStr = import_yaml.default.stringify(valuesYaml, {
|
|
135
|
+
defaultStringType: "QUOTE_SINGLE",
|
|
136
|
+
defaultKeyType: "PLAIN"
|
|
137
|
+
});
|
|
138
|
+
import_fs.default.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
139
|
+
};
|
|
140
|
+
configDeploy();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
// src/cli.ts
|
|
144
|
+
var import_minimist = __toESM(require("minimist"));
|
|
145
|
+
var import_child_process = require("child_process");
|
|
146
|
+
var import_path2 = __toESM(require("path"));
|
|
147
|
+
var argv = (0, import_minimist.default)(process.argv.slice(2));
|
|
148
|
+
var commands = argv._;
|
|
149
|
+
var _commands = _sliced_to_array(commands, 1), command = _commands[0];
|
|
150
|
+
var appPackageRoot = import_path2.default.resolve(__dirname, "../");
|
|
151
|
+
if (command === "dev") {
|
|
152
|
+
(0, import_child_process.execSync)("node ".concat(import_path2.default.join(appPackageRoot, "scripts/dev.js")), {
|
|
153
|
+
stdio: "inherit"
|
|
154
|
+
});
|
|
155
|
+
} else if (command === "build") {
|
|
156
|
+
(0, import_child_process.execSync)("node ".concat(import_path2.default.join(appPackageRoot, "scripts/build.js")), {
|
|
157
|
+
stdio: "inherit"
|
|
158
|
+
});
|
|
159
|
+
} else if (command === "config") {
|
|
160
|
+
Promise.resolve().then(function() {
|
|
161
|
+
return init_config();
|
|
162
|
+
});
|
|
163
|
+
}
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = function(to, from, except, desc) {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
11
|
+
try {
|
|
12
|
+
var _loop = function() {
|
|
13
|
+
var key = _step.value;
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: function() {
|
|
16
|
+
return from[key];
|
|
17
|
+
},
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
22
|
+
} catch (err) {
|
|
23
|
+
_didIteratorError = true;
|
|
24
|
+
_iteratorError = err;
|
|
25
|
+
} finally{
|
|
26
|
+
try {
|
|
27
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
28
|
+
_iterator.return();
|
|
29
|
+
}
|
|
30
|
+
} finally{
|
|
31
|
+
if (_didIteratorError) {
|
|
32
|
+
throw _iteratorError;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return to;
|
|
38
|
+
};
|
|
39
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
40
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
41
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
42
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
43
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
44
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
45
|
+
value: mod,
|
|
46
|
+
enumerable: true
|
|
47
|
+
}) : target, mod);
|
|
48
|
+
};
|
|
49
|
+
// src/config.ts
|
|
50
|
+
var import_path = __toESM(require("path"));
|
|
51
|
+
var import_fs = __toESM(require("fs"));
|
|
52
|
+
var import_yaml = __toESM(require("yaml"));
|
|
53
|
+
var configDeploy = function() {
|
|
54
|
+
var xfeConfig = JSON.parse(import_fs.default.readFileSync("./xfe.json", "utf8"));
|
|
55
|
+
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.deploy)) return;
|
|
56
|
+
var droneConfigFilePath = import_path.default.resolve(__dirname, "../deploy/.drone.yml");
|
|
57
|
+
import_fs.default.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
58
|
+
var valuesYamlFilePath = import_path.default.resolve(__dirname, "../deploy/helm/values.yaml");
|
|
59
|
+
var valuesYamlFile = import_fs.default.readFileSync(valuesYamlFilePath, "utf8");
|
|
60
|
+
var valuesYaml = import_yaml.default.parse(valuesYamlFile);
|
|
61
|
+
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
62
|
+
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = {
|
|
63
|
+
test: [],
|
|
64
|
+
stage: [],
|
|
65
|
+
prod: []
|
|
66
|
+
};
|
|
67
|
+
var _xfeConfig_deploy = xfeConfig.deploy, _xfeConfig_deploy_virtualServiceEnabled = _xfeConfig_deploy.virtualServiceEnabled, virtualServiceEnabled = _xfeConfig_deploy_virtualServiceEnabled === void 0 ? true : _xfeConfig_deploy_virtualServiceEnabled, _xfeConfig_deploy_hostsProd = _xfeConfig_deploy.hostsProd, hostsProd = _xfeConfig_deploy_hostsProd === void 0 ? [] : _xfeConfig_deploy_hostsProd, _xfeConfig_deploy_hostsStage = _xfeConfig_deploy.hostsStage, hostsStage = _xfeConfig_deploy_hostsStage === void 0 ? [] : _xfeConfig_deploy_hostsStage, _xfeConfig_deploy_hostsTest = _xfeConfig_deploy.hostsTest, hostsTest = _xfeConfig_deploy_hostsTest === void 0 ? [] : _xfeConfig_deploy_hostsTest, _xfeConfig_deploy_gateways = _xfeConfig_deploy.gateways, gateways = _xfeConfig_deploy_gateways === void 0 ? [
|
|
68
|
+
"common-gateway-eshetang"
|
|
69
|
+
] : _xfeConfig_deploy_gateways;
|
|
70
|
+
var _xfeConfig_deploy1 = xfeConfig.deploy, _xfeConfig_deploy_targetK8s = _xfeConfig_deploy1.targetK8s, targetK8s = _xfeConfig_deploy_targetK8s === void 0 ? "saas" : _xfeConfig_deploy_targetK8s, _xfeConfig_deploy_targetNamespace = _xfeConfig_deploy1.targetNamespace, targetNamespace = _xfeConfig_deploy_targetNamespace === void 0 ? "" : _xfeConfig_deploy_targetNamespace;
|
|
71
|
+
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
72
|
+
valuesYaml.virtualService.gateways = gateways;
|
|
73
|
+
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
74
|
+
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
75
|
+
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
76
|
+
valuesYaml.targetK8s = targetK8s;
|
|
77
|
+
valuesYaml.namespace = targetNamespace;
|
|
78
|
+
var valuesYamlStr = import_yaml.default.stringify(valuesYaml, {
|
|
79
|
+
defaultStringType: "QUOTE_SINGLE",
|
|
80
|
+
defaultKeyType: "PLAIN"
|
|
81
|
+
});
|
|
82
|
+
import_fs.default.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
83
|
+
};
|
|
84
|
+
configDeploy();
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/web-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"bin": {
|
|
5
5
|
"xfe-web": "./bin/index.js"
|
|
6
6
|
},
|
|
7
7
|
"files": [
|
|
8
|
+
"dist",
|
|
8
9
|
"bin",
|
|
9
10
|
"config",
|
|
10
11
|
"deploy",
|
|
@@ -22,6 +23,9 @@
|
|
|
22
23
|
"@testing-library/jest-dom": "^5.16.5",
|
|
23
24
|
"@testing-library/react": "^13.4.0",
|
|
24
25
|
"@testing-library/user-event": "^13.5.0",
|
|
26
|
+
"@types/minimist": "^1.2.5",
|
|
27
|
+
"@types/node": "^18",
|
|
28
|
+
"@types/react": "^18.0.0",
|
|
25
29
|
"babel-jest": "^27.4.2",
|
|
26
30
|
"babel-loader": "^8.2.3",
|
|
27
31
|
"babel-plugin-named-asset-import": "^0.3.8",
|
|
@@ -39,6 +43,7 @@
|
|
|
39
43
|
"file-loader": "^6.2.0",
|
|
40
44
|
"fs-extra": "^10.0.0",
|
|
41
45
|
"html-webpack-plugin": "^5.5.0",
|
|
46
|
+
"husky": "^9.1.6",
|
|
42
47
|
"identity-obj-proxy": "^3.0.0",
|
|
43
48
|
"ignore-loader": "^0.1.2",
|
|
44
49
|
"jest": "^27.4.3",
|
|
@@ -55,10 +60,8 @@
|
|
|
55
60
|
"postcss-normalize": "^10.0.1",
|
|
56
61
|
"postcss-preset-env": "^7.0.1",
|
|
57
62
|
"prompts": "^2.4.2",
|
|
58
|
-
"react": "18.2.0",
|
|
59
63
|
"react-app-polyfill": "^3.0.0",
|
|
60
64
|
"react-dev-utils": "^12.0.1",
|
|
61
|
-
"react-dom": "18.2.0",
|
|
62
65
|
"react-refresh": "^0.11.0",
|
|
63
66
|
"resolve": "^1.20.0",
|
|
64
67
|
"resolve-url-loader": "^4.0.0",
|
|
@@ -75,7 +78,17 @@
|
|
|
75
78
|
"webpack-manifest-plugin": "^4.0.2",
|
|
76
79
|
"workbox-webpack-plugin": "^7.0.0",
|
|
77
80
|
"yaml": "^2.3.4",
|
|
78
|
-
"@xfe-repo/eslint-config": "0.0.
|
|
81
|
+
"@xfe-repo/eslint-config": "0.0.5",
|
|
79
82
|
"@xfe-repo/typescript-config": "0.0.6"
|
|
83
|
+
},
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"react": "18.2.0",
|
|
86
|
+
"react-dom": "18.2.0"
|
|
87
|
+
},
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "tsup",
|
|
90
|
+
"dev": "tsup --watch",
|
|
91
|
+
"lint": "eslint \"src/**/*.ts*\"",
|
|
92
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
80
93
|
}
|
|
81
94
|
}
|
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
const webpack = require('webpack')
|
|
6
|
-
const resolve = require('resolve')
|
|
7
|
-
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
|
|
8
|
-
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin')
|
|
9
|
-
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent')
|
|
10
|
-
const ESLintPlugin = require('eslint-webpack-plugin')
|
|
11
|
-
const paths = require('../paths')
|
|
12
|
-
const modules = require('../modules')
|
|
13
|
-
const getClientEnvironment = require('../env')
|
|
14
|
-
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin')
|
|
15
|
-
const ForkTsCheckerWebpackPlugin =
|
|
16
|
-
process.env.TSC_COMPILE_ON_ERROR === 'true'
|
|
17
|
-
? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
|
|
18
|
-
: require('react-dev-utils/ForkTsCheckerWebpackPlugin')
|
|
19
|
-
|
|
20
|
-
const createEnvironmentHash = require('./persistentCache/createEnvironmentHash')
|
|
21
|
-
|
|
22
|
-
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'
|
|
23
|
-
|
|
24
|
-
const babelRuntimeEntry = require.resolve('babel-preset-react-app')
|
|
25
|
-
const babelRuntimeEntryHelpers = require.resolve('@babel/runtime/helpers/esm/assertThisInitialized', { paths: [babelRuntimeEntry] })
|
|
26
|
-
const babelRuntimeRegenerator = require.resolve('@babel/runtime/regenerator', {
|
|
27
|
-
paths: [babelRuntimeEntry],
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const emitErrorsAsWarnings = process.env.ESLINT_NO_DEV_ERRORS === 'true'
|
|
31
|
-
const disableESLintPlugin = process.env.DISABLE_ESLINT_PLUGIN === 'true'
|
|
32
|
-
|
|
33
|
-
const imageInlineSizeLimit = parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || '10000')
|
|
34
|
-
|
|
35
|
-
const useTypeScript = fs.existsSync(paths.appTsConfig)
|
|
36
|
-
|
|
37
|
-
const cssRegex = /\.css$/
|
|
38
|
-
const cssModuleRegex = /\.module\.css$/
|
|
39
|
-
// modify sass 修改为 less
|
|
40
|
-
const lessRegex = /\.less$/
|
|
41
|
-
const lessModuleRegex = /\.module\.less$/
|
|
42
|
-
|
|
43
|
-
const hasJsxRuntime = (() => {
|
|
44
|
-
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
|
|
45
|
-
return false
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
require.resolve('react/jsx-runtime')
|
|
50
|
-
return true
|
|
51
|
-
} catch (e) {
|
|
52
|
-
return false
|
|
53
|
-
}
|
|
54
|
-
})()
|
|
55
|
-
|
|
56
|
-
module.exports = function (webpackEnv) {
|
|
57
|
-
const isEnvDevelopment = webpackEnv === 'development'
|
|
58
|
-
const isEnvProduction = webpackEnv === 'production'
|
|
59
|
-
|
|
60
|
-
const isEnvProductionProfile = isEnvProduction && process.argv.includes('--profile')
|
|
61
|
-
|
|
62
|
-
const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1))
|
|
63
|
-
|
|
64
|
-
const getStyleLoaders = (cssOptions, preProcessor) => {
|
|
65
|
-
const loaders = [
|
|
66
|
-
'ignore-loader',
|
|
67
|
-
{
|
|
68
|
-
loader: require.resolve('css-loader'),
|
|
69
|
-
options: cssOptions,
|
|
70
|
-
},
|
|
71
|
-
].filter(Boolean)
|
|
72
|
-
if (preProcessor) {
|
|
73
|
-
loaders.push(
|
|
74
|
-
{
|
|
75
|
-
loader: require.resolve('resolve-url-loader'),
|
|
76
|
-
options: {
|
|
77
|
-
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
78
|
-
root: paths.appSrc,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
loader: require.resolve(preProcessor),
|
|
83
|
-
options: {
|
|
84
|
-
sourceMap: true,
|
|
85
|
-
},
|
|
86
|
-
}
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
return loaders
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
target: ['node'],
|
|
94
|
-
mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
|
|
95
|
-
stats: 'errors-warnings',
|
|
96
|
-
bail: isEnvProduction,
|
|
97
|
-
devtool: isEnvProduction ? (shouldUseSourceMap ? 'source-map' : false) : isEnvDevelopment && 'cheap-module-source-map',
|
|
98
|
-
entry: paths.appSSRJs,
|
|
99
|
-
output: {
|
|
100
|
-
path: paths.appBuildServer,
|
|
101
|
-
filename: 'index.js',
|
|
102
|
-
libraryExport: 'default',
|
|
103
|
-
libraryTarget: 'commonjs2',
|
|
104
|
-
pathinfo: isEnvDevelopment,
|
|
105
|
-
chunkFilename: 'chunks/[name].[contenthash:8].chunk.js',
|
|
106
|
-
publicPath: paths.publicUrlOrPath,
|
|
107
|
-
devtoolModuleFilenameTemplate: isEnvProduction
|
|
108
|
-
? (info) => path.relative(paths.appSrc, info.absoluteResourcePath).replace(/\\/g, '/')
|
|
109
|
-
: isEnvDevelopment && ((info) => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
|
|
110
|
-
},
|
|
111
|
-
cache: {
|
|
112
|
-
type: 'filesystem',
|
|
113
|
-
version: createEnvironmentHash(env.raw),
|
|
114
|
-
cacheDirectory: paths.appWebpackCache,
|
|
115
|
-
store: 'pack',
|
|
116
|
-
buildDependencies: {
|
|
117
|
-
defaultWebpack: ['webpack/lib/'],
|
|
118
|
-
config: [__filename],
|
|
119
|
-
tsconfig: [paths.appTsConfig, paths.appJsConfig].filter((f) => fs.existsSync(f)),
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
infrastructureLogging: {
|
|
123
|
-
level: 'none',
|
|
124
|
-
},
|
|
125
|
-
resolve: {
|
|
126
|
-
modules: ['node_modules', paths.appNodeModules].concat(modules.additionalModulePaths || []),
|
|
127
|
-
extensions: paths.moduleFileExtensions.map((ext) => `.${ext}`).filter((ext) => useTypeScript || !ext.includes('ts')),
|
|
128
|
-
alias: {
|
|
129
|
-
'react-native': 'react-native-web',
|
|
130
|
-
...(isEnvProductionProfile && {
|
|
131
|
-
'react-dom$': 'react-dom/profiling',
|
|
132
|
-
'scheduler/tracing': 'scheduler/tracing-profiling',
|
|
133
|
-
}),
|
|
134
|
-
...(modules.webpackAliases || {}),
|
|
135
|
-
},
|
|
136
|
-
plugins: [
|
|
137
|
-
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson, babelRuntimeEntry, babelRuntimeEntryHelpers, babelRuntimeRegenerator]),
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
module: {
|
|
141
|
-
strictExportPresence: true,
|
|
142
|
-
rules: [
|
|
143
|
-
shouldUseSourceMap && {
|
|
144
|
-
enforce: 'pre',
|
|
145
|
-
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
146
|
-
test: /\.(js|mjs|jsx|ts|tsx|css)$/,
|
|
147
|
-
loader: require.resolve('source-map-loader'),
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
oneOf: [
|
|
151
|
-
{
|
|
152
|
-
test: [/\.avif$/],
|
|
153
|
-
type: 'asset',
|
|
154
|
-
mimetype: 'image/avif',
|
|
155
|
-
parser: {
|
|
156
|
-
dataUrlCondition: {
|
|
157
|
-
maxSize: imageInlineSizeLimit,
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
163
|
-
type: 'asset',
|
|
164
|
-
parser: {
|
|
165
|
-
dataUrlCondition: {
|
|
166
|
-
maxSize: imageInlineSizeLimit,
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
|
172
|
-
include: paths.appSrc,
|
|
173
|
-
loader: require.resolve('babel-loader'),
|
|
174
|
-
options: {
|
|
175
|
-
customize: require.resolve('babel-preset-react-app/webpack-overrides'),
|
|
176
|
-
presets: [
|
|
177
|
-
[
|
|
178
|
-
require.resolve('babel-preset-react-app'),
|
|
179
|
-
{
|
|
180
|
-
runtime: hasJsxRuntime ? 'automatic' : 'classic',
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
],
|
|
184
|
-
|
|
185
|
-
plugins: [
|
|
186
|
-
// modify 异步按需加载
|
|
187
|
-
['@loadable/babel-plugin'],
|
|
188
|
-
].filter(Boolean),
|
|
189
|
-
cacheDirectory: true,
|
|
190
|
-
cacheCompression: false,
|
|
191
|
-
compact: isEnvProduction,
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
test: /\.(js|mjs)$/,
|
|
196
|
-
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
197
|
-
loader: require.resolve('babel-loader'),
|
|
198
|
-
options: {
|
|
199
|
-
babelrc: false,
|
|
200
|
-
configFile: false,
|
|
201
|
-
compact: false,
|
|
202
|
-
presets: [[require.resolve('babel-preset-react-app/dependencies'), { helpers: true }]],
|
|
203
|
-
cacheDirectory: true,
|
|
204
|
-
cacheCompression: false,
|
|
205
|
-
sourceMaps: shouldUseSourceMap,
|
|
206
|
-
inputSourceMap: shouldUseSourceMap,
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
test: cssRegex,
|
|
211
|
-
exclude: cssModuleRegex,
|
|
212
|
-
use: getStyleLoaders({
|
|
213
|
-
importLoaders: 1,
|
|
214
|
-
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
215
|
-
modules: {
|
|
216
|
-
mode: 'icss',
|
|
217
|
-
},
|
|
218
|
-
}),
|
|
219
|
-
sideEffects: true,
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
test: cssModuleRegex,
|
|
223
|
-
use: getStyleLoaders({
|
|
224
|
-
importLoaders: 1,
|
|
225
|
-
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
226
|
-
modules: {
|
|
227
|
-
mode: 'local',
|
|
228
|
-
getLocalIdent: getCSSModuleLocalIdent,
|
|
229
|
-
},
|
|
230
|
-
}),
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
test: lessRegex,
|
|
234
|
-
exclude: lessModuleRegex,
|
|
235
|
-
use: getStyleLoaders(
|
|
236
|
-
{
|
|
237
|
-
importLoaders: 3,
|
|
238
|
-
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
239
|
-
modules: {
|
|
240
|
-
mode: 'icss',
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
'less-loader'
|
|
244
|
-
),
|
|
245
|
-
sideEffects: true,
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
test: lessModuleRegex,
|
|
249
|
-
use: getStyleLoaders(
|
|
250
|
-
{
|
|
251
|
-
importLoaders: 3,
|
|
252
|
-
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
253
|
-
modules: {
|
|
254
|
-
mode: 'local',
|
|
255
|
-
getLocalIdent: getCSSModuleLocalIdent,
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
'less-loader'
|
|
259
|
-
),
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
|
|
263
|
-
type: 'asset/resource',
|
|
264
|
-
},
|
|
265
|
-
],
|
|
266
|
-
},
|
|
267
|
-
].filter(Boolean),
|
|
268
|
-
},
|
|
269
|
-
plugins: [
|
|
270
|
-
new ModuleNotFoundPlugin(paths.appPath),
|
|
271
|
-
new webpack.DefinePlugin(env.stringified),
|
|
272
|
-
isEnvDevelopment && new CaseSensitivePathsPlugin(),
|
|
273
|
-
new webpack.IgnorePlugin({
|
|
274
|
-
resourceRegExp: /^\.\/locale$/,
|
|
275
|
-
contextRegExp: /moment$/,
|
|
276
|
-
}),
|
|
277
|
-
useTypeScript &&
|
|
278
|
-
new ForkTsCheckerWebpackPlugin({
|
|
279
|
-
async: isEnvDevelopment,
|
|
280
|
-
typescript: {
|
|
281
|
-
typescriptPath: resolve.sync('typescript', {
|
|
282
|
-
basedir: paths.appNodeModules,
|
|
283
|
-
}),
|
|
284
|
-
configOverwrite: {
|
|
285
|
-
compilerOptions: {
|
|
286
|
-
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
287
|
-
skipLibCheck: true,
|
|
288
|
-
inlineSourceMap: false,
|
|
289
|
-
declarationMap: false,
|
|
290
|
-
noEmit: true,
|
|
291
|
-
incremental: true,
|
|
292
|
-
tsBuildInfoFile: paths.appTsBuildInfoFile,
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
context: paths.appPath,
|
|
296
|
-
diagnosticOptions: {
|
|
297
|
-
syntactic: true,
|
|
298
|
-
},
|
|
299
|
-
mode: 'write-references',
|
|
300
|
-
},
|
|
301
|
-
issue: {
|
|
302
|
-
include: [{ file: '../**/src/**/*.{ts,tsx}' }, { file: '**/src/**/*.{ts,tsx}' }],
|
|
303
|
-
exclude: [
|
|
304
|
-
{ file: '**/src/**/__tests__/**' },
|
|
305
|
-
{ file: '**/src/**/?(*.){spec|test}.*' },
|
|
306
|
-
{ file: '**/src/setupProxy.*' },
|
|
307
|
-
{ file: '**/src/setupTests.*' },
|
|
308
|
-
],
|
|
309
|
-
},
|
|
310
|
-
logger: {
|
|
311
|
-
infrastructure: 'silent',
|
|
312
|
-
},
|
|
313
|
-
}),
|
|
314
|
-
!disableESLintPlugin &&
|
|
315
|
-
new ESLintPlugin({
|
|
316
|
-
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
|
|
317
|
-
formatter: require.resolve('react-dev-utils/eslintFormatter'),
|
|
318
|
-
eslintPath: require.resolve('eslint'),
|
|
319
|
-
failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
|
|
320
|
-
context: paths.appSrc,
|
|
321
|
-
cache: true,
|
|
322
|
-
cacheLocation: path.resolve(paths.appNodeModules, '.cache/.eslintcache'),
|
|
323
|
-
resolvePluginsRelativeTo: __dirname,
|
|
324
|
-
baseConfig: {
|
|
325
|
-
extends: [require.resolve('eslint-config-react-app/base')],
|
|
326
|
-
rules: {
|
|
327
|
-
...(!hasJsxRuntime && {
|
|
328
|
-
'react/react-in-jsx-scope': 'error',
|
|
329
|
-
}),
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
}),
|
|
333
|
-
].filter(Boolean),
|
|
334
|
-
performance: false,
|
|
335
|
-
}
|
|
336
|
-
}
|
package/scripts/config.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// 读取配置并作出相应的处理
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const yaml = require('yaml')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
|
|
6
|
-
/* deploy 相关配置写入 */
|
|
7
|
-
const configDeploy = () => {
|
|
8
|
-
// 读取xfe.json
|
|
9
|
-
const xfeConfig = JSON.parse(fs.readFileSync('./xfe.json', 'utf8'))
|
|
10
|
-
|
|
11
|
-
if (!xfeConfig?.deploy) return
|
|
12
|
-
|
|
13
|
-
// 处理drone配置 将drone配置写入.drone.yml
|
|
14
|
-
const droneConfigFilePath = path.resolve(__dirname, '../deploy/.drone.yml')
|
|
15
|
-
|
|
16
|
-
// 将drone配置写入.drone.yml
|
|
17
|
-
fs.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || './.drone.yml')
|
|
18
|
-
|
|
19
|
-
// 处理写入deploy values配置
|
|
20
|
-
const valuesYamlFilePath = path.resolve(__dirname, '../deploy/helm/values.yaml')
|
|
21
|
-
const valuesYamlFile = fs.readFileSync(valuesYamlFilePath, 'utf8')
|
|
22
|
-
const valuesYaml = yaml.parse(valuesYamlFile)
|
|
23
|
-
|
|
24
|
-
if(!valuesYaml.virtualService) valuesYaml.virtualService = {}
|
|
25
|
-
|
|
26
|
-
if(!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = { test: [], stage: [], prod: [] }
|
|
27
|
-
|
|
28
|
-
const { virtualServiceEnabled = true, hostsProd = [], hostsStage = [], hostsTest = [], gateways = ["common-gateway-eshetang"] } = xfeConfig.deploy
|
|
29
|
-
const { targetK8s = 'saas', targetNamespace = '' } = xfeConfig.deploy
|
|
30
|
-
|
|
31
|
-
// 是否启用virtualService 如果xfe.json中未配置则默认启用
|
|
32
|
-
valuesYaml.virtualService.enabled = typeof virtualServiceEnabled === 'boolean' ? virtualServiceEnabled : true
|
|
33
|
-
|
|
34
|
-
valuesYaml.virtualService.gateways = gateways
|
|
35
|
-
|
|
36
|
-
valuesYaml.virtualService.hosts.prod = hostsProd
|
|
37
|
-
valuesYaml.virtualService.hosts.stage = hostsStage
|
|
38
|
-
valuesYaml.virtualService.hosts.test = hostsTest
|
|
39
|
-
|
|
40
|
-
// 修改目标集群
|
|
41
|
-
valuesYaml.targetK8s = targetK8s
|
|
42
|
-
|
|
43
|
-
// 修改目标命名空间
|
|
44
|
-
valuesYaml.namespace = targetNamespace
|
|
45
|
-
|
|
46
|
-
// 写入values.yaml
|
|
47
|
-
const valuesYamlStr = yaml.stringify(valuesYaml, { defaultStringType: 'QUOTE_SINGLE', defaultKeyType: 'PLAIN' })
|
|
48
|
-
fs.writeFileSync(valuesYamlFilePath, valuesYamlStr, 'utf8')
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/* 其他配置待扩展 */
|
|
52
|
-
configDeploy()
|
package/scripts/devSSR.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
process.env.NODE_ENV = 'development'
|
|
4
|
-
|
|
5
|
-
const chalk = require('chalk')
|
|
6
|
-
const webpack = require('webpack')
|
|
7
|
-
const nodemon = require('nodemon')
|
|
8
|
-
const configFactory = require('../config/webpack/webpack.config.ssr')
|
|
9
|
-
|
|
10
|
-
console.log(
|
|
11
|
-
chalk.magenta('\n[INFO]') +
|
|
12
|
-
' You need to open the ' +
|
|
13
|
-
chalk.underline('dev server') +
|
|
14
|
-
' with ' +
|
|
15
|
-
chalk.underline('npm start') +
|
|
16
|
-
' command first.'
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
console.log(chalk.cyan('\nWebpack starts to build and watch your files...\n'))
|
|
20
|
-
|
|
21
|
-
const config = configFactory('development')
|
|
22
|
-
|
|
23
|
-
const compiler = webpack(config)
|
|
24
|
-
|
|
25
|
-
let nm
|
|
26
|
-
|
|
27
|
-
compiler.watch('./src/**/*.[js,jsx,ts,tsx]', (err, stats) => {
|
|
28
|
-
if (err) {
|
|
29
|
-
console.error(err.stack || err)
|
|
30
|
-
|
|
31
|
-
if (err.details) console.error(err.details)
|
|
32
|
-
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const statsString = stats.toString({
|
|
37
|
-
colors: true,
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
console.log(statsString)
|
|
41
|
-
|
|
42
|
-
console.log(chalk.magenta('[Webpack]') + ' Compiled' + chalk.grey(' [timestamp:' + Date.now() + ']'))
|
|
43
|
-
|
|
44
|
-
// spawn nodemon process if it wasn't already spawned
|
|
45
|
-
if (!nm) {
|
|
46
|
-
console.log(chalk.cyan('\nStarting nodemon...\n'))
|
|
47
|
-
nm = spawnNodemon('./server/index.js')
|
|
48
|
-
} else {
|
|
49
|
-
nm.restart()
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
function spawnNodemon(filePath) {
|
|
54
|
-
nodemon({
|
|
55
|
-
script: filePath,
|
|
56
|
-
watch: ['./server/'],
|
|
57
|
-
ext: 'js,json',
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
nodemon
|
|
61
|
-
.on('start', function () {
|
|
62
|
-
console.log(chalk.yellow('[nodemon]') + ' App has started')
|
|
63
|
-
})
|
|
64
|
-
.on('quit', function () {
|
|
65
|
-
console.log(chalk.yellow('[nodemon]') + ' App has quit')
|
|
66
|
-
})
|
|
67
|
-
.on('restart', function (files) {
|
|
68
|
-
console.log(chalk.yellow('[nodemon]') + ' App restarted due to: ' + files)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
process.once('SIGINT', function () {
|
|
72
|
-
nodemon.once('exit', function () {
|
|
73
|
-
process.exit()
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
return nodemon
|
|
78
|
-
}
|
package/scripts/test.js
DELETED
|
@@ -1,52 +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 = '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);
|