diff --git a/.npmrc b/.npmrc index 2f82be8e..d32bad1b 100644 --- a/.npmrc +++ b/.npmrc @@ -1,4 +1,4 @@ -# registry = "https://registry.npmmirror.com" +registry = "https://registry.npmmirror.com" public-hoist-pattern[]=husky public-hoist-pattern[]=eslint public-hoist-pattern[]=prettier diff --git a/apps/web-antd/src/preferences.ts b/apps/web-antd/src/preferences.ts index 9683596a..63edb3a9 100644 --- a/apps/web-antd/src/preferences.ts +++ b/apps/web-antd/src/preferences.ts @@ -6,4 +6,7 @@ import { defineOverridesPreferences } from '@vben/preferences'; */ export const overridesPreferences = defineOverridesPreferences({ // overrides + app: { + name: import.meta.env.VITE_APP_TITLE, + }, }); diff --git a/apps/web-naive/src/preferences.ts b/apps/web-naive/src/preferences.ts index 9683596a..63edb3a9 100644 --- a/apps/web-naive/src/preferences.ts +++ b/apps/web-naive/src/preferences.ts @@ -6,4 +6,7 @@ import { defineOverridesPreferences } from '@vben/preferences'; */ export const overridesPreferences = defineOverridesPreferences({ // overrides + app: { + name: import.meta.env.VITE_APP_TITLE, + }, }); diff --git a/package.json b/package.json index d31aeb40..29c82f58 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "check:type": "turbo run typecheck", "clean": "vsh clean", "commit": "czg", - "dev": "cross-env turbo run dev", + "dev": "turbo-run dev", "dev:antd": "pnpm -F @vben/web-antd", "dev:naive": "pnpm -F @vben/web-naive", "dev:docs": "pnpm -F @vben/website run docs:dev", @@ -49,6 +49,7 @@ "publint": "vsh publint", "reinstall": "pnpm clean --del-lock && pnpm bootstrap", "test:unit": "vitest", + "turbo-run": "turbo-run", "update:deps": " pnpm update --latest --recursive", "version": "pnpm exec changeset version && pnpm install --no-frozen-lockfile" }, @@ -65,6 +66,7 @@ "@vben/stylelint-config": "workspace:*", "@vben/tailwind-config": "workspace:*", "@vben/tsconfig": "workspace:*", + "@vben/turbo-run": "workspace:*", "@vben/vite-config": "workspace:*", "@vben/vsh": "workspace:*", "@vue/test-utils": "^2.4.6", diff --git a/packages/@core/preferences/src/config.ts b/packages/@core/preferences/src/config.ts index 427d7b93..248d7cc4 100644 --- a/packages/@core/preferences/src/config.ts +++ b/packages/@core/preferences/src/config.ts @@ -18,7 +18,7 @@ const defaultPreferences: Preferences = { layout: 'sidebar-nav', locale: 'zh-CN', loginExpiredMode: 'modal', - name: 'Vben Admin Naive', + name: 'Vben Admin', watermark: false, }, breadcrumb: { diff --git a/packages/@core/preferences/src/constants.ts b/packages/@core/preferences/src/constants.ts index 354a5896..94cfbf81 100644 --- a/packages/@core/preferences/src/constants.ts +++ b/packages/@core/preferences/src/constants.ts @@ -8,10 +8,10 @@ interface BuiltinThemePreset { } const BUILT_IN_THEME_PRESETS: BuiltinThemePreset[] = [ - // { - // color: 'hsl(231 98% 65%)', - // type: 'default', - // }, + { + color: 'hsl(231 98% 65%)', + type: 'default', + }, { color: 'hsl(245 82% 67%)', type: 'violet', diff --git a/packages/@core/preferences/src/update-css-variables.ts b/packages/@core/preferences/src/update-css-variables.ts index 790264fd..1a2289bc 100644 --- a/packages/@core/preferences/src/update-css-variables.ts +++ b/packages/@core/preferences/src/update-css-variables.ts @@ -5,7 +5,7 @@ import { generatorColorVariables, } from '@vben-core/shared'; -import { BUILT_IN_THEME_PRESETS, type BuiltinThemePreset } from './constants'; +import { BUILT_IN_THEME_PRESETS } from './constants'; /** * 更新主题的 CSS 变量以及其他 CSS 变量 @@ -37,13 +37,9 @@ function updateCSSVariables(preferences: Preferences) { } // 获取当前的内置主题 - const currentBuiltType = [ - { - color: preferences.theme.colorPrimary, - type: 'default', - } as BuiltinThemePreset, - ...BUILT_IN_THEME_PRESETS, - ].find((item) => item.type === builtinType); + const currentBuiltType = [...BUILT_IN_THEME_PRESETS].find( + (item) => item.type === builtinType, + ); let builtinTypeColorPrimary: string | undefined = ''; diff --git a/packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue b/packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue index 7181672a..3c94ca68 100644 --- a/packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue +++ b/packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue @@ -27,10 +27,6 @@ const inputValue = computed(() => { const builtinThemePresets = computed(() => { return [ - { - color: 'hsl(231 98% 65%)', - type: 'default', - }, // { // color: 'hsl(231 98% 65%)', // type: 'default', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf31af0f..474b2171 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,6 +49,9 @@ importers: '@vben/tsconfig': specifier: workspace:* version: link:internal/tsconfig + '@vben/turbo-run': + specifier: workspace:* + version: link:scripts/turbo-run '@vben/vite-config': specifier: workspace:* version: link:internal/vite-config @@ -978,6 +981,18 @@ importers: specifier: ^4.4.0 version: 4.4.0(vue@3.4.34(typescript@5.5.4)) + scripts/turbo-run: + dependencies: + '@clack/prompts': + specifier: ^0.7.0 + version: 0.7.0 + '@vben/node-utils': + specifier: workspace:* + version: link:../../internal/node-utils + cac: + specifier: ^6.7.14 + version: 6.7.14 + scripts/vsh: dependencies: '@vben/node-utils': @@ -995,9 +1010,6 @@ importers: publint: specifier: ^0.2.9 version: 0.2.9 - zx: - specifier: ^8.1.4 - version: 8.1.4 website: dependencies: @@ -1895,6 +1907,14 @@ packages: '@changesets/write@0.3.1': resolution: {integrity: sha512-SyGtMXzH3qFqlHKcvFY2eX+6b0NGiFcNav8AFsYwy5l8hejOeoeTDemu5Yjmke2V5jpzY+pBvM0vCCQ3gdZpfw==} + '@clack/core@0.3.4': + resolution: {integrity: sha512-H4hxZDXgHtWTwV3RAVenqcC4VbJZNegbBjlPvzOzCouXtS2y3sDvlO3IsbrPNWuLWPPlYVYPghQdSF64683Ldw==} + + '@clack/prompts@0.7.0': + resolution: {integrity: sha512-0MhX9/B4iL6Re04jPrttDm+BsP8y6mS7byuv0BvXgdXhbV5PdlsHt55dvNsuBCPZ7xq1oTAOOuotR9NFbQyMSA==} + bundledDependencies: + - is-unicode-supported + '@cloudflare/kv-asset-handler@0.3.4': resolution: {integrity: sha512-YLPHc8yASwjNkmcDMQMY35yiWjoKAKnhUbPRszBRS0YgH+IXtsMp61j+yTcnCE3oO2DgP0U3iejLC8FTtKDC8Q==} engines: {node: '>=16.13'} @@ -3169,6 +3189,7 @@ packages: '@ls-lint/ls-lint@2.2.3': resolution: {integrity: sha512-ekM12jNm/7O2I/hsRv9HvYkRdfrHpiV1epVuI2NP+eTIcEgdIdKkKCs9KgQydu/8R5YXTov9aHdOgplmCHLupw==} + cpu: [x64, arm64, s390x] os: [darwin, linux, win32] hasBin: true @@ -8241,6 +8262,9 @@ packages: resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==} engines: {node: '>= 10'} + sisteransi@1.0.5: + resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -10704,6 +10728,17 @@ snapshots: human-id: 1.0.2 prettier: 2.8.8 + '@clack/core@0.3.4': + dependencies: + picocolors: 1.0.1 + sisteransi: 1.0.5 + + '@clack/prompts@0.7.0': + dependencies: + '@clack/core': 0.3.4 + picocolors: 1.0.1 + sisteransi: 1.0.5 + '@cloudflare/kv-asset-handler@0.3.4': dependencies: mime: 3.0.0 @@ -17426,6 +17461,8 @@ snapshots: mrmime: 2.0.0 totalist: 3.0.1 + sisteransi@1.0.5: {} + slash@3.0.0: {} slash@4.0.0: {} diff --git a/scripts/turbo-run/README.md b/scripts/turbo-run/README.md new file mode 100644 index 00000000..7cc8fbf5 --- /dev/null +++ b/scripts/turbo-run/README.md @@ -0,0 +1,3 @@ +# @vben/vsh + +shell 脚本工具集合 diff --git a/scripts/turbo-run/bin/turbo-run.mjs b/scripts/turbo-run/bin/turbo-run.mjs new file mode 100755 index 00000000..407754d4 --- /dev/null +++ b/scripts/turbo-run/bin/turbo-run.mjs @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +import('../dist/index.mjs'); diff --git a/scripts/turbo-run/build.config.ts b/scripts/turbo-run/build.config.ts new file mode 100644 index 00000000..97e572c5 --- /dev/null +++ b/scripts/turbo-run/build.config.ts @@ -0,0 +1,7 @@ +import { defineBuildConfig } from 'unbuild'; + +export default defineBuildConfig({ + clean: true, + declaration: true, + entries: ['src/index'], +}); diff --git a/scripts/turbo-run/package.json b/scripts/turbo-run/package.json new file mode 100644 index 00000000..3fc68e67 --- /dev/null +++ b/scripts/turbo-run/package.json @@ -0,0 +1,29 @@ +{ + "name": "@vben/turbo-run", + "version": "5.0.0", + "private": true, + "license": "MIT", + "type": "module", + "scripts": { + "stub": "pnpm unbuild --stub" + }, + "files": [ + "dist" + ], + "bin": { + "turbo-run": "./bin/turbo-run.mjs" + }, + "main": "./dist/index.mjs", + "module": "./dist/index.mjs", + "exports": { + ".": { + "default": "./dist/index.mjs" + }, + "./package.json": "./package.json" + }, + "dependencies": { + "@clack/prompts": "^0.7.0", + "@vben/node-utils": "workspace:*", + "cac": "^6.7.14" + } +} diff --git a/scripts/turbo-run/src/index.ts b/scripts/turbo-run/src/index.ts new file mode 100644 index 00000000..2f8dad0f --- /dev/null +++ b/scripts/turbo-run/src/index.ts @@ -0,0 +1,29 @@ +import { colors, consola } from '@vben/node-utils'; + +import { cac } from 'cac'; + +import { run } from './run'; + +try { + const turboRun = cac('turbo-run'); + + turboRun + .command('[script]') + .usage(`Run turbo interactively.`) + .action(async (command: string) => { + run({ command }); + }); + + // Invalid command + turboRun.on('command:*', () => { + consola.error(colors.red('Invalid command!')); + process.exit(1); + }); + + turboRun.usage('turbo-run'); + turboRun.help(); + turboRun.parse(); +} catch (error) { + consola.error(error); + process.exit(1); +} diff --git a/scripts/turbo-run/src/run.ts b/scripts/turbo-run/src/run.ts new file mode 100644 index 00000000..178d62cf --- /dev/null +++ b/scripts/turbo-run/src/run.ts @@ -0,0 +1,63 @@ +import type { Package } from '@vben/node-utils'; + +import { join } from 'node:path'; + +import { $, fs, getPackages } from '@vben/node-utils'; + +import { cancel, isCancel, multiselect } from '@clack/prompts'; + +interface RunOptions { + command?: string; +} + +export async function run(options: RunOptions) { + const { command } = options; + const { packages } = await getPackages(); + const appPkgs = await findApps(process.cwd(), packages); + + const selectApps = await multiselect({ + message: `Select the app you need to run [${command}]:`, + options: appPkgs.map((item) => ({ label: item, value: item })), + required: true, + }); + + if (isCancel(selectApps)) { + cancel('👋 Has cancelled'); + process.exit(0); + } + + if (selectApps.length === 1) { + $.verbose = true; + // 让控制台显示颜色 + process.env.FORCE_COLOR = '1'; + await $`pnpm --filter=${selectApps[0]} run ${command} `; + return; + } + const filters = []; + for (const app of selectApps) { + filters.push(`--filter=${app}`); + } + $.verbose = true; + // 让控制台显示颜色 + process.env.FORCE_COLOR = '1'; + await $`turbo run ${command} ${filters}`; +} + +/** + * 过滤app包 + * @param root + * @param packages + */ +async function findApps(root: string, packages: Package[]) { + // apps内的 + const appPackages = packages + .filter((pkg) => { + const viteConfigExists = fs.existsSync(join(pkg.dir, 'vite.config.mts')); + return pkg.dir.startsWith(join(root, 'apps')) && viteConfigExists; + }) + .map((pkg) => { + return pkg.packageJson.name; + }); + + return appPackages; +} diff --git a/scripts/turbo-run/tsconfig.json b/scripts/turbo-run/tsconfig.json new file mode 100644 index 00000000..b2ec3b61 --- /dev/null +++ b/scripts/turbo-run/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@vben/tsconfig/node.json", + "include": ["src"], + "exclude": ["node_modules"] +} diff --git a/scripts/vsh/package.json b/scripts/vsh/package.json index 148f8860..a7c10a0f 100644 --- a/scripts/vsh/package.json +++ b/scripts/vsh/package.json @@ -26,7 +26,6 @@ "cac": "^6.7.14", "circular-dependency-scanner": "^2.2.2", "depcheck": "^1.4.7", - "publint": "^0.2.9", - "zx": "^8.1.4" + "publint": "^0.2.9" } } diff --git a/vben-admin.code-workspace b/vben-admin.code-workspace index d2d6592a..5bf30504 100644 --- a/vben-admin.code-workspace +++ b/vben-admin.code-workspace @@ -144,6 +144,10 @@ "name": "@vben/utils", "path": "packages/utils", }, + { + "name": "@vben/turbo-run", + "path": "scripts/turbo-run", + }, { "name": "@vben/vsh", "path": "scripts/vsh",