Skip to content

Commit 7ba33c5

Browse files
fix(add): allow passing add-on as argument that dependsOn another (#691)
* fix(add): allow passing add-on as argument that depends on another add-on * fix: setupAddons later on only once * tweak ordering --------- Co-authored-by: AdrianGonz97 <[email protected]>
1 parent 2287ac1 commit 7ba33c5

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

.changeset/light-taxis-share.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+
fix(add): allow passing add-on as argument that depends on another add-on

packages/cli/commands/add/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,13 @@ export async function runAddCommand(
380380

381381
// prepare official addons
382382
let workspace = await createWorkspace({ cwd: options.cwd });
383-
const setups = selectedAddons.length ? selectedAddons.map(({ addon }) => addon) : officialAddons;
384-
const addonSetupResults = setupAddons(setups, workspace);
385383

386384
// prompt which addons to apply
387385
if (selectedAddons.length === 0) {
386+
const allSetupResults = setupAddons(officialAddons, workspace);
388387
const addonOptions = officialAddons
389388
// only display supported addons relative to the current environment
390-
.filter(({ id }) => addonSetupResults[id].unsupported.length === 0)
389+
.filter(({ id }) => allSetupResults[id].unsupported.length === 0)
391390
.map(({ id, homepage, shortDescription }) => ({
392391
label: id,
393392
value: id,
@@ -414,7 +413,9 @@ export async function runAddCommand(
414413
for (const { addon } of selectedAddons) {
415414
workspace = await createWorkspace(workspace);
416415

417-
const setupResult = addonSetupResults[addon.id];
416+
const setups = selectedAddons.map(({ addon }) => addon);
417+
const setupResult = setupAddons(setups, workspace)[addon.id];
418+
418419
const missingDependencies = setupResult.dependsOn.filter(
419420
(depId) => !selectedAddons.some((a) => a.addon.id === depId)
420421
);
@@ -436,8 +437,11 @@ export async function runAddCommand(
436437
}
437438
}
438439

439-
// run verifications
440+
// run all setups after inter-addon deps have been added
440441
const addons = selectedAddons.map(({ addon }) => addon);
442+
const addonSetupResults = setupAddons(addons, workspace);
443+
444+
// run verifications
441445
const verifications = [
442446
...verifyCleanWorkingDirectory(options.cwd, options.gitCheck),
443447
...verifyUnsupportedAddons(addons, addonSetupResults)

0 commit comments

Comments
 (0)