Skip to content

Commit 3021c69

Browse files
authored
Merge branch 'main' into ship-docs
2 parents 416f2e4 + 90e7beb commit 3021c69

14 files changed

Lines changed: 1180 additions & 757 deletions

File tree

packages/cli/snap-tests-todo/test-panicked-fix/snap.txt

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/cli/snap-tests/bin-oxfmt-wrapper/snap.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Output Options:
2424
Config Options
2525
-c, --config=PATH Path to the configuration file (.json, .jsonc, .ts, .mts, .cts, .js,
2626
.mjs, .cjs)
27+
--disable-nested-config Do not search for configuration files in subdirectories
2728

2829
Ignore Options
2930
--ignore-path=PATH Path to ignore file(s). Can be specified multiple times. If not
@@ -64,6 +65,7 @@ Output Options:
6465
Config Options
6566
-c, --config=PATH Path to the configuration file (.json, .jsonc, .ts, .mts, .cts, .js,
6667
.mjs, .cjs)
68+
--disable-nested-config Do not search for configuration files in subdirectories
6769

6870
Ignore Options
6971
--ignore-path=PATH Path to ignore file(s). Can be specified multiple times. If not

packages/cli/snap-tests/command-helper/snap.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Output Options:
9595
Config Options
9696
-c, --config=PATH Path to the configuration file (.json, .jsonc, .ts, .mts, .cts, .js,
9797
.mjs, .cjs)
98+
--disable-nested-config Do not search for configuration files in subdirectories
9899

99100
Ignore Options
100101
--ignore-path=PATH Path to ignore file(s). Can be specified multiple times. If not
@@ -234,7 +235,7 @@ Options:
234235
--assetsInlineLimit <number> [number] static asset base64 inline threshold in bytes (default: 4096)
235236
--ssr [entry] [string] build specified entry for server-side rendering
236237
--sourcemap [output] [boolean | "inline" | "hidden"] output source maps for build (default: false)
237-
--minify [minifier] [boolean | "terser" | "esbuild"] enable/disable minification, or specify minifier to use (default: esbuild)
238+
--minify [minifier] [boolean | "oxc" | "terser" | "esbuild"] enable/disable minification, or specify minifier to use (default: oxc)
238239
--manifest [name] [boolean | string] emit build manifest json
239240
--ssrManifest [name] [boolean | string] emit ssr manifest json
240241
--emptyOutDir [boolean] force empty outDir when it's outside of root
@@ -293,7 +294,7 @@ Options:
293294
--api [port] Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to 51204. Use '--help --api' for more info.
294295
--silent [value] Silent console output from tests. Use 'passed-only' to see logs from failing tests only.
295296
--hideSkippedTests Hide logs for skipped tests
296-
--reporter <name> Specify reporters (default, agent, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions)
297+
--reporter <name> Specify reporters (default, agent, minimal, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions)
297298
--outputFile <filename/-s> Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters (example: --outputFile.tap=./tap.txt)
298299
--coverage Enable coverage report. Use '--help --coverage' for more info.
299300
--mode <name> Override Vite mode (default: test or benchmark)

packages/cli/snap-tests-todo/test-panicked-fix/package.json renamed to packages/cli/snap-tests/test-panicked-fix/package.json

File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
> vp lint --help | head -n 20 # print help message and no panicked
2+
Usage: [-c=<./.oxlintrc.json>] [PATH]...
3+
4+
Basic Configuration
5+
-c, --config=<./.oxlintrc.json> Oxlint configuration file
6+
* `.json` and `.jsonc` config files are supported in all runtimes
7+
* JavaScript/TypeScript config files are experimental and require
8+
running via Node.js
9+
* you can use comments in configuration files.
10+
* tries to be compatible with ESLint v8's format
11+
--tsconfig=<./tsconfig.json> Override the TypeScript config used for import resolution.
12+
Oxlint automatically discovers the relevant `tsconfig.json` for each
13+
file. Use this only when your project uses a non-standard tsconfig
14+
name or location.
15+
--init Initialize oxlint configuration with default values
16+
17+
Allowing / Denying Multiple Lints
18+
Accumulate rules and categories from left to right on the command-line.
19+
For example `-D correctness -A no-debugger` or `-A all -D no-debugger`.
20+
The categories are:
21+
* `correctness` - Code that is outright wrong or useless (default)

packages/cli/snap-tests-todo/test-panicked-fix/steps.json renamed to packages/cli/snap-tests/test-panicked-fix/steps.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"ignoredPlatforms": ["win32"],
32
"commands": ["vp lint --help | head -n 20 # print help message and no panicked"]
43
}

packages/cli/src/create/bin.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
selectAgentTargetPaths,
2121
writeAgentInstructions,
2222
} from '../utils/agent.ts';
23-
import { detectExistingEditor, selectEditor, writeEditorConfigs } from '../utils/editor.ts';
23+
import { detectExistingEditors, selectEditors, writeEditorConfigs } from '../utils/editor.ts';
2424
import { renderCliDoc } from '../utils/help.ts';
2525
import { displayRelative } from '../utils/path.ts';
2626
import {
@@ -438,7 +438,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
438438
let selectedTemplateName = templateName as string;
439439
let selectedTemplateArgs = [...templateArgs];
440440
let selectedAgentTargetPaths: string[] | undefined;
441-
let selectedEditor: Awaited<ReturnType<typeof selectEditor>>;
441+
let selectedEditors: Awaited<ReturnType<typeof selectEditors>>;
442442
let selectedParentDir: string | undefined;
443443
let remoteTargetDir: string | undefined;
444444
let shouldSetupHooks = false;
@@ -678,13 +678,13 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
678678
onCancel: () => cancelAndExit(),
679679
});
680680

681-
const existingEditor =
681+
const existingEditors =
682682
options.editor || !options.interactive
683683
? undefined
684-
: detectExistingEditor(workspaceInfoOptional.rootDir);
685-
selectedEditor =
686-
existingEditor ??
687-
(await selectEditor({
684+
: detectExistingEditors(workspaceInfoOptional.rootDir);
685+
selectedEditors =
686+
existingEditors ??
687+
(await selectEditors({
688688
interactive: options.interactive,
689689
editor: options.editor,
690690
onCancel: () => cancelAndExit(),
@@ -796,7 +796,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
796796
pauseCreateProgress();
797797
await writeEditorConfigs({
798798
projectRoot: fullPath,
799-
editorId: selectedEditor,
799+
editorId: selectedEditors,
800800
interactive: options.interactive,
801801
silent: compactOutput,
802802
extraVsCodeSettings: { 'npm.scriptRunner': 'vp' },
@@ -886,7 +886,7 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
886886
pauseCreateProgress();
887887
await writeEditorConfigs({
888888
projectRoot: fullPath,
889-
editorId: selectedEditor,
889+
editorId: selectedEditors,
890890
interactive: options.interactive,
891891
silent: compactOutput,
892892
extraVsCodeSettings: { 'npm.scriptRunner': 'vp' },

packages/cli/src/utils/__tests__/editor.spec.ts

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import fs from 'node:fs';
22
import os from 'node:os';
33
import path from 'node:path';
44

5-
import { afterEach, describe, expect, it } from 'vitest';
5+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
6+
import { afterEach, describe, expect, it, vi } from 'vitest';
67

7-
import { writeEditorConfigs } from '../editor.js';
8+
import { detectExistingEditors, selectEditors, writeEditorConfigs } from '../editor.js';
89

910
const tempDirs: string[] = [];
1011

@@ -15,11 +16,82 @@ function createTempDir() {
1516
}
1617

1718
afterEach(() => {
19+
vi.restoreAllMocks();
1820
for (const dir of tempDirs.splice(0, tempDirs.length)) {
1921
fs.rmSync(dir, { recursive: true, force: true });
2022
}
2123
});
2224

25+
describe('selectEditors', () => {
26+
it('prompts with editor config targets and supports multiple selections', async () => {
27+
const multiselectSpy = vi.spyOn(prompts, 'multiselect').mockResolvedValue(['vscode', 'zed']);
28+
29+
await expect(
30+
selectEditors({
31+
interactive: true,
32+
onCancel: vi.fn(),
33+
}),
34+
).resolves.toEqual(['vscode', 'zed']);
35+
36+
expect(multiselectSpy).toHaveBeenCalledWith(
37+
expect.objectContaining({
38+
message: expect.stringContaining('Which editors are you using?'),
39+
initialValues: ['vscode'],
40+
required: false,
41+
options: expect.arrayContaining([
42+
expect.objectContaining({
43+
label: 'VSCode',
44+
value: 'vscode',
45+
hint: '.vscode',
46+
}),
47+
expect.objectContaining({
48+
label: 'Zed',
49+
value: 'zed',
50+
hint: '.zed',
51+
}),
52+
]),
53+
}),
54+
);
55+
});
56+
57+
it('skips editor config selection when no editors are selected', async () => {
58+
vi.spyOn(prompts, 'multiselect').mockResolvedValue([]);
59+
60+
await expect(
61+
selectEditors({
62+
interactive: true,
63+
onCancel: vi.fn(),
64+
}),
65+
).resolves.toBeUndefined();
66+
});
67+
68+
it('keeps explicit --editor selection as a single editor', async () => {
69+
await expect(
70+
selectEditors({
71+
interactive: false,
72+
editor: 'zed',
73+
onCancel: vi.fn(),
74+
}),
75+
).resolves.toEqual(['zed']);
76+
});
77+
});
78+
79+
describe('detectExistingEditors', () => {
80+
it('detects multiple existing editor config directories', () => {
81+
const projectRoot = createTempDir();
82+
fs.mkdirSync(path.join(projectRoot, '.vscode'), { recursive: true });
83+
fs.mkdirSync(path.join(projectRoot, '.zed'), { recursive: true });
84+
fs.writeFileSync(path.join(projectRoot, '.vscode', 'settings.json'), '{}');
85+
fs.writeFileSync(path.join(projectRoot, '.zed', 'settings.json'), '{}');
86+
87+
expect(detectExistingEditors(projectRoot)).toEqual(['vscode', 'zed']);
88+
});
89+
90+
it('returns undefined when no editor config files exist', () => {
91+
expect(detectExistingEditors(createTempDir())).toBeUndefined();
92+
});
93+
});
94+
2395
describe('writeEditorConfigs', () => {
2496
it('writes vscode settings that align formatter config with vite.config.ts', async () => {
2597
const projectRoot = createTempDir();
@@ -177,4 +249,31 @@ describe('writeEditorConfigs', () => {
177249
'./vite.config.ts',
178250
);
179251
});
252+
253+
it('writes multiple editor configs in one call', async () => {
254+
const projectRoot = createTempDir();
255+
256+
await writeEditorConfigs({
257+
projectRoot,
258+
editorId: ['vscode', 'zed'],
259+
interactive: false,
260+
silent: true,
261+
extraVsCodeSettings: { 'npm.scriptRunner': 'vp' },
262+
});
263+
264+
const vscodeSettings = JSON.parse(
265+
fs.readFileSync(path.join(projectRoot, '.vscode', 'settings.json'), 'utf8'),
266+
) as Record<string, unknown>;
267+
const vscodeExtensions = JSON.parse(
268+
fs.readFileSync(path.join(projectRoot, '.vscode', 'extensions.json'), 'utf8'),
269+
) as Record<string, unknown>;
270+
const zedSettings = JSON.parse(
271+
fs.readFileSync(path.join(projectRoot, '.zed', 'settings.json'), 'utf8'),
272+
) as Record<string, unknown>;
273+
274+
expect(vscodeSettings['npm.scriptRunner']).toBe('vp');
275+
expect(vscodeExtensions.recommendations).toContain('VoidZero.vite-plus-extension-pack');
276+
expect(zedSettings['npm.scriptRunner']).toBeUndefined();
277+
expect(zedSettings.lsp).toBeDefined();
278+
});
180279
});

0 commit comments

Comments
 (0)