Skip to content

Commit 727fb33

Browse files
chore: don't select devtools-json by default (#605)
* dont select devtools-json by default * Create brown-peas-shop.md --------- Co-authored-by: Manuel <[email protected]>
1 parent 7cfaf90 commit 727fb33

File tree

6 files changed

+12
-32
lines changed

6 files changed

+12
-32
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

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)