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[]=husky
|
||||||
public-hoist-pattern[]=eslint
|
public-hoist-pattern[]=eslint
|
||||||
public-hoist-pattern[]=prettier
|
public-hoist-pattern[]=prettier
|
||||||
|
|
|
@ -6,4 +6,7 @@ import { defineOverridesPreferences } from '@vben/preferences';
|
||||||
*/
|
*/
|
||||||
export const overridesPreferences = defineOverridesPreferences({
|
export const overridesPreferences = defineOverridesPreferences({
|
||||||
// overrides
|
// overrides
|
||||||
|
app: {
|
||||||
|
name: import.meta.env.VITE_APP_TITLE,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,4 +6,7 @@ import { defineOverridesPreferences } from '@vben/preferences';
|
||||||
*/
|
*/
|
||||||
export const overridesPreferences = defineOverridesPreferences({
|
export const overridesPreferences = defineOverridesPreferences({
|
||||||
// overrides
|
// overrides
|
||||||
|
app: {
|
||||||
|
name: import.meta.env.VITE_APP_TITLE,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
"check:type": "turbo run typecheck",
|
"check:type": "turbo run typecheck",
|
||||||
"clean": "vsh clean",
|
"clean": "vsh clean",
|
||||||
"commit": "czg",
|
"commit": "czg",
|
||||||
"dev": "cross-env turbo run dev",
|
"dev": "turbo-run dev",
|
||||||
"dev:antd": "pnpm -F @vben/web-antd",
|
"dev:antd": "pnpm -F @vben/web-antd",
|
||||||
"dev:naive": "pnpm -F @vben/web-naive",
|
"dev:naive": "pnpm -F @vben/web-naive",
|
||||||
"dev:docs": "pnpm -F @vben/website run docs:dev",
|
"dev:docs": "pnpm -F @vben/website run docs:dev",
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
"publint": "vsh publint",
|
"publint": "vsh publint",
|
||||||
"reinstall": "pnpm clean --del-lock && pnpm bootstrap",
|
"reinstall": "pnpm clean --del-lock && pnpm bootstrap",
|
||||||
"test:unit": "vitest",
|
"test:unit": "vitest",
|
||||||
|
"turbo-run": "turbo-run",
|
||||||
"update:deps": " pnpm update --latest --recursive",
|
"update:deps": " pnpm update --latest --recursive",
|
||||||
"version": "pnpm exec changeset version && pnpm install --no-frozen-lockfile"
|
"version": "pnpm exec changeset version && pnpm install --no-frozen-lockfile"
|
||||||
},
|
},
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
"@vben/stylelint-config": "workspace:*",
|
"@vben/stylelint-config": "workspace:*",
|
||||||
"@vben/tailwind-config": "workspace:*",
|
"@vben/tailwind-config": "workspace:*",
|
||||||
"@vben/tsconfig": "workspace:*",
|
"@vben/tsconfig": "workspace:*",
|
||||||
|
"@vben/turbo-run": "workspace:*",
|
||||||
"@vben/vite-config": "workspace:*",
|
"@vben/vite-config": "workspace:*",
|
||||||
"@vben/vsh": "workspace:*",
|
"@vben/vsh": "workspace:*",
|
||||||
"@vue/test-utils": "^2.4.6",
|
"@vue/test-utils": "^2.4.6",
|
||||||
|
|
|
@ -18,7 +18,7 @@ const defaultPreferences: Preferences = {
|
||||||
layout: 'sidebar-nav',
|
layout: 'sidebar-nav',
|
||||||
locale: 'zh-CN',
|
locale: 'zh-CN',
|
||||||
loginExpiredMode: 'modal',
|
loginExpiredMode: 'modal',
|
||||||
name: 'Vben Admin Naive',
|
name: 'Vben Admin',
|
||||||
watermark: false,
|
watermark: false,
|
||||||
},
|
},
|
||||||
breadcrumb: {
|
breadcrumb: {
|
||||||
|
|
|
@ -8,10 +8,10 @@ interface BuiltinThemePreset {
|
||||||
}
|
}
|
||||||
|
|
||||||
const BUILT_IN_THEME_PRESETS: BuiltinThemePreset[] = [
|
const BUILT_IN_THEME_PRESETS: BuiltinThemePreset[] = [
|
||||||
// {
|
{
|
||||||
// color: 'hsl(231 98% 65%)',
|
color: 'hsl(231 98% 65%)',
|
||||||
// type: 'default',
|
type: 'default',
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
color: 'hsl(245 82% 67%)',
|
color: 'hsl(245 82% 67%)',
|
||||||
type: 'violet',
|
type: 'violet',
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
generatorColorVariables,
|
generatorColorVariables,
|
||||||
} from '@vben-core/shared';
|
} from '@vben-core/shared';
|
||||||
|
|
||||||
import { BUILT_IN_THEME_PRESETS, type BuiltinThemePreset } from './constants';
|
import { BUILT_IN_THEME_PRESETS } from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新主题的 CSS 变量以及其他 CSS 变量
|
* 更新主题的 CSS 变量以及其他 CSS 变量
|
||||||
|
@ -37,13 +37,9 @@ function updateCSSVariables(preferences: Preferences) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前的内置主题
|
// 获取当前的内置主题
|
||||||
const currentBuiltType = [
|
const currentBuiltType = [...BUILT_IN_THEME_PRESETS].find(
|
||||||
{
|
(item) => item.type === builtinType,
|
||||||
color: preferences.theme.colorPrimary,
|
);
|
||||||
type: 'default',
|
|
||||||
} as BuiltinThemePreset,
|
|
||||||
...BUILT_IN_THEME_PRESETS,
|
|
||||||
].find((item) => item.type === builtinType);
|
|
||||||
|
|
||||||
let builtinTypeColorPrimary: string | undefined = '';
|
let builtinTypeColorPrimary: string | undefined = '';
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,6 @@ const inputValue = computed(() => {
|
||||||
|
|
||||||
const builtinThemePresets = computed(() => {
|
const builtinThemePresets = computed(() => {
|
||||||
return [
|
return [
|
||||||
{
|
|
||||||
color: 'hsl(231 98% 65%)',
|
|
||||||
type: 'default',
|
|
||||||
},
|
|
||||||
// {
|
// {
|
||||||
// color: 'hsl(231 98% 65%)',
|
// color: 'hsl(231 98% 65%)',
|
||||||
// type: 'default',
|
// type: 'default',
|
||||||
|
|
|
@ -49,6 +49,9 @@ importers:
|
||||||
'@vben/tsconfig':
|
'@vben/tsconfig':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:internal/tsconfig
|
version: link:internal/tsconfig
|
||||||
|
'@vben/turbo-run':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:scripts/turbo-run
|
||||||
'@vben/vite-config':
|
'@vben/vite-config':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:internal/vite-config
|
version: link:internal/vite-config
|
||||||
|
@ -978,6 +981,18 @@ importers:
|
||||||
specifier: ^4.4.0
|
specifier: ^4.4.0
|
||||||
version: 4.4.0(vue@3.4.34(typescript@5.5.4))
|
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:
|
scripts/vsh:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vben/node-utils':
|
'@vben/node-utils':
|
||||||
|
@ -995,9 +1010,6 @@ importers:
|
||||||
publint:
|
publint:
|
||||||
specifier: ^0.2.9
|
specifier: ^0.2.9
|
||||||
version: 0.2.9
|
version: 0.2.9
|
||||||
zx:
|
|
||||||
specifier: ^8.1.4
|
|
||||||
version: 8.1.4
|
|
||||||
|
|
||||||
website:
|
website:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -1895,6 +1907,14 @@ packages:
|
||||||
'@changesets/write@0.3.1':
|
'@changesets/write@0.3.1':
|
||||||
resolution: {integrity: sha512-SyGtMXzH3qFqlHKcvFY2eX+6b0NGiFcNav8AFsYwy5l8hejOeoeTDemu5Yjmke2V5jpzY+pBvM0vCCQ3gdZpfw==}
|
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':
|
'@cloudflare/kv-asset-handler@0.3.4':
|
||||||
resolution: {integrity: sha512-YLPHc8yASwjNkmcDMQMY35yiWjoKAKnhUbPRszBRS0YgH+IXtsMp61j+yTcnCE3oO2DgP0U3iejLC8FTtKDC8Q==}
|
resolution: {integrity: sha512-YLPHc8yASwjNkmcDMQMY35yiWjoKAKnhUbPRszBRS0YgH+IXtsMp61j+yTcnCE3oO2DgP0U3iejLC8FTtKDC8Q==}
|
||||||
engines: {node: '>=16.13'}
|
engines: {node: '>=16.13'}
|
||||||
|
@ -3169,6 +3189,7 @@ packages:
|
||||||
|
|
||||||
'@ls-lint/ls-lint@2.2.3':
|
'@ls-lint/ls-lint@2.2.3':
|
||||||
resolution: {integrity: sha512-ekM12jNm/7O2I/hsRv9HvYkRdfrHpiV1epVuI2NP+eTIcEgdIdKkKCs9KgQydu/8R5YXTov9aHdOgplmCHLupw==}
|
resolution: {integrity: sha512-ekM12jNm/7O2I/hsRv9HvYkRdfrHpiV1epVuI2NP+eTIcEgdIdKkKCs9KgQydu/8R5YXTov9aHdOgplmCHLupw==}
|
||||||
|
cpu: [x64, arm64, s390x]
|
||||||
os: [darwin, linux, win32]
|
os: [darwin, linux, win32]
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
@ -8241,6 +8262,9 @@ packages:
|
||||||
resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==}
|
resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
|
|
||||||
|
sisteransi@1.0.5:
|
||||||
|
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
|
||||||
|
|
||||||
slash@3.0.0:
|
slash@3.0.0:
|
||||||
resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==}
|
resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
@ -10704,6 +10728,17 @@ snapshots:
|
||||||
human-id: 1.0.2
|
human-id: 1.0.2
|
||||||
prettier: 2.8.8
|
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':
|
'@cloudflare/kv-asset-handler@0.3.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
mime: 3.0.0
|
mime: 3.0.0
|
||||||
|
@ -17426,6 +17461,8 @@ snapshots:
|
||||||
mrmime: 2.0.0
|
mrmime: 2.0.0
|
||||||
totalist: 3.0.1
|
totalist: 3.0.1
|
||||||
|
|
||||||
|
sisteransi@1.0.5: {}
|
||||||
|
|
||||||
slash@3.0.0: {}
|
slash@3.0.0: {}
|
||||||
|
|
||||||
slash@4.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",
|
"cac": "^6.7.14",
|
||||||
"circular-dependency-scanner": "^2.2.2",
|
"circular-dependency-scanner": "^2.2.2",
|
||||||
"depcheck": "^1.4.7",
|
"depcheck": "^1.4.7",
|
||||||
"publint": "^0.2.9",
|
"publint": "^0.2.9"
|
||||||
"zx": "^8.1.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,10 @@
|
||||||
"name": "@vben/utils",
|
"name": "@vben/utils",
|
||||||
"path": "packages/utils",
|
"path": "packages/utils",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "@vben/turbo-run",
|
||||||
|
"path": "scripts/turbo-run",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "@vben/vsh",
|
"name": "@vben/vsh",
|
||||||
"path": "scripts/vsh",
|
"path": "scripts/vsh",
|
||||||
|
|
Loading…
Reference in New Issue