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