From d9cf87af94eb85c96ec297045a3a3516d7ae067a Mon Sep 17 00:00:00 2001 From: "DESKTOP-31IBRMI\\Administrator" <1509326266@qq.com> Date: Mon, 2 Sep 2024 11:20:03 +0800 Subject: [PATCH] chore(other): print project information in console --- build/plugins/index.ts | 4 ++- build/plugins/info.ts | 23 +++++++++++++++ package.json | 5 +++- pnpm-lock.yaml | 66 +++++++++++++++++++++++++++++++++++++++++- 4 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 build/plugins/info.ts diff --git a/build/plugins/index.ts b/build/plugins/index.ts index 4ea12c0..5f63fe9 100644 --- a/build/plugins/index.ts +++ b/build/plugins/index.ts @@ -7,6 +7,7 @@ import { setupUnocss } from './unocss'; import { setupUnPluginIcon } from './unplugin-icon'; import { setupElegantRouter } from './router'; import { setupHtmlPlugin } from './html'; +import { setupProjectInfo } from './info'; export function setupVitePlugins(viteEnv: Env.ImportMeta, buildTime: string) { const plugins: PluginOption = [ @@ -17,7 +18,8 @@ export function setupVitePlugins(viteEnv: Env.ImportMeta, buildTime: string) { setupElegantRouter(), Inspect(), removeConsole(), - setupHtmlPlugin(buildTime) + setupHtmlPlugin(buildTime), + setupProjectInfo() ]; return plugins; } diff --git a/build/plugins/info.ts b/build/plugins/info.ts new file mode 100644 index 0000000..5b71f64 --- /dev/null +++ b/build/plugins/info.ts @@ -0,0 +1,23 @@ +import type { Plugin } from 'vite'; +import gradientString from 'gradient-string'; +import boxen, { type Options as BoxenOptions } from 'boxen'; + +const welcomeMessage = gradientString('#646cff', 'magenta').multiline( + `您好! 欢迎使用 react-soybean 开源项目\n我们为您精心准备了精美的保姆级文档\nhttps://react-soybean-docs.pages.dev/index-cn?theme=dark` +); + +const boxenOptions: BoxenOptions = { + padding: 0.5, + borderColor: '#646cff', + borderStyle: 'round' +}; + +export function setupProjectInfo(): Plugin { + return { + name: 'vite:buildInfo', + + buildStart() { + console.log(boxen(welcomeMessage, boxenOptions)); + } + }; +} diff --git a/package.json b/package.json index 72931b2..7b28b5c 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "@soybeanjs/eslint-config": "1.4.0", "@svgr/core": "8.1.0", "@svgr/plugin-jsx": "8.1.0", + "@types/gradient-string": "1.1.6", "@types/node": "22.5.0", "@types/nprogress": "0.2.3", "@types/react": "18.3.4", @@ -101,11 +102,13 @@ "@unocss/transformer-variant-group": "0.62.3", "@unocss/vite": "0.62.3", "@vitejs/plugin-react": "4.3.1", + "boxen": "8.0.1", "eslint": "9.9.1", "eslint-plugin-react": "7.35.0", "eslint-plugin-react-hooks": "4.6.2", "eslint-plugin-react-refresh": "0.4.11", - "json5": "^2.2.3", + "gradient-string": "2.0.2", + "json5": "2.2.3", "lint-staged": "15.2.9", "sass": "1.77.8", "simple-git-hooks": "2.11.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5449fde..a285e4a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -87,7 +87,7 @@ importers: specifier: 4.4.5 version: 4.4.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1) typeit: - specifier: ^8.8.4 + specifier: 8.8.4 version: 8.8.4 devDependencies: '@iconify/json': @@ -114,6 +114,9 @@ importers: '@svgr/plugin-jsx': specifier: 8.1.0 version: 8.1.0(@svgr/core@8.1.0(typescript@5.5.4)) + '@types/gradient-string': + specifier: ^1.1.6 + version: 1.1.6 '@types/node': specifier: 22.5.0 version: 22.5.0 @@ -156,6 +159,9 @@ importers: '@vitejs/plugin-react': specifier: 4.3.1 version: 4.3.1(vite@5.4.2(@types/node@22.5.0)(sass@1.77.8)) + boxen: + specifier: ^8.0.1 + version: 8.0.1 eslint: specifier: 9.9.1 version: 9.9.1(jiti@1.21.6) @@ -168,6 +174,9 @@ importers: eslint-plugin-react-refresh: specifier: 0.4.11 version: 0.4.11(eslint@9.9.1(jiti@1.21.6)) + gradient-string: + specifier: ^2.0.2 + version: 2.0.2 json5: specifier: ^2.2.3 version: 2.2.3 @@ -1193,6 +1202,9 @@ packages: '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} + '@types/gradient-string@1.1.6': + resolution: {integrity: sha512-LkaYxluY4G5wR1M4AKQUal2q61Di1yVVCw42ImFTuaIoQVgmV0WP1xUaLB8zwb47mp82vWTpePI9JmrjEnJ7nQ==} + '@types/hoist-non-react-statics@3.3.5': resolution: {integrity: sha512-SbcrWzkKBw2cdwRTwQAswfpB9g9LJWfjtUeW/jvNwbhC8cpmmNYVePa+ncbUe0rGTQ7G3Ff6mYUN2VMfLVr+Sg==} @@ -1450,6 +1462,9 @@ packages: ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} + ansi-align@3.0.1: + resolution: {integrity: sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==} + ansi-colors@4.1.3: resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} engines: {node: '>=6'} @@ -1601,6 +1616,10 @@ packages: boolbase@1.0.0: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} + boxen@8.0.1: + resolution: {integrity: sha512-F3PH5k5juxom4xktynS7MoFY+NUWH5LC4CnH11YB8NPew+HLpmBLCybSAEyb2F+4pRXhuhWqFesoQd6DAyc2hw==} + engines: {node: '>=18'} + brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} @@ -1670,6 +1689,10 @@ packages: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} + camelcase@8.0.0: + resolution: {integrity: sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==} + engines: {node: '>=16'} + caniuse-lite@1.0.30001653: resolution: {integrity: sha512-XGWQVB8wFQ2+9NZwZ10GxTYC5hk0Fa+q8cSkr0tgvMhYhMHP/QC+WTgrePMDBWiWc/pV+1ik82Al20XOK25Gcw==} @@ -1718,6 +1741,10 @@ packages: resolution: {integrity: sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==} engines: {node: '>=4'} + cli-boxes@3.0.0: + resolution: {integrity: sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==} + engines: {node: '>=10'} + cli-cursor@5.0.0: resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==} engines: {node: '>=18'} @@ -4412,6 +4439,10 @@ packages: resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==} engines: {node: '>=8'} + type-fest@4.26.0: + resolution: {integrity: sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==} + engines: {node: '>=16'} + typed-array-buffer@1.0.2: resolution: {integrity: sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==} engines: {node: '>= 0.4'} @@ -4632,6 +4663,10 @@ packages: engines: {node: '>= 8'} hasBin: true + widest-line@5.0.0: + resolution: {integrity: sha512-c9bZp7b5YtRj2wOe6dlj32MK+Bx/M/d+9VB2SHM1OtsUHR0aV0tdP6DWh/iMt0kWi1t5g1Iudu6hQRNd1A4PVA==} + engines: {node: '>=18'} + word-wrap@1.2.5: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} @@ -5465,6 +5500,10 @@ snapshots: '@types/estree@1.0.5': {} + '@types/gradient-string@1.1.6': + dependencies: + '@types/tinycolor2': 1.4.6 + '@types/hoist-non-react-statics@3.3.5': dependencies: '@types/react': 18.3.4 @@ -5836,6 +5875,10 @@ snapshots: json-schema-traverse: 0.4.1 uri-js: 4.4.1 + ansi-align@3.0.1: + dependencies: + string-width: 4.2.3 + ansi-colors@4.1.3: {} ansi-escapes@7.0.0: @@ -6042,6 +6085,17 @@ snapshots: boolbase@1.0.0: {} + boxen@8.0.1: + dependencies: + ansi-align: 3.0.1 + camelcase: 8.0.0 + chalk: 5.3.0 + cli-boxes: 3.0.0 + string-width: 7.2.0 + type-fest: 4.26.0 + widest-line: 5.0.0 + wrap-ansi: 9.0.0 + brace-expansion@1.1.11: dependencies: balanced-match: 1.0.2 @@ -6147,6 +6201,8 @@ snapshots: camelcase@6.3.0: {} + camelcase@8.0.0: {} + caniuse-lite@1.0.30001653: {} chalk@1.1.3: @@ -6205,6 +6261,8 @@ snapshots: dependencies: escape-string-regexp: 1.0.5 + cli-boxes@3.0.0: {} + cli-cursor@5.0.0: dependencies: restore-cursor: 5.1.0 @@ -9276,6 +9334,8 @@ snapshots: type-fest@0.8.1: {} + type-fest@4.26.0: {} + typed-array-buffer@1.0.2: dependencies: call-bind: 1.0.7 @@ -9556,6 +9616,10 @@ snapshots: dependencies: isexe: 2.0.0 + widest-line@5.0.0: + dependencies: + string-width: 7.2.0 + word-wrap@1.2.5: {} wrap-ansi@7.0.0: