autotel-cli 0.1.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 +220 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2889 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# autotel-cli
|
|
2
|
+
|
|
3
|
+
CLI for autotel - setup wizard, diagnostics, and incremental features.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g autotel-cli
|
|
9
|
+
# or
|
|
10
|
+
npx autotel <command>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
### `autotel init`
|
|
16
|
+
|
|
17
|
+
Interactive setup wizard to initialize autotel in your project.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Interactive mode
|
|
21
|
+
npx autotel init
|
|
22
|
+
|
|
23
|
+
# Use defaults (local backend, all auto-instrumentations)
|
|
24
|
+
npx autotel init --yes
|
|
25
|
+
|
|
26
|
+
# Use a quick preset
|
|
27
|
+
npx autotel init --preset node-datadog-pino
|
|
28
|
+
|
|
29
|
+
# Dry run - see what would be created
|
|
30
|
+
npx autotel init --dry-run
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Options:**
|
|
34
|
+
- `--yes, -y` - Accept defaults, non-interactive
|
|
35
|
+
- `--preset <name>` - Use a quick preset (e.g., `node-datadog-pino`, `node-honeycomb`)
|
|
36
|
+
- `--dry-run` - Skip installation and print what would be done
|
|
37
|
+
- `--no-install` - Generate files only, skip package installation
|
|
38
|
+
- `--force` - Overwrite existing config (creates backup first)
|
|
39
|
+
|
|
40
|
+
**Quick presets:**
|
|
41
|
+
- `node-datadog-pino` - Node.js + Datadog + Pino logging
|
|
42
|
+
- `node-datadog-agent` - Node.js + Datadog Agent (local development)
|
|
43
|
+
- `node-honeycomb` - Node.js + Honeycomb
|
|
44
|
+
- `node-otlp` - Node.js + Generic OTLP endpoint
|
|
45
|
+
|
|
46
|
+
### `autotel doctor`
|
|
47
|
+
|
|
48
|
+
Run diagnostics on your autotel setup.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Run all checks
|
|
52
|
+
npx autotel doctor
|
|
53
|
+
|
|
54
|
+
# Output as JSON
|
|
55
|
+
npx autotel doctor --json
|
|
56
|
+
|
|
57
|
+
# Auto-fix resolvable issues
|
|
58
|
+
npx autotel doctor --fix
|
|
59
|
+
|
|
60
|
+
# List available checks
|
|
61
|
+
npx autotel doctor --list-checks
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Options:**
|
|
65
|
+
- `--json` - Output machine-readable JSON
|
|
66
|
+
- `--fix` - Auto-fix resolvable issues
|
|
67
|
+
- `--list-checks` - List all available checks
|
|
68
|
+
- `--env-file <path>` - Specify env file to check
|
|
69
|
+
|
|
70
|
+
**Exit codes:**
|
|
71
|
+
- `0` - All checks passed
|
|
72
|
+
- `1` - Warnings found
|
|
73
|
+
- `2` - Errors found
|
|
74
|
+
|
|
75
|
+
### `autotel add <type> <name>`
|
|
76
|
+
|
|
77
|
+
Add a backend, subscriber, plugin, or platform incrementally.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Add Datadog backend
|
|
81
|
+
npx autotel add backend datadog
|
|
82
|
+
|
|
83
|
+
# Add PostHog event subscriber
|
|
84
|
+
npx autotel add subscriber posthog
|
|
85
|
+
|
|
86
|
+
# Add Mongoose plugin
|
|
87
|
+
npx autotel add plugin mongoose
|
|
88
|
+
|
|
89
|
+
# List all available presets
|
|
90
|
+
npx autotel add --list
|
|
91
|
+
|
|
92
|
+
# List backends only
|
|
93
|
+
npx autotel add backend --list
|
|
94
|
+
|
|
95
|
+
# Show help for a specific preset
|
|
96
|
+
npx autotel add backend datadog --help
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Types:**
|
|
100
|
+
- `backend` - Telemetry backends (Datadog, Honeycomb, OTLP, etc.)
|
|
101
|
+
- `subscriber` - Event subscribers (PostHog, Mixpanel, Segment, Slack, etc.)
|
|
102
|
+
- `plugin` - Database/ORM plugins (Mongoose, Drizzle, etc.)
|
|
103
|
+
- `platform` - Platform support (AWS Lambda, Cloudflare Workers, etc.)
|
|
104
|
+
|
|
105
|
+
**Options:**
|
|
106
|
+
- `--list` - List available presets
|
|
107
|
+
- `--dry-run` - Skip installation and print what would be done
|
|
108
|
+
- `--force` - Overwrite non-CLI-owned config (creates backup first)
|
|
109
|
+
|
|
110
|
+
## Global Options
|
|
111
|
+
|
|
112
|
+
All commands support these options:
|
|
113
|
+
|
|
114
|
+
- `--cwd <path>` - Target directory (default: current working directory)
|
|
115
|
+
- `--verbose` - Show detailed output
|
|
116
|
+
- `--quiet` - Only show warnings and errors
|
|
117
|
+
|
|
118
|
+
## Package Manager Detection
|
|
119
|
+
|
|
120
|
+
The CLI automatically detects your package manager from the nearest lockfile:
|
|
121
|
+
|
|
122
|
+
1. `pnpm-lock.yaml` → pnpm
|
|
123
|
+
2. `bun.lockb` → bun
|
|
124
|
+
3. `yarn.lock` → yarn
|
|
125
|
+
4. `package-lock.json` → npm
|
|
126
|
+
|
|
127
|
+
Fallback: npm if no lockfile found.
|
|
128
|
+
|
|
129
|
+
## Monorepo Support
|
|
130
|
+
|
|
131
|
+
The CLI detects workspace roots and handles installation correctly:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Install at package root (default)
|
|
135
|
+
npx autotel init --cwd ./packages/my-app
|
|
136
|
+
|
|
137
|
+
# Install at workspace root
|
|
138
|
+
npx autotel init --cwd ./packages/my-app --workspace-root
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Generated Files
|
|
142
|
+
|
|
143
|
+
### `src/instrumentation.mts`
|
|
144
|
+
|
|
145
|
+
The CLI generates an instrumentation file with clear section markers:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
/**
|
|
149
|
+
* autotel instrumentation - managed by autotel-cli
|
|
150
|
+
* Run `autotel add <feature>` to update this file
|
|
151
|
+
*/
|
|
152
|
+
import 'autotel/register';
|
|
153
|
+
import { init } from 'autotel';
|
|
154
|
+
|
|
155
|
+
// --- AUTOTEL:BACKEND ---
|
|
156
|
+
import { createDatadogConfig } from 'autotel-backends/datadog';
|
|
157
|
+
|
|
158
|
+
init({
|
|
159
|
+
// --- AUTOTEL:BACKEND_CONFIG ---
|
|
160
|
+
...createDatadogConfig({
|
|
161
|
+
apiKey: process.env.DATADOG_API_KEY,
|
|
162
|
+
}),
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### `.env.example`
|
|
167
|
+
|
|
168
|
+
Environment variable template based on selected presets:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Autotel configuration
|
|
172
|
+
# Copy to .env and fill in values
|
|
173
|
+
|
|
174
|
+
# Datadog API key for authentication
|
|
175
|
+
# ⚠️ SENSITIVE: Do not commit this value
|
|
176
|
+
DATADOG_API_KEY=your-api-key
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Starting Your App
|
|
180
|
+
|
|
181
|
+
After running `autotel init`, start your app with the `--import` flag:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Node.js ESM
|
|
185
|
+
node --import ./src/instrumentation.mts dist/index.js
|
|
186
|
+
|
|
187
|
+
# With tsx (development)
|
|
188
|
+
tsx --import ./src/instrumentation.mts src/index.ts
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Or add it to your `package.json` scripts:
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"scripts": {
|
|
196
|
+
"start": "node --import ./src/instrumentation.mjs dist/index.js",
|
|
197
|
+
"dev": "tsx --import ./src/instrumentation.mts src/index.ts"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Development
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Install dependencies
|
|
206
|
+
pnpm install
|
|
207
|
+
|
|
208
|
+
# Build
|
|
209
|
+
pnpm build
|
|
210
|
+
|
|
211
|
+
# Run tests
|
|
212
|
+
pnpm test
|
|
213
|
+
|
|
214
|
+
# Type check
|
|
215
|
+
pnpm typecheck
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT
|
package/dist/index.d.ts
ADDED