Skip to content
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/ripe-hoops-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

fix(cli): avoid printing duplicated `--no-install` flag
2 changes: 1 addition & 1 deletion documentation/docs/20-commands/10-sv-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
12 changes: 4 additions & 8 deletions packages/cli/commands/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const add = new Command('add')
options,
selectedAddons,
workspace,
withLogArgs: true
fromCommand: 'add'
});

if (nextSteps.length > 0) {
Expand Down Expand Up @@ -547,15 +547,15 @@ export async function runAddonsApply({
selectedAddons,
addonSetupResults,
workspace,
withLogArgs
fromCommand
}: {
answersOfficial: Record<string, OptionValues<any>>;
answersCommunity: Record<string, OptionValues<any>>;
options: Options;
selectedAddons: SelectedAddon[];
addonSetupResults?: Record<string, AddonSetupResult>;
workspace: Workspace;
withLogArgs?: boolean;
fromCommand: 'create' | 'add';
}): Promise<{ nextSteps: string[]; argsFormattedAddons: string[] }> {
if (!addonSetupResults) {
const setups = selectedAddons.length
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions packages/cli/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ async function createProject(cwd: ProjectPath, options: Options) {
},
selectedAddons,
addonSetupResults: undefined,
workspace
workspace,
fromCommand: 'create'
});
argsFormattedAddons = argsFormatted;

Expand All @@ -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);

Expand All @@ -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 ?? defaultPath]);

await addPnpmBuildDependencies(projectPath, packageManager, ['esbuild']);
if (packageManager) await installDependencies(packageManager, projectPath);
Expand Down
19 changes: 14 additions & 5 deletions packages/cli/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading