Skip to content

Commit

Permalink
switch to lerna + workspace mode
Browse files Browse the repository at this point in the history
  • Loading branch information
FateRiddle committed Dec 23, 2020
1 parent 27c4119 commit d6da931
Show file tree
Hide file tree
Showing 82 changed files with 280 additions and 108 deletions.
40 changes: 3 additions & 37 deletions .fatherrc.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,6 @@
import commonjs from 'rollup-plugin-commonjs';

// 通用的配置,可以在每个package里写 fatherrc.js 来覆盖
export default {
entry: ['src/index.js', 'src/antd.js', 'src/fusion.js'],
esm: 'rollup',
cjs: 'babel',
extraRollupPlugins: [
commonjs({
include: 'node_modules/**',
}),
],
extraBabelPlugins: [
[
'import',
{
libraryName: 'antd',
libraryDirectory: 'lib',
style: 'css',
},
'antd',
],
[
'import',
{
libraryName: '@alifd/next',
libraryDirectory: 'lib',
},
'@alifd/next',
],
[
'import',
{
libraryName: '@ant-design/icons',
libraryDirectory: 'lib/icons',
camel2DashComponentName: false,
},
'@ant-design/icons',
],
],
disableTypeCheck: false, // 如果出了问题,这个可以改成true
cjs: { type: 'babel', lazy: true },
};
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/yarn.lock
/package-lock.json


# production
/dist
/lib
Expand All @@ -15,13 +16,24 @@
.idea
.DS_Store
.idea
.vscode

# umi
.umi
.umi-production
.umi-test
.env.local

# lerna

/packages/*/es
/packages/*/lib
/packages/*/node_modules
/packages/*/.local
/packages/*/dist
/.local
/packages/**/node_modules

# custom
old-doc
test.json
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ package.json
.umi
.umi-production
.umi-test
/packages/*/node_modules
/node_modules
4 changes: 3 additions & 1 deletion .umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default defineConfig({
},
],
mode: 'site',
alias: { 'form-render/dist': path.resolve(__dirname, 'dist') },
alias: {
'form-render/dist': path.resolve(__dirname, 'packages/form-render/dist'),
},
base: '/form-render/',
publicPath: '/form-render/',
exportStatic: {},
Expand Down
4 changes: 2 additions & 2 deletions docs/demo/FR2/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect, useRef } from 'react';
import FormRender from '../../../src/antd';
import FormRender from '../../../packages/form-render/src/antd';
import { Button } from 'antd';
// import FormRender from '../../../src/fusion';
// import FormRender from '../../../packages/form-render/src/fusion';
// import '@alifd/next/dist/next.min.css';

const Demo = ({ schema = {} }) => {
Expand Down
64 changes: 64 additions & 0 deletions docs/guide/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
order: 1
title: test
nav:
order: 1
title: 教程
---

```jsx
import React from 'react';
import FR from '../demo/FR2/index.jsx';
import json from '../demo/new-feature/test.json';

export default () => <FR schema={json} />;
```

```jsx
import React from 'react';
import A from '@formrender/tester';

export default () => <A />;
```

```jsx
import React, { useState } from 'react';
import FR from 'form-render/lib/antd';
import A from '@formrender/tester';

export default () => {
const [data, setData] = useState();

const submit = () => {
alert(JSON.stringify(data, null, 2));
};

return (
<div>
<FR
formData={data}
onChange={setData}
widgets={{ test: A }}
schema={{
type: 'object',
'ui:displayType': 'row',
properties: {
string: {
title: '字符串',
type: 'string',
'ui:widget': 'test',
},
select: {
title: '单选',
type: 'string',
enum: ['a', 'b', 'c'],
enumNames: ['选项1', '选项2', '选项3'],
},
},
}}
/>
<button onClick={submit}>haha</button>
</div>
);
};
```
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"packages": ["packages/*"],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true
}
77 changes: 9 additions & 68 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,88 +1,29 @@
{
"name": "form-render",
"version": "0.9.2",
"description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
"repository": {
"type": "git",
"url": "git@github.com:alibaba/form-render.git"
},
"keywords": [
"FormRender",
"Render",
"React",
"Json Schema",
"Ant Design",
"Fusion Design"
],
"contributors": [
{
"name": "Tw93",
"email": "tw93@qq.com"
},
{
"name": "mankaiviky",
"email": "mankaiviky@163.com"
},
{
"name": "FateRiddle",
"email": "fateriddle@gmail.com"
}
"name": "root",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"start": "dumi dev",
"build": "father-build",
"prepare": "npm run build",
"postpublish": "git push --tags",
"build": "lerna run build",
"docs:build": "dumi build",
"predeploy": "npm run docs:build",
"deploy": "gh-pages -d docs-dist",
"beta": "npm publish --tag beta",
"prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
"test": "umi-test",
"test:coverage": "umi-test --coverage",
"size": "ANALYZE=1 dumi build"
},
"main": "lib/index.js",
"module": "dist/index.esm.js",
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,jsx,less,md,json}": [
"prettier --write"
],
"*.ts?(x)": [
"prettier --parser=typescript --write"
]
},
"dependencies": {
"@ant-design/icons": "^4.0.2",
"color": "^3.1.2",
"lodash.debounce": "^4.0.8",
"moment": "^2.24.0",
"pope": "^2.0.2",
"prop-types": "^15.x",
"rc-color-picker": "^1.2.6",
"react-sortable-hoc": "^1.6.1",
"validator": "^10.7.1"
},
"peerDependencies": {
"@alifd/next": "^1.x",
"antd": "^4.x",
"react": "^16.8.0 || ^17.0.0",
"react-dom": "^16.8.0 || ^17.0.0"
"start": "dumi dev",
"size": "ANALYZE=1 dumi build",
"clean": "lerna clean -y"
},
"devDependencies": {
"@alifd/next": "^1.x",
"@umijs/preset-react": "1.x",
"@umijs/test": "^3.0.5",
"antd": "^4.x",
"babel-plugin-import": "^1.13.0",
"deep-equal": "^2.0.3",
"dumi": "^1.0.33",
"father-build": "^1.17.2",
"fetch-jsonp": "^1.1.3",
"gh-pages": "^3.0.0",
"lerna": "^3.22.1",
"lint-staged": "^10.0.7",
"prettier": "^1.19.1",
"prismjs": "^1.20.0",
Expand Down
40 changes: 40 additions & 0 deletions packages/form-render/.fatherrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import commonjs from 'rollup-plugin-commonjs';

export default {
entry: ['src/index.js', 'src/antd.js', 'src/fusion.js'],
esm: 'rollup',
cjs: 'babel',
extraRollupPlugins: [
commonjs({
include: 'node_modules/**',
}),
],
extraBabelPlugins: [
[
'import',
{
libraryName: 'antd',
libraryDirectory: 'lib',
style: 'css',
},
'antd',
],
[
'import',
{
libraryName: '@alifd/next',
libraryDirectory: 'lib',
},
'@alifd/next',
],
[
'import',
{
libraryName: '@ant-design/icons',
libraryDirectory: 'lib/icons',
camel2DashComponentName: false,
},
'@ant-design/icons',
],
],
};
4 changes: 4 additions & 0 deletions CHANGELOG.md → packages/form-render/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

### 0.9.3

- [内部] 对使用者无影响。为了方便后续自定义组件的开发,使用 lerna 将 form-render 从单仓库切换到 monorepo。之后的插件 & 自定义组件的开发都在 form-render 同一个仓库里进行

### 0.9.2

- [!] `format: url` 类型使用的兼容判断放宽,考虑到一些非常见的的网址
Expand Down
File renamed without changes.
73 changes: 73 additions & 0 deletions packages/form-render/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "form-render",
"version": "0.9.2",
"description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
"repository": {
"type": "git",
"url": "git@github.com:alibaba/form-render.git"
},
"keywords": [
"FormRender",
"Render",
"React",
"Json Schema",
"Ant Design",
"Fusion Design"
],
"contributors": [
{
"name": "Tw93",
"email": "tw93@qq.com"
},
{
"name": "mankaiviky",
"email": "mankaiviky@163.com"
},
{
"name": "FateRiddle",
"email": "fateriddle@gmail.com"
}
],
"scripts": {
"build": "father-build",
"prepare": "npm run build",
"postpublish": "git push --tags",
"beta": "npm publish --tag beta",
"prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
"test": "umi-test",
"test:coverage": "umi-test --coverage"
},
"main": "lib/index.js",
"module": "dist/index.esm.js",
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,jsx,less,md,json}": [
"prettier --write"
],
"*.ts?(x)": [
"prettier --parser=typescript --write"
]
},
"dependencies": {
"@ant-design/icons": "^4.0.2",
"color": "^3.1.2",
"lodash.debounce": "^4.0.8",
"moment": "^2.24.0",
"pope": "^2.0.2",
"prop-types": "^15.x",
"rc-color-picker": "^1.2.6",
"react-sortable-hoc": "^1.6.1",
"validator": "^10.7.1"
},
"peerDependencies": {
"@alifd/next": "^1.x",
"antd": "^4.x",
"react": "^16.8.0 || ^17.0.0",
"react-dom": "^16.8.0 || ^17.0.0"
},
"devDependencies": {
"deep-equal": "^2.0.3"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit d6da931

Please sign in to comment.