@herb-tools/formatter 0.4.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -15
- package/dist/herb-format.js +3379 -2212
- package/dist/herb-format.js.map +1 -1
- package/dist/index.cjs +2069 -901
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +2069 -902
- package/dist/index.esm.js.map +1 -1
- package/dist/types/format-printer.d.ts +243 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +5 -2
- package/src/cli.ts +57 -29
- package/src/format-printer.ts +1822 -0
- package/src/formatter.ts +2 -2
- package/src/index.ts +2 -3
- package/dist/types/printer.d.ts +0 -127
- package/src/printer.ts +0 -1644
package/README.md
CHANGED
|
@@ -11,46 +11,144 @@ Auto-formatter for HTML+ERB templates with intelligent indentation, line wrappin
|
|
|
11
11
|
|
|
12
12
|
Perfect for format-on-save in editors and formatting verification in CI/CD pipelines. Transforms templates into consistently formatted, readable code while preserving all functionality.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## Installation
|
|
15
15
|
|
|
16
|
+
### Global Installation
|
|
16
17
|
|
|
17
18
|
:::code-group
|
|
19
|
+
|
|
18
20
|
```shell [npm]
|
|
19
|
-
npm
|
|
21
|
+
npm install -g @herb-tools/formatter
|
|
20
22
|
```
|
|
21
23
|
|
|
22
24
|
```shell [pnpm]
|
|
23
|
-
pnpm add @herb-tools/formatter
|
|
25
|
+
pnpm add -g @herb-tools/formatter
|
|
24
26
|
```
|
|
25
27
|
|
|
26
28
|
```shell [yarn]
|
|
27
|
-
yarn add @herb-tools/formatter
|
|
29
|
+
yarn global add @herb-tools/formatter
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
```shell [bun]
|
|
31
|
-
bun add @herb-tools/formatter
|
|
33
|
+
bun add -g @herb-tools/formatter
|
|
32
34
|
```
|
|
33
|
-
:::
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
:::
|
|
36
37
|
|
|
38
|
+
Then run directly:
|
|
39
|
+
```bash
|
|
40
|
+
herb-format template.html.erb
|
|
41
|
+
```
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
### One-time Usage
|
|
44
|
+
For occasional use without installing:
|
|
39
45
|
|
|
40
46
|
```bash
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
npx @herb-tools/formatter template.html.erb
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Project Installation
|
|
51
|
+
|
|
52
|
+
:::code-group
|
|
53
|
+
|
|
54
|
+
```shell [npm]
|
|
55
|
+
npm add -D @herb-tools/formatter
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```shell [pnpm]
|
|
59
|
+
pnpm add -D @herb-tools/formatter
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```shell [yarn]
|
|
63
|
+
yarn add -D @herb-tools/formatter
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```shell [bun]
|
|
67
|
+
bun add -D @herb-tools/formatter
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
:::
|
|
71
|
+
|
|
72
|
+
After installing as a dev dependency, add format scripts to your `package.json`:
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"scripts": {
|
|
76
|
+
"herb:format": "herb-format",
|
|
77
|
+
"herb:format:check": "herb-format --check"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Then run the scripts:
|
|
83
|
+
|
|
84
|
+
:::code-group
|
|
43
85
|
|
|
44
|
-
|
|
45
|
-
herb
|
|
86
|
+
```shell [npm]
|
|
87
|
+
npm run herb:format
|
|
88
|
+
npm run herb:format:check
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```shell [pnpm]
|
|
92
|
+
pnpm herb:format
|
|
93
|
+
pnpm herb:format:check
|
|
46
94
|
```
|
|
47
95
|
|
|
48
|
-
|
|
96
|
+
```shell [yarn]
|
|
97
|
+
yarn herb:format
|
|
98
|
+
yarn herb:format:check
|
|
99
|
+
```
|
|
49
100
|
|
|
101
|
+
```shell [bun]
|
|
102
|
+
bun run herb:format
|
|
103
|
+
bun run herb:format:check
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
:::
|
|
107
|
+
|
|
108
|
+
## Usage
|
|
109
|
+
|
|
110
|
+
### Command Line
|
|
111
|
+
|
|
112
|
+
Basic usage:
|
|
50
113
|
```bash
|
|
114
|
+
herb-format
|
|
115
|
+
herb-format template.html.erb
|
|
116
|
+
herb-format templates/
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Options
|
|
120
|
+
|
|
121
|
+
**Check Mode:**
|
|
122
|
+
```bash
|
|
123
|
+
# Check if files are formatted without modifying them
|
|
124
|
+
herb-format --check template.html.erb
|
|
125
|
+
|
|
126
|
+
# Check all files in current directory
|
|
127
|
+
herb-format --check
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Input Sources:**
|
|
131
|
+
```bash
|
|
132
|
+
# Format specific file
|
|
133
|
+
herb-format templates/index.html.erb
|
|
134
|
+
|
|
135
|
+
# Format all .html.erb files in directory
|
|
136
|
+
herb-format templates/
|
|
137
|
+
|
|
138
|
+
# Format all .html.erb files in current directory (default)
|
|
139
|
+
herb-format
|
|
140
|
+
|
|
141
|
+
# Format from stdin
|
|
51
142
|
cat template.html.erb | herb-format
|
|
52
|
-
|
|
53
|
-
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Help and Version:**
|
|
146
|
+
```bash
|
|
147
|
+
# Show help
|
|
148
|
+
herb-format --help
|
|
149
|
+
|
|
150
|
+
# Show version information
|
|
151
|
+
herb-format --version
|
|
54
152
|
```
|
|
55
153
|
|
|
56
154
|
<!-- #### Configuration Options -->
|