init: 项目初始化提交
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled

This commit is contained in:
2025-05-27 18:35:06 +08:00
commit d3609c21c0
1430 changed files with 122218 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# @vben/turbo-run
turbo-run is a command line tool that allows you to run multiple commands in parallel.

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
import('../dist/index.mjs');

View File

@@ -0,0 +1,7 @@
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ['src/index'],
});

View File

@@ -0,0 +1,29 @@
{
"name": "@vben/turbo-run",
"version": "5.5.4",
"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": "catalog:",
"@vben/node-utils": "workspace:*",
"cac": "catalog:"
}
}

View File

@@ -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);
}

View File

@@ -0,0 +1,67 @@
import { execaCommand, getPackages } from '@vben/node-utils';
import { cancel, isCancel, select } from '@clack/prompts';
interface RunOptions {
command?: string;
}
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 websitePkg = packages.find(
// (item) => item.packageJson.name === '@vben/website',
// );
// 只显示有对应命令的包
const selectPkgs = packages.filter((pkg) => {
return (pkg?.packageJson as Record<string, any>)?.scripts?.[command];
});
let selectPkg: string | symbol;
if (selectPkgs.length > 1) {
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);
}
} else {
selectPkg = selectPkgs[0]?.packageJson?.name ?? '';
}
if (!selectPkg) {
console.error('No app found');
process.exit(1);
}
execaCommand(`pnpm --filter=${selectPkg} run ${command}`, {
stdio: 'inherit',
});
}
/**
* 过滤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;
// });
// return appPackages;
// }

View File

@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@vben/tsconfig/node.json",
"include": ["src"],
"exclude": ["node_modules"]
}