From 997693ddabd3e4c07bb84cfc6bf523dc06723a4c Mon Sep 17 00:00:00 2001 From: Chuns Chen Date: Tue, 22 Nov 2022 09:53:07 +0800 Subject: [PATCH 1/4] chore: revert compile with lib --- .antd-tools.config.js | 18 ++++++++---------- .github/workflows/test.yml | 8 +++++++- package.json | 7 ++++--- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.antd-tools.config.js b/.antd-tools.config.js index 5c139e9d30fc..deb1c0406387 100644 --- a/.antd-tools.config.js +++ b/.antd-tools.config.js @@ -1,23 +1,21 @@ const fs = require('fs'); const path = require('path'); +const restCssPath = path.join(process.cwd(), 'components', 'style', 'reset.css'); + function finalizeCompile() { if (fs.existsSync(path.join(__dirname, './es'))) { - // Build less entry file: dist/antd.less - fs.copyFileSync( - path.join(process.cwd(), 'components', 'style', 'reset.css'), - path.join(process.cwd(), 'es', 'style', 'reset.css'), - ); + fs.copyFileSync(restCssPath, path.join(process.cwd(), 'es', 'style', 'reset.css')); + } + + if (fs.existsSync(path.join(__dirname, './lib'))) { + fs.copyFileSync(restCssPath, path.join(process.cwd(), 'lib', 'style', 'reset.css')); } } function finalizeDist() { if (fs.existsSync(path.join(__dirname, './dist'))) { - // Build less entry file: dist/antd.less - fs.copyFileSync( - path.join(process.cwd(), 'components', 'style', 'reset.css'), - path.join(process.cwd(), 'dist', 'reset.css'), - ); + fs.copyFileSync(restCssPath, path.join(process.cwd(), 'dist', 'reset.css')); } } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d52252668991..1f5643bc7722 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -250,6 +250,12 @@ jobs: path: node_modules key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} + - name: cache lib + uses: actions/cache@v3 + with: + path: lib + key: lib-${{ github.sha }} + - name: cache es uses: actions/cache@v3 with: @@ -266,7 +272,7 @@ jobs: strategy: matrix: react: ['16', '17', '18'] - module: [es] + module: [lib, es] shard: ['1/2', '2/2'] env: REACT: ${{ matrix.react }} diff --git a/package.json b/package.json index 3310ddec3f27..df0052b94cb1 100644 --- a/package.json +++ b/package.json @@ -33,12 +33,13 @@ "files": [ "dist", "es", + "lib", "locale" ], "sideEffects": [ "*.less" ], - "main": "dist/antd.js", + "main": "lib/index.js", "module": "es/index.js", "unpkg": "dist/antd.min.js", "typings": "es/index.d.ts", @@ -59,7 +60,7 @@ "pretest": "npm run version", "predist": "npm run version", "presite": "npm run version && npm run collect-token-statistic", - "compile": "npm run clean && antd-tools run compile-experimental", + "compile": "npm run clean && antd-tools run compile", "changelog": "node ./scripts/print-changelog", "predeploy": "antd-tools run clean && npm run site && cp CNAME _site && npm run site:test", "deploy": "gh-pages -d _site -b gh-pages -f", @@ -77,7 +78,7 @@ "lint:script": "eslint . --ext .js,.jsx,.ts,.tsx", "pre-publish": "npm run test-all -- --skip-build", "prettier": "prettier -c --write **/*", - "pub": "npm run version && npm run collect-token-statistic && antd-tools run pub-experimental", + "pub": "npm run version && npm run collect-token-statistic && antd-tools run pub", "rome:format": "rome format --write .", "prepublishOnly": "antd-tools run guard", "postpublish": "node ./scripts/post-script.js", From 713476000928e71ab990217f5d12a1dffbc9abd3 Mon Sep 17 00:00:00 2001 From: Chuns Chen Date: Tue, 22 Nov 2022 10:47:30 +0800 Subject: [PATCH 2/4] chore: lib dekko test --- .github/workflows/test.yml | 3 ++ tests/dekko/ lib.test.js | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tests/dekko/ lib.test.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f5643bc7722..53d87f61fd48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -264,6 +264,9 @@ jobs: - name: compile run: npm run compile + + - name: check + run: node ./tests/dekko/lib.test.js needs: setup compiled-module-test: diff --git a/tests/dekko/ lib.test.js b/tests/dekko/ lib.test.js new file mode 100644 index 000000000000..73c626f124f4 --- /dev/null +++ b/tests/dekko/ lib.test.js @@ -0,0 +1,60 @@ +const $ = require('dekko'); +const chalk = require('chalk'); +const path = require('path'); + +function getFileName(filePath) { + return filePath.slice(filePath.lastIndexOf(path.sep) + 1); +} + +$('lib').isDirectory().hasFile('index.js').hasFile('index.d.ts'); + +$('lib/*') + .filter( + (filename) => + !filename.endsWith('index.js') && + !filename.endsWith('index.d.ts') && + !filename.endsWith('.map'), + ) + .isDirectory() + .filter( + (filename) => + !filename.endsWith('style') && !filename.endsWith('_util') && !filename.endsWith('locale'), + ) + .hasFile('index.js') + .hasFile('index.d.ts'); + +// locale + +const filterLocaleFile = (filePath) => { + const fileName = getFileName(filePath); + return ( + !fileName.endsWith('index.js') && + !fileName.endsWith('.d.ts') && + !fileName.endsWith('.map') && + !fileName.endsWith('style') && + !fileName.includes('-') && + !fileName.endsWith('LocaleReceiver.js') && + !fileName.endsWith('context.js') + ); +}; +const localeFiles = $('lib/locale/*').filter(filterLocaleFile); +const localeProviderFiles = $('lib/locale-provider/*').filter(filterLocaleFile); + +function compare(originFiles, targetFiles, targetPath) { + originFiles.assert( + `not exist in '${targetPath}'. Please use 'scripts/generateLegacyLocale.js' to refresh locale files.`, + (filePath) => { + const fileName = getFileName(filePath); + + return targetFiles.filenames.some( + (targetFilePath) => getFileName(targetFilePath) === fileName, + ); + }, + ); +} + +compare(localeFiles, localeProviderFiles, '/locale-provider'); +compare(localeProviderFiles, localeFiles, '/locale'); + +// eslint-disable-next-line no-console +console.log(chalk.green('✨ `lib` directory is valid.')); From 7f7f91d2b41cbc75f34aada310bfef9f600830db Mon Sep 17 00:00:00 2001 From: Chuns Chen Date: Tue, 22 Nov 2022 11:22:26 +0800 Subject: [PATCH 3/4] fix: filename has spaces --- tests/dekko/{ lib.test.js => lib.test.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/dekko/{ lib.test.js => lib.test.js} (100%) diff --git a/tests/dekko/ lib.test.js b/tests/dekko/lib.test.js similarity index 100% rename from tests/dekko/ lib.test.js rename to tests/dekko/lib.test.js From 7b2e916cc84190842d8044caa13abe352d327b80 Mon Sep 17 00:00:00 2001 From: Chuns Chen Date: Tue, 22 Nov 2022 11:41:34 +0800 Subject: [PATCH 4/4] chore: bump @ant-design/tools --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df0052b94cb1..b57abb003d62 100644 --- a/package.json +++ b/package.json @@ -158,7 +158,7 @@ "devDependencies": { "@ant-design/bisheng-plugin": "^3.3.0-alpha.4", "@ant-design/hitu": "^0.0.0-alpha.13", - "@ant-design/tools": "^16.0.0-alpha.3", + "@ant-design/tools": "^16.1.0-alpha.2", "@docsearch/css": "^3.0.0", "@emotion/babel-preset-css-prop": "^11.10.0", "@emotion/css": "^11.10.5",