or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli-tools.mdeslint-configuration.mdindex.mdprettier-configuration.mdstylelint-configuration.md

cli-tools.mddocs/

0

# CLI Tools

1

2

@umijs/fabric provides command-line utilities for code quality validation and commit message verification through the `fabric` CLI command.

3

4

## Installation and Access

5

6

```bash

7

# Install the package

8

npm install @umijs/fabric --save-dev

9

10

# Use the CLI directly

11

npx fabric [command] [options]

12

13

# Or if installed globally

14

npm install -g @umijs/fabric

15

fabric [command] [options]

16

```

17

18

## CLI Commands

19

20

### Main Command

21

22

```bash { .api }

23

# Main CLI entry point

24

fabric [command] [options]

25

```

26

27

### Version Information

28

29

```bash { .api }

30

# Display package version

31

fabric --version

32

fabric -v

33

34

# Output format:

35

# 3.0.0

36

# @local (if development version)

37

```

38

39

### Help Information

40

41

```bash { .api }

42

# Display help information

43

fabric --help

44

fabric -h

45

46

# Shows available commands and usage examples

47

```

48

49

### Commit Verification

50

51

```bash { .api }

52

# Verify commit message format (used with git hooks)

53

fabric verify-commit

54

55

# Validates commit messages against conventional commit format

56

# Typically used via git hooks, not directly by users

57

```

58

59

## Commit Message Verification

60

61

### Overview

62

63

The `verify-commit` command validates git commit messages against a conventional commit format with emoji support and localized error messages.

64

65

```typescript { .api }

66

/**

67

* Commit message validation regular expression

68

* Supports emoji, conventional types, scope, and message format

69

*/

70

const commitRE: RegExp = /^(((\ud83c[\udf00-\udfff])|(\ud83d[\udc00-\ude4f\ude80-\udeff])|[\u2600-\u2B55]) )?(revert: )?(feat|fix|docs|UI|refactor|perf|workflow|build|CI|typos|chore|tests|types|wip|release|dep|locale)(\(.+\))?: .{1,50}/;

71

```

72

73

### Supported Commit Types

74

75

```typescript { .api }

76

/**

77

* Valid commit types for conventional commits

78

*/

79

type CommitType =

80

| 'feat' // New features

81

| 'fix' // Bug fixes

82

| 'docs' // Documentation changes

83

| 'UI' // User interface changes

84

| 'refactor' // Code refactoring

85

| 'perf' // Performance improvements

86

| 'workflow' // Workflow changes

87

| 'build' // Build system changes

88

| 'CI' // Continuous integration changes

89

| 'typos' // Typo fixes

90

| 'chore' // Maintenance tasks

91

| 'tests' // Test additions or modifications

92

| 'types' // Type definition changes

93

| 'wip' // Work in progress

94

| 'release' // Release preparation

95

| 'dep' // Dependency updates

96

| 'locale'; // Internationalization changes

97

```

98

99

### Commit Format

100

101

```bash { .api }

102

# Basic format

103

[<emoji>] [revert: ?]<type>[(scope)?]: <message>

104

105

# Examples:

106

💥 feat(compiler): add 'comments' option

107

🐛 fix(compiler): fix some bug

108

📝 docs(compiler): add some docs

109

🌷 UI(compiler): better styles

110

🏰 chore(compiler): Made some changes to the scaffolding

111

🌐 locale(compiler): Made a small contribution to internationalization

112

113

# Without emoji:

114

feat(api): add user authentication

115

fix: resolve memory leak in cache

116

docs: update installation instructions

117

```

118

119

### Environment Variables

120

121

```typescript { .api }

122

/**

123

* Environment variables used by commit verification

124

*/

125

interface CommitVerificationEnv {

126

/**

127

* Git hook parameter (legacy)

128

*/

129

GIT_PARAMS?: string;

130

131

/**

132

* Husky git hook parameter (modern)

133

*/

134

HUSKY_GIT_PARAMS?: string;

135

}

136

```

137

138

### Localization Support

139

140

The verification tool provides localized error messages:

141

142

```typescript { .api }

143

/**

144

* Supported locales for error messages

145

*/

146

type SupportedLocale = 'zh-CN' | 'en-US';

147

148

/**

149

* Get system locale for error message localization

150

* @returns Promise resolving to locale string

151

*/

152

function getLocale(): Promise<string>;

153

```

154

155

## Git Hooks Integration

156

157

### Husky Integration

158

159

```json

160

// package.json

161

{

162

"husky": {

163

"hooks": {

164

"commit-msg": "fabric verify-commit"

165

}

166

}

167

}

168

```

169

170

### Manual Git Hook

171

172

```bash

173

#!/bin/sh

174

# .git/hooks/commit-msg

175

176

npx fabric verify-commit

177

```

178

179

### Yorkie Integration

180

181

```json

182

// package.json

183

{

184

"gitHooks": {

185

"commit-msg": "fabric verify-commit"

186

}

187

}

188

```

189

190

## Usage Examples

191

192

### Basic Help

193

194

```bash

195

# Display help information

196

$ fabric --help

197

198

Commands:

199

verify-commit 检查 commit 提交的信息

200

201

Examples:

202

fabric

203

fabric -h

204

verify-commit

205

fabric verify-commit

206

```

207

208

### Version Check

209

210

```bash

211

# Check installed version

212

$ fabric --version

213

3.0.0

214

215

# Development version

216

$ fabric -v

217

3.0.0

218

@local

219

```

220

221

### Commit Message Validation

222

223

```bash

224

# This command is typically called by git hooks

225

# It reads the commit message from git parameters

226

$ fabric verify-commit

227

228

# Success: no output (exit code 0)

229

# Failure: formatted error message (exit code 1)

230

```

231

232

## Error Messages

233

234

### English Error Format

235

236

```text

237

ERROR invalid commit message format.

238

239

Proper commit message format is required for automated changelog generation. Examples:

240

241

[<emoji>] [revert: ?]<type>[(scope)?]: <message>

242

243

💥 feat(compiler): add 'comments' option

244

🐛 fix(compiler): fix some bug

245

📝 docs(compiler): add some docs

246

🌷 UI(compiler): better styles

247

🏰 chore(compiler): Made some changes to the scaffolding

248

🌐 locale(compiler): Made a small contribution to internationalization

249

250

Other commit types: refactor, perf, workflow, build, CI, typos, tests, types, wip, release, dep

251

252

See https://github.com/vuejs/core/blob/main/.github/commit-convention.md

253

```

254

255

### Chinese Error Format

256

257

```text

258

ERROR 提交日志不符合规范

259

260

合法的提交日志格式如下(emoji 和 模块可选填):

261

262

[<emoji>] [revert: ?]<type>[(scope)?]: <message>

263

264

💥 feat(模块): 添加了个很棒的功能

265

🐛 fix(模块): 修复了一些 bug

266

📝 docs(模块): 更新了一下文档

267

🌷 UI(模块): 修改了一下样式

268

🏰 chore(模块): 对脚手架做了些更改

269

🌐 locale(模块): 为国际化做了微小的贡献

270

271

其他提交类型: refactor, perf, workflow, build, CI, typos, tests, types, wip, release, dep

272

273

See https://github.com/vuejs/core/blob/main/.github/commit-convention.md

274

```

275

276

## Node.js Version Requirements

277

278

```typescript { .api }

279

/**

280

* Minimum Node.js version requirement

281

*/

282

const MIN_NODE_VERSION = '8.0.0';

283

284

/**

285

* Check if current Node.js version meets requirements

286

* Exits with error if version is too old

287

*/

288

function checkNodeVersion(): void;

289

```

290

291

The CLI tools require Node.js version 8.0.0 or higher and will display an error message if an older version is detected.

292

293

## Development and Local Builds

294

295

The CLI detects local development builds:

296

297

```typescript { .api }

298

/**

299

* Check if running a local development build

300

* @returns true if .local file exists in package directory

301

*/

302

function isLocalBuild(): boolean;

303

```

304

305

When a `.local` file is present in the package directory, the version command will display `@local` to indicate a development build.

306

307

## Integration with Development Workflows

308

309

### Pre-commit Hooks

310

311

```json

312

{

313

"lint-staged": {

314

"*.{js,jsx,ts,tsx}": [

315

"eslint --fix",

316

"git add"

317

]

318

},

319

"husky": {

320

"hooks": {

321

"pre-commit": "lint-staged",

322

"commit-msg": "fabric verify-commit"

323

}

324

}

325

}

326

```

327

328

### CI/CD Integration

329

330

```yaml

331

# GitHub Actions example

332

- name: Validate commit message

333

run: |

334

if [ "${{ github.event_name }}" = "push" ]; then

335

echo "${{ github.event.head_commit.message }}" | npx fabric verify-commit

336

fi

337

```

338

339

The CLI tools integrate seamlessly with existing development workflows and continuous integration systems to maintain code quality standards.