flagshark 1.1.1 → 1.1.2

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.
Files changed (3) hide show
  1. package/README.md +177 -0
  2. package/dist/cli.js +2 -2
  3. package/package.json +24 -20
package/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # flagshark
2
+
3
+ Find stale feature flags in your codebase. CLI tool + GitHub Action.
4
+
5
+ ```bash
6
+ npx flagshark scan
7
+ ```
8
+
9
+ ```
10
+ 🦈 FlagShark v1.1.1
11
+
12
+ Scanned 156 files across 4 languages
13
+ Detected providers: LaunchDarkly (JS SDK), Unleash (Go SDK)
14
+ Found 23 feature flags, 7 stale
15
+
16
+ Stale flags:
17
+ ┌──────────────────┬────────────────────────┬───────────────┬──────────────────────────────┐
18
+ │ Flag │ File │ Added │ Signal │
19
+ ├──────────────────┼────────────────────────┼───────────────┼──────────────────────────────┤
20
+ │ CHECKOUT_V2 │ src/checkout.ts:47 │ 14 months ago │ Age > 6 months │
21
+ │ NEW_NAV │ src/layout.tsx:12 │ 8 months ago │ Age > 6 months, Single file │
22
+ │ BETA_SEARCH │ src/search.ts:91 │ 11 months ago │ Single file reference │
23
+ └──────────────────┴────────────────────────┴───────────────┴──────────────────────────────┘
24
+
25
+ Flag Health Score: 70/100 (7/23 flags are stale)
26
+ ```
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ # Run without installing
32
+ npx flagshark scan
33
+
34
+ # Or install globally
35
+ npm install -g flagshark
36
+ ```
37
+
38
+ Building a tool on top of the engine? Use [`@flagshark/core`](https://www.npmjs.com/package/@flagshark/core) directly.
39
+
40
+ ## CLI Usage
41
+
42
+ ```bash
43
+ # Scan current directory
44
+ flagshark scan
45
+
46
+ # JSON output (for piping to other tools)
47
+ flagshark scan --json
48
+
49
+ # Only scan files changed since a git ref
50
+ flagshark scan --diff HEAD~1
51
+ flagshark scan --diff main
52
+
53
+ # Custom staleness threshold (default: 6 months)
54
+ flagshark scan --threshold 3
55
+
56
+ # Show all stale flags (default shows top 10)
57
+ flagshark scan --verbose
58
+ ```
59
+
60
+ ### Exit codes
61
+
62
+ | Code | Meaning |
63
+ |------|---------|
64
+ | 0 | No stale flags found |
65
+ | 1 | Stale flags detected |
66
+ | 2 | Runtime error |
67
+
68
+ ## GitHub Action
69
+
70
+ Add to your workflow:
71
+
72
+ ```yaml
73
+ name: FlagShark
74
+ on: [pull_request]
75
+
76
+ permissions:
77
+ contents: read
78
+ pull-requests: write
79
+
80
+ jobs:
81
+ flagshark:
82
+ runs-on: ubuntu-latest
83
+ steps:
84
+ - uses: actions/checkout@v4
85
+ with:
86
+ fetch-depth: 0 # Required for git blame (staleness) and changed-file scanning
87
+ - uses: FlagShark/flagshark@v1
88
+ env:
89
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90
+ ```
91
+
92
+ ### Action Inputs
93
+
94
+ | Input | Default | Description |
95
+ |-------|---------|-------------|
96
+ | `scan` | `changed` | `changed` (PR files only) or `full` (entire repo) |
97
+ | `threshold` | `6` | Staleness threshold in months |
98
+ | `fail-threshold` | `0` | Health score below which the check fails (0 = never fail) |
99
+
100
+ ### Scan Modes
101
+
102
+ **`scan: changed`** (default) scans only files modified in the PR. Fast, focused on what you're changing.
103
+
104
+ **`scan: full`** scans the entire repository. Shows your full flag health score and finds stale flags everywhere, not just in changed files:
105
+
106
+ ```yaml
107
+ - uses: FlagShark/flagshark@v1
108
+ with:
109
+ scan: full
110
+ env:
111
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112
+ ```
113
+
114
+ ### What the Action does
115
+
116
+ On every PR, FlagShark comments with a table of stale flags:
117
+
118
+ > ### 🦈 FlagShark found 3 stale flags
119
+ >
120
+ > | Flag | File | Added | Signal |
121
+ > |------|------|-------|--------|
122
+ > | `CHECKOUT_V2` | src/checkout.ts:47 | 14 months ago | Age > 6 months |
123
+ > | `NEW_NAV` | src/layout.tsx:12 | 8 months ago | Single file |
124
+ >
125
+ > **Flag Health:** 70/100
126
+
127
+ It also sets a GitHub status check that can optionally block merge if health drops below a threshold.
128
+
129
+ ## Supported Languages
130
+
131
+ FlagShark detects feature flags across 13 languages:
132
+
133
+ | Language | Extensions |
134
+ |----------|-----------|
135
+ | TypeScript/JavaScript | .ts, .tsx, .js, .jsx, .mjs, .cjs |
136
+ | Go | .go |
137
+ | Python | .py |
138
+ | Java | .java |
139
+ | Kotlin | .kt |
140
+ | Swift | .swift |
141
+ | Ruby | .rb |
142
+ | C# | .cs |
143
+ | PHP | .php |
144
+ | Rust | .rs |
145
+ | C/C++ | .c, .cpp, .h, .hpp |
146
+ | Objective-C | .m |
147
+
148
+ ## Supported Providers
149
+
150
+ Auto-detected from imports (no configuration needed):
151
+
152
+ - LaunchDarkly
153
+ - Unleash
154
+ - Flipt
155
+ - Split.io
156
+ - PostHog
157
+ - Flagsmith
158
+ - ConfigCat
159
+ - Statsig
160
+ - GrowthBook
161
+ - DevCycle
162
+ - Eppo
163
+ - Optimizely
164
+ - Custom flag implementations
165
+
166
+ ## How Staleness Works
167
+
168
+ A flag is marked stale if **any** of these signals fires:
169
+
170
+ 1. **Age:** `git blame` shows the flag reference was added more than 6 months ago (configurable with `--threshold`)
171
+ 2. **Single file:** The flag name appears in only one file across the entire repo, suggesting a completed rollout
172
+
173
+ FlagShark only checks files that actually import a flag SDK. A function called `isEnabled()` in a file that doesn't import LaunchDarkly/Unleash/etc. won't be flagged. This prevents false positives.
174
+
175
+ ## License
176
+
177
+ MIT
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import { scanRepo } from "@flagshark/core";
5
5
 
6
6
  // src/formatter.ts
7
- var VERSION = "1.1.1";
7
+ var VERSION = "1.1.2";
8
8
  function pad(str, width) {
9
9
  if (str.length > width) {
10
10
  return str.slice(0, width - 1) + "\u2026";
@@ -121,7 +121,7 @@ function formatJson(result) {
121
121
  }
122
122
 
123
123
  // src/cli.ts
124
- var VERSION2 = "1.1.1";
124
+ var VERSION2 = "1.1.2";
125
125
  var HELP_TEXT = `
126
126
  flagshark scan [options]
127
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flagshark",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "description": "Find stale feature flags in your codebase",
6
6
  "license": "MIT",
@@ -11,23 +11,27 @@
11
11
  "directory": "packages/cli"
12
12
  },
13
13
  "keywords": ["feature-flags", "stale-flags", "cleanup", "technical-debt"],
14
- "bin": { "flagshark": "./bin/flagshark.mjs" },
15
- "main": "./dist/cli.js",
16
- "files": ["dist/", "bin/"],
17
- "scripts": {
18
- "build": "esbuild src/cli.ts --bundle --platform=node --target=node18 --format=esm --outfile=dist/cli.js --external:zod --external:@flagshark/core",
19
- "test": "vitest run",
20
- "typecheck": "tsc --noEmit"
21
- },
22
- "dependencies": {
23
- "@flagshark/core": "^1.0.0",
24
- "zod": "^3.23.0"
25
- },
26
- "devDependencies": {
27
- "@types/node": "^22.0.0",
28
- "esbuild": "^0.24.0",
29
- "typescript": "^5.7.0",
30
- "vitest": "^3.0.0"
31
- },
32
- "engines": { "node": ">=18.0.0" }
14
+ "bin": {
15
+ "flagshark": "./bin/flagshark.mjs"
16
+ },
17
+ "main": "./dist/cli.js",
18
+ "files": ["dist/", "bin/"],
19
+ "scripts": {
20
+ "build": "esbuild src/cli.ts --bundle --platform=node --target=node18 --format=esm --outfile=dist/cli.js --external:zod --external:@flagshark/core",
21
+ "test": "vitest run",
22
+ "typecheck": "tsc --noEmit"
23
+ },
24
+ "dependencies": {
25
+ "@flagshark/core": "1.0.0",
26
+ "zod": "^3.23.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^22.0.0",
30
+ "esbuild": "^0.24.0",
31
+ "typescript": "^5.7.0",
32
+ "vitest": "^3.0.0"
33
+ },
34
+ "engines": {
35
+ "node": ">=18.0.0"
36
+ }
33
37
  }