1ls 0.0.1
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 +335 -0
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/parser.d.ts +2 -0
- package/dist/formatter/colors.d.ts +6 -0
- package/dist/formatter/output.d.ts +15 -0
- package/dist/index.js +110 -0
- package/dist/navigator/json.d.ts +8 -0
- package/dist/parser/lexer.d.ts +21 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/types.d.ts +99 -0
- package/dist/utils/constants.d.ts +11 -0
- package/dist/utils/file.d.ts +6 -0
- package/dist/utils/logger.d.ts +22 -0
- package/dist/utils/parsers.d.ts +8 -0
- package/dist/utils/shortcuts.d.ts +8 -0
- package/dist/utils/stream.d.ts +2 -0
- package/dist/utils/types.d.ts +38 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# 1ls - One Line Script
|
|
2
|
+
|
|
3
|
+
A lightweight, fast JSON/YAML/CSV processor with JavaScript syntax. Built with Bun for blazing performance.
|
|
4
|
+
|
|
5
|
+
## Why 1ls?
|
|
6
|
+
|
|
7
|
+
- **JavaScript Syntax**: Use familiar JavaScript array methods and syntax instead of learning jq's DSL
|
|
8
|
+
- **Multi-format**: Works with JSON, YAML, TOML, CSV, TSV out of the box
|
|
9
|
+
- **Fast**: Built with Bun for exceptional performance
|
|
10
|
+
- **Intuitive**: Property access with dot notation, just like JavaScript
|
|
11
|
+
- **Powerful**: Full support for array methods, arrow functions, and object operations
|
|
12
|
+
- **Shortcuts**: Built-in shortcuts for common operations (e.g., `.mp` for `.map`)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Using Bun
|
|
18
|
+
bun install -g 1ls
|
|
19
|
+
|
|
20
|
+
# Using npm
|
|
21
|
+
npm install -g 1ls
|
|
22
|
+
|
|
23
|
+
# Using curl
|
|
24
|
+
curl -fsSL https://raw.githubusercontent.com/yowainwright/1ls/main/install.sh | bash
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Get a property
|
|
31
|
+
echo '{"name": "John", "age": 30}' | 1ls '.name'
|
|
32
|
+
# Output: "John"
|
|
33
|
+
|
|
34
|
+
# Array operations
|
|
35
|
+
echo '[1, 2, 3, 4, 5]' | 1ls '.filter(x => x > 2)'
|
|
36
|
+
# Output: [3, 4, 5]
|
|
37
|
+
|
|
38
|
+
# Map with arrow functions
|
|
39
|
+
echo '[1, 2, 3]' | 1ls '.map(x => x * 2)'
|
|
40
|
+
# Output: [2, 4, 6]
|
|
41
|
+
|
|
42
|
+
# Chain operations
|
|
43
|
+
echo '[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]' | 1ls '.filter(x => x.age > 26).map(x => x.name)'
|
|
44
|
+
# Output: ["Alice"]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Examples
|
|
48
|
+
|
|
49
|
+
### Working with JSON
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Access nested properties
|
|
53
|
+
echo '{"user": {"name": "John", "posts": [1, 2, 3]}}' | 1ls '.user.name'
|
|
54
|
+
|
|
55
|
+
# Array indexing (negative indexes supported)
|
|
56
|
+
echo '["first", "second", "third"]' | 1ls '.[0]' # "first"
|
|
57
|
+
echo '["first", "second", "third"]' | 1ls '.[-1]' # "third"
|
|
58
|
+
|
|
59
|
+
# Array slicing
|
|
60
|
+
echo '[1, 2, 3, 4, 5]' | 1ls '.[1:3]' # [2, 3]
|
|
61
|
+
echo '[1, 2, 3, 4, 5]' | 1ls '.[:2]' # [1, 2]
|
|
62
|
+
echo '[1, 2, 3, 4, 5]' | 1ls '.[2:]' # [3, 4, 5]
|
|
63
|
+
|
|
64
|
+
# Object operations
|
|
65
|
+
echo '{"a": 1, "b": 2, "c": 3}' | 1ls '.{keys}' # ["a", "b", "c"]
|
|
66
|
+
echo '{"a": 1, "b": 2, "c": 3}' | 1ls '.{values}' # [1, 2, 3]
|
|
67
|
+
echo '{"a": 1, "b": 2, "c": 3}' | 1ls '.{entries}' # [["a", 1], ["b", 2], ["c", 3]]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Array Methods
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Filter
|
|
74
|
+
echo '[1, 2, 3, 4, 5]' | 1ls '.filter(x => x % 2 === 0)'
|
|
75
|
+
# Output: [2, 4]
|
|
76
|
+
|
|
77
|
+
# Map
|
|
78
|
+
echo '["hello", "world"]' | 1ls '.map(x => x.toUpperCase())'
|
|
79
|
+
# Output: ["HELLO", "WORLD"]
|
|
80
|
+
|
|
81
|
+
# Reduce
|
|
82
|
+
echo '[1, 2, 3, 4]' | 1ls '.reduce((sum, x) => sum + x, 0)'
|
|
83
|
+
# Output: 10
|
|
84
|
+
|
|
85
|
+
# Find
|
|
86
|
+
echo '[{"id": 1}, {"id": 2}, {"id": 3}]' | 1ls '.find(x => x.id === 2)'
|
|
87
|
+
# Output: {"id": 2}
|
|
88
|
+
|
|
89
|
+
# Some/Every
|
|
90
|
+
echo '[2, 4, 6]' | 1ls '.every(x => x % 2 === 0)' # true
|
|
91
|
+
echo '[1, 2, 3]' | 1ls '.some(x => x > 2)' # true
|
|
92
|
+
|
|
93
|
+
# Chaining methods
|
|
94
|
+
echo '[1, 2, 3, 4, 5]' | 1ls '.filter(x => x > 2).map(x => x * 2)'
|
|
95
|
+
# Output: [6, 8, 10]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Multi-format Support
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# YAML input
|
|
102
|
+
echo 'name: John
|
|
103
|
+
age: 30
|
|
104
|
+
city: NYC' | 1ls '.name'
|
|
105
|
+
# Output: "John"
|
|
106
|
+
|
|
107
|
+
# CSV input
|
|
108
|
+
echo 'name,age
|
|
109
|
+
John,30
|
|
110
|
+
Jane,25' | 1ls '.map(x => x.name)'
|
|
111
|
+
# Output: ["John", "Jane"]
|
|
112
|
+
|
|
113
|
+
# Specify input format explicitly
|
|
114
|
+
cat data.yaml | 1ls --input-format yaml '.users[0].name'
|
|
115
|
+
cat data.csv | 1ls --input-format csv '.filter(x => x.age > 25)'
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### File Operations
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Read from file
|
|
122
|
+
1ls readFile data.json '.users.filter(x => x.active)'
|
|
123
|
+
|
|
124
|
+
# List files
|
|
125
|
+
1ls --list . --recursive --ext .json
|
|
126
|
+
|
|
127
|
+
# Grep files
|
|
128
|
+
1ls --grep "TODO" --find . --recursive
|
|
129
|
+
|
|
130
|
+
# With line numbers
|
|
131
|
+
1ls --grep "function" --find ./src --line-numbers
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Shortcuts
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Use shortcuts for common operations
|
|
138
|
+
echo '[1, 2, 3]' | 1ls '.mp(x => x * 2)' # Short for .map()
|
|
139
|
+
echo '[1, 2, 3]' | 1ls '.flt(x => x > 1)' # Short for .filter()
|
|
140
|
+
echo '["a", "b"]' | 1ls '.jn(",")' # Short for .join()
|
|
141
|
+
|
|
142
|
+
# Show all shortcuts
|
|
143
|
+
1ls --shortcuts
|
|
144
|
+
|
|
145
|
+
# Expand shortcuts
|
|
146
|
+
1ls --expand ".mp(x => x * 2)" # Output: .map(x => x * 2)
|
|
147
|
+
|
|
148
|
+
# Shorten expression
|
|
149
|
+
1ls --shorten ".map(x => x * 2)" # Output: .mp(x => x * 2)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## CLI Options
|
|
153
|
+
|
|
154
|
+
### Basic Options
|
|
155
|
+
|
|
156
|
+
| Option | Short | Description |
|
|
157
|
+
|--------|-------|-------------|
|
|
158
|
+
| `--help` | `-h` | Show help |
|
|
159
|
+
| `--version` | `-v` | Show version |
|
|
160
|
+
| `--raw` | `-r` | Output raw strings, not JSON |
|
|
161
|
+
| `--pretty` | `-p` | Pretty print output |
|
|
162
|
+
| `--compact` | `-c` | Compact output |
|
|
163
|
+
| `--type` | `-t` | Show type of result |
|
|
164
|
+
|
|
165
|
+
### Format Options
|
|
166
|
+
|
|
167
|
+
| Option | Description | Values |
|
|
168
|
+
|--------|-------------|--------|
|
|
169
|
+
| `--format` | Output format | `json`, `yaml`, `csv`, `table` |
|
|
170
|
+
| `--input-format`, `-if` | Input format | `json`, `yaml`, `toml`, `csv`, `tsv`, `lines`, `text` |
|
|
171
|
+
|
|
172
|
+
### File Operations
|
|
173
|
+
|
|
174
|
+
| Option | Short | Description |
|
|
175
|
+
|--------|-------|-------------|
|
|
176
|
+
| `readFile` | | Read JSON from file |
|
|
177
|
+
| `--list` | `-l` | List files in directory |
|
|
178
|
+
| `--find` | `-f` | Find files matching pattern |
|
|
179
|
+
| `--grep` | `-g` | Search for pattern in files |
|
|
180
|
+
| `--recursive` | `-R` | Recursive search |
|
|
181
|
+
| `--ignore-case` | `-i` | Case insensitive search |
|
|
182
|
+
| `--line-numbers` | `-n` | Show line numbers |
|
|
183
|
+
| `--ext` | | Filter by extensions (comma-separated) |
|
|
184
|
+
| `--max-depth` | | Maximum depth for recursive operations |
|
|
185
|
+
|
|
186
|
+
### Shortcut Operations
|
|
187
|
+
|
|
188
|
+
| Option | Description |
|
|
189
|
+
|--------|-------------|
|
|
190
|
+
| `--shortcuts` | Show all available shortcuts |
|
|
191
|
+
| `--expand` | Expand shortcuts to full syntax |
|
|
192
|
+
| `--shorten` | Convert to shortcut syntax |
|
|
193
|
+
|
|
194
|
+
## API Reference
|
|
195
|
+
|
|
196
|
+
### Property Access
|
|
197
|
+
- `.property` - Access object property
|
|
198
|
+
- `["property"]` - Access property with brackets
|
|
199
|
+
- `.[index]` - Array index access (negative indexes supported)
|
|
200
|
+
- `.[start:end]` - Array slice
|
|
201
|
+
- `.[]` - Array spread
|
|
202
|
+
|
|
203
|
+
### Object Operations
|
|
204
|
+
- `.{keys}` - Get object keys
|
|
205
|
+
- `.{values}` - Get object values
|
|
206
|
+
- `.{entries}` - Get object entries
|
|
207
|
+
- `.{length}` - Get length
|
|
208
|
+
|
|
209
|
+
### Array Methods
|
|
210
|
+
All standard JavaScript array methods are supported:
|
|
211
|
+
- `.map()`, `.filter()`, `.reduce()`
|
|
212
|
+
- `.find()`, `.findIndex()`
|
|
213
|
+
- `.some()`, `.every()`
|
|
214
|
+
- `.sort()`, `.reverse()`
|
|
215
|
+
- `.slice()`, `.splice()`
|
|
216
|
+
- `.join()`, `.split()`
|
|
217
|
+
- `.includes()`, `.indexOf()`
|
|
218
|
+
- `.flat()`, `.flatMap()`
|
|
219
|
+
|
|
220
|
+
### String Methods
|
|
221
|
+
- `.toLowerCase()`, `.toUpperCase()`
|
|
222
|
+
- `.trim()`, `.trimStart()`, `.trimEnd()`
|
|
223
|
+
- `.replace()`, `.replaceAll()`
|
|
224
|
+
- `.startsWith()`, `.endsWith()`
|
|
225
|
+
- `.substring()`, `.charAt()`
|
|
226
|
+
- `.match()`, `.split()`
|
|
227
|
+
|
|
228
|
+
### Arrow Functions
|
|
229
|
+
Full support for arrow functions in method calls:
|
|
230
|
+
```bash
|
|
231
|
+
.map(x => x * 2)
|
|
232
|
+
.filter((item, index) => index > 0)
|
|
233
|
+
.reduce((acc, val) => acc + val, 0)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Advanced Examples
|
|
237
|
+
|
|
238
|
+
### Complex Data Processing
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Process API response
|
|
242
|
+
curl https://api.github.com/users/github/repos | 1ls \
|
|
243
|
+
'.filter(x => !x.fork)
|
|
244
|
+
.map(x => ({name: x.name, stars: x.stargazers_count}))
|
|
245
|
+
.sort((a, b) => b.stars - a.stars)
|
|
246
|
+
.slice(0, 5)'
|
|
247
|
+
|
|
248
|
+
# Extract and transform nested data
|
|
249
|
+
echo '{
|
|
250
|
+
"users": [
|
|
251
|
+
{"name": "Alice", "posts": [{"title": "Post 1"}, {"title": "Post 2"}]},
|
|
252
|
+
{"name": "Bob", "posts": [{"title": "Post 3"}]}
|
|
253
|
+
]
|
|
254
|
+
}' | 1ls '.users.flatMap(u => u.posts.map(p => ({user: u.name, title: p.title})))'
|
|
255
|
+
|
|
256
|
+
# Group and aggregate
|
|
257
|
+
echo '[
|
|
258
|
+
{"category": "A", "value": 10},
|
|
259
|
+
{"category": "B", "value": 20},
|
|
260
|
+
{"category": "A", "value": 30}
|
|
261
|
+
]' | 1ls '.reduce((acc, item) => {
|
|
262
|
+
acc[item.category] = (acc[item.category] || 0) + item.value;
|
|
263
|
+
return acc;
|
|
264
|
+
}, {})'
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Working with Files
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Find all JSON files and extract specific fields
|
|
271
|
+
1ls --list ./data --recursive --ext .json | \
|
|
272
|
+
1ls '.map(f => f.path)' | \
|
|
273
|
+
xargs -I {} sh -c 'echo {} && 1ls readFile {} ".version"'
|
|
274
|
+
|
|
275
|
+
# Search for TODOs in code
|
|
276
|
+
1ls --grep "TODO" --find ./src --recursive --line-numbers
|
|
277
|
+
|
|
278
|
+
# Process multiple CSV files
|
|
279
|
+
for file in *.csv; do
|
|
280
|
+
echo "Processing $file"
|
|
281
|
+
cat "$file" | 1ls --input-format csv '.filter(x => x.status === "active")'
|
|
282
|
+
done
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Environment Variables
|
|
286
|
+
|
|
287
|
+
- `NO_COLOR` - Disable colored output
|
|
288
|
+
|
|
289
|
+
## Performance
|
|
290
|
+
|
|
291
|
+
1ls is built with Bun and optimized for speed:
|
|
292
|
+
- Fast JSON parsing and stringification
|
|
293
|
+
- Minimal overhead for expression evaluation
|
|
294
|
+
- Efficient streaming for large files
|
|
295
|
+
- Native binary compilation
|
|
296
|
+
|
|
297
|
+
## Contributing
|
|
298
|
+
|
|
299
|
+
Contributions are welcome! Please check out the [Contributing Guide](CONTRIBUTING.md).
|
|
300
|
+
|
|
301
|
+
## License
|
|
302
|
+
|
|
303
|
+
MIT © Jeff Wainwright
|
|
304
|
+
|
|
305
|
+
## Comparison with Similar Tools
|
|
306
|
+
|
|
307
|
+
| Feature | 1ls | jq | fx |
|
|
308
|
+
|---------|-----|----|----|
|
|
309
|
+
| Syntax | JavaScript | DSL | JavaScript |
|
|
310
|
+
| Performance | ⚡ Fast (Bun) | ⚡ Fast | 🚀 Good |
|
|
311
|
+
| Learning Curve | Easy | Steep | Easy |
|
|
312
|
+
| Multi-format | ✅ | ❌ | ❌ |
|
|
313
|
+
| Shortcuts | ✅ | ❌ | ❌ |
|
|
314
|
+
| Arrow Functions | ✅ | ❌ | ✅ |
|
|
315
|
+
| File Operations | ✅ | ❌ | ❌ |
|
|
316
|
+
|
|
317
|
+
## Troubleshooting
|
|
318
|
+
|
|
319
|
+
### Installation Issues
|
|
320
|
+
- Ensure Bun is installed: `curl -fsSL https://bun.sh/install | bash`
|
|
321
|
+
- Check PATH includes Bun location
|
|
322
|
+
|
|
323
|
+
### Expression Errors
|
|
324
|
+
- Wrap expressions in quotes to prevent shell interpretation
|
|
325
|
+
- Use single quotes for expressions containing dollar signs
|
|
326
|
+
|
|
327
|
+
### Performance
|
|
328
|
+
- For large files, use streaming: `cat large.json | 1ls '.property'`
|
|
329
|
+
- Use `--compact` for smaller output size
|
|
330
|
+
|
|
331
|
+
## Links
|
|
332
|
+
|
|
333
|
+
- [GitHub Repository](https://github.com/yowainwright/1ls)
|
|
334
|
+
- [Documentation](https://1ls.dev)
|
|
335
|
+
- [Issue Tracker](https://github.com/yowainwright/1ls/issues)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function showHelp(): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function colorize(json: string): string;
|
|
2
|
+
export declare function error(message: string): string;
|
|
3
|
+
export declare function success(message: string): string;
|
|
4
|
+
export declare function warning(message: string): string;
|
|
5
|
+
export declare function info(message: string): string;
|
|
6
|
+
export declare function dim(message: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CliOptions } from "../types";
|
|
2
|
+
export declare class Formatter {
|
|
3
|
+
private options;
|
|
4
|
+
constructor(options: CliOptions);
|
|
5
|
+
format(data: any): string;
|
|
6
|
+
private formatRaw;
|
|
7
|
+
private formatJson;
|
|
8
|
+
private formatWithType;
|
|
9
|
+
private formatYaml;
|
|
10
|
+
private toYaml;
|
|
11
|
+
private formatCsv;
|
|
12
|
+
private escapeCsvValue;
|
|
13
|
+
private formatTable;
|
|
14
|
+
private formatObjectTable;
|
|
15
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
var q={format:"json",pretty:!1,raw:!1,compact:!1,type:!1,recursive:!1,ignoreCase:!1,showLineNumbers:!1,inputFormat:void 0};function B(r){let s={...q},i=0;while(i<r.length){let n=r[i];switch(n){case"--help":case"-h":s.help=!0;break;case"--version":case"-v":s.version=!0;break;case"--raw":case"-r":s.raw=!0;break;case"--pretty":case"-p":s.pretty=!0;break;case"--compact":case"-c":s.compact=!0;break;case"--type":case"-t":s.type=!0;break;case"--format":if(i++,i<r.length){let o=r[i],e=["json","yaml","csv","table"].includes(o);if(o&&e)s.format=o}break;case"--input-format":case"-if":if(i++,i<r.length){let o=r[i];if(["json","yaml","toml","csv","tsv","lines","text"].includes(o))s.inputFormat=o}break;case"readFile":s.readFile=!0,i+=2;break;case"--find":case"-f":if(i++,i<r.length)s.find=r[i];break;case"--grep":case"-g":if(i++,i<r.length)s.grep=r[i];break;case"--list":case"-l":if(i++,i<r.length)s.list=r[i];break;case"--recursive":case"-R":s.recursive=!0;break;case"--ignore-case":case"-i":s.ignoreCase=!0;break;case"--line-numbers":case"-n":s.showLineNumbers=!0;break;case"--ext":if(i++,i<r.length){let o=r[i].split(",");s.extensions=o.map((t)=>t.startsWith(".")?t:`.${t}`)}break;case"--max-depth":if(i++,i<r.length)s.maxDepth=parseInt(r[i],10);break;case"--shorten":if(i++,i<r.length)s.shorten=r[i];break;case"--expand":if(i++,i<r.length)s.expand=r[i];break;case"--shortcuts":s.shortcuts=!0;break;default:if(n.startsWith(".")||n.startsWith("["))s.expression=n;break}i++}return s}function g(){console.log(`
|
|
4
|
+
1ls - 1 line script for JSON manipulation and file operations
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
echo '{"key": "value"}' | 1ls [expression] [options]
|
|
8
|
+
1ls readFile <file> [expression] [options]
|
|
9
|
+
1ls --list <dir> [options]
|
|
10
|
+
1ls --grep <pattern> --find <path> [options]
|
|
11
|
+
|
|
12
|
+
JSON Expressions:
|
|
13
|
+
.key Access property
|
|
14
|
+
.user.email Nested properties
|
|
15
|
+
.["complex-key"] Bracket notation
|
|
16
|
+
.users[] All array elements
|
|
17
|
+
.users[0] Array index
|
|
18
|
+
.users[-1] Negative index
|
|
19
|
+
.users[0:3] Array slice
|
|
20
|
+
.obj.{keys} Object keys
|
|
21
|
+
.obj.{values} Object values
|
|
22
|
+
.obj.{entries} Object entries
|
|
23
|
+
|
|
24
|
+
JavaScript Methods:
|
|
25
|
+
.users.map(u => u.name)
|
|
26
|
+
.users.filter(u => u.active)
|
|
27
|
+
.email.includes('@gmail.com')
|
|
28
|
+
.name.toLowerCase()
|
|
29
|
+
|
|
30
|
+
Shorthand Methods (use --shortcuts for full list):
|
|
31
|
+
.mp(x => x * 2) # Short for .map()
|
|
32
|
+
.flt(x => x > 5) # Short for .filter()
|
|
33
|
+
.kys # Short for .{keys}
|
|
34
|
+
.lc() # Short for .toLowerCase()
|
|
35
|
+
|
|
36
|
+
File Operations:
|
|
37
|
+
-l, --list <dir> List files in directory
|
|
38
|
+
-g, --grep <pattern> Search for pattern in files
|
|
39
|
+
-f, --find <path> Path to search in
|
|
40
|
+
-R, --recursive Recursive search
|
|
41
|
+
-i, --ignore-case Case insensitive search
|
|
42
|
+
-n, --line-numbers Show line numbers
|
|
43
|
+
--ext <exts> Filter by extensions (comma-separated)
|
|
44
|
+
--max-depth <n> Maximum recursion depth
|
|
45
|
+
|
|
46
|
+
Output Options:
|
|
47
|
+
-r, --raw Raw output (no formatting)
|
|
48
|
+
-p, --pretty Pretty print JSON
|
|
49
|
+
-c, --compact Compact JSON
|
|
50
|
+
-t, --type Show value type info
|
|
51
|
+
--format <type> Output format (json|yaml|csv|table)
|
|
52
|
+
-h, --help Show help
|
|
53
|
+
-v, --version Show version
|
|
54
|
+
|
|
55
|
+
Shorthand Options:
|
|
56
|
+
--shortcuts Show all available shortcuts
|
|
57
|
+
--shorten <expr> Convert expression to shorthand
|
|
58
|
+
--expand <expr> Convert shorthand to full form
|
|
59
|
+
|
|
60
|
+
Examples:
|
|
61
|
+
# JSON manipulation
|
|
62
|
+
echo '{"name": "John"}' | 1ls .name
|
|
63
|
+
1ls readFile package.json .version
|
|
64
|
+
echo '[1,2,3]' | 1ls '.map(x => x * 2)'
|
|
65
|
+
|
|
66
|
+
# File operations
|
|
67
|
+
1ls --list . --recursive --ext js,ts
|
|
68
|
+
1ls --grep "TODO" --find src --recursive
|
|
69
|
+
1ls --list src --format table
|
|
70
|
+
|
|
71
|
+
# Shorthand operations
|
|
72
|
+
echo '[1,2,3]' | 1ls '.mp(x => x * 2)' # Using shortcuts
|
|
73
|
+
1ls --shorten ".map(x => x * 2)" # Convert to shorthand
|
|
74
|
+
1ls --expand ".mp(x => x * 2)" # Convert to full form
|
|
75
|
+
1ls --shortcuts # Show all shortcuts
|
|
76
|
+
`)}function v(r){let s=r.trim();if(s.startsWith("{")&&s.endsWith("}")||s.startsWith("[")&&s.endsWith("]"))try{return JSON.parse(s),"json"}catch{}if(s.includes("---")||s.includes(": ")||s.match(/^[\s]*-\s+/m))return"yaml";if(s.match(/^\[[\w.]+\]/m)||s.match(/^\w+\s*=\s*/m))return"toml";let i=s.split(`
|
|
77
|
+
`);if(i.length>1){let n=i[0],c=(n.match(/,/g)||[]).length,o=(n.match(/\t/g)||[]).length;if(o>0&&o>=c)return"tsv";if(c>0)return"csv"}if(i.length>1)return"lines";return"text"}function Q(r){return r.trim().split(`
|
|
78
|
+
`).filter((s)=>s.length>0)}function H(r,s=","){let i=r.trim().split(`
|
|
79
|
+
`);if(i.length===0)return[];let n=G(i[0],s);if(i.length===1)return[];let c=[];for(let o=1;o<i.length;o++){let t=G(i[o],s);if(t.length===0)continue;let e={};for(let f=0;f<n.length;f++)e[n[f]]=Y(t[f]||"");c.push(e)}return c}function G(r,s){let i=[],n="",c=!1;for(let o=0;o<r.length;o++){let t=r[o],e=r[o+1];if(t==='"')if(c&&e==='"')n+='"',o++;else c=!c;else if(t===s&&!c)i.push(n),n="";else n+=t}return i.push(n),i.map((o)=>o.trim())}function Y(r){let s=r.trim();if(s.startsWith('"')&&s.endsWith('"'))return s.slice(1,-1).replace(/""/g,'"');if(/^-?\d+(\.\d+)?$/.test(s))return parseFloat(s);if(s.toLowerCase()==="true")return!0;if(s.toLowerCase()==="false")return!1;if(s===""||s.toLowerCase()==="null")return null;return s}function j(r){return H(r,"\t")}function y(r){let s=r.trim().split(`
|
|
80
|
+
`),i={},n=[i],c=[0],o=null,t=-1;for(let e=0;e<s.length;e++){let f=s[e],p=f.indexOf("#");if(p>=0){let F=f.substring(0,p);if((F.match(/["']/g)||[]).length%2===0)f=F}if(!f.trim())continue;if(f.trim()==="---"||f.trim()==="...")continue;let O=f.length-f.trimStart().length,h=f.trim();if(h.startsWith("- ")){let F=h.substring(2).trim();if(o&&O===t)o.push(w(F));else{o=[w(F)],t=O;while(c.length>1&&c[c.length-1]>=O)n.pop(),c.pop();let l=n[n.length-1];if(typeof l==="object"&&!Array.isArray(l)){let N=V(s,e);if(N)l[N]=o}}continue}if(!h.startsWith("- "))o=null,t=-1;let E=h.indexOf(":");if(E>0){let F=h.substring(0,E).trim(),l=h.substring(E+1).trim();while(c.length>1&&c[c.length-1]>=O)n.pop(),c.pop();let N=n[n.length-1];if(!l){let u=e+1;if(u<s.length){if(s[u].trim().startsWith("- "))continue}let A={};N[F]=A,n.push(A),c.push(O)}else N[F]=w(l)}}return i}function V(r,s){for(let i=s-1;i>=0;i--){let n=r[i],c=n.indexOf("#");if(c>=0){let t=n.substring(0,c);if((t.match(/["']/g)||[]).length%2===0)n=t}let o=n.trim();if(o&&!o.startsWith("-")&&o.includes(":")){let t=o.indexOf(":"),e=o.substring(0,t).trim();if(!o.substring(t+1).trim())return e}}return null}function w(r){if(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))return r.slice(1,-1);if(r==="true"||r==="yes"||r==="on")return!0;if(r==="false"||r==="no"||r==="off")return!1;if(r==="null"||r==="~"||r==="")return null;if(/^-?\d+$/.test(r))return parseInt(r,10);if(/^-?\d+\.\d+$/.test(r))return parseFloat(r);if(r.startsWith("[")&&r.endsWith("]"))return r.slice(1,-1).split(",").map((s)=>w(s.trim()));if(r.startsWith("{")&&r.endsWith("}")){let s={},i=r.slice(1,-1).split(",");for(let n of i){let[c,o]=n.split(":").map((t)=>t.trim());if(c&&o)s[c]=w(o)}return s}return r}function k(r){let s=r.trim().split(`
|
|
81
|
+
`),i={},n=i,c=[];for(let o of s){let t=o.indexOf("#");if(t>=0){let p=o.substring(0,t);if((p.match(/["']/g)||[]).length%2===0)o=p}let e=o.trim();if(!e)continue;if(e.startsWith("[")&&e.endsWith("]")){let p=e.slice(1,-1).split(".");n=i,c=[];for(let O of p){if(!n[O])n[O]={};n=n[O],c.push(O)}continue}let f=e.indexOf("=");if(f>0){let p=e.substring(0,f).trim(),O=e.substring(f+1).trim();n[p]=$(O)}}return i}function $(r){if(r.startsWith('"')&&r.endsWith('"'))return r.slice(1,-1).replace(/\\"/g,'"');if(r.startsWith("'")&&r.endsWith("'"))return r.slice(1,-1);if(r==="true")return!0;if(r==="false")return!1;if(/^[+-]?\d+$/.test(r))return parseInt(r,10);if(/^[+-]?\d+\.\d+$/.test(r))return parseFloat(r);if(r.startsWith("[")&&r.endsWith("]"))return r.slice(1,-1).split(",").map((i)=>$(i.trim()));if(r.startsWith("{")&&r.endsWith("}")){let s={},i=r.slice(1,-1).split(",");for(let n of i){let[c,o]=n.split("=").map((t)=>t.trim());if(c&&o)s[c]=$(o)}return s}return r}function L(r,s){switch(s||v(r)){case"json":return JSON.parse(r);case"yaml":return y(r);case"toml":return k(r);case"csv":return H(r);case"tsv":return j(r);case"lines":return Q(r);case"text":default:return r}}async function W(r){let s=[];for await(let n of process.stdin)s.push(n);let i=Buffer.concat(s).toString("utf-8").trim();if(!i)return null;return L(i,r)}import{readdir as rr,stat as M}from"fs/promises";import{join as sr,extname as ir,basename as nr}from"path";var T=[".ts",".js",".tsx",".jsx"],d=[".json",".yml",".yaml"],a=[".md",".txt"],J=[...T,...d,...a];async function b(r){try{let i=await Bun.file(r).text();if(r.endsWith(".json"))try{return JSON.parse(i)}catch{return i}return i}catch(s){throw new Error(`Failed to read file ${r}: ${s.message}`)}}async function or(r){let s=await M(r);return{path:r,name:nr(r),ext:ir(r),size:s.size,isDirectory:s.isDirectory(),isFile:s.isFile(),modified:s.mtime,created:s.birthtime}}async function P(r,s={}){let i=[],n=0;async function c(o,t){if(s.maxDepth!==void 0&&t>s.maxDepth)return;let e=await rr(o);for(let f of e){let p=f.startsWith(".");if(!s.includeHidden&&p)continue;let h=sr(o,f),E=await or(h);if(E.isFile){let l=s.extensions===void 0||s.extensions?.includes(E.ext)||!1,u=s.pattern===void 0||s.pattern?.test(E.name)||!1;if(l&&u)i.push(E)}else if(E.isDirectory){if(i.push(E),s.recursive===!0)await c(h,t+1)}}}return await c(r,0),i}async function X(r,s,i={}){let n=[],c=typeof r==="string"?new RegExp(r,i.ignoreCase?"gi":"g"):r;async function o(e){try{let f=await b(e);if(typeof f!=="string")return;let p=f.split(`
|
|
82
|
+
`),O=0;for(let h=0;h<p.length;h++){let E=p[h],F=[...E.matchAll(c)];for(let l of F){if(i.maxMatches&&O>=i.maxMatches)return;let N={file:e,line:h+1,column:l.index+1,match:E};if(i.context){let u=Math.max(0,h-i.context),A=Math.min(p.length,h+i.context+1);N.context=p.slice(u,A)}n.push(N),O++}}}catch{}}let t=await M(s);if(t.isFile())await o(s);else if(t.isDirectory()&&i.recursive){let e=await P(s,{recursive:!0,extensions:[...J]});for(let f of e)if(f.isFile)await o(f.path)}return n}class D{input;position=0;current;constructor(r){this.input=r,this.current=this.input[0]||""}tokenize(){let r=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let s=this.nextToken();if(s)r.push(s)}return r.push({type:"EOF",value:"",position:this.position}),r}nextToken(){let r=this.position;if(this.current===".")return this.advance(),{type:"DOT",value:".",position:r};if(this.current==="[")return this.advance(),{type:"LEFT_BRACKET",value:"[",position:r};if(this.current==="]")return this.advance(),{type:"RIGHT_BRACKET",value:"]",position:r};if(this.current==="{")return this.advance(),{type:"LEFT_BRACE",value:"{",position:r};if(this.current==="}")return this.advance(),{type:"RIGHT_BRACE",value:"}",position:r};if(this.current==="(")return this.advance(),{type:"LEFT_PAREN",value:"(",position:r};if(this.current===")")return this.advance(),{type:"RIGHT_PAREN",value:")",position:r};if(this.current===":")return this.advance(),{type:"COLON",value:":",position:r};if(this.current===",")return this.advance(),{type:"COMMA",value:",",position:r};if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),{type:"ARROW",value:"=>",position:r};if(this.current==='"'||this.current==="'")return this.readString();if(this.isDigit(this.current)||this.current==="-"&&this.isDigit(this.peek()))return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let r=this.position,s=this.current,i="";this.advance();while(this.current!==s&&this.position<this.input.length)if(this.current==="\\"){if(this.advance(),this.position<this.input.length)i+=this.current,this.advance()}else i+=this.current,this.advance();if(this.current===s)this.advance();return{type:"STRING",value:i,position:r}}readNumber(){let r=this.position,s="";if(this.current==="-")s+=this.current,this.advance();while(this.isDigit(this.current))s+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){s+=this.current,this.advance();while(this.isDigit(this.current))s+=this.current,this.advance()}return{type:"NUMBER",value:s,position:r}}readIdentifier(){let r=this.position,s="";while(this.isIdentifierChar(this.current))s+=this.current,this.advance();return{type:"IDENTIFIER",value:s,position:r}}readOperator(){let r=this.position,s="";while(this.isOperator(this.current))s+=this.current,this.advance();return{type:"OPERATOR",value:s,position:r}}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(r){return r===" "||r==="\t"||r===`
|
|
83
|
+
`||r==="\r"}isDigit(r){return r>="0"&&r<="9"}isIdentifierStart(r){return r>="a"&&r<="z"||r>="A"&&r<="Z"||r==="_"||r==="$"}isIdentifierChar(r){return this.isIdentifierStart(r)||this.isDigit(r)}isOperator(r){return"+-*/%<>!&|=".includes(r)}}class I{tokens;position=0;current;constructor(r){this.tokens=r,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return{type:"Root"};return{type:"Root",expression:this.parseExpression()}}parseExpression(){return this.parsePrimary()}parsePrimary(){let r;if(this.current.type==="DOT")this.advance(),r=this.parseAccessChain();else if(this.current.type==="LEFT_BRACKET")r=this.parseArrayAccess();else if(this.current.type==="IDENTIFIER")r=this.parseIdentifierOrFunction();else if(this.current.type==="STRING"){let s=this.current.value;this.advance(),r={type:"Literal",value:s}}else if(this.current.type==="NUMBER"){let s=Number(this.current.value);this.advance(),r={type:"Literal",value:s}}else if(this.current.type==="LEFT_PAREN"){let s=this.parseFunctionParams();return this.parseArrowFunction(s)}if(!r)throw new Error(`Unexpected token: ${this.current.type} at position ${this.current.position}`);return this.parsePostfix(r)}parseAccessChain(r){if(this.current.type==="IDENTIFIER"){let s=this.current.value;this.advance();let i={type:"PropertyAccess",property:s,object:r};return this.parsePostfix(i)}if(this.current.type==="LEFT_BRACKET")return this.parseBracketAccess(r);if(this.current.type==="LEFT_BRACE")return this.parseObjectOperation(r);throw new Error(`Expected property name after dot at position ${this.current.position}`)}parseBracketAccess(r){if(this.advance(),this.current.type==="RIGHT_BRACKET"){this.advance();let i={type:"ArraySpread",object:r};return this.parsePostfix(i)}if(this.current.type==="STRING"){let i=this.current.value;this.advance(),this.expect("RIGHT_BRACKET");let n={type:"PropertyAccess",property:i,object:r};return this.parsePostfix(n)}if(this.current.type==="NUMBER"||this.current.type==="OPERATOR"&&this.current.value==="-"){let i=this.parseNumber();if(this.advance(),this.current.type==="COLON"){this.advance();let c,o=this.current.type;if(o==="NUMBER"||o==="OPERATOR"&&this.current.value==="-")c=this.parseNumber(),this.advance();this.expect("RIGHT_BRACKET");let t={type:"SliceAccess",start:i,end:c,object:r};return this.parsePostfix(t)}this.expect("RIGHT_BRACKET");let n={type:"IndexAccess",index:i,object:r};return this.parsePostfix(n)}if(this.current.type==="COLON"){this.advance();let i,n=this.current.type;if(n==="NUMBER"||n==="OPERATOR"&&this.current.value==="-")i=this.parseNumber(),this.advance();this.expect("RIGHT_BRACKET");let c={type:"SliceAccess",end:i,object:r};return this.parsePostfix(c)}throw new Error(`Unexpected token in bracket access: ${this.current.type} at position ${this.current.position}`)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(r){if(this.advance(),this.current.type!=="IDENTIFIER")throw new Error(`Expected operation name after { at position ${this.current.position}`);let s=this.current.value;if(!["keys","values","entries","length"].includes(s))throw new Error(`Invalid object operation: ${s} at position ${this.current.position}`);this.advance(),this.expect("RIGHT_BRACE");let c={type:"ObjectOperation",operation:s,object:r};return this.parsePostfix(c)}parseIdentifierOrFunction(){let r=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([r]);let s={type:"PropertyAccess",property:r};return this.parsePostfix(s)}parseArrowFunction(r){this.expect("ARROW");let s=this.parseFunctionBody();return{type:"ArrowFunction",params:r,body:s}}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let s=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),s}return this.parseBinaryExpression()}parseBinaryExpression(){let r=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let s=this.current.value;this.advance();let i=this.parseFunctionTerm();r={type:"MethodCall",method:`__operator_${s}__`,args:[i],object:r}}return r}parseFunctionTerm(){if(this.current.type==="IDENTIFIER"){let r=this.current.value;this.advance();let s={type:"PropertyAccess",property:r};while(this.current.type==="DOT")if(this.advance(),this.current.type==="IDENTIFIER"){let n=this.current.value;this.advance(),s={type:"PropertyAccess",property:n,object:s}}else break;return s}if(this.current.type==="NUMBER"){let r=Number(this.current.value);return this.advance(),{type:"Literal",value:r}}if(this.current.type==="STRING"){let r=this.current.value;return this.advance(),{type:"Literal",value:r}}if(this.current.type==="LEFT_PAREN"){this.advance();let r=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),r}throw new Error(`Unexpected token in function body: ${this.current.type} at position ${this.current.position}`)}parseMethodCall(r,s){this.expect("LEFT_PAREN");let i=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="LEFT_PAREN"){let n=this.parseFunctionParams();i.push(this.parseArrowFunction(n))}else if(this.current.type==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="ARROW")i.push(this.parseArrowFunction([n]));else i.push({type:"PropertyAccess",property:n})}else if(this.current.type==="NUMBER"){let n=Number(this.current.value);this.advance(),i.push({type:"Literal",value:n})}else if(this.current.type==="STRING"){let n=this.current.value;this.advance(),i.push({type:"Literal",value:n})}else i.push(this.parseExpression());if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),{type:"MethodCall",method:s,args:i,object:r}}parseFunctionParams(){this.expect("LEFT_PAREN");let r=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")r.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),r}parsePostfix(r){while(!0)if(this.current.type==="DOT"){this.advance();let s=this.current.type;if(s==="IDENTIFIER"){let i=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")r=this.parseMethodCall(r,i);else r={type:"PropertyAccess",property:i,object:r}}else if(s==="LEFT_BRACKET")r=this.parseBracketAccess(r);else if(s==="LEFT_BRACE")r=this.parseObjectOperation(r);else throw new Error(`Expected property name after dot at position ${this.current.position}`)}else if(this.current.type==="LEFT_BRACKET")r=this.parseBracketAccess(r);else if(this.current.type==="LEFT_PAREN")if(r.type==="PropertyAccess"&&!r.object){let s=r.property;r=this.parseMethodCall({type:"Root"},s)}else break;else break;return r}parseNumber(){let r=this.current.value==="-";if(r)this.advance();if(this.current.type!=="NUMBER")throw new Error(`Expected number after minus sign at position ${this.current.position}`);let s=Number(this.current.value);return r?-s:s}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(r){if(this.current.type!==r)throw new Error(`Expected ${r} but got ${this.current.type} at position ${this.current.position}`);this.advance()}}class C{evaluate(r,s){switch(r.type){case"Root":return r.expression?this.evaluate(r.expression,s):s;case"PropertyAccess":let i=r.object?this.evaluate(r.object,s):s;if(!i)return;return i[r.property];case"IndexAccess":let n=r.object?this.evaluate(r.object,s):s;if(!Array.isArray(n))return;let c=r.index<0?n.length+r.index:r.index;return n[c];case"SliceAccess":let o=r.object?this.evaluate(r.object,s):s;if(!Array.isArray(o))return;let t=o.length,e=r.start!==void 0?r.start<0?t+r.start:r.start:0,f=r.end!==void 0?r.end<0?t+r.end:r.end:t;return o.slice(e,f);case"ArraySpread":let p=r.object?this.evaluate(r.object,s):s;if(!Array.isArray(p))return;return p;case"MethodCall":let O=r.object?this.evaluate(r.object,s):s;return this.executeMethod(O,r.method,r.args,s);case"ObjectOperation":let h=r.object?this.evaluate(r.object,s):s;if(!(h&&typeof h==="object"))return;switch(r.operation){case"keys":return Object.keys(h);case"values":return Object.values(h);case"entries":return Object.entries(h);case"length":return Array.isArray(h)?h.length:Object.keys(h).length;default:return}case"Literal":return r.value;case"ArrowFunction":return this.createFunction(r);default:throw new Error(`Unknown AST node type: ${r.type}`)}}executeMethod(r,s,i,n){if(!r)return;let c=i.map((e)=>{return e.type==="ArrowFunction"?this.createFunction(e):this.evaluate(e,n)});if(s.startsWith("__operator_")&&s.endsWith("__")){let e=s.slice(11,-2);return this.executeOperator(r,e,c[0])}if(typeof r[s]!=="function")throw new Error(`Method ${s} does not exist on ${typeof r}`);try{return r[s](...c)}catch(e){throw new Error(`Error executing method ${s}: ${e.message}`)}}executeOperator(r,s,i){switch(s){case"+":return r+i;case"-":return r-i;case"*":return r*i;case"/":return r/i;case"%":return r%i;case">":return r>i;case"<":return r<i;case">=":return r>=i;case"<=":return r<=i;case"==":return r==i;case"===":return r===i;case"!=":return r!=i;case"!==":return r!==i;case"&&":return r&&i;case"||":return r||i;default:throw new Error(`Unknown operator: ${s}`)}}createFunction(r){return(...s)=>{let i={};return r.params.forEach((n,c)=>{i[n]=s[c]}),this.evaluateFunctionBody(r.body,i)}}evaluateFunctionBody(r,s){switch(r.type){case"PropertyAccess":if(!r.object){if(s.hasOwnProperty(r.property))return s[r.property];let p=Object.values(s)[0];return p&&typeof p==="object"?p[r.property]:void 0}let i=this.evaluateFunctionBody(r.object,s);return i?i[r.property]:void 0;case"MethodCall":let n=r.object?this.evaluateFunctionBody(r.object,s):Object.values(s)[0],c=r.args.map((f)=>this.evaluateFunctionBody(f,s));if(r.method.startsWith("__operator_")&&r.method.endsWith("__")){let f=r.method.slice(11,-2);return this.executeOperator(n,f,c[0])}if(!n)return;let t=n[r.method];return typeof t==="function"?t(...c):void 0;case"Literal":return r.value;case"Root":return r.expression?this.evaluateFunctionBody(r.expression,s):s;default:return this.evaluate(r,Object.values(s)[0])}}}var x={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"};function U(r){if(process.env.NO_COLOR)return r;return r.replace(/"([^"]+)":/g,`${x.cyan}"$1"${x.reset}:`).replace(/: "([^"]*)"/g,`: ${x.green}"$1"${x.reset}`).replace(/: (-?\d+\.?\d*)/g,`: ${x.yellow}$1${x.reset}`).replace(/: (true|false)/g,`: ${x.magenta}$1${x.reset}`).replace(/: (null)/g,`: ${x.gray}$1${x.reset}`).replace(/([{[])/g,`${x.gray}$1${x.reset}`).replace(/([}\]])/g,`${x.gray}$1${x.reset}`)}function z(r){if(process.env.NO_COLOR)return r;return`${x.yellow}${r}${x.reset}`}function m(r){if(process.env.NO_COLOR)return r;return`${x.cyan}${r}${x.reset}`}class _{options;constructor(r){this.options=r}format(r){if(this.options.raw)return this.formatRaw(r);if(this.options.type)return this.formatWithType(r);switch(this.options.format){case"yaml":return this.formatYaml(r);case"csv":return this.formatCsv(r);case"table":return this.formatTable(r);default:return this.formatJson(r)}}formatRaw(r){if(typeof r==="string")return r;if(r===void 0)return"";if(r===null)return"null";if(typeof r==="object")return JSON.stringify(r);return String(r)}formatJson(r){if(r===void 0)return"undefined";if(this.options.compact)return JSON.stringify(r);if(this.options.pretty){let s=JSON.stringify(r,null,2);return U(s)}return JSON.stringify(r,null,2)}formatWithType(r){let s=Array.isArray(r)?"array":typeof r,i=this.formatJson(r);return`[${s}] ${i}`}formatYaml(r){return this.toYaml(r,0)}toYaml(r,s){let i=" ".repeat(s);if(r===null||r===void 0)return"null";if(typeof r==="string")return r.includes(`
|
|
84
|
+
`)||r.includes('"')||r.includes("'")?`|
|
|
85
|
+
${i} ${r.replace(/\n/g,`
|
|
86
|
+
`+i+" ")}`:r;if(typeof r==="number"||typeof r==="boolean")return String(r);if(Array.isArray(r)){if(r.length===0)return"[]";return r.map((n)=>`${i}- ${this.toYaml(n,s+2).trim()}`).join(`
|
|
87
|
+
`)}if(typeof r==="object"){let n=Object.entries(r);if(n.length===0)return"{}";return n.map(([c,o])=>{let t=this.toYaml(o,s+2);if(typeof o==="object"&&o!==null)return`${i}${c}:
|
|
88
|
+
${t}`;return`${i}${c}: ${t}`}).join(`
|
|
89
|
+
`)}return String(r)}formatCsv(r){if(!Array.isArray(r))return this.formatJson(r);if(r.length===0)return"";if(typeof r[0]==="object"&&r[0]!==null&&!Array.isArray(r[0])){let s=Object.keys(r[0]),i=s.join(","),n=r.map((c)=>s.map((o)=>this.escapeCsvValue(c[o])).join(","));return[i,...n].join(`
|
|
90
|
+
`)}return r.map((s)=>this.escapeCsvValue(s)).join(`
|
|
91
|
+
`)}escapeCsvValue(r){if(r===null||r===void 0)return"";let s=String(r);if(s.includes(",")||s.includes('"')||s.includes(`
|
|
92
|
+
`))return`"${s.replace(/"/g,'""')}"`;return s}formatTable(r){if(!Array.isArray(r))return this.formatJson(r);if(r.length===0)return"(empty array)";if(typeof r[0]==="object"&&r[0]!==null&&!Array.isArray(r[0]))return this.formatObjectTable(r);return r.map((s,i)=>`${i}: ${this.formatRaw(s)}`).join(`
|
|
93
|
+
`)}formatObjectTable(r){let s=[...new Set(r.flatMap((t)=>Object.keys(t)))],i={};s.forEach((t)=>{i[t]=Math.max(t.length,...r.map((e)=>String(e[t]??"").length))});let n=s.map((t)=>t.padEnd(i[t])).join(" | "),c=s.map((t)=>"-".repeat(i[t])).join("-+-"),o=r.map((t)=>s.map((e)=>String(t[e]??"").padEnd(i[e])).join(" | "));return[n,c,...o].join(`
|
|
94
|
+
`)}}var R=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".fndIdx",full:".findIndex",description:"Find index of first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".psh",full:".push",description:"Add to end",type:"array"},{short:".pp",full:".pop",description:"Remove from end",type:"array"},{short:".shft",full:".shift",description:"Remove from start",type:"array"},{short:".unshft",full:".unshift",description:"Add to start",type:"array"},{short:".fltMap",full:".flatMap",description:"Map and flatten",type:"array"},{short:".flt1",full:".flat",description:"Flatten array",type:"array"},{short:".incl",full:".includes",description:"Check if includes",type:"array"},{short:".idxOf",full:".indexOf",description:"Find index",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".trmSt",full:".trimStart",description:"Remove leading whitespace",type:"string"},{short:".trmEnd",full:".trimEnd",description:"Remove trailing whitespace",type:"string"},{short:".rpl",full:".replace",description:"Replace text",type:"string"},{short:".rplAll",full:".replaceAll",description:"Replace all occurrences",type:"string"},{short:".pdSt",full:".padStart",description:"Pad start",type:"string"},{short:".pdEnd",full:".padEnd",description:"Pad end",type:"string"},{short:".stsWith",full:".startsWith",description:"Check if starts with",type:"string"},{short:".endsWith",full:".endsWith",description:"Check if ends with",type:"string"},{short:".sbstr",full:".substring",description:"Extract substring",type:"string"},{short:".chr",full:".charAt",description:"Get character at index",type:"string"},{short:".chrCd",full:".charCodeAt",description:"Get character code",type:"string"},{short:".mtch",full:".match",description:"Match pattern",type:"string"},{short:".str",full:".toString",description:"Convert to string",type:"any"},{short:".json",full:".toJSON",description:"Convert to JSON",type:"any"},{short:".val",full:".valueOf",description:"Get primitive value",type:"any"}],Qr=new Map(R.map((r)=>[r.short,r.full])),Yr=new Map(R.map((r)=>[r.full,r.short]));function S(r){let s=r,i=[...R].sort((n,c)=>c.short.length-n.short.length);for(let n of i){let c=new RegExp(`\\${n.short}(?![a-zA-Z])`,"g");s=s.replace(c,n.full)}return s}function K(r){let s=r,i=[...R].sort((n,c)=>c.full.length-n.full.length);for(let n of i){let c=new RegExp(`\\${n.full.replace(/[{}]/g,"\\$&")}(?![a-zA-Z])`,"g");s=s.replace(c,n.short)}return s}function Z(){let r=R.filter((o)=>o.type==="array"),s=R.filter((o)=>o.type==="object"),i=R.filter((o)=>o.type==="string"),n=R.filter((o)=>o.type==="any"),c=(o,t)=>{let e=Math.max(...t.map((h)=>h.short.length)),f=Math.max(...t.map((h)=>h.full.length)),p=`
|
|
95
|
+
${o}:
|
|
96
|
+
`,O=t.map((h)=>` ${h.short.padEnd(e+2)} \u2192 ${h.full.padEnd(f+2)} # ${h.description}`).join(`
|
|
97
|
+
`);return p+O};return`
|
|
98
|
+
Shorthand Reference:
|
|
99
|
+
${c("Array Methods",r)}
|
|
100
|
+
${c("Object Methods",s)}
|
|
101
|
+
${c("String Methods",i)}
|
|
102
|
+
${c("Universal Methods",n)}
|
|
103
|
+
|
|
104
|
+
Examples:
|
|
105
|
+
echo '[1,2,3]' | 1ls '.mp(x => x * 2)' # Short form
|
|
106
|
+
echo '[1,2,3]' | 1ls '.map(x => x * 2)' # Full form
|
|
107
|
+
|
|
108
|
+
1ls --shorten ".map(x => x * 2)" # Returns: .mp(x => x * 2)
|
|
109
|
+
1ls --expand ".mp(x => x * 2)" # Returns: .map(x => x * 2)
|
|
110
|
+
`}async function tr(r){if(r.help)g(),process.exit(0);if(r.version)console.log("1ls version 1.0.0"),process.exit(0);return!1}async function er(r){if(r.shortcuts)console.log(Z()),process.exit(0);if(r.shorten){let s=K(r.shorten);console.log(s),process.exit(0)}if(r.expand){let s=S(r.expand);console.log(s),process.exit(0)}return!1}async function fr(r){if(r.list){let s=await P(r.list,{recursive:r.recursive,extensions:r.extensions,maxDepth:r.maxDepth}),i=new _(r);return console.log(i.format(s)),!0}if(r.grep&&r.find)return await hr(r),!0;return!1}async function hr(r){let s=await X(r.grep,r.find,{recursive:r.recursive,ignoreCase:r.ignoreCase,showLineNumbers:r.showLineNumbers});if(s.length===0){console.log(z("No matches found"));return}for(let i of s){let n=`${m(i.file)}:${i.line}:${i.column}`,c=r.showLineNumbers?`${n}: ${i.match}`:`${m(i.file)}: ${i.match}`;console.log(c)}}async function pr(r,s){if(r.readFile){let c=s[s.indexOf("readFile")+1],o=await b(c);return r.expression=s[s.indexOf("readFile")+2]||".",o}let i=!process.stdin.isTTY,n=r.list||r.grep;if(!i&&!n)g(),process.exit(1);if(i)return await W(r.inputFormat);return null}async function Or(r,s){if(!r.expression){let i=new _(r);console.log(i.format(s));return}try{let i=S(r.expression),c=new D(i).tokenize(),t=new I(c).parse(),f=new C().evaluate(t,s),p=new _(r);console.log(p.format(f))}catch(i){console.error("Error:",i.message),process.exit(1)}}async function xr(r){let s=B(r);if(await tr(s),await er(s),await fr(s))return;let n=await pr(s,r);await Or(s,n)}if(import.meta.main)xr(process.argv.slice(2)).catch((r)=>{console.error("Error:",r.message),process.exit(1)});export{xr as main};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Token } from "../types";
|
|
2
|
+
export declare class Lexer {
|
|
3
|
+
private input;
|
|
4
|
+
private position;
|
|
5
|
+
private current;
|
|
6
|
+
constructor(input: string);
|
|
7
|
+
tokenize(): Token[];
|
|
8
|
+
private nextToken;
|
|
9
|
+
private readString;
|
|
10
|
+
private readNumber;
|
|
11
|
+
private readIdentifier;
|
|
12
|
+
private readOperator;
|
|
13
|
+
private skipWhitespace;
|
|
14
|
+
private advance;
|
|
15
|
+
private peek;
|
|
16
|
+
private isWhitespace;
|
|
17
|
+
private isDigit;
|
|
18
|
+
private isIdentifierStart;
|
|
19
|
+
private isIdentifierChar;
|
|
20
|
+
private isOperator;
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Token, RootNode } from "../types";
|
|
2
|
+
export declare class Parser {
|
|
3
|
+
private tokens;
|
|
4
|
+
private position;
|
|
5
|
+
private current;
|
|
6
|
+
constructor(tokens: Token[]);
|
|
7
|
+
parse(): RootNode;
|
|
8
|
+
private parseExpression;
|
|
9
|
+
private parsePrimary;
|
|
10
|
+
private parseAccessChain;
|
|
11
|
+
private parseBracketAccess;
|
|
12
|
+
private parseArrayAccess;
|
|
13
|
+
private parseObjectOperation;
|
|
14
|
+
private parseIdentifierOrFunction;
|
|
15
|
+
private parseArrowFunction;
|
|
16
|
+
private parseFunctionBody;
|
|
17
|
+
private parseBinaryExpression;
|
|
18
|
+
private parseFunctionTerm;
|
|
19
|
+
private parseMethodCall;
|
|
20
|
+
private parseFunctionParams;
|
|
21
|
+
private parsePostfix;
|
|
22
|
+
private parseNumber;
|
|
23
|
+
private advance;
|
|
24
|
+
private expect;
|
|
25
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { DataFormat } from "./utils/types";
|
|
2
|
+
export type OutputFormat = "json" | "yaml" | "csv" | "table";
|
|
3
|
+
export interface FileOperationOptions {
|
|
4
|
+
find?: string;
|
|
5
|
+
grep?: string;
|
|
6
|
+
list?: string;
|
|
7
|
+
recursive?: boolean;
|
|
8
|
+
ignoreCase?: boolean;
|
|
9
|
+
showLineNumbers?: boolean;
|
|
10
|
+
extensions?: string[];
|
|
11
|
+
maxDepth?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ShorthandOptions {
|
|
14
|
+
shorten?: string;
|
|
15
|
+
expand?: string;
|
|
16
|
+
shortcuts?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface FormattingOptions {
|
|
19
|
+
raw?: boolean;
|
|
20
|
+
pretty?: boolean;
|
|
21
|
+
compact?: boolean;
|
|
22
|
+
type?: boolean;
|
|
23
|
+
format?: OutputFormat;
|
|
24
|
+
inputFormat?: DataFormat;
|
|
25
|
+
}
|
|
26
|
+
export interface CliOptions extends FileOperationOptions, ShorthandOptions, FormattingOptions {
|
|
27
|
+
expression?: string;
|
|
28
|
+
readFile?: boolean;
|
|
29
|
+
help?: boolean;
|
|
30
|
+
version?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare enum TokenType {
|
|
33
|
+
DOT = "DOT",
|
|
34
|
+
IDENTIFIER = "IDENTIFIER",
|
|
35
|
+
LEFT_BRACKET = "LEFT_BRACKET",
|
|
36
|
+
RIGHT_BRACKET = "RIGHT_BRACKET",
|
|
37
|
+
LEFT_BRACE = "LEFT_BRACE",
|
|
38
|
+
RIGHT_BRACE = "RIGHT_BRACE",
|
|
39
|
+
LEFT_PAREN = "LEFT_PAREN",
|
|
40
|
+
RIGHT_PAREN = "RIGHT_PAREN",
|
|
41
|
+
NUMBER = "NUMBER",
|
|
42
|
+
STRING = "STRING",
|
|
43
|
+
COLON = "COLON",
|
|
44
|
+
COMMA = "COMMA",
|
|
45
|
+
ARROW = "ARROW",
|
|
46
|
+
OPERATOR = "OPERATOR",
|
|
47
|
+
EOF = "EOF"
|
|
48
|
+
}
|
|
49
|
+
export interface Token {
|
|
50
|
+
type: TokenType;
|
|
51
|
+
value: string;
|
|
52
|
+
position: number;
|
|
53
|
+
}
|
|
54
|
+
export type ASTNode = PropertyAccessNode | IndexAccessNode | SliceAccessNode | MethodCallNode | ObjectOperationNode | ArraySpreadNode | LiteralNode | ArrowFunctionNode | RootNode;
|
|
55
|
+
export interface PropertyAccessNode {
|
|
56
|
+
type: "PropertyAccess";
|
|
57
|
+
property: string;
|
|
58
|
+
object?: ASTNode;
|
|
59
|
+
}
|
|
60
|
+
export interface IndexAccessNode {
|
|
61
|
+
type: "IndexAccess";
|
|
62
|
+
index: number;
|
|
63
|
+
object?: ASTNode;
|
|
64
|
+
}
|
|
65
|
+
export interface SliceAccessNode {
|
|
66
|
+
type: "SliceAccess";
|
|
67
|
+
start?: number;
|
|
68
|
+
end?: number;
|
|
69
|
+
object?: ASTNode;
|
|
70
|
+
}
|
|
71
|
+
export interface MethodCallNode {
|
|
72
|
+
type: "MethodCall";
|
|
73
|
+
method: string;
|
|
74
|
+
args: ASTNode[];
|
|
75
|
+
object?: ASTNode;
|
|
76
|
+
}
|
|
77
|
+
export type ObjectOperationType = "keys" | "values" | "entries" | "length";
|
|
78
|
+
export interface ObjectOperationNode {
|
|
79
|
+
type: "ObjectOperation";
|
|
80
|
+
operation: ObjectOperationType;
|
|
81
|
+
object?: ASTNode;
|
|
82
|
+
}
|
|
83
|
+
export interface ArraySpreadNode {
|
|
84
|
+
type: "ArraySpread";
|
|
85
|
+
object?: ASTNode;
|
|
86
|
+
}
|
|
87
|
+
export interface LiteralNode {
|
|
88
|
+
type: "Literal";
|
|
89
|
+
value: string | number | boolean | null;
|
|
90
|
+
}
|
|
91
|
+
export interface ArrowFunctionNode {
|
|
92
|
+
type: "ArrowFunction";
|
|
93
|
+
params: string[];
|
|
94
|
+
body: ASTNode;
|
|
95
|
+
}
|
|
96
|
+
export interface RootNode {
|
|
97
|
+
type: "Root";
|
|
98
|
+
expression?: ASTNode;
|
|
99
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const SUPPORTED_CODE_EXTENSIONS: readonly [".ts", ".js", ".tsx", ".jsx"];
|
|
2
|
+
export declare const SUPPORTED_DATA_EXTENSIONS: readonly [".json", ".yml", ".yaml"];
|
|
3
|
+
export declare const SUPPORTED_TEXT_EXTENSIONS: readonly [".md", ".txt"];
|
|
4
|
+
export declare const DEFAULT_SEARCH_EXTENSIONS: readonly [".ts", ".js", ".tsx", ".jsx", ".json", ".yml", ".yaml", ".md", ".txt"];
|
|
5
|
+
export declare const OPERATOR_METHOD_PREFIX = "__operator_";
|
|
6
|
+
export declare const OPERATOR_METHOD_SUFFIX = "__";
|
|
7
|
+
export declare const APP_VERSION = "1.0.0";
|
|
8
|
+
export declare const APP_NAME = "1ls";
|
|
9
|
+
export declare const VALID_OUTPUT_FORMATS: readonly ["json", "yaml", "csv", "table"];
|
|
10
|
+
export declare const VALID_INPUT_FORMATS: readonly ["json", "yaml", "toml", "csv", "tsv", "lines", "text"];
|
|
11
|
+
export declare const VALID_OBJECT_OPERATIONS: readonly ["keys", "values", "entries", "length"];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FileInfo, ListOptions, GrepOptions, GrepResult } from "./types";
|
|
2
|
+
export declare function readFile(path: string): Promise<any>;
|
|
3
|
+
export declare function writeFile(path: string, content: any): Promise<void>;
|
|
4
|
+
export declare function getFileInfo(path: string): Promise<FileInfo>;
|
|
5
|
+
export declare function listFiles(dir: string, options?: ListOptions): Promise<FileInfo[]>;
|
|
6
|
+
export declare function grep(pattern: string | RegExp, path: string, options?: GrepOptions): Promise<GrepResult[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const LogLevel: {
|
|
2
|
+
readonly ERROR: 0;
|
|
3
|
+
readonly WARN: 1;
|
|
4
|
+
readonly INFO: 2;
|
|
5
|
+
readonly DEBUG: 3;
|
|
6
|
+
};
|
|
7
|
+
export type LogLevelType = (typeof LogLevel)[keyof typeof LogLevel];
|
|
8
|
+
export interface LogData {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export declare class Logger {
|
|
12
|
+
private level;
|
|
13
|
+
private name;
|
|
14
|
+
constructor(name: string, level?: LogLevelType);
|
|
15
|
+
setLevel(level: LogLevelType): void;
|
|
16
|
+
private formatMessage;
|
|
17
|
+
error(message: string, error?: Error): void;
|
|
18
|
+
warn(message: string): void;
|
|
19
|
+
info(message: string): void;
|
|
20
|
+
debug(message: string, data?: LogData): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function createLogger(name: string): Logger;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DataFormat } from "./types";
|
|
2
|
+
export declare function detectFormat(input: string): DataFormat;
|
|
3
|
+
export declare function parseLines(input: string): string[];
|
|
4
|
+
export declare function parseCSV(input: string, delimiter?: string): any[];
|
|
5
|
+
export declare function parseTSV(input: string): any[];
|
|
6
|
+
export declare function parseYAML(input: string): any;
|
|
7
|
+
export declare function parseTOML(input: string): any;
|
|
8
|
+
export declare function parseInput(input: string, format?: DataFormat): any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ShortcutMapping } from "./types";
|
|
2
|
+
export declare const SHORTCUTS: ShortcutMapping[];
|
|
3
|
+
export declare function expandShortcuts(expression: string): string;
|
|
4
|
+
export declare function shortenExpression(expression: string): string;
|
|
5
|
+
export declare function getShortcutHelp(): string;
|
|
6
|
+
export declare function isShortcut(method: string): boolean;
|
|
7
|
+
export declare function getFullMethod(shortMethod: string): string | undefined;
|
|
8
|
+
export declare function getShortMethod(fullMethod: string): string | undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface FileInfo {
|
|
2
|
+
path: string;
|
|
3
|
+
name: string;
|
|
4
|
+
ext: string;
|
|
5
|
+
size: number;
|
|
6
|
+
isDirectory: boolean;
|
|
7
|
+
isFile: boolean;
|
|
8
|
+
modified: Date;
|
|
9
|
+
created: Date;
|
|
10
|
+
}
|
|
11
|
+
export interface ListOptions {
|
|
12
|
+
recursive?: boolean;
|
|
13
|
+
pattern?: RegExp;
|
|
14
|
+
extensions?: string[];
|
|
15
|
+
includeHidden?: boolean;
|
|
16
|
+
maxDepth?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface GrepOptions {
|
|
19
|
+
ignoreCase?: boolean;
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
maxMatches?: number;
|
|
22
|
+
showLineNumbers?: boolean;
|
|
23
|
+
context?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface GrepResult {
|
|
26
|
+
file: string;
|
|
27
|
+
line: number;
|
|
28
|
+
column: number;
|
|
29
|
+
match: string;
|
|
30
|
+
context?: string[];
|
|
31
|
+
}
|
|
32
|
+
export type DataFormat = "json" | "yaml" | "toml" | "csv" | "tsv" | "lines" | "text";
|
|
33
|
+
export interface ShortcutMapping {
|
|
34
|
+
short: string;
|
|
35
|
+
full: string;
|
|
36
|
+
description: string;
|
|
37
|
+
type: "array" | "object" | "string" | "any";
|
|
38
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"workspaces": [
|
|
3
|
+
"site"
|
|
4
|
+
],
|
|
5
|
+
"name": "1ls",
|
|
6
|
+
"version": "0.0.1",
|
|
7
|
+
"description": "1 line script - Lightweight JSON CLI with JavaScript syntax",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"1ls": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"bun": ">=1.0.0"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "bun run clean && bun build ./src/cli/index.ts --outdir dist --target bun --minify && tsc --emitDeclarationOnly --outDir dist",
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"dev": "bun run ./src/cli/index.ts",
|
|
29
|
+
"prepublishOnly": "bun run test && bun run build",
|
|
30
|
+
"test": "bun test",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "bunx oxlint src/",
|
|
33
|
+
"lint:fix": "bunx oxlint src/ --fix",
|
|
34
|
+
"format": "bunx prettier --check 'src/**/*.{ts,tsx,js,jsx,json}'",
|
|
35
|
+
"format:fix": "bunx prettier --write 'src/**/*.{ts,tsx,js,jsx,json}'"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"json",
|
|
39
|
+
"cli",
|
|
40
|
+
"javascript",
|
|
41
|
+
"bun",
|
|
42
|
+
"fx",
|
|
43
|
+
"jq"
|
|
44
|
+
],
|
|
45
|
+
"author": "Jeff Wainwright <https://jeffry.in> (yowainwright@gmail.com)",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/yowainwright/1ls.git"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/yowainwright/1ls/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/yowainwright/1ls",
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/bun": "latest",
|
|
57
|
+
"turbo": "^2.3.3",
|
|
58
|
+
"typescript": "5.9.2"
|
|
59
|
+
},
|
|
60
|
+
"packageManager": "bun@1.1.38"
|
|
61
|
+
}
|