From ff52bbcc865cb9b0ea61931c92cc110151007e8a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Dec 2024 18:27:18 +0800 Subject: [PATCH] chore(deps): update dependency chalk to v5 (#52109) * chore(deps): update dependency chalk to v5 * migrate chalk * Update .github/workflows/test.yml Signed-off-by: afc163 --------- Signed-off-by: afc163 Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: afc163 --- .dumi/theme/plugin.ts | 4 ++-- .github/workflows/test.yml | 2 +- package.json | 4 ++-- scripts/test-all.sh | 4 ++-- tests/dekko/{dist.test.js => dist.test.ts} | 4 ++-- tests/dekko/index.test.js | 3 --- tests/dekko/index.test.ts | 3 +++ tests/dekko/lib-es.test.js | 24 ------------------- tests/dekko/lib-es.test.ts | 28 ++++++++++++++++++++++ tests/dekko/use-client.test.js | 28 ---------------------- tests/dekko/use-client.test.ts | 28 ++++++++++++++++++++++ typings/custom-typings.d.ts | 2 ++ 12 files changed, 70 insertions(+), 64 deletions(-) rename tests/dekko/{dist.test.js => dist.test.ts} (86%) delete mode 100644 tests/dekko/index.test.js create mode 100644 tests/dekko/index.test.ts delete mode 100644 tests/dekko/lib-es.test.js create mode 100644 tests/dekko/lib-es.test.ts delete mode 100644 tests/dekko/use-client.test.js create mode 100644 tests/dekko/use-client.test.ts diff --git a/.dumi/theme/plugin.ts b/.dumi/theme/plugin.ts index 78b2de1f78..b668f48c1d 100644 --- a/.dumi/theme/plugin.ts +++ b/.dumi/theme/plugin.ts @@ -2,7 +2,6 @@ import { createHash } from 'crypto'; import fs from 'fs'; import path from 'path'; import createEmotionServer from '@emotion/server/create-instance'; -import chalk from 'chalk'; import type { IApi, IRoute } from 'dumi'; import ReactTechStack from 'dumi/dist/techStacks/react'; import sylvanas from 'sylvanas'; @@ -126,7 +125,8 @@ class AntdReactTechStack extends ReactTechStack { const resolve = (p: string): string => require.resolve(p); -const RoutesPlugin = (api: IApi) => { +const RoutesPlugin = async (api: IApi) => { + const chalk = await import('chalk').then((m) => m.default); // const ssrCssFileName = `ssr-${Date.now()}.css`; const writeCSSFile = (key: string, hashKey: string, cssString: string) => { diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 411387d53a..662d7d09da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -175,7 +175,7 @@ jobs: CI: 1 - name: check build files - run: node ./tests/dekko/index.test.js + run: bun run test:dekko # Artifact build files - uses: actions/upload-artifact@v4 diff --git a/package.json b/package.json index e4dbf112df..33d33a27ce 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "pretest": "npm run version", "test": "jest --config .jest.js --no-cache", "test:all": "sh -e ./scripts/test-all.sh", - "test:dekko": "node ./tests/dekko/index.test.js", + "test:dekko": "tsx ./tests/dekko/index.test.ts", "test:image": "jest --config .jest.image.js --no-cache -i -u --forceExit", "test:node": "npm run version && jest --config .jest.node.js --no-cache", "test:package-diff": "antd-tools run package-diff", @@ -222,7 +222,7 @@ "antd-style": "^3.7.0", "antd-token-previewer": "^2.0.8", "axios": "^1.7.7", - "chalk": "^4.1.2", + "chalk": "^5.0.0", "cheerio": "^1.0.0", "circular-dependency-plugin": "^5.2.2", "cli-progress": "^3.12.0", diff --git a/scripts/test-all.sh b/scripts/test-all.sh index 6abba21700..c0ba9b5f35 100755 --- a/scripts/test-all.sh +++ b/scripts/test-all.sh @@ -58,11 +58,11 @@ fi if ! has_arg '--skip-dekko' "$@"; then echo "[TEST ALL] dekko dist" echo "[TEST ALL] dekko dist" > ~test-all.txt - node ./tests/dekko/dist.test.js + tsx ./tests/dekko/dist.test.ts echo "[TEST ALL] dekko lib and es" echo "[TEST ALL] dekko lib and es" > ~test-all.txt - node ./tests/dekko/lib-es.test.js + tsx ./tests/dekko/lib-es.test.ts else echo "[TEST ALL] dekko test...skip" fi diff --git a/tests/dekko/dist.test.js b/tests/dekko/dist.test.ts similarity index 86% rename from tests/dekko/dist.test.js rename to tests/dekko/dist.test.ts index 326646c53e..4cf7e4145a 100644 --- a/tests/dekko/dist.test.js +++ b/tests/dekko/dist.test.ts @@ -1,5 +1,5 @@ -const $ = require('dekko'); -const chalk = require('chalk'); +import $ from 'dekko'; +import chalk from 'chalk'; $('dist') .isDirectory() diff --git a/tests/dekko/index.test.js b/tests/dekko/index.test.js deleted file mode 100644 index 8160b09099..0000000000 --- a/tests/dekko/index.test.js +++ /dev/null @@ -1,3 +0,0 @@ -require('./dist.test'); -require('./lib-es.test'); -require('./use-client.test'); diff --git a/tests/dekko/index.test.ts b/tests/dekko/index.test.ts new file mode 100644 index 0000000000..bbae682c34 --- /dev/null +++ b/tests/dekko/index.test.ts @@ -0,0 +1,3 @@ +import './dist.test'; +import './lib-es.test'; +import './use-client.test'; diff --git a/tests/dekko/lib-es.test.js b/tests/dekko/lib-es.test.js deleted file mode 100644 index 0a1fad2c3d..0000000000 --- a/tests/dekko/lib-es.test.js +++ /dev/null @@ -1,24 +0,0 @@ -const $ = require('dekko'); -const chalk = require('chalk'); - -$('lib').isDirectory().hasFile('index.js').hasFile('index.d.ts'); - -$('lib/*') - .filter((filename) => !['index.js', 'index.d.ts', '.map'].some((ext) => filename.endsWith(ext))) - .isDirectory() - .filter((filename) => !['style', '_util', 'locale'].some((ext) => filename.endsWith(ext))) - .hasFile('index.js') - .hasFile('index.d.ts'); - -console.log(chalk.green('✨ `lib` directory is valid.')); - -$('es').isDirectory().hasFile('index.js').hasFile('index.d.ts'); - -$('es/*') - .filter((filename) => !['index.js', 'index.d.ts', '.map'].some((ext) => filename.endsWith(ext))) - .isDirectory() - .filter((filename) => !['style', '_util', 'locale'].some((ext) => filename.endsWith(ext))) - .hasFile('index.js') - .hasFile('index.d.ts'); - -console.log(chalk.green('✨ `es` directory is valid.')); diff --git a/tests/dekko/lib-es.test.ts b/tests/dekko/lib-es.test.ts new file mode 100644 index 0000000000..61e55ea5d6 --- /dev/null +++ b/tests/dekko/lib-es.test.ts @@ -0,0 +1,28 @@ +import $ from 'dekko'; +import chalk from 'chalk'; + +$('lib').isDirectory().hasFile('index.js').hasFile('index.d.ts'); + +$('lib/*') + .filter( + (filename: string) => !['index.js', 'index.d.ts', '.map'].some((ext) => filename.endsWith(ext)), + ) + .isDirectory() + .filter((filename: string) => !['style', '_util', 'locale'].some((ext) => filename.endsWith(ext))) + .hasFile('index.js') + .hasFile('index.d.ts'); + +console.log(chalk.green('✨ `lib` directory is valid.')); + +$('es').isDirectory().hasFile('index.js').hasFile('index.d.ts'); + +$('es/*') + .filter( + (filename: string) => !['index.js', 'index.d.ts', '.map'].some((ext) => filename.endsWith(ext)), + ) + .isDirectory() + .filter((filename: string) => !['style', '_util', 'locale'].some((ext) => filename.endsWith(ext))) + .hasFile('index.js') + .hasFile('index.d.ts'); + +console.log(chalk.green('✨ `es` directory is valid.')); diff --git a/tests/dekko/use-client.test.js b/tests/dekko/use-client.test.js deleted file mode 100644 index 243318d396..0000000000 --- a/tests/dekko/use-client.test.js +++ /dev/null @@ -1,28 +0,0 @@ -const $ = require('dekko'); -const chalk = require('chalk'); -const fs = require('fs'); - -const includeUseClient = (filename) => - fs.readFileSync(filename).toString().includes('"use client"'); - -$('dist/*') - .isFile() - .assert("doesn't contain use client", (filename) => !includeUseClient(filename)); -$('{es,lib}/index.js') - .isFile() - .assert('contain use client', (filename) => includeUseClient(filename)); -$('{es,lib}/*/index.js') - .isFile() - .assert('contain use client', (filename) => includeUseClient(filename)); - -// check tsx files -$('{es,lib}/typography/*.js') - .isFile() - .assert('contain use client', (filename) => includeUseClient(filename)); - -$('{es,lib}/typography/Base/*.js') - .isFile() - .filter((filename) => !filename.endsWith('/util.js')) - .assert('contain use client', (filename) => includeUseClient(filename)); - -console.log(chalk.green('✨ use client passed!')); diff --git a/tests/dekko/use-client.test.ts b/tests/dekko/use-client.test.ts new file mode 100644 index 0000000000..0bf680f043 --- /dev/null +++ b/tests/dekko/use-client.test.ts @@ -0,0 +1,28 @@ +import $ from 'dekko'; +import chalk from 'chalk'; +import fs from 'node:fs'; + +const includeUseClient = (filename: string) => + fs.readFileSync(filename).toString().includes('"use client"'); + +$('dist/*') + .isFile() + .assert("doesn't contain use client", (filename: string) => !includeUseClient(filename)); +$('{es,lib}/index.js') + .isFile() + .assert('contain use client', (filename: string) => includeUseClient(filename)); +$('{es,lib}/*/index.js') + .isFile() + .assert('contain use client', (filename: string) => includeUseClient(filename)); + +// check tsx files +$('{es,lib}/typography/*.js') + .isFile() + .assert('contain use client', (filename: string) => includeUseClient(filename)); + +$('{es,lib}/typography/Base/*.js') + .isFile() + .filter((filename: string) => !filename.endsWith('/util.js')) + .assert('contain use client', (filename: string) => includeUseClient(filename)); + +console.log(chalk.green('✨ use client passed!')); diff --git a/typings/custom-typings.d.ts b/typings/custom-typings.d.ts index 2a12b0bd35..758a40db17 100644 --- a/typings/custom-typings.d.ts +++ b/typings/custom-typings.d.ts @@ -27,3 +27,5 @@ declare module '@npmcli/run-script' { } declare module '@microflash/rehype-figure'; + +declare module 'dekko';