Match-id-58f9bf96c370082eacead160f6c816ffae9ac973
This commit is contained in:
commit
a176e21f7f
35
README.md
35
README.md
|
@ -2,45 +2,20 @@
|
||||||
## 工程编译:
|
## 工程编译:
|
||||||
Horizon采用monorepo方式管理项目,意思是在版本控制系统的单个代码库里包含了许多项目的代码
|
Horizon采用monorepo方式管理项目,意思是在版本控制系统的单个代码库里包含了许多项目的代码
|
||||||
|
|
||||||
monorepo工具采用yarn
|
monorepo工具采用npm workspaces **(npm版本需要大于7.x)**
|
||||||
### yarn配置
|
|
||||||
1. yarn1(推荐)
|
|
||||||
``` shell
|
|
||||||
// 先安装yarn
|
|
||||||
npm i yarn -g
|
|
||||||
```
|
|
||||||
在 `C:\Users\[工号]\.yarnrc`无相应文件需要新建
|
|
||||||
|
|
||||||
加入yarn配置:
|
|
||||||
```shell
|
|
||||||
registry "http://szxy1.artifactory.cd-cloud-artifact.tools.huawei.com/artifactory/api/npm/sz-npm-public"
|
|
||||||
no-proxy .huawei.com
|
|
||||||
lastUpdateCheck 1646381423295
|
|
||||||
strict-ssl false
|
|
||||||
```
|
|
||||||
2. yarn2
|
|
||||||
|
|
||||||
由于yarn2+有不兼容更新,安装方式依赖node 16+的corepack功能,安装参考 [yarn官网](https://yarnpkg.com/getting-started/install)
|
|
||||||
在 `C:\Users\[工号]\.yarnrc.yml`加入yarn配置,无相应文件需要新建
|
|
||||||
|
|
||||||
加入yarn配置:
|
|
||||||
```shell
|
|
||||||
npmRegistryServer "http://szxy1.artifactory.cd-cloud-artifact.tools.huawei.com/artifactory/api/npm/sz-npm-public"
|
|
||||||
```
|
|
||||||
注意:yarn2配置文件和字段都存在大量不兼容,参考[详细配置](https://yarnpkg.com/configuration/yarnrc#npmRegistryServer)
|
|
||||||
### 工程命令
|
### 工程命令
|
||||||
#### 安装
|
#### 安装
|
||||||
```shell
|
```shell
|
||||||
yarn
|
npm install
|
||||||
```
|
```
|
||||||
> 需要使用yarn安装,monorepo的依赖才能正确安装到node_modules
|
> 需要使用npm7.x以后版本安装,monorepo的依赖才能正确安装到node_modules
|
||||||
#### 打包
|
#### 打包
|
||||||
```shell
|
```shell
|
||||||
yarn run build
|
npm run build
|
||||||
```
|
```
|
||||||
#### 全局单元测试
|
#### 全局单元测试
|
||||||
```shell
|
```shell
|
||||||
yarn run test
|
npm run test
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 发布包:
|
#### 发布包:
|
||||||
|
|
|
@ -30,7 +30,7 @@ function isValidKey(key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mergeDefault(sourceObj, defaultObj) {
|
function mergeDefault(sourceObj, defaultObj) {
|
||||||
Object.keys(defaultObj).forEach((key) => {
|
Object.keys(defaultObj).forEach(key => {
|
||||||
if (sourceObj[key] === undefined) {
|
if (sourceObj[key] === undefined) {
|
||||||
sourceObj[key] = defaultObj[key];
|
sourceObj[key] = defaultObj[key];
|
||||||
}
|
}
|
||||||
|
@ -44,10 +44,10 @@ function buildElement(isClone, type, setting, children) {
|
||||||
const props = isClone ? { ...type.props } : {};
|
const props = isClone ? { ...type.props } : {};
|
||||||
let vNode = isClone ? type.belongClassVNode : getProcessingClassVNode();
|
let vNode = isClone ? type.belongClassVNode : getProcessingClassVNode();
|
||||||
|
|
||||||
if (setting != null) {
|
if (setting !== null) {
|
||||||
const keys = Object.keys(setting);
|
const keys = Object.keys(setting);
|
||||||
const keyLength = keys.length;
|
const keyLength = keys.length;
|
||||||
for(let i = 0; i < keyLength; i++) {
|
for (let i = 0; i < keyLength; i++) {
|
||||||
const k = keys[i];
|
const k = keys[i];
|
||||||
if (isValidKey(k)) {
|
if (isValidKey(k)) {
|
||||||
props[k] = setting[k];
|
props[k] = setting[k];
|
||||||
|
@ -81,5 +81,5 @@ export function cloneElement(element, setting, ...children) {
|
||||||
|
|
||||||
// 检测结构体是否为合法的Element
|
// 检测结构体是否为合法的Element
|
||||||
export function isValidElement(element) {
|
export function isValidElement(element) {
|
||||||
return !!(element && element.vtype === TYPE_COMMON_ELEMENT);
|
return (element && element.vtype === TYPE_COMMON_ELEMENT);
|
||||||
}
|
}
|
||||||
|
|
34
package.json
34
package.json
|
@ -59,14 +59,9 @@
|
||||||
"babel-preset-env": "^1.7.0",
|
"babel-preset-env": "^1.7.0",
|
||||||
"babel-preset-react": "^6.24.1",
|
"babel-preset-react": "^6.24.1",
|
||||||
"chalk": "^3.0.0",
|
"chalk": "^3.0.0",
|
||||||
"clean-webpack-plugin": "^4.0.0-alpha.0",
|
|
||||||
"concurrently": "^6.2.0",
|
|
||||||
"confusing-browser-globals": "^1.0.9",
|
"confusing-browser-globals": "^1.0.9",
|
||||||
"copy-webpack-plugin": "5.0.4",
|
"copy-webpack-plugin": "5.0.4",
|
||||||
"core-js": "^3.6.4",
|
"core-js": "^3.6.4",
|
||||||
"coveralls": "^3.0.9",
|
|
||||||
"cross-env": "^7.0.3",
|
|
||||||
"css-loader": "3.4.2",
|
|
||||||
"danger": "^9.2.10",
|
"danger": "^9.2.10",
|
||||||
"ejs": "^3.1.6",
|
"ejs": "^3.1.6",
|
||||||
"error-stack-parser": "^2.0.6",
|
"error-stack-parser": "^2.0.6",
|
||||||
|
@ -80,46 +75,25 @@
|
||||||
"eslint-plugin-no-function-declare-after-return": "^1.0.0",
|
"eslint-plugin-no-function-declare-after-return": "^1.0.0",
|
||||||
"eslint-plugin-react": "^6.7.1",
|
"eslint-plugin-react": "^6.7.1",
|
||||||
"eslint-webpack-plugin": "^3.0.1",
|
"eslint-webpack-plugin": "^3.0.1",
|
||||||
"express": "^4.17.1",
|
|
||||||
"filesize": "^6.0.1",
|
|
||||||
"glob": "^7.1.6",
|
|
||||||
"glob-stream": "^6.1.0",
|
|
||||||
"gzip-size": "^5.1.1",
|
|
||||||
"html-webpack-plugin": "4.4.1",
|
|
||||||
"jest": "^25.5.4",
|
"jest": "^25.5.4",
|
||||||
"jest-cli": "^25.2.7",
|
"jest-cli": "^25.2.7",
|
||||||
"jest-diff": "^25.2.6",
|
"jest-diff": "^25.2.6",
|
||||||
"jest-environment-jsdom-sixteen": "^1.0.3",
|
"jest-environment-jsdom-sixteen": "^1.0.3",
|
||||||
"jest-react": "^0.12.0",
|
"jest-react": "^0.12.0",
|
||||||
"jest-snapshot-serializer-raw": "^1.1.0",
|
"jest-snapshot-serializer-raw": "^1.1.0",
|
||||||
"minimatch": "^3.0.4",
|
|
||||||
"minimist": "^1.2.3",
|
"minimist": "^1.2.3",
|
||||||
"mkdirp": "^0.5.1",
|
|
||||||
"ncp": "^2.0.0",
|
|
||||||
"object-assign": "^4.1.1",
|
"object-assign": "^4.1.1",
|
||||||
"pacote": "^10.3.0",
|
|
||||||
"power-assert": "^1.6.1",
|
|
||||||
"prettier": "1.19.1",
|
"prettier": "1.19.1",
|
||||||
"prop-types": "^15.6.2",
|
|
||||||
"random-seed": "^0.3.0",
|
|
||||||
"react-lifecycles-compat": "^3.0.4",
|
"react-lifecycles-compat": "^3.0.4",
|
||||||
"regenerator-runtime": "^0.13.9",
|
"regenerator-runtime": "^0.13.9",
|
||||||
"resemblejs": "^4.0.0",
|
|
||||||
"rimraf": "^3.0.0",
|
"rimraf": "^3.0.0",
|
||||||
"semver": "^7.1.1",
|
|
||||||
"style-loader": "1.0.0",
|
|
||||||
"targz": "^1.0.1",
|
|
||||||
"through2": "^3.0.1",
|
|
||||||
"tmp": "^0.1.0",
|
|
||||||
"tslint": "^6.0.0",
|
"tslint": "^6.0.0",
|
||||||
"typescript": "^3.9.7",
|
"typescript": "^3.9.7",
|
||||||
"url-loader": "^4.1.1",
|
|
||||||
"wait-on": "^6.0.0",
|
|
||||||
"webpack": "^4.46.0",
|
"webpack": "^4.46.0",
|
||||||
"webpack-cli": "^4.7.2",
|
"webpack-cli": "^4.7.2"
|
||||||
"yargs": "^15.3.1"
|
|
||||||
},
|
},
|
||||||
"devEngines": {
|
"engines": {
|
||||||
"node": "8.x || 9.x || 10.x || 11.x || 12.x || 13.x || 14.x"
|
"node": ">=10.x",
|
||||||
|
"npm": ">=7.x"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
'use strict';
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const libPath = path.join(__dirname, '../../libs');
|
const libPath = path.join(__dirname, '../../libs/horizon');
|
||||||
const baseConfig = {
|
const baseConfig = {
|
||||||
entry: path.resolve(libPath, 'index.ts'),
|
entry: path.resolve(libPath, 'index.ts'),
|
||||||
module: {
|
module: {
|
||||||
|
@ -10,7 +9,7 @@ const baseConfig = {
|
||||||
test: /\.(js)|ts$/,
|
test: /\.(js)|ts$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
use: [
|
use: [
|
||||||
{
|
{
|
||||||
loader: 'babel-loader'
|
loader: 'babel-loader'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue