thrift-support 3.0.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/LICENSE +21 -0
- package/README.md +143 -0
- package/dist/cli.js +9811 -0
- package/dist/cli.js.map +7 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 tanzz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# thrift-support
|
|
2
|
+
|
|
3
|
+
CLI tool for Apache Thrift IDL: format, lint, parse, and list symbols.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/thrift-support)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g thrift-support
|
|
12
|
+
# or as a dev dependency
|
|
13
|
+
npm install --save-dev thrift-support
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Commands
|
|
17
|
+
|
|
18
|
+
### `format`
|
|
19
|
+
|
|
20
|
+
Format one or more Thrift IDL files.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
thrift-support format [options] <files...>
|
|
24
|
+
|
|
25
|
+
Options:
|
|
26
|
+
--check Exit 1 if any file is not formatted (CI mode)
|
|
27
|
+
--write, -w Write formatted output back to files
|
|
28
|
+
--stdin Read from stdin, write to stdout
|
|
29
|
+
--stdin-filepath <p> Filepath hint used with --stdin for config lookup
|
|
30
|
+
--indent-size <n> Spaces per indent level (default: 4)
|
|
31
|
+
--max-line-length <n> Target max line length (default: 100)
|
|
32
|
+
--trailing-comma <m> preserve | add | remove (default: preserve)
|
|
33
|
+
--collection-style <m> preserve | multiline | auto (default: preserve)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Check formatting in CI
|
|
40
|
+
thrift-support format --check src/**/*.thrift
|
|
41
|
+
|
|
42
|
+
# Format all files in a directory
|
|
43
|
+
thrift-support format --write src/
|
|
44
|
+
|
|
45
|
+
# Pipe through stdin
|
|
46
|
+
cat myfile.thrift | thrift-support format --stdin
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### `lint`
|
|
50
|
+
|
|
51
|
+
Run diagnostic rules (syntax checks, semantic checks, include validation).
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
thrift-support lint [options] <files...>
|
|
55
|
+
|
|
56
|
+
Options:
|
|
57
|
+
--severity <level> error | warning | all (default: all)
|
|
58
|
+
--json Output results as JSON
|
|
59
|
+
--include-path <dir> Directory to search for included files (repeatable)
|
|
60
|
+
--quiet, -q Suppress output when no issues found
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Examples:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Lint with all severities
|
|
67
|
+
thrift-support lint src/**/*.thrift
|
|
68
|
+
|
|
69
|
+
# CI: fail only on errors, JSON output
|
|
70
|
+
thrift-support lint --severity error --json src/**/*.thrift
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### `parse`
|
|
74
|
+
|
|
75
|
+
Parse a Thrift file and output the AST as JSON.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
thrift-support parse [options] <file>
|
|
79
|
+
thrift-support parse --stdin
|
|
80
|
+
|
|
81
|
+
Options:
|
|
82
|
+
--stdin Read source from stdin
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### `symbols`
|
|
86
|
+
|
|
87
|
+
List all symbols (structs, enums, services, typedefs, etc.) defined in a file.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
thrift-support symbols [options] <file>
|
|
91
|
+
|
|
92
|
+
Options:
|
|
93
|
+
--json Output as JSON array
|
|
94
|
+
--flat Flat output (no indentation / nesting)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Configuration
|
|
98
|
+
|
|
99
|
+
The CLI resolves options in this order (highest priority first):
|
|
100
|
+
|
|
101
|
+
1. CLI flags
|
|
102
|
+
2. `--config <path>` flag
|
|
103
|
+
3. `.thriftrc.json` found by searching upward from the target file
|
|
104
|
+
4. Built-in defaults
|
|
105
|
+
|
|
106
|
+
`.thriftrc.json` example:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"format": {
|
|
111
|
+
"indentSize": 4,
|
|
112
|
+
"trailingComma": "add",
|
|
113
|
+
"alignTypes": true,
|
|
114
|
+
"alignNames": true,
|
|
115
|
+
"alignAssignments": true,
|
|
116
|
+
"alignComments": true,
|
|
117
|
+
"maxLineLength": 100,
|
|
118
|
+
"collectionStyle": "preserve"
|
|
119
|
+
},
|
|
120
|
+
"lint": {
|
|
121
|
+
"severity": "error"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Exit Codes
|
|
127
|
+
|
|
128
|
+
| Code | Meaning |
|
|
129
|
+
|------|---------|
|
|
130
|
+
| `0` | Success |
|
|
131
|
+
| `1` | Lint errors found, or `--check` detected unformatted files |
|
|
132
|
+
| `2` | Usage / argument error |
|
|
133
|
+
| `3` | Internal error (parse failure, file I/O error, etc.) |
|
|
134
|
+
|
|
135
|
+
## Relation to the VS Code Extension
|
|
136
|
+
|
|
137
|
+
This package contains the same formatting and diagnostic engine as the
|
|
138
|
+
[Thrift Support VS Code extension](https://marketplace.visualstudio.com/items?itemName=tanzz.thrift-support).
|
|
139
|
+
Options map directly to `thrift.format.*` settings in VS Code.
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT — see [LICENSE](LICENSE).
|