Skip to content

Commit 6f14e7f

Browse files
authored
feat(cli)!: remove setup command (#432)
1 parent ecce7e6 commit 6f14e7f

6 files changed

Lines changed: 8 additions & 85 deletions

File tree

‎packages/rstack/src/cli/commandHelp.ts‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ export type HelpTopic =
4646
| 'fmt'
4747
| 'staged'
4848
| 'hooks'
49-
| 'hooks uninstall'
50-
| 'setup';
49+
| 'hooks uninstall';
5150

5251
const CONFIG_OPTION: HelpItem = [
5352
'-c, --config <path>',
@@ -528,23 +527,6 @@ const HELP_DEFINITIONS = {
528527
},
529528
],
530529
},
531-
setup: {
532-
usage: 'rs setup [options]',
533-
description: 'Install Git hooks in the current repository',
534-
sections: [
535-
{
536-
title: 'Options',
537-
items: [
538-
['-f, --force', 'Install despite an existing Git hooks setup'],
539-
[
540-
'--hooks-dir <path>',
541-
'Specify hooks directory relative to the Git repository root',
542-
],
543-
HELP_OPTION,
544-
],
545-
},
546-
],
547-
},
548530
} satisfies Record<HelpTopic, HelpDefinition>;
549531

550532
const renderItems = (items: readonly HelpItem[]): string => {

‎packages/rstack/src/cli/commands.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,12 @@ export async function setupCommands(): Promise<void> {
252252
return;
253253
}
254254

255-
if (command === 'hooks' || command === 'setup') {
255+
if (command === 'hooks') {
256256
const { runHooksCLI } = await import(
257257
/* rspackChunkName: 'hooks' */
258258
'../setup/index.ts'
259259
);
260-
await runHooksCLI(args.slice(1), command);
260+
await runHooksCLI(args.slice(1));
261261
return;
262262
}
263263

‎packages/rstack/src/setup/index.ts‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import { printCommandHelp } from '../cli/help.ts';
44
import { installHooks } from './install.ts';
55
import { uninstallHooks } from './uninstall.ts';
66

7-
const runInstallCLI = async (
8-
args: string[],
9-
command: 'hooks' | 'setup',
10-
): Promise<void> => {
7+
const runInstallCLI = async (args: string[]): Promise<void> => {
118
const { values } = parseArgs({
129
args,
1310
options: {
@@ -29,7 +26,7 @@ const runInstallCLI = async (
2926
const hooksDir = hooksDirs?.[0];
3027

3128
if (values.help) {
32-
await printCommandHelp(command);
29+
await printCommandHelp('hooks');
3330
return;
3431
}
3532

@@ -122,14 +119,11 @@ const runUninstallCLI = async (args: string[]): Promise<void> => {
122119
throw new Error(result.message);
123120
};
124121

125-
export const runHooksCLI = async (
126-
args: string[],
127-
command: 'hooks' | 'setup' = 'hooks',
128-
): Promise<void> => {
129-
if (command === 'hooks' && args[0] === 'uninstall') {
122+
export const runHooksCLI = async (args: string[]): Promise<void> => {
123+
if (args[0] === 'uninstall') {
130124
await runUninstallCLI(args.slice(1));
131125
return;
132126
}
133127

134-
await runInstallCLI(args, command);
128+
await runInstallCLI(args);
135129
};

‎packages/rstack/tests/cli/setup/index.test.ts‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎website/docs/en/guide/cli/hooks.mdx‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ rs hooks uninstall
1717

1818
Run `rs hooks` without a subcommand to install or update hooks.
1919

20-
:::tip Alias
21-
`rs setup` is an alias for `rs hooks`.
22-
:::
23-
2420
## Install hooks
2521

2622
By default, hook scripts are stored in `.rstack/hooks` at the Git repository root. If the current directory is outside a Git repository, the command skips installation.

‎website/docs/zh/guide/cli/hooks.mdx‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ rs hooks uninstall
1717

1818
直接运行 `rs hooks` 即可安装或更新 hooks。
1919

20-
:::tip 别名
21-
`rs setup` 是 `rs hooks` 的别名。
22-
:::
23-
2420
## 安装 hooks \{#install-hooks}
2521

2622
hook 脚本默认存放在 Git 仓库根目录的 `.rstack/hooks` 中。如果当前目录不在 Git 仓库内,命令会跳过安装。

0 commit comments

Comments
 (0)