mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-14 17:01:19 +08:00
3aeeeb2aed
* refactor: transfer、tooltip (#4306) * refactor(transfer): use composition api (#4135) * refactor(transfer): use composition api * fix: remove console * refactor(tooltip): use composition api (#4059) * refactor(tooltip): use composition api * chore: useConfigInject * fix: remove useless * style: format code * refactor: transfer * refactor: tooltip Co-authored-by: ajuner <106791576@qq.com> * Refactor mentions (#4341) * refactor(mentions): use compositionAPI (#4313) * refactor: mentions * refactor: mentions Co-authored-by: ajuner <106791576@qq.com> * Refactor progress (#4358) * fix: timepicker error border not show #4331 * fix(UploadDragger): fix UploadDrager no export (#4334) * refactor(switch): support customize checked value #4329 (#4332) * refactor(switch): support customize checked value #4329 * test: add test case * refactor: update props name * refactor: update ts * refactor: optimize * style: uncheckedValue to unCheckedValue * test: update snap * feat: udpate switch ts * docs: remove ie11 * fix: tree-select throw error when use slot title * fix: TypeScript definition of Table interface for typescript 4.3.5 (#4353) * fix type for typescript 4.3.5 * Update interface.ts close #4296 * fix: dropdown submenu style error #4351 close #4351 * fix(notification): 完善notification类型 (#4346) * refactor(progress): use composition API (#4355) * refactor(progress): use composition API * refactor(vc-progress): update * refactor: progress * refactor: progress * fix: timepicker error border not show #4331 * fix(UploadDragger): fix UploadDrager no export (#4334) * refactor(switch): support customize checked value #4329 (#4332) * refactor(switch): support customize checked value #4329 * test: add test case * refactor: update props name * refactor: update ts * refactor: optimize * style: uncheckedValue to unCheckedValue * test: update snap * feat: udpate switch ts * docs: remove ie11 * fix: tree-select throw error when use slot title * fix: TypeScript definition of Table interface for typescript 4.3.5 (#4353) * fix type for typescript 4.3.5 * Update interface.ts close #4296 * fix: dropdown submenu style error #4351 close #4351 * fix(notification): 完善notification类型 (#4346) * refactor(progress): use composition API (#4355) * refactor(progress): use composition API * refactor(vc-progress): update * refactor: progress * refactor: progress Co-authored-by: Jarvis <35361626+fanhaoyuan@users.noreply.github.com> Co-authored-by: John <John60676@qq.com> Co-authored-by: 艾斯特洛 <axetroy.dev@gmail.com> Co-authored-by: zanllp <qc@zanllp.cn> * docs: add changelog * refactor: tree * refactor: tree * style: lint * refactor: tree * 热factor: tree * refactor: tree * refactor: tree * refactor: tree * refactor: directory tree * refactor: tree * refactor: tree-select * refactor: tree-select * refactor: tree-select * refactor: tree-select * refactor: tree-select * style: lint format * refactor: tree-select * refactor: tree-select * refactor: tree-select * refactor: tree-select * refactor: tree-select * refactor: tree-select * fix: upload ts error * fix: update tree title render & switchIcon * test: update tree test * feat: add VirtualScroll tree * refactor: datePicker & calendar & trigger (#4522) * style: update * test: update calendar test * test: update test * test: update test * refactor: slider * feat: update slider css * refactor: slider to ts * refactor: slider to ts * perf: update default itemHeight * test: update * fix: uddate ts type * fix: update skeleton * fix: update skeleton * refactor: update vc-pagination * refactor: pagination * refactor: timeline * refactor: steps * refactor: collapse * refactor: collapse * refactor: popconfirm * refactor: popover * refactor: dropdown * doc: merge doc * chore: vite for dev (#4602) * style: js to jsx * doc: add site * style: lint * style: format ts type * doc: update * style: format code * style: format site * doc: update * style: dmeo * style: format scripts * chore: remove sub-modules * chore: update vite * site: add site build * test: update snap * doc(select): add tip (#4606) * refactor: table (#4641) * refactor: table * refactor: table * refactor: table * refactor: table * refactor: table * refactor: table * refactor: table * refactor: table * refactor: table * fix: column not pass to cell * doc: uppate table * fix: update bodyCell headerCell * doc: remove examples * refactor: table * fix: table title not work * fix: table selection * fix: table checkStrictly * refactor: table * fix: table template error * feat: table support summary * test: update snap * perf: table * docs(table): fix ajax demo (#4639) * test: update table * refactor: remove old table * doc: update table doc * doc: update doc * doc: update select * doc: update summary Co-authored-by: John <John60676@qq.com> * doc: update doc * fix: menu arrow not work * test: update * doc: add next site * style: format * doc: update * doc: update site script * fix: expand icon not fixed * feat: use renderSlot * test: update table snap * feat: confirm support reactively * feat: configProvider.config * feat: message support configprovider.config * feat: notification support configprovider.config * doc: update doc * fix: typescript compile error * style: add import eslint * doc: update demo * chore: set transpileOnly true * style: fix eslint error * test: update snap * doc: update * test: mock date * test: update snap * chore: remove gulp-typescript (#4675) * feat: V3 form (#4678) * chore: update husky * perf: update formItem * perf: useInjectFormItemContext * fix: table ts error * doc: add Customized Form Controls demo * feat: export useInjectFormItemContext * doc: update form doc * doc: update doc * doc: update doc * feat: autocomplete support option slot * doc: update * feat: add form item rest * style: remove omit.js * refactor: autocomplete * doc: add changelog to site * doc: update site anchor * doc: update doc layout * test: update table test * doc: update * chore: udpate gulp script * chore: udpate gulp script * doc: add changelog * doc: update * test: ignore some test wait vue-test-utils * fix: form id error #4582 close #4582 * doc: add select Responsive demo * doc: remove temp doc Co-authored-by: ajuner <106791576@qq.com> Co-authored-by: Jarvis <35361626+fanhaoyuan@users.noreply.github.com> Co-authored-by: John <John60676@qq.com> Co-authored-by: 艾斯特洛 <axetroy.dev@gmail.com> Co-authored-by: zanllp <qc@zanllp.cn> Co-authored-by: Amour1688 <lcz_1996@foxmail.com>
454 lines
12 KiB
JavaScript
454 lines
12 KiB
JavaScript
/* eslint-disable no-console */
|
|
const { getProjectPath } = require('./utils/projectHelper');
|
|
const runCmd = require('./runCmd');
|
|
const getBabelCommonConfig = require('./getBabelCommonConfig');
|
|
const merge2 = require('merge2');
|
|
const { execSync } = require('child_process');
|
|
const through2 = require('through2');
|
|
const transformLess = require('./transformLess');
|
|
const webpack = require('webpack');
|
|
const babel = require('gulp-babel');
|
|
const argv = require('minimist')(process.argv.slice(2));
|
|
const { Octokit } = require('@octokit/rest');
|
|
|
|
// const getNpm = require('./getNpm')
|
|
// const selfPackage = require('../package.json')
|
|
const chalk = require('chalk');
|
|
const getNpmArgs = require('./utils/get-npm-args');
|
|
const getChangelog = require('./utils/getChangelog');
|
|
const path = require('path');
|
|
const gulp = require('gulp');
|
|
const fg = require('fast-glob');
|
|
const fs = require('fs');
|
|
const rimraf = require('rimraf');
|
|
const { createCompilerHost, createProgram } = require('typescript');
|
|
const stripCode = require('gulp-strip-code');
|
|
const compareVersions = require('compare-versions');
|
|
// const getTSCommonConfig = require('./getTSCommonConfig');
|
|
const replaceLib = require('./replaceLib');
|
|
|
|
const packageJson = require(getProjectPath('package.json'));
|
|
const cwd = process.cwd();
|
|
const libDir = getProjectPath('lib');
|
|
const esDir = getProjectPath('es');
|
|
|
|
// const tsConfig = getTSCommonConfig();
|
|
|
|
function dist(done) {
|
|
rimraf.sync(path.join(cwd, 'dist'));
|
|
process.env.RUN_ENV = 'PRODUCTION';
|
|
const webpackConfig = require(getProjectPath('webpack.build.conf.js'));
|
|
webpack(webpackConfig, (err, stats) => {
|
|
if (err) {
|
|
console.error(err.stack || err);
|
|
if (err.details) {
|
|
console.error(err.details);
|
|
}
|
|
return;
|
|
}
|
|
|
|
const info = stats.toJson();
|
|
|
|
if (stats.hasErrors()) {
|
|
console.error(info.errors);
|
|
}
|
|
|
|
if (stats.hasWarnings()) {
|
|
console.warn(info.warnings);
|
|
}
|
|
|
|
const buildInfo = stats.toString({
|
|
colors: true,
|
|
children: true,
|
|
chunks: false,
|
|
modules: false,
|
|
chunkModules: false,
|
|
hash: false,
|
|
version: false,
|
|
});
|
|
console.log(buildInfo);
|
|
done(0);
|
|
});
|
|
}
|
|
|
|
async function compileTs(modules = false, cb) {
|
|
const options = {
|
|
allowJs: true,
|
|
declaration: true,
|
|
emitDeclarationOnly: true,
|
|
};
|
|
|
|
const createdFiles = {};
|
|
const host = createCompilerHost(options);
|
|
host.writeFile = (fileName, contents) => {
|
|
createdFiles[path.isAbsolute(fileName) ? path.relative(cwd, fileName) : fileName] = contents;
|
|
};
|
|
|
|
const files = await fg(
|
|
[
|
|
'components/**/*.js',
|
|
'components/**/*.jsx',
|
|
'components/**/*.tsx',
|
|
'components/**/*.ts',
|
|
'!components/*/__tests__/*',
|
|
'!components/*/style/*',
|
|
'!components/styles.ts',
|
|
],
|
|
{ cwd },
|
|
);
|
|
|
|
const program = createProgram(files, options, host);
|
|
program.emit();
|
|
|
|
Object.keys(createdFiles).forEach(fileName => {
|
|
const contents = createdFiles[fileName];
|
|
const filePath = path.join(
|
|
cwd,
|
|
fileName.replace(/^components/, modules === false ? 'es' : 'lib'),
|
|
);
|
|
const dir = path.dirname(filePath);
|
|
if (!fs.existsSync(dir)) {
|
|
fs.mkdirSync(dir, { recursive: true });
|
|
}
|
|
fs.writeFileSync(filePath, contents);
|
|
});
|
|
cb(0);
|
|
}
|
|
|
|
gulp.task('tsc', () => compileTs());
|
|
|
|
function babelify(js, modules) {
|
|
const babelConfig = getBabelCommonConfig(modules);
|
|
babelConfig.babelrc = false;
|
|
delete babelConfig.cacheDirectory;
|
|
if (modules === false) {
|
|
babelConfig.plugins.push(replaceLib);
|
|
}
|
|
let stream = js.pipe(babel(babelConfig)).pipe(
|
|
through2.obj(function z(file, encoding, next) {
|
|
this.push(file.clone());
|
|
if (file.path.match(/\/style\/index\.(js|jsx|ts|tsx)$/)) {
|
|
const content = file.contents.toString(encoding);
|
|
file.contents = Buffer.from(
|
|
content
|
|
.replace(/\/style\/?'/g, "/style/css'")
|
|
.replace(/\/style\/?"/g, '/style/css"')
|
|
.replace(/\.less/g, '.css'),
|
|
);
|
|
file.path = file.path.replace(/index\.(js|jsx|ts|tsx)$/, 'css.js');
|
|
this.push(file);
|
|
} else if (modules !== false) {
|
|
const content = file.contents.toString(encoding);
|
|
file.contents = Buffer.from(
|
|
content
|
|
.replace(/lodash-es/g, 'lodash')
|
|
.replace(/@ant-design\/icons-vue/g, '@ant-design/icons-vue/lib/icons'),
|
|
);
|
|
this.push(file);
|
|
}
|
|
next();
|
|
}),
|
|
);
|
|
if (modules === false) {
|
|
stream = stream.pipe(
|
|
stripCode({
|
|
start_comment: '@remove-on-es-build-begin',
|
|
end_comment: '@remove-on-es-build-end',
|
|
}),
|
|
);
|
|
}
|
|
return stream.pipe(gulp.dest(modules === false ? esDir : libDir));
|
|
}
|
|
|
|
function compile(modules) {
|
|
rimraf.sync(modules !== false ? libDir : esDir);
|
|
const less = gulp
|
|
.src(['components/**/*.less'])
|
|
.pipe(
|
|
through2.obj(function (file, encoding, next) {
|
|
this.push(file.clone());
|
|
if (
|
|
file.path.match(/\/style\/index\.less$/) ||
|
|
file.path.match(/\/style\/v2-compatible-reset\.less$/)
|
|
) {
|
|
transformLess(file.path)
|
|
.then(css => {
|
|
file.contents = Buffer.from(css);
|
|
file.path = file.path.replace(/\.less$/, '.css');
|
|
this.push(file);
|
|
next();
|
|
})
|
|
.catch(e => {
|
|
console.error(e);
|
|
});
|
|
} else {
|
|
next();
|
|
}
|
|
}),
|
|
)
|
|
.pipe(gulp.dest(modules === false ? esDir : libDir));
|
|
const assets = gulp
|
|
.src(['components/**/*.@(png|svg)'])
|
|
.pipe(gulp.dest(modules === false ? esDir : libDir));
|
|
// let error = 0;
|
|
const source = [
|
|
'components/**/*.js',
|
|
'components/**/*.jsx',
|
|
'components/**/*.tsx',
|
|
'components/**/*.ts',
|
|
'typings/**/*.d.ts',
|
|
'!components/*/__tests__/*',
|
|
];
|
|
|
|
const jsFilesStream = babelify(gulp.src(source), modules);
|
|
return merge2([less, jsFilesStream, assets]);
|
|
}
|
|
|
|
function tag() {
|
|
console.log('tagging');
|
|
const { version } = packageJson;
|
|
execSync(`git config --global user.email ${process.env.GITHUB_USER_EMAIL}`);
|
|
execSync(`git config --global user.name ${process.env.GITHUB_USER_NAME}`);
|
|
execSync(`git tag ${version}`);
|
|
execSync(
|
|
`git push https://${process.env.GITHUB_TOKEN}@github.com/vueComponent/ant-design-vue.git ${version}:${version}`,
|
|
);
|
|
execSync(
|
|
`git push https://${process.env.GITHUB_TOKEN}@github.com/vueComponent/ant-design-vue.git master:master`,
|
|
);
|
|
console.log('tagged');
|
|
}
|
|
|
|
function githubRelease(done) {
|
|
const changlogFiles = [
|
|
path.join(cwd, 'CHANGELOG.en-US.md'),
|
|
path.join(cwd, 'CHANGELOG.zh-CN.md'),
|
|
];
|
|
console.log('creating release on GitHub');
|
|
if (!process.env.GITHUB_TOKEN) {
|
|
console.log('no GitHub token found, skip');
|
|
return;
|
|
}
|
|
if (!changlogFiles.every(file => fs.existsSync(file))) {
|
|
console.log('no changelog found, skip');
|
|
return;
|
|
}
|
|
const github = new Octokit({
|
|
auth: process.env.GITHUB_TOKEN,
|
|
});
|
|
const date = new Date();
|
|
const { version } = packageJson;
|
|
const enChangelog = getChangelog(changlogFiles[0], version);
|
|
const cnChangelog = getChangelog(changlogFiles[1], version);
|
|
const changelog = [
|
|
`\`${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}\``,
|
|
enChangelog,
|
|
'\n',
|
|
'---',
|
|
'\n',
|
|
cnChangelog,
|
|
].join('\n');
|
|
const [_, owner, repo] = execSync('git remote get-url origin') // eslint-disable-line
|
|
.toString()
|
|
.match(/github.com[:/](.+)\/(.+)\.git/);
|
|
github.repos
|
|
.createRelease({
|
|
owner,
|
|
repo,
|
|
tag_name: version,
|
|
name: version,
|
|
body: changelog,
|
|
})
|
|
.then(() => {
|
|
done();
|
|
})
|
|
.catch(err => {
|
|
console.log(err);
|
|
});
|
|
}
|
|
|
|
gulp.task(
|
|
'tag',
|
|
gulp.series(done => {
|
|
tag();
|
|
githubRelease(done);
|
|
}),
|
|
);
|
|
|
|
gulp.task(
|
|
'check-git',
|
|
gulp.series(done => {
|
|
runCmd('git', ['status', '--porcelain'], (code, result) => {
|
|
if (/^\?\?/m.test(result)) {
|
|
return done(`There are untracked files in the working tree.\n${result}
|
|
`);
|
|
}
|
|
if (/^([ADRM]| [ADRM])/m.test(result)) {
|
|
return done(`There are uncommitted changes in the working tree.\n${result}
|
|
`);
|
|
}
|
|
return done();
|
|
});
|
|
}),
|
|
);
|
|
|
|
function publish(tagString, done) {
|
|
let args = ['publish', '--with-antd-tools'];
|
|
if (tagString) {
|
|
args = args.concat(['--tag', tagString]);
|
|
}
|
|
const publishNpm = process.env.PUBLISH_NPM_CLI || 'npm';
|
|
runCmd(publishNpm, args, code => {
|
|
tag();
|
|
githubRelease(() => {
|
|
done(code);
|
|
});
|
|
});
|
|
}
|
|
|
|
function pub(done) {
|
|
const notOk = !packageJson.version.match(/^\d+\.\d+\.\d+$/);
|
|
let tagString;
|
|
if (argv['npm-tag']) {
|
|
tagString = argv['npm-tag'];
|
|
}
|
|
if (!tagString && notOk) {
|
|
tagString = 'next';
|
|
}
|
|
if (packageJson.scripts['pre-publish']) {
|
|
runCmd('npm', ['run', 'pre-publish'], code2 => {
|
|
if (code2) {
|
|
done(code2);
|
|
return;
|
|
}
|
|
publish(tagString, done);
|
|
});
|
|
} else {
|
|
publish(tagString, done);
|
|
}
|
|
}
|
|
|
|
let startTime = new Date();
|
|
gulp.task('compile-with-es', done => {
|
|
startTime = new Date();
|
|
console.log('start compile at ', startTime);
|
|
console.log('[Parallel] Compile to es...');
|
|
compile(false).on('finish', done);
|
|
});
|
|
|
|
gulp.task('compile-with-lib', done => {
|
|
console.log('[Parallel] Compile to js...');
|
|
compile().on('finish', done);
|
|
});
|
|
|
|
gulp.task('compile-with-es-ts-type', async done => {
|
|
console.log('[Parallel] Compile to es ts type...');
|
|
await compileTs(false, done);
|
|
});
|
|
|
|
gulp.task('compile-with-lib-ts-type', async done => {
|
|
console.log('[Parallel] Compile to lib ts type...');
|
|
await compileTs(true, done);
|
|
});
|
|
|
|
gulp.task(
|
|
'compile',
|
|
gulp.series(
|
|
gulp.parallel(
|
|
'compile-with-es',
|
|
'compile-with-lib',
|
|
'compile-with-es-ts-type',
|
|
'compile-with-lib-ts-type',
|
|
),
|
|
done => {
|
|
console.log('end compile at ', new Date());
|
|
console.log('compile time ', (new Date() - startTime) / 1000, 's');
|
|
done();
|
|
},
|
|
),
|
|
);
|
|
|
|
gulp.task(
|
|
'dist',
|
|
gulp.series(done => {
|
|
dist(done);
|
|
}),
|
|
);
|
|
|
|
gulp.task(
|
|
'pub',
|
|
gulp.series('check-git', 'compile', 'dist', done => {
|
|
// if (!process.env.GITHUB_TOKEN) {
|
|
// console.log('no GitHub token found, skip');
|
|
// } else {
|
|
// pub(done);
|
|
// }
|
|
pub(done);
|
|
}),
|
|
);
|
|
|
|
gulp.task(
|
|
'pub-with-ci',
|
|
gulp.series(done => {
|
|
if (!process.env.NPM_TOKEN) {
|
|
console.log('no NPM token found, skip');
|
|
} else {
|
|
const github = new Octokit({
|
|
auth: process.env.GITHUB_TOKEN,
|
|
});
|
|
const [_, owner, repo] = execSync('git remote get-url origin') // eslint-disable-line
|
|
.toString()
|
|
.match(/github.com[:/](.+)\/(.+)\.git/);
|
|
const getLatestRelease = github.repos.getLatestRelease({
|
|
owner,
|
|
repo,
|
|
});
|
|
const listCommits = github.repos.listCommits({
|
|
owner,
|
|
repo,
|
|
per_page: 1,
|
|
});
|
|
Promise.all([getLatestRelease, listCommits]).then(([latestRelease, commits]) => {
|
|
const preVersion = latestRelease.data.tag_name;
|
|
const { version } = packageJson;
|
|
const [_, newVersion] = commits.data[0].commit.message.trim().match(/bump (.+)/) || []; // eslint-disable-line
|
|
if (
|
|
compareVersions(version, preVersion) === 1 &&
|
|
newVersion &&
|
|
newVersion.trim() === version
|
|
) {
|
|
// eslint-disable-next-line no-unused-vars
|
|
runCmd('npm', ['run', 'pub'], code => {
|
|
done();
|
|
});
|
|
} else {
|
|
console.log('donot need publish' + version);
|
|
}
|
|
});
|
|
}
|
|
}),
|
|
);
|
|
|
|
gulp.task(
|
|
'guard',
|
|
gulp.series(done => {
|
|
function reportError() {
|
|
console.log(chalk.bgRed('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'));
|
|
console.log(chalk.bgRed('!! `npm publish` is forbidden for this package. !!'));
|
|
console.log(chalk.bgRed('!! Use `npm run pub` instead. !!'));
|
|
console.log(chalk.bgRed('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'));
|
|
}
|
|
const npmArgs = getNpmArgs();
|
|
if (npmArgs) {
|
|
for (let arg = npmArgs.shift(); arg; arg = npmArgs.shift()) {
|
|
if (/^pu(b(l(i(sh?)?)?)?)?$/.test(arg) && npmArgs.indexOf('--with-antd-tools') < 0) {
|
|
reportError();
|
|
done(1);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
done();
|
|
}),
|
|
);
|