or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli-usage.mdindex.mdsafe-transforms.mdunsafe-transforms.md
tile.json

cli-usage.mddocs/

0

# CLI Usage

1

2

Lebab provides a comprehensive command-line interface for transforming JavaScript files in batch operations.

3

4

## Installation

5

6

```bash

7

# Global installation for CLI usage

8

npm install -g lebab

9

10

# Local installation for project-specific usage

11

npm install lebab

12

```

13

14

## Capabilities

15

16

### Basic File Transformation

17

18

Transform a single file with specified transforms.

19

20

```bash { .api }

21

# Basic syntax

22

lebab <input-file> -o <output-file> --transform <transforms>

23

24

# Examples

25

lebab es5.js -o es6.js --transform let

26

lebab old-code.js -o modern-code.js --transform let,arrow,arrow-return

27

```

28

29

### In-Place Directory Transformation

30

31

Transform all files in a directory or matching a pattern.

32

33

```bash { .api }

34

# Transform all .js files in directory

35

lebab --replace src/js/ --transform arrow

36

37

# Transform with specific glob patterns

38

lebab --replace 'src/js/**/*.jsx' --transform arrow

39

lebab --replace 'lib/**/*.js' --transform let,arrow

40

41

# Transform multiple file types

42

lebab --replace 'src/**/*.{js,jsx}' --transform class,commonjs

43

```

44

45

### Transform Options

46

47

Specify which transformations to apply.

48

49

```bash { .api }

50

# Single transform

51

--transform let

52

-t let

53

54

# Multiple transforms (comma-separated)

55

--transform let,arrow,arrow-return

56

-t class,template,obj-shorthand

57

58

# All safe transforms

59

--transform arrow,arrow-return,for-of,for-each,arg-rest,arg-spread,obj-method,obj-shorthand,no-strict,exponent,multi-var

60

61

# Common unsafe transforms

62

--transform let,class,commonjs,template,default-param

63

```

64

65

### Command Options

66

67

```bash { .api }

68

# Show help

69

lebab --help

70

lebab -h

71

72

# Show version

73

lebab --version

74

lebab -v

75

76

# Input/output options

77

--out-file <file> # Specify output file

78

-o <file> # Alias for --out-file

79

80

--replace <pattern> # In-place transformation with glob pattern

81

-r <pattern> # Alias for --replace

82

83

--transform <list> # Comma-separated transform names

84

-t <list> # Alias for --transform

85

```

86

87

## Usage Examples

88

89

### Modernizing Legacy Code

90

91

```bash

92

# Start with safe transforms

93

lebab --replace 'src/**/*.js' --transform arrow,arrow-return,obj-method,obj-shorthand

94

95

# Add variable declarations

96

lebab --replace 'src/**/*.js' --transform let

97

98

# Convert to classes (review output carefully)

99

lebab --replace 'src/**/*.js' --transform class

100

101

# Convert to ES6 modules (review imports/exports)

102

lebab --replace 'src/**/*.js' --transform commonjs

103

```

104

105

### Step-by-Step Modernization

106

107

```bash

108

# Step 1: Safe syntax improvements

109

lebab old-app.js -o step1.js --transform arrow,obj-method,obj-shorthand

110

111

# Step 2: Variable declarations

112

lebab step1.js -o step2.js --transform let

113

114

# Step 3: Template literals

115

lebab step2.js -o step3.js --transform template

116

117

# Step 4: Modern features

118

lebab step3.js -o modern-app.js --transform default-param,arg-spread,includes

119

```

120

121

### Processing Specific Frameworks

122

123

```bash

124

# React components

125

lebab --replace 'src/components/**/*.jsx' --transform let,arrow,class,obj-method

126

127

# Node.js modules

128

lebab --replace 'lib/**/*.js' --transform let,arrow,commonjs,template

129

130

# Express.js applications

131

lebab --replace 'routes/**/*.js' --transform let,arrow,default-param,arg-spread

132

```

133

134

## Output and Warnings

135

136

The CLI provides detailed feedback about the transformation process:

137

138

```bash

139

# Example output with warnings

140

$ lebab problematic.js -o result.js --transform let

141

142

problematic.js:

143

5: warning Unable to transform var (let)

144

12: warning Variable used before declaration (let)

145

146

# Successful transformation

147

$ lebab simple.js -o result.js --transform arrow

148

149

# No output indicates successful transformation

150

```

151

152

### Warning Types

153

154

Common warning messages and their meanings:

155

156

- `Unable to transform var (let)` - Variable cannot be safely converted to let/const

157

- `Variable used before declaration (let)` - Temporal dead zone issues

158

- `Cannot convert to arrow function (arrow)` - Function uses `this` or `arguments`

159

- `Potential prototype conflict (class)` - Class conversion may affect prototype chain

160

161

## Best Practices

162

163

### Recommended Workflow

164

165

1. **Start with safe transforms** - Apply low-risk transforms first

166

2. **One transform at a time** - Apply transforms individually to review changes

167

3. **Test thoroughly** - Run tests after each transformation

168

4. **Review diffs** - Manually inspect all changes, especially for unsafe transforms

169

5. **Version control** - Commit between transformation steps

170

171

### Transform Order Recommendations

172

173

```bash

174

# Recommended order for comprehensive modernization

175

lebab --replace 'src/**/*.js' --transform multi-var # 1. Split declarations

176

lebab --replace 'src/**/*.js' --transform obj-shorthand # 2. Object syntax

177

lebab --replace 'src/**/*.js' --transform obj-method # 3. Method syntax

178

lebab --replace 'src/**/*.js' --transform let # 4. Variable declarations

179

lebab --replace 'src/**/*.js' --transform arrow # 5. Arrow functions

180

lebab --replace 'src/**/*.js' --transform arrow-return # 6. Concise arrows

181

lebab --replace 'src/**/*.js' --transform class # 7. ES6 classes

182

lebab --replace 'src/**/*.js' --transform template # 8. Template literals

183

lebab --replace 'src/**/*.js' --transform commonjs # 9. ES6 modules (last)

184

```

185

186

### Error Prevention

187

188

```bash

189

# Always backup before in-place transforms

190

cp -r src src-backup

191

lebab --replace 'src/**/*.js' --transform let

192

193

# Use version control

194

git add -A

195

git commit -m "Before lebab transformation"

196

lebab --replace 'src/**/*.js' --transform arrow

197

git diff # Review changes

198

```