Browse Source

chore: revert compile with lib (#38832)

* chore: revert compile with lib

* chore: lib dekko test

* fix: filename has spaces

* chore: bump @ant-design/tools
pull/38854/head
Chuns Chen 2 years ago
committed by GitHub
parent
commit
b22ab1a83c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      .antd-tools.config.js
  2. 11
      .github/workflows/test.yml
  3. 9
      package.json
  4. 60
      tests/dekko/lib.test.js

18
.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'));
}
}

11
.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:
@ -258,6 +264,9 @@ jobs:
- name: compile
run: npm run compile
- name: check
run: node ./tests/dekko/lib.test.js
needs: setup
compiled-module-test:
@ -266,7 +275,7 @@ jobs:
strategy:
matrix:
react: ['16', '17', '18']
module: [es]
module: [lib, es]
shard: ['1/2', '2/2']
env:
REACT: ${{ matrix.react }}

9
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",
@ -157,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",

60
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.'));
Loading…
Cancel
Save