Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const { task } = await cli.build({
const output = (await task).find((o) => o.kind === 'node');

await build({
input: ['./src/bin.ts', './src/index.ts'],
external: [/^node:/, 'rolldown-vite'],
input: ['./src/bin.ts', './src/index.ts', './src/test.ts'],
external: [/^node:/, 'rolldown-vite', 'vitest'],
output: {
format: 'esm',
},
Expand All @@ -64,6 +64,7 @@ const program = createProgram({
rootNames: [
join(srcDir, 'index.ts'),
join(srcDir, 'client.ts'),
join(srcDir, 'test.ts'),
],
options: {
...options,
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
},
"./client": {
"types": "./dist/client.d.ts"
},
"./test": {
"import": "./dist/test.js",
"types": "./dist/test.d.ts"
}
},
"engines": {
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*/

import { run } from '../binding/index.js';
import { doc } from './doc.js';
import { fmt } from './fmt.js';
import { lib } from './lib.js';
import { lint } from './lint.js';
import { test } from './test.js';
import { vite } from './vite.js';
import { doc } from './resolve-doc.js';
import { fmt } from './resolve-fmt.js';
import { lib } from './resolve-lib.js';
import { lint } from './resolve-lint.js';
import { test } from './resolve-test.js';
import { vite } from './resolve-vite.js';

async function resolveUniversalViteConfig(err: null | Error, viteConfigCwd: string) {
if (err) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions packages/cli/src/resolve-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Vitest tool resolver for the vite-plus CLI.
*
* This module exports a function that resolves the Vitest binary path
* using Node.js module resolution. The resolved path is passed back
* to the Rust core, which then executes Vitest for running tests.
*
* Used for: `vite-plus test` command
*/

import { DEFAULT_ENVS, resolve } from './utils.js';

/**
* Resolves the Vitest binary path and environment variables.
*
* @returns Promise containing:
* - binPath: Absolute path to the Vitest CLI entry point (vitest.mjs)
* - envs: Environment variables to set when executing Vitest
*
* Vitest is Vite's testing framework that provides a Jest-compatible
* testing experience with Vite's fast HMR and transformation pipeline.
*/
export async function test(): Promise<{
binPath: string;
envs: Record<string, string>;
}> {
// Resolve the Vitest CLI module directly
const binPath = resolve('vitest/vitest.mjs');

return {
binPath,
// Pass through source map debugging environment variable if set
envs: process.env.DEBUG_DISABLE_SOURCE_MAP
? {
...DEFAULT_ENVS,
DEBUG_DISABLE_SOURCE_MAP: process.env.DEBUG_DISABLE_SOURCE_MAP,
}
: {
...DEFAULT_ENVS,
},
};
}
File renamed without changes.
43 changes: 1 addition & 42 deletions packages/cli/src/test.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1 @@
/**
* Vitest tool resolver for the vite-plus CLI.
*
* This module exports a function that resolves the Vitest binary path
* using Node.js module resolution. The resolved path is passed back
* to the Rust core, which then executes Vitest for running tests.
*
* Used for: `vite-plus test` command
*/

import { DEFAULT_ENVS, resolve } from './utils.js';

/**
* Resolves the Vitest binary path and environment variables.
*
* @returns Promise containing:
* - binPath: Absolute path to the Vitest CLI entry point (vitest.mjs)
* - envs: Environment variables to set when executing Vitest
*
* Vitest is Vite's testing framework that provides a Jest-compatible
* testing experience with Vite's fast HMR and transformation pipeline.
*/
export async function test(): Promise<{
binPath: string;
envs: Record<string, string>;
}> {
// Resolve the Vitest CLI module directly
const binPath = resolve('vitest/vitest.mjs');

return {
binPath,
// Pass through source map debugging environment variable if set
envs: process.env.DEBUG_DISABLE_SOURCE_MAP
? {
...DEFAULT_ENVS,
DEBUG_DISABLE_SOURCE_MAP: process.env.DEBUG_DISABLE_SOURCE_MAP,
}
: {
...DEFAULT_ENVS,
},
};
}
export * from 'vitest';
2 changes: 1 addition & 1 deletion packages/tools/src/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { tmpdir } from 'node:os';

import { describe, expect, test } from 'vitest';
import { describe, expect, test } from '@voidzero-dev/vite-plus/test';

import { replaceUnstableOutput } from '../utils.ts';
Comment thread
Brooooooklyn marked this conversation as resolved.

Expand Down
Loading