mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-22 22:16:18 +08:00
chore: Resolve merge conflicts
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
# @vben/vsh
|
||||
# @vben/turbo-run
|
||||
|
||||
shell 脚本工具集合
|
||||
turbo-run is a command line tool that allows you to run multiple commands in parallel.
|
||||
|
@@ -1,10 +1,6 @@
|
||||
import type { Package } from '@vben/node-utils';
|
||||
import { execaCommand, getPackages } from '@vben/node-utils';
|
||||
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { $, fs, getPackages } from '@vben/node-utils';
|
||||
|
||||
import { cancel, isCancel, multiselect } from '@clack/prompts';
|
||||
import { cancel, isCancel, select } from '@clack/prompts';
|
||||
|
||||
interface RunOptions {
|
||||
command?: string;
|
||||
@@ -12,35 +8,45 @@ interface RunOptions {
|
||||
|
||||
export async function run(options: RunOptions) {
|
||||
const { command } = options;
|
||||
if (!command) {
|
||||
console.error('Please enter the command to run');
|
||||
process.exit(1);
|
||||
}
|
||||
const { packages } = await getPackages();
|
||||
const appPkgs = await findApps(process.cwd(), packages);
|
||||
// const appPkgs = await findApps(process.cwd(), packages);
|
||||
// const websitePkg = packages.find(
|
||||
// (item) => item.packageJson.name === '@vben/website',
|
||||
// );
|
||||
|
||||
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,
|
||||
// 只显示有对应命令的包
|
||||
const selectPkgs = packages.filter((pkg) => {
|
||||
return (pkg?.packageJson as Record<string, any>).scripts?.[command];
|
||||
});
|
||||
|
||||
if (isCancel(selectApps)) {
|
||||
const selectPkg = await select<any, string>({
|
||||
message: `Select the app you need to run [${command}]:`,
|
||||
options: selectPkgs.map((item) => ({
|
||||
label: item?.packageJson.name,
|
||||
value: item?.packageJson.name,
|
||||
})),
|
||||
});
|
||||
|
||||
if (isCancel(selectPkg) || !selectPkg) {
|
||||
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}`;
|
||||
execaCommand(`pnpm --filter=${selectPkg} run ${command}`, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
// const filters = [];
|
||||
// for (const app of selectApps) {
|
||||
// filters.push(`--filter=${app}`);
|
||||
// }
|
||||
// $.verbose = true;
|
||||
// execaCommand(`turbo run ${command} ${filters}`, {
|
||||
// stdio: 'inherit',
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,16 +54,12 @@ export async function run(options: RunOptions) {
|
||||
* @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;
|
||||
});
|
||||
// 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;
|
||||
// });
|
||||
|
||||
return appPackages;
|
||||
}
|
||||
// return appPackages;
|
||||
// }
|
||||
|
@@ -2,13 +2,7 @@ import type { CAC } from 'cac';
|
||||
|
||||
import { join } from 'node:path';
|
||||
|
||||
import {
|
||||
colors,
|
||||
consola,
|
||||
getPackages,
|
||||
rimraf,
|
||||
spinner,
|
||||
} from '@vben/node-utils';
|
||||
import { colors, getPackages, rimraf, spinner } from '@vben/node-utils';
|
||||
|
||||
const CLEAN_DIRS = ['dist', 'node_modules', '.turbo'];
|
||||
|
||||
@@ -38,10 +32,15 @@ async function runClean({
|
||||
|
||||
const cleanDirsText = JSON.stringify(cleanDirs);
|
||||
|
||||
spinner(`${colors.dim(cleanDirsText)} cleaning in progress...`, async () => {
|
||||
await clean({ delLock, dirs: cleanDirs, recursive });
|
||||
consola.success(colors.green(`clean up all \`${cleanDirsText}\` success.`));
|
||||
});
|
||||
spinner(
|
||||
{
|
||||
successText: colors.green(`clean up all \`${cleanDirsText}\` success.`),
|
||||
title: `${colors.dim(cleanDirsText)} cleaning in progress...`,
|
||||
},
|
||||
async () => {
|
||||
await clean({ delLock, dirs: cleanDirs, recursive });
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async function clean({ delLock, dirs = [], recursive }: CleanCommandOptions) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import type { CAC } from 'cac';
|
||||
|
||||
import { $ } from '@vben/node-utils';
|
||||
import { execaCommand } from '@vben/node-utils';
|
||||
|
||||
interface LintCommandOptions {
|
||||
/**
|
||||
@@ -10,21 +10,31 @@ interface LintCommandOptions {
|
||||
}
|
||||
|
||||
async function runLint({ format }: LintCommandOptions) {
|
||||
process.env.FORCE_COLOR = '3';
|
||||
// process.env.FORCE_COLOR = '3';
|
||||
|
||||
if (format) {
|
||||
await $`stylelint "**/*.{vue,css,less.scss}" --cache --fix`;
|
||||
await $`eslint . --cache --fix`;
|
||||
await $`prettier . --write --cache --log-level warn`;
|
||||
await execaCommand(`stylelint "**/*.{vue,css,less.scss}" --cache --fix`, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
await execaCommand(`eslint . --cache --fix`, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
await execaCommand(`prettier . --write --cache --log-level warn`, {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
return;
|
||||
}
|
||||
$.verbose = true;
|
||||
await Promise.all([
|
||||
$`cspell lint "**/*.ts" "**/README.md" ".changeset/*.md" --no-progress`,
|
||||
$`eslint . --cache`,
|
||||
execaCommand(`eslint . --cache`, {
|
||||
stdio: 'inherit',
|
||||
}),
|
||||
// $`ls-lint`,
|
||||
$`prettier . --ignore-unknown --check --cache`,
|
||||
$`stylelint "**/*.{vue,css,less.scss}" --cache`,
|
||||
execaCommand(`prettier . --ignore-unknown --check --cache`, {
|
||||
stdio: 'inherit',
|
||||
}),
|
||||
execaCommand(`stylelint "**/*.{vue,css,less.scss}" --cache`, {
|
||||
stdio: 'inherit',
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user