feat: Support multiple application launch scripts
parent
fdee2d2239
commit
a26630b6e0
2
.npmrc
2
.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
|
||||
|
|
|
@ -6,4 +6,7 @@ import { defineOverridesPreferences } from '@vben/preferences';
|
|||
*/
|
||||
export const overridesPreferences = defineOverridesPreferences({
|
||||
// overrides
|
||||
app: {
|
||||
name: import.meta.env.VITE_APP_TITLE,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,4 +6,7 @@ import { defineOverridesPreferences } from '@vben/preferences';
|
|||
*/
|
||||
export const overridesPreferences = defineOverridesPreferences({
|
||||
// overrides
|
||||
app: {
|
||||
name: import.meta.env.VITE_APP_TITLE,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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 = '';
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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: {}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# @vben/vsh
|
||||
|
||||
shell 脚本工具集合
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import('../dist/index.mjs');
|
|
@ -0,0 +1,7 @@
|
|||
import { defineBuildConfig } from 'unbuild';
|
||||
|
||||
export default defineBuildConfig({
|
||||
clean: true,
|
||||
declaration: true,
|
||||
entries: ['src/index'],
|
||||
});
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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<any, string>({
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "@vben/tsconfig/node.json",
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,10 @@
|
|||
"name": "@vben/utils",
|
||||
"path": "packages/utils",
|
||||
},
|
||||
{
|
||||
"name": "@vben/turbo-run",
|
||||
"path": "scripts/turbo-run",
|
||||
},
|
||||
{
|
||||
"name": "@vben/vsh",
|
||||
"path": "scripts/vsh",
|
||||
|
|
Loading…
Reference in New Issue