Commit 62194a91 authored by 邓晓峰's avatar 邓晓峰

feat: custom package foler and perf leran config

parent 1d769a37
Pipeline #27033 failed with stages
in 14 seconds
......@@ -3,18 +3,28 @@ import { join } from 'path';
// utils must build before core
const headPkgs = [
'DeviceTree',
'Empty',
'HistoryInfo',
'ImageSelect',
'MqttView',
'QuotaSelect',
'RealTimeInfo',
'TimeRangePicker',
// 'DeviceTree',
// 'Empty',
// 'HistoryInfo',
// 'ImageSelect',
// 'MqttView',
// 'QuotaSelect',
// 'RealTimeInfo',
// 'TimeRangePicker',
];
const tailPkgs = readdirSync(join(__dirname, 'packages')).filter(
(pkg) => pkg.charAt(0) !== '.' && !headPkgs.includes(pkg),
);
const pkgList = ['base-components', 'extend-components']
.map((dir) => {
const list = readdirSync(join(__dirname, 'packages', dir)).map((item) => `${item}!${dir}`);
return list;
})
.flat();
const tailPkgs = pkgList
.filter((pkg) => pkg.charAt(0) !== '.' && !headPkgs.includes(pkg))
.map((item) => {
const [name, path] = item.split('!');
return `${path}/${name}`;
});
export default {
cjs: { type: 'babel', lazy: true },
......
......@@ -16,7 +16,7 @@ before_script:
init:
stage: init
script:
- cd /d %DEPLOY_PATH%/src/wisdom-components
- cd /d %DEPLOY_PATH%/src/wisdom-extend-components
- dir
- git pull
- echo 开始安装依赖...
......@@ -25,13 +25,13 @@ init:
bootstrap:
stage: bootstrap
script:
- cd /d %DEPLOY_PATH%/src/wisdom-components
- cd /d %DEPLOY_PATH%/src/wisdom-extend-components
- dir
build:
stage: build
script:
- cd /d %DEPLOY_PATH%/src/wisdom-components
- cd /d %DEPLOY_PATH%/src/wisdom-extend-components
- echo 开始打包...
- npm run site
- echo 打包完成
......@@ -39,7 +39,7 @@ build:
release:
stage: release
script:
- cd /d %DEPLOY_PATH%/src/wisdom-components
- cd /d %DEPLOY_PATH%/src/wisdom-extend-components
- echo 开始拷贝发布包...
- robocopy dist %DEPLOY_PATH%/dist /e || cmd /c "exit /b 0"
- echo 发布完成.
......@@ -3,12 +3,17 @@ import { readdirSync } from 'fs';
import { join } from 'path';
const headPkgList = [];
const pkgList = readdirSync(join(__dirname, 'packages')).filter(
(pkg) => pkg.charAt(0) !== '.' && !headPkgList.includes(pkg),
);
const pkgList = ['base-components', 'extend-components']
.map((dir) => {
const list = readdirSync(join(__dirname, 'packages', dir)).map((item) => item + `!${dir}`);
return list.filter((pkg) => pkg.charAt(0) !== '.' && !headPkgList.includes(pkg));
})
.flat();
const alias = pkgList.reduce((pre, pkg) => {
pre[`@wisdom-components/pro-${pkg}`] = join(__dirname, 'packages', pkg, 'src');
const path = pkg.split('!');
pre[`@wisdom-components/pro-${path[0]}`] = join(__dirname, 'packages', path[1], path[0], 'src');
return {
...pre,
};
......@@ -17,11 +22,15 @@ const alias = pkgList.reduce((pre, pkg) => {
console.log(`🌼 alias list \n${chalk.blue(Object.keys(alias).join('\n'))}`);
const tailPkgList = pkgList
.map((path) => [join('packages', path, 'src'), join('packages', path, 'src', 'components')])
.map((pkg) => {
const path = pkg.split('!');
return [
join('packages', path[1], path[0], 'src'),
join('packages', path[0], 'src', 'components'),
];
})
.reduce((acc, val) => acc.concat(val), []);
const isProduction = process.env.NODE_ENV === 'production';
export default {
title: 'panda-components',
mode: 'site',
......@@ -90,5 +99,10 @@ export default {
children: ['DeviceTree', 'RealTimeInfo', 'HistoryInfo'],
},
],
'/extend-components': [
{
title: 'base',
},
],
},
};
......@@ -2,6 +2,7 @@
"version": "independent",
"npmClient": "npm",
"useWorkspaces": true,
"packages": ["packages/*"],
"changelog": {
"repo": "wisdom-components",
"cacheDir": ".changelog"
......
......@@ -2,7 +2,8 @@
"private": true,
"license": "MIT",
"workspaces": [
"packages/*"
"packages/base-components/*",
"packages/extend-components/*"
],
"scripts": {
"bootstrap": "node ./scripts/bootstrap.js",
......@@ -152,97 +153,145 @@
},
"size-limit": [
{
"path": "packages/DeviceTree/lib/**/*.js",
"path": "packages/base-components/BasicTable/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/DeviceTree/es/**/*.js",
"path": "packages/base-components/BasicTable/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/Empty/lib/**/*.js",
"path": "packages/base-components/BasicTools/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/Empty/es/**/*.js",
"path": "packages/base-components/BasicTools/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/HistoryInfo/lib/**/*.js",
"path": "packages/base-components/DeviceTree/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/HistoryInfo/es/**/*.js",
"path": "packages/base-components/DeviceTree/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/ImageSelect/lib/**/*.js",
"path": "packages/base-components/Empty/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/ImageSelect/es/**/*.js",
"path": "packages/base-components/Empty/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/MqttView/lib/**/*.js",
"path": "packages/base-components/ExportExcel/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/MqttView/es/**/*.js",
"path": "packages/base-components/ExportExcel/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/QuotaSelect/lib/**/*.js",
"path": "packages/base-components/HistoryInfo/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/QuotaSelect/es/**/*.js",
"path": "packages/base-components/HistoryInfo/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/RealTimeInfo/lib/**/*.js",
"path": "packages/base-components/ImageSelect/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/RealTimeInfo/es/**/*.js",
"path": "packages/base-components/ImageSelect/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/TimeRangePicker/lib/**/*.js",
"path": "packages/base-components/MqttView/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/TimeRangePicker/es/**/*.js",
"path": "packages/base-components/MqttView/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/base-components/ParseForm/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/base-components/ParseForm/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/base-components/QuotaSelect/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/base-components/QuotaSelect/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/base-components/RealTimeInfo/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/base-components/RealTimeInfo/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/base-components/TimeRangePicker/lib/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
},
{
"path": "packages/base-components/TimeRangePicker/es/**/*.js",
"limit": "2 s",
"webpack": false,
"running": false
......
---
title: BasicTable - 标准表格
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
// @ts-ignore
import React, { useEffect, useState } from 'react';
import Empty from '@wisdom-components/empty';
import BasicTable from '../index';
......@@ -42,11 +43,10 @@ const Demo = () => {
});
};
// @ts-ignore
return (
<div style={{ height: '400px' }}>
{!!dataSource.length && (
<BasicTable dataSource={dataSource} columns={columns} bordered={true} />
)}
{!!dataSource.length && <BasicTable dataSource={dataSource} columns={columns} bordered />}
{!dataSource.length && <Empty description={'暂无数据'} />}
</div>
);
......
@import (reference) '~antd/es/style/themes/default';
@import (reference) '../../../../node_modules/antd/es/style/themes/default';
@basic-table-prefix-cls: ~'@{ant-prefix}-basic-table';
.@{basic-table-prefix-cls} {
......
---
title: BasicTools - 通用工具库
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......@@ -16,7 +16,7 @@ group:
## 使用说明
```javascript
import { getTimeRange, getRange } from '@wisdom-components/basictools';
import { getTimeRange, getRange } from 'packages/base-components/BasicTools/lib/index';
let result1 = getTimeRange('lastYear');
let result2 = getTimeRange('nextWeek');
......
---
title: DeviceTree - 设备树
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
@import (reference) '~antd/es/style/themes/default';
@import (reference) '../../../../node_modules/antd/es/style/themes/default';
@device-tree-prefix-cls: ~'@{ant-prefix}-device-tree';
.@{device-tree-prefix-cls} {
......
---
title: Empty - 空状态
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
@import (reference) '~antd/es/style/themes/default';
@import (reference) '../../../../node_modules/antd/es/style/themes/default';
@panda-empty-prefix-cls: ~'@{ant-prefix}-panda-empty';
.@{panda-empty-prefix-cls} {
......
---
title: ExportExcel - Excel表格导出
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
---
title: HistoryInfo - 历史数据查看
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
@import (reference) '~antd/es/style/themes/default';
@import (reference) '../../../../node_modules/antd/es/style/themes/default';
@history-info-prefix-cls: ~'@{ant-prefix}-history-info';
.@{history-info-prefix-cls} {
......
---
title: ImageSelect - 图片选择
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
@import (reference) '~antd/es/style/themes/default';
@import (reference) '../../../../node_modules/antd/es/style/themes/default';
@image-select-prefix-cls: ~'@{ant-prefix}-image-select';
.@{image-select-prefix-cls} {
......
'use strict';
const mqttView = require('..');
const mqttView = require('../lib');
describe('@wisdom-components/MqttView', () => {
describe('@wisdom-extend-components/MqttView', () => {
it('needs tests');
});
---
title: MqttView - Mqtt连接
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
---
title: ParseForm - 台账解析
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
---
title: QuotaSelect - 指标选择
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
@import (reference) '~antd/es/style/themes/default';
@import (reference) '../../../../node_modules/antd/es/style/themes/default';
@quota-select-prefix-cls: ~'@{ant-prefix}-quota-select';
.@{quota-select-prefix-cls} {
......
---
title: RealTimeInfo - 实时数据查看
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
@import (reference) '~antd/es/style/themes/default';
@import (reference) '../../../../node_modules/antd/es/style/themes/default';
@realtime-info-prefix-cls: ~'@{ant-prefix}-realtime-info';
.@{realtime-info-prefix-cls} {
......
---
title: TimeRangePicker - 自定义类型时间选择
nav:
title: 组件
title: 基础组件
path: /components
group:
path: /
......
@import (reference) '~antd/es/style/themes/default';
@import (reference) '../../../../node_modules/antd/es/style/themes/default';
@time-range-picker-prefix-cls: ~'@{ant-prefix}-time-range-picker';
.@{time-range-picker-prefix-cls} {
......
......@@ -5,20 +5,26 @@ const { yParser } = require('@umijs/utils');
(async () => {
const args = yParser(process.argv);
const version = '1.0.0-beta.1';
const pkgs = readdirSync(join(__dirname, '../packages')).filter((pkg) => pkg.charAt(0) !== '.');
// readdirSync(join(__dirname, '../packages')).filter((pkg) => pkg.charAt(0) !== '.');
const pkgs = ['base-components', 'extend-components']
.map((dir) => {
const list = readdirSync(join(__dirname, '../packages', dir)).map((item) => `${item}!${dir}`);
return list.filter((pkg) => pkg.charAt(0) !== '.');
})
.flat();
pkgs.forEach((shortName) => {
const name = `@wisdom-components/pro-${shortName}`;
const [name, dir] = shortName.split('!');
const desc = `@wisdom-components/pro-${name}`;
const pkgJSONPath = join(__dirname, '..', 'packages', dir, name, 'package.json');
const pkgJSONPath = join(__dirname, '..', 'packages', shortName, 'package.json');
const pkgJSONExists = existsSync(pkgJSONPath);
let json;
if (args.force || !pkgJSONExists) {
json = {
name,
version,
description: name,
description: desc,
module: 'es/index.js',
main: 'lib/index.js',
types: 'lib/index.d.ts',
......@@ -32,7 +38,7 @@ const { yParser } = require('@umijs/utils');
authors: ['dengxiaofeng'],
license: 'MIT',
bugs: 'https://g.civnet.cn:8443/ReactWeb5/winsdom-components/plugins/issues',
homepage: `https://g.civnet.cn:8443/ReactWeb5/winsdom-components/tree/master/packages/${shortName}#readme`,
homepage: `https://g.civnet.cn:8443/ReactWeb5/winsdom-components/tree/master/packages/${name}#readme`,
peerDependencies: {
umi: '3.x',
},
......@@ -63,13 +69,13 @@ const { yParser } = require('@umijs/utils');
writeFileSync(pkgJSONPath, `${JSON.stringify(json, null, 2)}\n`);
}
const readmePath = join(__dirname, '..', 'packages', shortName, 'README.md');
const readmePath = join(__dirname, '..', 'packages', name, 'README.md');
if (args.force || !existsSync(readmePath)) {
writeFileSync(
readmePath,
`# ${name}
> ${json.description}.
See our website [${name}](https://umijs.org/plugins/${shortName}) for more information.
See our website [${name}](https://umijs.org/plugins/${name}) for more information.
## Install
Using npm:
\`\`\`bash
......
......@@ -52,7 +52,6 @@ const getMds = (allVersion = false) => {
.filter((tag) => tag.includes(pkg))
.map((tag) => tag.split('@').pop());
}
console.log(versions);
// eslint-disable-next-line array-callback-return
versions.map((version) => {
const versionPkg = `@wisdom-components/pro-${pkg}@${version}`;
......@@ -62,8 +61,8 @@ const getMds = (allVersion = false) => {
}
github.repos
.createRelease({
owner: 'wisdom-components',
repo: 'wisdom-components',
owner: 'wisdom-extend-components',
repo: 'wisdom-extend-components',
tag_name: versionPkg,
name: versionPkg,
body: changeLog,
......
const fs = require('fs');
const { join } = require('path');
const fg = require('fast-glob');
const getPackages = require('./utils/getPackages');
const pkgList = fs
.readdirSync(join(__dirname, '../', 'packages'))
.filter((pkg) => pkg.charAt(0) !== '.');
const pkgList = getPackages();
pkgList.map(async (path) => {
const baseUrl = `${join(__dirname, '../', 'packages')}/${path}/src`;
pkgList.map(async (pkg) => {
const [name, path] = pkg.split('!');
const baseUrl = `${join(__dirname, '../', 'packages')}/${path}/${name}/src`;
const lessFiles = await fg(`${baseUrl}/**/*.less`, {
ignore: ['**/demos/**'],
deep: 5,
......@@ -16,7 +16,8 @@ pkgList.map(async (path) => {
return `@import "../es${lessPath.replace(baseUrl, '')}";`;
});
const distPath = `${join(__dirname, '../', 'packages', path, 'dist', `${path}.less`)}`;
fs.writeFileSync(distPath, importFiles.join('\n'));
const distPath = `${join(__dirname, '../', 'packages', path, name, 'dist', `${name}.less`)}`;
if (fs.existsSync(distPath)) {
fs.writeFileSync(distPath, importFiles.join('\n'));
}
});
const path = require('path');
const fs = require('fs');
const writePkg = require('write-pkg');
const getPackages = require('./utils/getPackages');
const cwd = process.cwd();
const ignoreDirPath = ['.DS_Store'];
const filePath = path.resolve(cwd, 'package.json');
const packagesDir = path.resolve(cwd, 'packages');
// const packagesDir = path.resolve(cwd, 'packages');
const json = JSON.parse(fs.readFileSync(filePath, 'utf8'));
delete json['size-limit'];
let componentsNames = fs.readdirSync(packagesDir);
let componentsNames = getPackages();
componentsNames = componentsNames.filter((dir) => ignoreDirPath.indexOf(dir) === -1);
(async () => {
const sizeLimitConfig = [];
componentsNames.forEach((component) => {
const [shortName, p] = component.split('!');
sizeLimitConfig.push({
path: `packages/${component}/lib/**/*.js`,
path: `packages/${p}/${shortName}/lib/**/*.js`,
limit: '2 s',
webpack: false,
running: false,
});
sizeLimitConfig.push({
path: `packages/${component}/es/**/*.js`,
path: `packages/${p}/${shortName}/es/**/*.js`,
limit: '2 s',
webpack: false,
running: false,
......
......@@ -40,7 +40,7 @@ async function release() {
if (userRegistry.includes('https://registry.yarnpkg.com/')) {
printErrorAndExit(`Release failed, please use ${chalk.blue('npm run release')}.`);
}
//https://g.civnet.cn:4873
// https://g.civnet.cn:4873
// if (!userRegistry.includes('https://registry.npmjs.org/')) {
// const registry = chalk.blue('https://registry.npmjs.org/');
// printErrorAndExit(`Release failed, npm registry must be ${registry}.`);
......@@ -118,8 +118,11 @@ async function release() {
const pkgs = args.publishOnly ? getPackages() : updated;
logStep(`publish packages: ${chalk.blue(pkgs.join(', '))}`);
// eslint-disable-next-line consistent-return
pkgs.forEach((pkg, index) => {
const pkgPath = join(cwd, 'packages', pkg.replace('pro-', ''));
const [shortName, p] = pkg.split('!');
const pkgPath = join(cwd, 'packages', p, shortName.replace('pro-', ''));
// eslint-disable-next-line global-require,import/no-dynamic-require
const { name, version } = require(join(pkgPath, 'package.json'));
if (name === 'parseform') return false;
const isNext = isNextVersion(version);
......
......@@ -9,6 +9,7 @@ function replacePath(path) {
const esPath = dirname(join(cwd, `node_modules/${esModule}`));
if (fs.existsSync(esPath)) {
console.log(`[es build] replace ${path.node.source.value} with ${esModule}`);
// eslint-disable-next-line no-param-reassign
path.node.source.value = esModule;
}
}
......
......@@ -5,9 +5,11 @@ const getPackages = require('./utils/getPackages');
process.setMaxListeners(Infinity);
module.exports = (publishPkgList) => {
const pkgList = (publishPkgList || getPackages()).map((name) => {
const pkgList = (publishPkgList || getPackages()).map((pkg) => {
// eslint-disable-next-line global-require,import/no-dynamic-require
return require(join(__dirname, '../packages', name, 'package.json')).name;
const [name, path] = pkg.split('!');
// eslint-disable-next-line global-require,import/no-dynamic-require
return require(join(__dirname, '../packages', path, name, 'package.json')).name;
});
const commands = pkgList.map((pkg) => {
const subprocess = execa('tnpm', ['sync', pkg]);
......
......@@ -2,5 +2,12 @@ const { readdirSync } = require('fs');
const { join } = require('path');
module.exports = function getPackages() {
return readdirSync(join(__dirname, '../../packages')).filter((pkg) => pkg.charAt(0) !== '.');
return ['base-components', 'extend-components']
.map((dir) => {
const list = readdirSync(join(__dirname, '../../packages', dir)).map(
(item) => `${item}!${dir}`,
);
return list.filter((pkg) => pkg.charAt(0) !== '.');
})
.flat();
};
const path = require('path');
const fs = require('fs');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const { readdirSync } = require('fs');
const tailPkgs = readdirSync(path.join(__dirname, 'packages')).filter(
(pkg) => pkg.charAt(0) !== '.',
);
// const tailPkgs = readdirSync(path.join(__dirname, 'packages')).filter(
// (pkg) => pkg.charAt(0) !== '.',
// );
const tailPkgs = ['base-components', 'extend-components']
.map((dir) => {
const list = readdirSync(path.join(__dirname, 'packages', dir)).map((item) => `${item}!${dir}`);
return list.filter((pkg) => pkg.charAt(0) !== '.');
})
.flat();
const isCI = process.env.PRO_COMPONENTS_CI === 'CI';
const externals = isCI
? tailPkgs.reduce((pre, value) => {
const [name] = value.split('!');
return {
...pre,
[`@ant-design/pro-${value}`]: `Pro${value
[`@ant-design/pro-${name}`]: `Pro${name
.toLowerCase()
.replace(/( |^)[a-z]/g, (L) => L.toUpperCase())}`,
};
}, {})
: {};
console.log(externals);
const webPackConfigList = [];
// eslint-disable-next-line consistent-return
tailPkgs.forEach((pkg) => {
if (pkg == 'ParseForm') return false;
const [name, p] = pkg.split('!');
if (name === 'ParseForm') return false;
const entry = {};
entry[`${pkg}`] = `./packages/${pkg}/src/index.js`;
entry[`${pkg}.min`] = `./packages/${pkg}/src/index.js`;
entry[`${name}`] = `./packages/${p}/${name}/src/index.js`;
entry[`${name}.min`] = `./packages/${p}/${name}/src/index.js`;
const config = {
entry,
output: {
filename: '[name].js',
library: `WisDOM${pkg.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase())}`,
library: `WisDOM${name.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase())}`,
libraryExport: 'default',
path: path.resolve(__dirname, 'packages', pkg, 'dist'),
path: path.resolve(__dirname, 'packages', p, name, 'dist'),
globalObject: 'this',
},
mode: 'production',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment