@viyuni/vpp
v0.0.4
Published
A Vite+ extension toolkit for project-aware CLI command dispatch.
Downloads
614
Readme
vpp
vpp is a small extension toolkit for Vite+. It adds a CLI layer that can load project configuration and dispatch commands to different underlying tools.
The current focus is project-aware command dispatch. You can run:
vpp check
vpp testvpp reads your Vite+ config, resolves the configured behavior, and calls the matching underlying tools.
Supported Features
vpp checkcommand dispatchvpp testcommand dispatch- Config loading from
vite.config.tswithunconfig - Config merging with
defu - CLI argument parsing with
arg - Vite+ config type augmentation through
vpp - Command helpers for Vite+ tasks:
createCommandcreateArgsvpRun
- Test framework selection:
vpvitestbun:test
- Type-check runner selection for
vpp check:- Manual
nuxt typecheck - Manual
tsc --noEmit - Manual custom command
- Default passthrough to
vp check
- Manual
Command Helpers
@viyuni/vpp exports small helpers for composing Vite+ task commands in
vite.config.ts.
createCommand
Use createCommand when you want to build reusable command prefixes:
import { createCommand } from '@viyuni/vpp';
const vp = createCommand('vp');
const publish = vp.with('pm').with('publish');
vp('pack');
// => 'vp pack'
publish('--access public');
// => 'vp pm publish --access public'Empty fragments are ignored and command fragments are trimmed.
createArgs
Use createArgs when you need an argv array instead of a shell command string:
import { createArgs } from '@viyuni/vpp';
const testArgs = createArgs('test').with('tests/foo.test.ts');
testArgs('-t', 'case name');
// => ['test', 'tests/foo.test.ts', '-t', 'case name']vpRun
Use vpRun to generate vp run commands for Vite+ tasks and workspace runs:
import { defineConfig } from 'vite-plus';
import { vpRun } from '@viyuni/vpp';
export default defineConfig({
run: {
tasks: {
build: {
command: vpRun('build'),
},
dev: {
command: vpRun('dev', {
filter: '@my/app',
parallel: true,
recursive: true,
}),
cache: false,
},
details: {
command: vpRun('', {
lastDetails: true,
}),
},
},
},
});Examples:
vpRun('build');
// => 'vp run build'
vpRun('test', {
args: ['--reporter verbose'],
});
// => 'vp run test --reporter verbose'
vpRun('dev', {
concurrencyLimit: 4,
filter: ['@my/app', '!@my/utils'],
parallel: true,
recursive: true,
});
// => 'vp run -r --parallel --concurrency-limit 4 --filter @my/app --filter !@my/utils dev'Configuration
Configure vpp in vite.config.ts. vpp is intended to live inside the Vite+
config because it extends Vite+ behavior:
import { defineConfig } from 'vite-plus';
export default defineConfig({
vpp: {
test: 'bun:test',
},
});You can also use object form when you need extra environment variables:
import { defineConfig } from 'vite-plus';
export default defineConfig({
vpp: {
test: {
name: 'vitest',
env: {
NODE_ENV: 'test',
},
},
},
});If no test framework is configured, vpp defaults to:
{
vpp: {
test: 'vp',
},
}That resolves to:
vp testCheck Command
vpp check defaults to vp check and forwards arguments unchanged:
vpp check --fix
# => vp check --fixNuxt projects use the default vp check passthrough unless configured
explicitly:
import { defineConfig } from 'vite-plus';
export default defineConfig({
lint: {
options: {
typeCheck: true,
},
},
vpp: {
typecheck: 'nuxt',
},
});TypeScript projects can configure tsc manually:
import { defineConfig } from 'vite-plus';
export default defineConfig({
lint: {
options: {
typeCheck: true,
},
},
vpp: {
typecheck: 'tsc',
},
});You can also provide a custom command:
export default defineConfig({
vpp: {
typecheck: {
command: 'tsc',
args: ['--noEmit'],
},
},
});Supported flags match the Vite+ check command:
vpp check --fix
vpp check --no-fmt
vpp check --no-lint
vpp check --no-fmt --no-lintTest Command Mapping
| vpp config | Resolved command |
| ---------- | ---------------- |
| vp | vp test |
| vitest | vitest |
| bun:test | bun test |
Arguments after vpp test are forwarded after the resolved test command:
vpp test tests/example.test.tsFor bun:test, this becomes:
bun test tests/example.test.tsAI Prompt
When this project already has vpp available, prefer it for test commands.
- Use
vpp testinstead ofvp test. - Use
vpp test <args...>instead ofvp test <args...>. - Keep using existing Vite+ commands for non-test tasks, such as
vp check,vp pack, andvp run <script>. - Fall back to
vp testonly ifvppis not available.
Local Development
Install dependencies:
vp installRun tests:
vpp testRun checks:
vp checkBuild:
vp packLink locally as a global command:
pnpm link --globalThen run:
vpp test