Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove auto installing dependencies #164

Merged
merged 2 commits into from
Oct 17, 2024
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: 5 additions & 0 deletions .changeset/few-pots-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

chore: remove auto-installing dependencies
28 changes: 12 additions & 16 deletions packages/cli/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,28 @@ export async function formatFiles(cwd: string, paths: string[]): Promise<void> {

type PackageManagerOptions = Array<{ value: AgentName | null; label: AgentName | 'None' }>;
export async function suggestInstallingDependencies(cwd: string): Promise<'installed' | 'skipped'> {
const detectedPm = detectSync({ cwd });
let selectedPm = detectedPm?.agent ?? null;
const detected = detectSync({ cwd });
const agent = detected?.agent ?? getUserAgent() ?? null;

const agents = AGENTS.filter((agent): agent is AgentName => !agent.includes('@'));
const options: PackageManagerOptions = agents.map((pm) => ({ value: pm, label: pm }));
options.unshift({ label: 'None', value: null });

if (!selectedPm) {
const pm = await p.select({
message: 'Which package manager do you want to install dependencies with?',
options,
initialValue: getUserAgent()
});
if (p.isCancel(pm)) {
p.cancel('Operation cancelled.');
process.exit(1);
}

selectedPm = pm;
const pm = await p.select({
message: 'Which package manager do you want to install dependencies with?',
options,
initialValue: agent
});
if (p.isCancel(pm)) {
p.cancel('Operation cancelled.');
process.exit(1);
}

if (!selectedPm || !COMMANDS[selectedPm]) {
if (!pm) {
return 'skipped';
}

const { command, args } = constructCommand(COMMANDS[selectedPm].install, [])!;
const { command, args } = constructCommand(COMMANDS[pm].install, [])!;

const loadingSpinner = p.spinner();
loadingSpinner.start('Installing dependencies...');
Expand Down