From 0e30c189d59c5ce668abb8aad3bc74131c316bd8 Mon Sep 17 00:00:00 2001 From: jycouet Date: Fri, 21 Nov 2025 14:42:11 +0100 Subject: [PATCH 1/6] fix(cli): display agrs with no duplicates --- .changeset/ripe-hoops-leave.md | 5 +++++ .../docs/20-commands/10-sv-create.md | 2 +- packages/cli/commands/add/index.ts | 12 ++++-------- packages/cli/commands/create.ts | 10 ++++------ packages/cli/utils/common.ts | 19 ++++++++++++++----- 5 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 .changeset/ripe-hoops-leave.md diff --git a/.changeset/ripe-hoops-leave.md b/.changeset/ripe-hoops-leave.md new file mode 100644 index 000000000..f75c548b1 --- /dev/null +++ b/.changeset/ripe-hoops-leave.md @@ -0,0 +1,5 @@ +--- +'sv': patch +--- + +fix(cli): display agrs with no duplicates diff --git a/documentation/docs/20-commands/10-sv-create.md b/documentation/docs/20-commands/10-sv-create.md index 009e29fd4..2ac49088c 100644 --- a/documentation/docs/20-commands/10-sv-create.md +++ b/documentation/docs/20-commands/10-sv-create.md @@ -48,7 +48,7 @@ Add add-ons to the project in the `create` command. Following the same format as Example: ```sh -npx sv create --add eslint prettier +npx sv create --add eslint prettier [path] ``` ### `--no-add-ons` diff --git a/packages/cli/commands/add/index.ts b/packages/cli/commands/add/index.ts index d076b7a28..e2bbb96ee 100644 --- a/packages/cli/commands/add/index.ts +++ b/packages/cli/commands/add/index.ts @@ -184,7 +184,7 @@ export const add = new Command('add') options, selectedAddons, workspace, - withLogArgs: true + fromCommand: 'add' }); if (nextSteps.length > 0) { @@ -547,7 +547,7 @@ export async function runAddonsApply({ selectedAddons, addonSetupResults, workspace, - withLogArgs + fromCommand }: { answersOfficial: Record>; answersCommunity: Record>; @@ -555,7 +555,7 @@ export async function runAddonsApply({ selectedAddons: SelectedAddon[]; addonSetupResults?: Record; workspace: Workspace; - withLogArgs?: boolean; + fromCommand: 'create' | 'add'; }): Promise<{ nextSteps: string[]; argsFormattedAddons: string[] }> { if (!addonSetupResults) { const setups = selectedAddons.length @@ -657,11 +657,7 @@ export async function runAddonsApply({ } } - if (packageManager === null || packageManager === undefined) - argsFormattedAddons.push('--no-install'); - else argsFormattedAddons.push('--install', packageManager); - - if (withLogArgs) common.logArgs(packageManager ?? 'npm', 'add', argsFormattedAddons); + if (fromCommand === 'add') common.logArgs(packageManager, 'add', argsFormattedAddons); if (packageManager) { workspace.packageManager = packageManager; diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index d8f6ae5b2..c78463f07 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -281,7 +281,8 @@ async function createProject(cwd: ProjectPath, options: Options) { }, selectedAddons, addonSetupResults: undefined, - workspace + workspace, + fromCommand: 'create' }); argsFormattedAddons = argsFormatted; @@ -296,7 +297,7 @@ async function createProject(cwd: ProjectPath, options: Options) { : options.install; // Build args for next time based on non-default options - const argsFormatted = [cwd ?? defaultPath]; + const argsFormatted: string[] = []; argsFormatted.push('--template', template); @@ -306,10 +307,7 @@ async function createProject(cwd: ProjectPath, options: Options) { if (argsFormattedAddons.length > 0) argsFormatted.push('--add', ...argsFormattedAddons); - if (packageManager === null || packageManager === undefined) argsFormatted.push('--no-install'); - else argsFormatted.push('--install', packageManager); - - common.logArgs(packageManager ?? 'npm', 'create', argsFormatted); + common.logArgs(packageManager, 'create', argsFormatted, [cwd ?? projectName ?? defaultPath]); await addPnpmBuildDependencies(projectPath, packageManager, ['esbuild']); if (packageManager) await installDependencies(packageManager, projectPath); diff --git a/packages/cli/utils/common.ts b/packages/cli/utils/common.ts index 261691010..aa81a0cda 100644 --- a/packages/cli/utils/common.ts +++ b/packages/cli/utils/common.ts @@ -137,11 +137,20 @@ export function parseAddonOptions(optionFlags: string | undefined): string[] | u return options; } -export function logArgs(agent: AgentName, actionName: string, args: string[]) { - const defaultArgs = ['sv', actionName, ...args]; - const res = resolveCommand(agent, 'execute', defaultArgs); - if (res) p.log.message(pc.dim([res.command, ...res.args].join(' '))); - else p.log.message(pc.dim([`npx`, ...defaultArgs].join(' '))); +export function logArgs( + agent: AgentName | null | undefined, + command: 'create' | 'add', + args: string[], + lastArgs: string[] = [] +) { + const allArgs = ['sv', command, ...args]; + + // Handle install option + if (agent === null || agent === undefined) allArgs.push('--no-install'); + else allArgs.push('--install', agent); + + const res = resolveCommand(agent ?? 'npm', 'execute', [...allArgs, ...lastArgs])!; + p.log.message(pc.dim([res.command, ...res.args].join(' '))); } export function errorAndExit(message: string) { From 0c9d99fdc342d6006f95b2bc0f5dd4ff9909fb5e Mon Sep 17 00:00:00 2001 From: jycouet Date: Fri, 21 Nov 2025 14:46:15 +0100 Subject: [PATCH 2/6] simple --- packages/cli/commands/create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index c78463f07..ce21ed992 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -307,7 +307,7 @@ async function createProject(cwd: ProjectPath, options: Options) { if (argsFormattedAddons.length > 0) argsFormatted.push('--add', ...argsFormattedAddons); - common.logArgs(packageManager, 'create', argsFormatted, [cwd ?? projectName ?? defaultPath]); + common.logArgs(packageManager, 'create', argsFormatted, [cwd ?? defaultPath]); await addPnpmBuildDependencies(projectPath, packageManager, ['esbuild']); if (packageManager) await installDependencies(packageManager, projectPath); From 9391bfa7838bf299d52193df7087fd9160b3a82d Mon Sep 17 00:00:00 2001 From: jycouet Date: Fri, 21 Nov 2025 15:03:41 +0100 Subject: [PATCH 3/6] fix also the [path] --- packages/cli/commands/create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index ce21ed992..9e5e64489 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -307,7 +307,7 @@ async function createProject(cwd: ProjectPath, options: Options) { if (argsFormattedAddons.length > 0) argsFormatted.push('--add', ...argsFormattedAddons); - common.logArgs(packageManager, 'create', argsFormatted, [cwd ?? defaultPath]); + common.logArgs(packageManager, 'create', argsFormatted, [directory]); await addPnpmBuildDependencies(projectPath, packageManager, ['esbuild']); if (packageManager) await installDependencies(packageManager, projectPath); From ddc0928712b918d43e3f27d78fb2e4a98c358fa5 Mon Sep 17 00:00:00 2001 From: jycouet Date: Fri, 21 Nov 2025 15:17:18 +0100 Subject: [PATCH 4/6] bring back default to local place --- packages/cli/commands/create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index 9e5e64489..f2c84a782 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -69,7 +69,6 @@ const OptionsSchema = v.strictObject({ }); type Options = v.InferOutput; type ProjectPath = v.InferOutput; -const defaultPath = './'; export const create = new Command('create') .description('scaffolds a new SvelteKit project') @@ -150,6 +149,7 @@ async function createProject(cwd: ProjectPath, options: Options) { if (cwd) { return Promise.resolve(path.resolve(cwd)); } + const defaultPath = './'; return p.text({ message: 'Where would you like your project to be created?', placeholder: ` (hit Enter to use '${defaultPath}')`, From b85b7ad21d909f1b071f9ab97090f6b6339c9f0a Mon Sep 17 00:00:00 2001 From: Manuel Serret Date: Fri, 21 Nov 2025 15:42:46 +0100 Subject: [PATCH 5/6] don't use absolute path --- packages/cli/commands/create.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index f2c84a782..ce21ed992 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -69,6 +69,7 @@ const OptionsSchema = v.strictObject({ }); type Options = v.InferOutput; type ProjectPath = v.InferOutput; +const defaultPath = './'; export const create = new Command('create') .description('scaffolds a new SvelteKit project') @@ -149,7 +150,6 @@ async function createProject(cwd: ProjectPath, options: Options) { if (cwd) { return Promise.resolve(path.resolve(cwd)); } - const defaultPath = './'; return p.text({ message: 'Where would you like your project to be created?', placeholder: ` (hit Enter to use '${defaultPath}')`, @@ -307,7 +307,7 @@ async function createProject(cwd: ProjectPath, options: Options) { if (argsFormattedAddons.length > 0) argsFormatted.push('--add', ...argsFormattedAddons); - common.logArgs(packageManager, 'create', argsFormatted, [directory]); + common.logArgs(packageManager, 'create', argsFormatted, [cwd ?? defaultPath]); await addPnpmBuildDependencies(projectPath, packageManager, ['esbuild']); if (packageManager) await installDependencies(packageManager, projectPath); From 21ef687780ba2128d78300b345fbf9fcff3ba51c Mon Sep 17 00:00:00 2001 From: Manuel Serret Date: Fri, 21 Nov 2025 15:43:32 +0100 Subject: [PATCH 6/6] better changeset --- .changeset/ripe-hoops-leave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/ripe-hoops-leave.md b/.changeset/ripe-hoops-leave.md index f75c548b1..d9fc5be82 100644 --- a/.changeset/ripe-hoops-leave.md +++ b/.changeset/ripe-hoops-leave.md @@ -2,4 +2,4 @@ 'sv': patch --- -fix(cli): display agrs with no duplicates +fix(cli): avoid printing duplicated `--no-install` flag