Skip to content

Commit cf1960f

Browse files
authored
docs: improvements to the devtools-json docs (#598)
1 parent 02bb032 commit cf1960f

File tree

7 files changed

+31
-38
lines changed

7 files changed

+31
-38
lines changed

.changeset/brown-peas-shop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"sv": patch
3+
---
4+
5+
chore: don't select `devtools-json` by default

documentation/docs/30-add-ons/60-devtools-json.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22
title: devtools-json
33
---
44

5-
`devtools-json` is essentially a vite plugin [vite-plugin-devtools-json](https://github.com/ChromeDevTools/vite-plugin-devtools-json/) for generating the Chrome DevTools project settings file on-the-fly in the devserver.
5+
The `devtools-json` add-on installs [`vite-plugin-devtools-json`](https://github.com/ChromeDevTools/vite-plugin-devtools-json/), which is a Vite plugin for generating a Chromium DevTools project settings file on-the-fly in the development server. This file is served from `/.well-known/appspecific/com.chrome.devtools.json` and tells Chromium browsers where your project's source code lives so that you can use [the workspaces feature](https://developer.chrome.com/docs/devtools/workspaces) to edit source files in the browser.
66

7-
It will prevent this server log:
7+
> [!NOTE]
8+
> Installing the plugin enables the feature for all users connecting to the dev server with a Chromium browser, and allows the browser to read and write all files within the directory. If using Chrome's AI Assistance feature, this may also result in data being sent to Google.
89
9-
```sh
10-
Not found: /.well-known/appspecific/com.chrome.devtools.json
11-
```
10+
You can prevent the request from being issued on your machine by disabling the feature in your browser. You can do this in Chrome by visiting `chrome://flags` and disabling the "DevTools Project Settings". You may also be interested in disabling "DevTools Automatic Workspace Folders" since it’s closely related.
11+
12+
You can also prevent the web server from issuing a notice regarding the incoming request for all developers of your application by handling the request yourself. For example, you can create a file named `.well-known/appspecific/com.chrome.devtools.json` with the contents `"Go away, Chrome DevTools!"` or you can add logic to respond to the request in your [`handle`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle) hook:
13+
14+
```js
15+
/// file: src/hooks.server.js
16+
import { dev } from '$app/environment';
17+
18+
export function handle({ event, resolve }) {
19+
if (dev && event.url.pathname === '/.well-known/appspecific/com.chrome.devtools.json') {
20+
return new Response(undefined, { status: 404 });
21+
}
22+
23+
return resolve(event);
24+
}
1225

1326
## Usage
1427

@@ -18,4 +31,4 @@ npx sv add devtools-json
1831

1932
## What you get
2033

21-
- the `vite` plugin added to your vite plugin options.
34+
- `vite-plugin-devtools-json` added to your Vite plugin options

packages/addons/devtools-json/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ export default defineAddon({
88
homepage: 'https://github.com/ChromeDevTools/vite-plugin-devtools-json',
99
options: {},
1010

11-
setup: ({ defaultSelection }) => {
12-
defaultSelection({
13-
create: true,
14-
add: false
15-
});
16-
},
17-
1811
run: ({ sv, typescript }) => {
1912
const ext = typescript ? 'ts' : 'js';
2013

packages/cli/commands/add/index.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,15 @@ export const add = new Command('add')
201201

202202
common.runCommand(async () => {
203203
const selectedAddonIds = selectedAddons.map(({ id }) => id);
204-
const { nextSteps } = await runAddCommand(options, selectedAddonIds, 'add');
204+
const { nextSteps } = await runAddCommand(options, selectedAddonIds);
205205
if (nextSteps) p.note(nextSteps, 'Next steps', { format: (line: string) => line });
206206
});
207207
});
208208

209209
type SelectedAddon = { type: 'official' | 'community'; addon: AddonWithoutExplicitArgs };
210210
export async function runAddCommand(
211211
options: Options,
212-
selectedAddonIds: string[],
213-
from: 'create' | 'add'
212+
selectedAddonIds: string[]
214213
): Promise<{ nextSteps?: string; packageManager?: AgentName | null }> {
215214
const selectedAddons: SelectedAddon[] = selectedAddonIds.map((id) => ({
216215
type: 'official',
@@ -391,11 +390,6 @@ export async function runAddCommand(
391390
const setups = selectedAddons.length ? selectedAddons.map(({ addon }) => addon) : officialAddons;
392391
const addonSetupResults = setupAddons(setups, workspace);
393392

394-
// get all addons that have been marked to be preselected
395-
const initialValues = Object.entries(addonSetupResults)
396-
.filter(([_, value]) => value.defaultSelection[from] === true)
397-
.map(([key]) => key);
398-
399393
// prompt which addons to apply
400394
if (selectedAddons.length === 0) {
401395
const addonOptions = officialAddons
@@ -410,8 +404,7 @@ export async function runAddCommand(
410404
const selected = await p.multiselect({
411405
message: `What would you like to add to your project? ${pc.dim('(use arrow keys / space bar)')}`,
412406
options: addonOptions,
413-
required: false,
414-
initialValues
407+
required: false
415408
});
416409
if (p.isCancel(selected)) {
417410
p.cancel('Operation cancelled.');

packages/cli/commands/create.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ async function createProject(cwd: ProjectPath, options: Options) {
184184
community: [],
185185
addons: {}
186186
},
187-
[],
188-
'create'
187+
[]
189188
);
190189
packageManager = pm;
191190
addOnNextSteps = nextSteps;

packages/cli/lib/install.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ export function setupAddons(
9090
const setupResult: AddonSetupResult = {
9191
unsupported: [],
9292
dependsOn: [],
93-
runsAfter: [],
94-
defaultSelection: { create: false, add: false }
93+
runsAfter: []
9594
};
9695
addon.setup?.({
9796
...workspace,
@@ -100,10 +99,7 @@ export function setupAddons(
10099
setupResult.runsAfter.push(name);
101100
},
102101
unsupported: (reason) => setupResult.unsupported.push(reason),
103-
runsAfter: (name) => setupResult.runsAfter.push(name),
104-
defaultSelection: (defaultSelection) => {
105-
setupResult.defaultSelection = defaultSelection;
106-
}
102+
runsAfter: (name) => setupResult.runsAfter.push(name)
107103
});
108104
addonSetupResults[addon.id] = setupResult;
109105
}

packages/core/addon/config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export type Addon<Args extends OptionDefinition> = {
3838
dependsOn: (name: string) => void;
3939
unsupported: (reason: string) => void;
4040
runsAfter: (addonName: string) => void;
41-
defaultSelection: (args: { create: boolean; add: boolean }) => void;
4241
}
4342
) => MaybePromise<void>;
4443
run: (workspace: Workspace<Args> & { sv: SvApi }) => MaybePromise<void>;
@@ -61,12 +60,7 @@ export function defineAddon<Args extends OptionDefinition>(config: Addon<Args>):
6160
return config;
6261
}
6362

64-
export type AddonSetupResult = {
65-
dependsOn: string[];
66-
unsupported: string[];
67-
runsAfter: string[];
68-
defaultSelection: { create: boolean; add: boolean };
69-
};
63+
export type AddonSetupResult = { dependsOn: string[]; unsupported: string[]; runsAfter: string[] };
7064

7165
export type AddonWithoutExplicitArgs = Addon<Record<string, Question>>;
7266
export type AddonConfigWithoutExplicitArgs = Addon<Record<string, Question>>;

0 commit comments

Comments
 (0)