flagdoctor 0.0.0-stage → 0.2.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 +102 -2
- package/dist/index.js +4234 -0
- package/package.json +24 -4
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# FlagDoctor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Check that your code agrees with your [Flagsmith](https://flagsmith.com) feature-flag configuration — and see exactly where it doesn't.
|
|
4
|
+
|
|
5
|
+
FlagDoctor scans your source code (statically, read-only; it never runs your code), compares the flags it finds with a Flagsmith project and environment, and reports problems with file, line and column. It also maps which files, classes and functions each flag affects.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Requires Node.js 22.12 or newer.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g flagdoctor
|
|
13
|
+
flagdoctor --help
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or run it without installing: `npx flagdoctor scan --env production`.
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# 1. Sign in to your FlagDoctor dashboard (opens the browser; approve the code shown)
|
|
22
|
+
flagdoctor login --api-url https://your-flagdoctor.example.com
|
|
23
|
+
|
|
24
|
+
# 2. In your repository: create flagdoctor.yaml (guided; picks your Flagsmith project and environments)
|
|
25
|
+
cd my-app
|
|
26
|
+
flagdoctor init
|
|
27
|
+
|
|
28
|
+
# 3. Provide your Flagsmith Organisation API token (never written to flagdoctor.yaml)
|
|
29
|
+
export FLAGSMITH_TOKEN=... # PowerShell: $env:FLAGSMITH_TOKEN = "..."
|
|
30
|
+
|
|
31
|
+
# 4. Scan
|
|
32
|
+
flagdoctor scan --env production
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The report is uploaded to your dashboard automatically after `login`. Without `login`, FlagDoctor works fully offline from the dashboard: it just prints the report.
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
| Command | What it does |
|
|
40
|
+
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `flagdoctor login [--api-url <url>]` | Authorize this machine through the browser. Stores a project-scoped credential outside your repo. |
|
|
42
|
+
| `flagdoctor whoami` | Show the signed-in project. |
|
|
43
|
+
| `flagdoctor init [--ci] [--force]` | Create `flagdoctor.yaml`. `--ci` writes a starter file without prompts. |
|
|
44
|
+
| `flagdoctor scan --env <alias>` | Scan the repository and report findings. |
|
|
45
|
+
| `flagdoctor graph --env <alias> [--flag <name>]` | Show which files, classes and functions each flag affects. |
|
|
46
|
+
| `flagdoctor analyze --env <alias>` | AI review of the findings and dependency map (needs `GROQ_API_KEY`). |
|
|
47
|
+
|
|
48
|
+
Common options: `--format json` (machine-readable report), `--root <path>` (scan another directory), `-c, --config <path>`, `--ci` (plain output), `--no-sync` (don't upload).
|
|
49
|
+
|
|
50
|
+
## What it reports
|
|
51
|
+
|
|
52
|
+
| Rule | Meaning |
|
|
53
|
+
| ----- | ------------------------------------------------------------------------------- |
|
|
54
|
+
| FD001 | Code references a flag that doesn't exist in the Flagsmith environment (error). |
|
|
55
|
+
| FD002 | Code references an archived flag (error). |
|
|
56
|
+
| FD004 | A flag's value type doesn't match how the code reads it (warning). |
|
|
57
|
+
| FD006 | A flag name can't be resolved statically — reported, never guessed (info). |
|
|
58
|
+
| FDLLM | AI-suggested hints from `analyze`; low confidence, never fail a build. |
|
|
59
|
+
|
|
60
|
+
A disabled flag is not an error. JavaScript/TypeScript and Java are supported (Flagsmith JS and Java SDKs).
|
|
61
|
+
|
|
62
|
+
## Use in CI
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
flagdoctor scan --env production --ci --format json > flagdoctor-report.json
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Exit codes: `0` clean (warnings/info only), `1` confirmed errors, `2` configuration, credential or API failure, or an incomplete scan.
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
`flagdoctor.yaml` (created by `init`) holds only non-secret settings:
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
version: 1
|
|
76
|
+
repository:
|
|
77
|
+
root: .
|
|
78
|
+
include: []
|
|
79
|
+
exclude: []
|
|
80
|
+
flagsmith:
|
|
81
|
+
baseUrl: https://api.flagsmith.com/api/v1
|
|
82
|
+
project: 12345
|
|
83
|
+
environments:
|
|
84
|
+
production: <environment-api-key>
|
|
85
|
+
development: <environment-api-key>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Secrets come from the environment only:
|
|
89
|
+
|
|
90
|
+
| Variable | Used for |
|
|
91
|
+
| ------------------------ | -------------------------------------------------------------------------------------------- |
|
|
92
|
+
| `FLAGSMITH_TOKEN` | Flagsmith Organisation API token (required for `scan`, `graph`, `analyze`). |
|
|
93
|
+
| `GROQ_API_KEY` | Optional, enables `analyze`. Only findings and the dependency map are sent — no source code. |
|
|
94
|
+
| `FLAGDOCTOR_API_URL` | Dashboard server to sync with (alternative to `login --api-url`). |
|
|
95
|
+
| `FLAGDOCTOR_NO_SPLASH=1` | Turn off the welcome animation. |
|
|
96
|
+
|
|
97
|
+
A `.env` file in the working directory is also read.
|
|
98
|
+
|
|
99
|
+
## Privacy and safety
|
|
100
|
+
|
|
101
|
+
- Scans are static and read-only; repository code is never executed.
|
|
102
|
+
- Tokens are never printed, logged, or written to `flagdoctor.yaml`.
|
|
103
|
+
- Nothing in Flagsmith is modified.
|