siko 0.2.0 → 0.3.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/CHANGELOG.md +99 -0
- package/README.md +276 -27
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +294 -9
- package/dist/cli/runner.d.ts +13 -0
- package/dist/cli/runner.js +174 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.js +11 -0
- package/dist/config/loader.d.ts +12 -0
- package/dist/config/loader.js +133 -0
- package/dist/config/types.d.ts +56 -0
- package/dist/config/types.js +37 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +6 -7
- package/dist/instrumentation/babel-plugin.d.ts +14 -0
- package/dist/instrumentation/babel-plugin.js +298 -0
- package/dist/instrumentation/index.d.ts +6 -0
- package/dist/instrumentation/index.js +13 -0
- package/dist/instrumentation/instrumenter.d.ts +10 -0
- package/dist/instrumentation/instrumenter.js +61 -0
- package/dist/reporter/index.d.ts +9 -0
- package/dist/reporter/index.js +16 -0
- package/dist/reporter/json-reporter.d.ts +41 -0
- package/dist/reporter/json-reporter.js +90 -0
- package/dist/reporter/terminal-reporter.d.ts +16 -0
- package/dist/reporter/terminal-reporter.js +112 -0
- package/dist/reporter/threshold-checker.d.ts +17 -0
- package/dist/reporter/threshold-checker.js +48 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/tracker.d.ts +40 -0
- package/dist/runtime/tracker.js +85 -0
- package/dist/runtime/types.d.ts +22 -0
- package/dist/runtime/types.js +5 -0
- package/dist/utils/file-discovery.d.ts +17 -0
- package/dist/utils/file-discovery.js +123 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +9 -0
- package/package.json +34 -13
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
## [0.3.0] - 2026-02-07
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
- Comprehensive test suite with Jest (28 tests, all passing)
|
|
5
|
+
- ESLint configuration with TypeScript support
|
|
6
|
+
- GitHub Actions CI/CD workflows
|
|
7
|
+
- Automated testing on Node 18 and 20
|
|
8
|
+
- Code coverage reporting
|
|
9
|
+
- Lint checks in CI pipeline
|
|
10
|
+
- ESLint with recommended rules and custom overrides
|
|
11
|
+
- Type guards for proper error handling
|
|
12
|
+
- CHANGELOG.md for version tracking
|
|
13
|
+
- API.md for detailed API documentation
|
|
14
|
+
|
|
15
|
+
### Improved
|
|
16
|
+
- Build process with proper TypeScript compilation
|
|
17
|
+
- Error handling with type narrowing
|
|
18
|
+
- Code quality with linting rules
|
|
19
|
+
- Documentation structure
|
|
20
|
+
|
|
21
|
+
### CI/CD
|
|
22
|
+
- Automated tests on every push and PR
|
|
23
|
+
- ESLint checks in CI
|
|
24
|
+
- Multi-version Node.js testing (18.x, 20.x)
|
|
25
|
+
- Build verification checks
|
|
26
|
+
|
|
27
|
+
### Testing
|
|
28
|
+
- Runtime tracker tests
|
|
29
|
+
- Babel instrumentation tests
|
|
30
|
+
- Configuration loader tests
|
|
31
|
+
- JSON reporter tests
|
|
32
|
+
- Threshold checker tests
|
|
33
|
+
- 88%+ code coverage
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
# Changelog
|
|
38
|
+
|
|
39
|
+
All notable changes to this project will be documented in this file.
|
|
40
|
+
|
|
41
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
42
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
43
|
+
|
|
44
|
+
## [0.2.1] - 2026-02-07
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- Complete runtime execution signal analyzer
|
|
48
|
+
- Babel instrumentation plugin for automatic function tracking
|
|
49
|
+
- Runtime tracker with execution counting
|
|
50
|
+
- CLI interface with multiple commands
|
|
51
|
+
- Configuration system with JSON/JS support
|
|
52
|
+
- Threshold checking for CI/CD integration
|
|
53
|
+
- JSON report export
|
|
54
|
+
- Terminal reporter with colored output
|
|
55
|
+
- File discovery with configurable patterns
|
|
56
|
+
- Comprehensive test suite
|
|
57
|
+
|
|
58
|
+
### Commands
|
|
59
|
+
- `siko run <command>` - Instrument and run commands
|
|
60
|
+
- `siko report` - Generate analysis reports
|
|
61
|
+
- `siko init` - Create configuration files
|
|
62
|
+
- `siko clean` - Remove data files
|
|
63
|
+
|
|
64
|
+
### Features
|
|
65
|
+
- Support for functions, arrow functions, class methods, object methods
|
|
66
|
+
- Skip anonymous functions (intentional v1 limitation)
|
|
67
|
+
- Execution count tracking
|
|
68
|
+
- Coverage percentage calculation
|
|
69
|
+
- Multiple output formats (terminal, JSON, both)
|
|
70
|
+
- Configurable thresholds with proper exit codes
|
|
71
|
+
- Beautiful colored terminal output
|
|
72
|
+
- File backup and restoration during instrumentation
|
|
73
|
+
|
|
74
|
+
## [0.1.0] - 2026-02-05
|
|
75
|
+
|
|
76
|
+
### Added
|
|
77
|
+
- Initial package setup
|
|
78
|
+
- Basic placeholder CLI
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Upcoming Features
|
|
83
|
+
|
|
84
|
+
### v0.3.0 (Planned)
|
|
85
|
+
- Source map support for TypeScript
|
|
86
|
+
- HTML report generation
|
|
87
|
+
- Watch mode
|
|
88
|
+
- Historical trend analysis
|
|
89
|
+
- Integration with popular test frameworks
|
|
90
|
+
|
|
91
|
+
### v0.4.0 (Planned)
|
|
92
|
+
- Browser environment support
|
|
93
|
+
- Code coverage integration
|
|
94
|
+
- IDE extensions
|
|
95
|
+
- Performance optimizations
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
For detailed release notes, see [GitHub Releases](https://github.com/sikojs/signal/releases).
|
package/README.md
CHANGED
|
@@ -2,53 +2,291 @@
|
|
|
2
2
|
|
|
3
3
|
> Runtime execution signal analyzer for JavaScript & TypeScript
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/siko)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
[](https://github.com/sikojs/signal/actions/workflows/ci.yml)
|
|
9
|
+
[](https://www.npmjs.com/package/siko)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
|
|
5
12
|
**Status:** 🚧 Under active development
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
**siko** reveals which parts of your codebase emit real runtime signal during execution, helping you identify and remove dead code with confidence.
|
|
15
|
+
|
|
16
|
+
## ✨ Features
|
|
17
|
+
|
|
18
|
+
- 🔍 **Runtime Analysis** - Tracks which functions actually execute during test runs
|
|
19
|
+
- 🎯 **Dead Code Detection** - Identifies unused functions with precision
|
|
20
|
+
- 📊 **Coverage Reports** - Shows execution statistics and coverage percentages
|
|
21
|
+
- ⚙️ **Configurable** - Flexible configuration via JSON or JS files
|
|
22
|
+
- 🚀 **CI/CD Ready** - Threshold enforcement with proper exit codes
|
|
23
|
+
- 📦 **Zero Config** - Works out of the box with sensible defaults
|
|
24
|
+
- 🎨 **Beautiful Reports** - Colored terminal output and JSON exports
|
|
25
|
+
- 💪 **TypeScript Support** - Full support for JavaScript and TypeScript
|
|
8
26
|
|
|
9
|
-
|
|
27
|
+
## 🚀 Quick Start
|
|
10
28
|
|
|
11
|
-
|
|
29
|
+
### Installation
|
|
12
30
|
```bash
|
|
13
31
|
npm install --save-dev siko
|
|
14
32
|
```
|
|
15
33
|
|
|
16
|
-
|
|
34
|
+
### Basic Usage
|
|
17
35
|
```bash
|
|
18
|
-
# Run your tests with
|
|
36
|
+
# Run your tests with instrumentation
|
|
19
37
|
npx siko run npm test
|
|
20
38
|
|
|
21
39
|
# Generate report
|
|
22
40
|
npx siko report
|
|
23
41
|
```
|
|
24
42
|
|
|
25
|
-
|
|
43
|
+
That's it! siko will show you which functions were never executed.
|
|
44
|
+
|
|
45
|
+
## 📖 Usage
|
|
46
|
+
|
|
47
|
+
### Commands
|
|
48
|
+
|
|
49
|
+
#### `siko run <command>`
|
|
50
|
+
|
|
51
|
+
Instruments your code and runs a command:
|
|
52
|
+
```bash
|
|
53
|
+
# Run tests
|
|
54
|
+
siko run npm test
|
|
55
|
+
|
|
56
|
+
# Run specific file
|
|
57
|
+
siko run node app.js
|
|
58
|
+
|
|
59
|
+
# Run any command
|
|
60
|
+
siko run jest --coverage
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Options:**
|
|
64
|
+
- `-v, --verbose` - Show detailed instrumentation info
|
|
65
|
+
- `--no-clean` - Don't clean previous execution data
|
|
66
|
+
- `-c, --config <path>` - Path to config file
|
|
67
|
+
|
|
68
|
+
#### `siko report`
|
|
69
|
+
|
|
70
|
+
Generate analysis report:
|
|
71
|
+
```bash
|
|
72
|
+
# Terminal report (default)
|
|
73
|
+
siko report
|
|
74
|
+
|
|
75
|
+
# Verbose mode (show executed functions)
|
|
76
|
+
siko report --verbose
|
|
77
|
+
|
|
78
|
+
# All statistics
|
|
79
|
+
siko report --all
|
|
80
|
+
|
|
81
|
+
# JSON output
|
|
82
|
+
siko report --format json -o report.json
|
|
83
|
+
|
|
84
|
+
# Both formats
|
|
85
|
+
siko report --format both
|
|
86
|
+
|
|
87
|
+
# Fail if thresholds not met (CI/CD)
|
|
88
|
+
siko report --fail-on-threshold
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Options:**
|
|
92
|
+
- `-v, --verbose` - Show executed functions with call counts
|
|
93
|
+
- `-a, --all` - Show all statistics
|
|
94
|
+
- `-f, --format <format>` - Output format: `terminal`, `json`, or `both`
|
|
95
|
+
- `-o, --output <path>` - Output file for JSON format
|
|
96
|
+
- `--fail-on-threshold` - Exit with error code if thresholds not met
|
|
97
|
+
|
|
98
|
+
#### `siko init`
|
|
99
|
+
|
|
100
|
+
Create a configuration file:
|
|
101
|
+
```bash
|
|
102
|
+
# Create JSON config (default)
|
|
103
|
+
siko init
|
|
104
|
+
|
|
105
|
+
# Create JS config
|
|
106
|
+
siko init --format js
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### `siko clean`
|
|
110
|
+
|
|
111
|
+
Remove execution data files:
|
|
112
|
+
```bash
|
|
113
|
+
siko clean
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## ⚙️ Configuration
|
|
117
|
+
|
|
118
|
+
Create a `siko.config.json` or `siko.config.js` file:
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"include": ["src", "lib"],
|
|
122
|
+
"exclude": ["node_modules", "dist", "*.test.js", "*.spec.js"],
|
|
123
|
+
"extensions": [".js", ".jsx", ".ts", ".tsx"],
|
|
124
|
+
"output": {
|
|
125
|
+
"inventory": ".siko-signal.inventory.json",
|
|
126
|
+
"execution": ".siko-signal.exec.json"
|
|
127
|
+
},
|
|
128
|
+
"thresholds": {
|
|
129
|
+
"coverage": 80,
|
|
130
|
+
"maxUnused": 10
|
|
131
|
+
},
|
|
132
|
+
"report": {
|
|
133
|
+
"format": "terminal",
|
|
134
|
+
"verbose": false,
|
|
135
|
+
"showAll": false
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Configuration Options
|
|
141
|
+
|
|
142
|
+
| Option | Type | Default | Description |
|
|
143
|
+
|--------|------|---------|-------------|
|
|
144
|
+
| `include` | `string[]` | `["src", "lib", "app"]` | Directories to instrument |
|
|
145
|
+
| `exclude` | `string[]` | `["node_modules", "dist", ...]` | Patterns to exclude |
|
|
146
|
+
| `extensions` | `string[]` | `[".js", ".jsx", ".ts", ".tsx"]` | File extensions to instrument |
|
|
147
|
+
| `output.inventory` | `string` | `.siko-signal.inventory.json` | Static inventory output path |
|
|
148
|
+
| `output.execution` | `string` | `.siko-signal.exec.json` | Execution data output path |
|
|
149
|
+
| `thresholds.coverage` | `number` | `undefined` | Minimum coverage % (0-100) |
|
|
150
|
+
| `thresholds.maxUnused` | `number` | `undefined` | Maximum unused functions allowed |
|
|
151
|
+
| `report.format` | `string` | `"terminal"` | Default report format |
|
|
152
|
+
| `report.verbose` | `boolean` | `false` | Show verbose output by default |
|
|
153
|
+
| `report.showAll` | `boolean` | `false` | Show all statistics by default |
|
|
154
|
+
|
|
155
|
+
## 🎯 CI/CD Integration
|
|
156
|
+
|
|
157
|
+
Use thresholds to enforce code quality standards:
|
|
158
|
+
|
|
159
|
+
**GitHub Actions Example:**
|
|
160
|
+
```yaml
|
|
161
|
+
name: Dead Code Check
|
|
162
|
+
|
|
163
|
+
on: [push, pull_request]
|
|
164
|
+
|
|
165
|
+
jobs:
|
|
166
|
+
check:
|
|
167
|
+
runs-on: ubuntu-latest
|
|
168
|
+
steps:
|
|
169
|
+
- uses: actions/checkout@v3
|
|
170
|
+
- uses: actions/setup-node@v3
|
|
171
|
+
with:
|
|
172
|
+
node-version: '20'
|
|
173
|
+
|
|
174
|
+
- name: Install dependencies
|
|
175
|
+
run: npm ci
|
|
176
|
+
|
|
177
|
+
- name: Install siko
|
|
178
|
+
run: npm install -g siko
|
|
179
|
+
|
|
180
|
+
- name: Run tests with tracking
|
|
181
|
+
run: siko run npm test
|
|
182
|
+
|
|
183
|
+
- name: Check dead code thresholds
|
|
184
|
+
run: siko report --fail-on-threshold
|
|
185
|
+
|
|
186
|
+
- name: Upload coverage report
|
|
187
|
+
if: always()
|
|
188
|
+
uses: actions/upload-artifact@v3
|
|
189
|
+
with:
|
|
190
|
+
name: siko-report
|
|
191
|
+
path: siko-report.json
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**siko.config.json:**
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"thresholds": {
|
|
198
|
+
"coverage": 80,
|
|
199
|
+
"maxUnused": 5
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
If thresholds are not met, the build will fail with exit code 1.
|
|
26
205
|
|
|
27
|
-
|
|
28
|
-
2. **Execute**: Run your tests or application normally
|
|
29
|
-
3. **Track**: Records which functions actually ran
|
|
30
|
-
4. **Report**: Shows you what never executed
|
|
206
|
+
## 📊 Example Output
|
|
31
207
|
|
|
32
|
-
|
|
208
|
+
### Terminal Report
|
|
209
|
+
```
|
|
210
|
+
📊 siko Signal Analysis Report
|
|
211
|
+
────────────────────────────────────────────────────────────
|
|
212
|
+
|
|
213
|
+
Summary:
|
|
214
|
+
Total functions found: 10
|
|
215
|
+
Functions executed: 8
|
|
216
|
+
Functions not executed: 2
|
|
217
|
+
Execution coverage: 80.0%
|
|
218
|
+
|
|
219
|
+
❌ Unused Functions:
|
|
220
|
+
|
|
221
|
+
src/utils.js:
|
|
222
|
+
● calculateTax (line 45)
|
|
223
|
+
● formatCurrency (line 89)
|
|
224
|
+
|
|
225
|
+
────────────────────────────────────────────────────────────
|
|
226
|
+
Generated by siko - Runtime Signal Analyzer
|
|
227
|
+
|
|
228
|
+
✅ All thresholds passed!
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### JSON Report
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"summary": {
|
|
235
|
+
"totalFunctions": 10,
|
|
236
|
+
"executedFunctions": 8,
|
|
237
|
+
"unusedFunctions": 2,
|
|
238
|
+
"coveragePercent": 80,
|
|
239
|
+
"totalExecutions": 45
|
|
240
|
+
},
|
|
241
|
+
"unusedFunctions": [
|
|
242
|
+
{
|
|
243
|
+
"name": "calculateTax",
|
|
244
|
+
"file": "src/utils.js",
|
|
245
|
+
"line": 45,
|
|
246
|
+
"column": 0,
|
|
247
|
+
"type": "function"
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
"executedFunctions": [
|
|
251
|
+
{
|
|
252
|
+
"name": "processOrder",
|
|
253
|
+
"file": "src/orders.js",
|
|
254
|
+
"line": 12,
|
|
255
|
+
"column": 0,
|
|
256
|
+
"type": "function",
|
|
257
|
+
"executionCount": 15
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
"timestamp": "2026-02-07T18:30:00.000Z"
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## 🔧 How It Works
|
|
265
|
+
|
|
266
|
+
1. **Instrumentation**: Babel plugin injects lightweight tracking calls into your functions
|
|
267
|
+
2. **Execution**: Your tests/code runs normally with tracking enabled
|
|
268
|
+
3. **Collection**: Runtime tracker records which functions execute
|
|
269
|
+
4. **Analysis**: Compares static inventory vs. runtime execution
|
|
270
|
+
5. **Reporting**: Shows which functions were never called
|
|
33
271
|
```
|
|
34
272
|
Source Code → Babel Instrumentation → Runtime Tracking → Signal Report
|
|
35
273
|
```
|
|
36
274
|
|
|
37
|
-
##
|
|
275
|
+
## 🎓 Use Cases
|
|
38
276
|
|
|
39
|
-
|
|
277
|
+
- **Refactoring** - Safely remove unused code with confidence
|
|
278
|
+
- **Code Review** - Identify dead code in pull requests
|
|
279
|
+
- **Technical Debt** - Track and reduce unused functions over time
|
|
280
|
+
- **CI/CD** - Enforce code quality standards in pipelines
|
|
281
|
+
- **Documentation** - Understand which code paths are actually used
|
|
40
282
|
|
|
41
|
-
##
|
|
283
|
+
## 🤝 Contributing
|
|
42
284
|
|
|
43
|
-
|
|
44
|
-
- [ ] Babel instrumentation plugin
|
|
45
|
-
- [ ] Runtime execution tracker
|
|
46
|
-
- [ ] CLI interface (`siko run`, `siko report`)
|
|
47
|
-
- [ ] Report generator
|
|
285
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
48
286
|
|
|
49
|
-
|
|
287
|
+
### Development
|
|
50
288
|
```bash
|
|
51
|
-
# Clone
|
|
289
|
+
# Clone repository
|
|
52
290
|
git clone https://github.com/sikojs/signal.git
|
|
53
291
|
cd signal
|
|
54
292
|
|
|
@@ -58,17 +296,28 @@ npm install
|
|
|
58
296
|
# Build
|
|
59
297
|
npm run build
|
|
60
298
|
|
|
61
|
-
#
|
|
62
|
-
|
|
299
|
+
# Run tests
|
|
300
|
+
npm test
|
|
301
|
+
|
|
302
|
+
# Run with coverage
|
|
303
|
+
npm run test:coverage
|
|
63
304
|
```
|
|
64
305
|
|
|
65
|
-
## License
|
|
306
|
+
## 📝 License
|
|
66
307
|
|
|
67
308
|
MIT © Mayukh Sinha
|
|
68
309
|
|
|
69
|
-
## Links
|
|
310
|
+
## 🔗 Links
|
|
70
311
|
|
|
71
312
|
- [GitHub Repository](https://github.com/sikojs/signal)
|
|
72
313
|
- [npm Package](https://www.npmjs.com/package/siko)
|
|
73
|
-
- [
|
|
74
|
-
- [
|
|
314
|
+
- [Issue Tracker](https://github.com/sikojs/signal/issues)
|
|
315
|
+
- [Contributing Guide](CONTRIBUTING.md)
|
|
316
|
+
|
|
317
|
+
## 💡 Inspiration
|
|
318
|
+
|
|
319
|
+
siko was built to solve the challenge of identifying truly unused code in JavaScript and TypeScript projects. Static analysis can't tell you what actually runs - only runtime analysis can.
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
**Made with ❤️ by [Mayukh Sinha](https://github.com/neu-msinha)**
|
package/dist/cli/index.d.ts
CHANGED