@rahul05ranjan/dhruv-cli 1.4.6 → 1.5.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.
Files changed (76) hide show
  1. package/.github/workflows/ci.yml +18 -238
  2. package/.github/workflows/contribution.yml +6 -141
  3. package/.github/workflows/dependabot-auto-merge.yml +1 -0
  4. package/.github/workflows/labeler.yml +1 -0
  5. package/.github/workflows/security.yml +3 -0
  6. package/CHANGELOG.md +9 -4
  7. package/README.md +145 -40
  8. package/__tests__/cli-contract.test.ts +104 -0
  9. package/__tests__/core.test.ts +121 -0
  10. package/__tests__/diagnostics.test.ts +155 -0
  11. package/__tests__/file-workflows.test.ts +195 -0
  12. package/__tests__/interactive.test.ts +119 -0
  13. package/__tests__/setup.ts +1 -0
  14. package/__tests__/workflows.test.ts +27 -4
  15. package/dist/commands/generate.d.ts +6 -1
  16. package/dist/commands/generate.js +18 -4
  17. package/dist/commands/health.d.ts +4 -1
  18. package/dist/commands/health.js +59 -16
  19. package/dist/commands/init.js +11 -2
  20. package/dist/commands/menu.js +125 -100
  21. package/dist/commands/metrics.d.ts +5 -1
  22. package/dist/commands/metrics.js +37 -8
  23. package/dist/commands/optimize.js +1 -1
  24. package/dist/commands/review.d.ts +4 -1
  25. package/dist/commands/review.js +48 -8
  26. package/dist/commands/security-check.d.ts +4 -1
  27. package/dist/commands/security-check.js +67 -6
  28. package/dist/commands/status.js +40 -2
  29. package/dist/config/config.d.ts +5 -1
  30. package/dist/config/config.js +24 -7
  31. package/dist/core/ai.d.ts +11 -0
  32. package/dist/core/ai.js +33 -9
  33. package/dist/core/command-catalog.d.ts +10 -0
  34. package/dist/core/command-catalog.js +27 -0
  35. package/dist/core/command-runner.js +100 -21
  36. package/dist/core/logger.js +1 -0
  37. package/dist/core/metrics.d.ts +28 -0
  38. package/dist/core/metrics.js +78 -0
  39. package/dist/index.js +46 -24
  40. package/dist/utils/projectType.d.ts +1 -1
  41. package/dist/utils/projectType.js +26 -7
  42. package/docs/api/assets/highlight.css +4 -4
  43. package/docs/api/index.html +161 -39
  44. package/docs/api/media/CONTRIBUTING.md +60 -0
  45. package/docs/api/media/SECURITY.md +8 -0
  46. package/docs/api/media/dhruv-cli-preview.svg +42 -0
  47. package/docs/api/media/publishing-fix.md +34 -0
  48. package/docs/dhruv-cli-preview.svg +42 -0
  49. package/docs/index.html +631 -533
  50. package/docs/publishing-fix.md +34 -0
  51. package/package.json +1 -1
  52. package/src/commands/generate.ts +23 -4
  53. package/src/commands/health.ts +62 -17
  54. package/src/commands/init.ts +11 -2
  55. package/src/commands/menu.ts +54 -30
  56. package/src/commands/metrics.ts +42 -7
  57. package/src/commands/optimize.ts +1 -1
  58. package/src/commands/review.ts +53 -8
  59. package/src/commands/security-check.ts +80 -6
  60. package/src/commands/status.ts +39 -3
  61. package/src/config/config.ts +26 -7
  62. package/src/core/ai.ts +36 -8
  63. package/src/core/command-catalog.ts +37 -0
  64. package/src/core/command-runner.ts +102 -22
  65. package/src/core/logger.ts +1 -0
  66. package/src/core/metrics.ts +103 -0
  67. package/src/index.ts +45 -24
  68. package/src/utils/projectType.ts +22 -7
  69. package/tsconfig.json +1 -1
  70. package/.github/workflows/auto-assign.yml +0 -14
  71. package/.github/workflows/build-publish.yml +0 -154
  72. package/.github/workflows/deploy.yml +0 -336
  73. package/.github/workflows/monitoring.yml +0 -270
  74. package/PUBLISHING_FIX.md +0 -92
  75. package/logs/.8a99b6cf655346317fdbf29f4fffcf91131432f3-audit.json +0 -15
  76. package/logs/.eee104bf8fff5ecd38a6a2842df260de6470a7c3-audit.json +0 -15
@@ -1,119 +1,42 @@
1
- name: Dhruv CLI CI/CD
1
+ name: Dhruv CLI CI
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ main, develop ]
5
+ branches: [main]
6
6
  pull_request:
7
- branches: [ main, develop ]
8
- schedule:
9
- - cron: '0 2 * * 1' # Weekly security scans
10
-
11
- env:
12
- NODE_VERSION: '22.14.0'
13
- NODE_VERSION_MATRIX: '[18.x, 20.x, 21.x]'
7
+ branches: [main]
14
8
 
15
9
  permissions:
16
- contents: write
17
- security-events: write
18
- actions: read
19
- pull-requests: write
20
- id-token: write
21
- checks: write
10
+ contents: read
22
11
 
23
12
  jobs:
24
- security:
25
- name: Security Scan
26
- runs-on: ubuntu-latest
27
- timeout-minutes: 15
28
- steps:
29
- - name: Harden Runner
30
- uses: step-security/harden-runner@v2
31
- with:
32
- egress-policy: audit
33
-
34
- - uses: actions/checkout@v4
35
- with:
36
- fetch-depth: 0 # Full history for better security scanning
37
-
38
- - name: Set up Node.js
39
- uses: actions/setup-node@v4
40
- with:
41
- node-version: ${{ env.NODE_VERSION }}
42
- cache: 'npm'
43
-
44
- - name: Install dependencies
45
- run: npm ci --prefer-offline --no-audit
46
-
47
- - name: Run security audit
48
- run: npm audit --audit-level=moderate
49
- continue-on-error: true
50
-
51
- - name: Run Semgrep Security Scan
52
- uses: semgrep/semgrep-action@v1
53
- with:
54
- config: auto
55
- env:
56
- SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
57
- continue-on-error: true
58
-
59
- - name: Run Trivy vulnerability scanner
60
- uses: aquasecurity/trivy-action@master
61
- with:
62
- scan-type: 'fs'
63
- scan-ref: '.'
64
- format: 'sarif'
65
- output: 'trivy-results.sarif'
66
- severity: 'CRITICAL,HIGH,MEDIUM'
67
-
68
- - name: Upload Trivy scan results to GitHub Security tab
69
- uses: github/codeql-action/upload-sarif@v3
70
- if: always()
71
- with:
72
- sarif_file: 'trivy-results.sarif'
73
-
74
- - name: Run CodeQL Analysis
75
- uses: github/codeql-action/init@v3
76
- with:
77
- languages: javascript
78
- queries: security-and-quality
79
-
80
- - name: Perform CodeQL Analysis
81
- uses: github/codeql-action/analyze@v3
82
- with:
83
- category: "/language:javascript"
84
-
85
13
  test:
86
- name: Test Suite
87
- runs-on: ubuntu-latest
14
+ name: Test (${{ matrix.os }}, Node ${{ matrix.node-version }})
15
+ runs-on: ${{ matrix.os }}
88
16
  timeout-minutes: 20
89
17
  strategy:
90
18
  fail-fast: false
91
19
  matrix:
92
- node-version: [18.x, 20.x, 21.x]
93
- os: [ubuntu-latest, windows-latest, macos-latest]
94
20
  include:
95
- - node-version: 20.x
96
- coverage: true
97
- exclude:
98
- - os: windows-latest
21
+ - os: ubuntu-latest
99
22
  node-version: 18.x
23
+ - os: ubuntu-latest
24
+ node-version: 20.x
25
+ - os: ubuntu-latest
26
+ node-version: 22.x
27
+ coverage: true
100
28
  - os: macos-latest
101
- node-version: 18.x
29
+ node-version: 22.x
30
+ - os: windows-latest
31
+ node-version: 22.x
102
32
  steps:
103
- - name: Harden Runner
104
- uses: step-security/harden-runner@v2
105
- with:
106
- egress-policy: audit
107
-
108
33
  - uses: actions/checkout@v4
109
- with:
110
- fetch-depth: 0
111
34
 
112
35
  - name: Set up Node.js ${{ matrix.node-version }}
113
36
  uses: actions/setup-node@v4
114
37
  with:
115
38
  node-version: ${{ matrix.node-version }}
116
- cache: 'npm'
39
+ cache: npm
117
40
 
118
41
  - name: Install dependencies
119
42
  run: npm ci --prefer-offline --no-audit
@@ -132,12 +55,8 @@ jobs:
132
55
  env:
133
56
  CI: true
134
57
 
135
- - name: Generate coverage report
136
- if: matrix.coverage
137
- run: npm run test:coverage
138
-
139
- - name: Upload coverage to Codecov
140
- if: matrix.coverage
58
+ - name: Upload coverage
59
+ if: matrix.coverage == true
141
60
  uses: codecov/codecov-action@v4
142
61
  with:
143
62
  file: ./coverage/lcov.info
@@ -145,142 +64,3 @@ jobs:
145
64
  name: codecov-${{ matrix.node-version }}
146
65
  fail_ci_if_error: false
147
66
  token: ${{ secrets.CODECOV_TOKEN }}
148
-
149
- - name: Upload test results
150
- uses: dorny/test-reporter@v1
151
- if: always()
152
- continue-on-error: true
153
- with:
154
- name: Test Results (${{ matrix.node-version }})
155
- path: coverage/junit.xml
156
- reporter: jest-junit
157
- fail-on-error: false
158
-
159
- performance:
160
- name: Performance Testing
161
- runs-on: ubuntu-latest
162
- timeout-minutes: 15
163
- if: github.event_name == 'push' || github.event.pull_request.draft == false
164
- steps:
165
- - name: Harden Runner
166
- uses: step-security/harden-runner@v2
167
- with:
168
- egress-policy: audit
169
-
170
- - uses: actions/checkout@v4
171
-
172
- - name: Set up Node.js
173
- uses: actions/setup-node@v4
174
- with:
175
- node-version: ${{ env.NODE_VERSION }}
176
- cache: 'npm'
177
-
178
- - name: Install dependencies
179
- run: npm ci --prefer-offline --no-audit
180
-
181
- - name: Build project
182
- run: npm run build
183
-
184
- - name: Run Lighthouse CI
185
- run: |
186
- npm install -g @lhci/cli
187
- lhci autorun --config=lighthouserc.json || echo "Lighthouse CI completed with warnings"
188
- continue-on-error: true
189
-
190
- - name: Performance benchmark
191
- run: |
192
- npm install -g autocannon
193
- npm run benchmark || echo "Benchmark completed"
194
- continue-on-error: true
195
-
196
- - name: Bundle size analysis
197
- run: |
198
- npm install -g bundlesize
199
- bundlesize || echo "Bundle size check completed"
200
- continue-on-error: true
201
-
202
- build:
203
- name: Build & Publish
204
- runs-on: ubuntu-latest
205
- timeout-minutes: 15
206
- needs: [security, test, performance]
207
- if: always() && (needs.security.result == 'success' && needs.test.result == 'success')
208
- environment:
209
- name: ${{ github.ref == 'refs/heads/main' && 'production' || 'development' }}
210
- steps:
211
- - name: Harden Runner
212
- uses: step-security/harden-runner@v2
213
- with:
214
- egress-policy: audit
215
-
216
- - uses: actions/checkout@v4
217
- with:
218
- fetch-depth: 0
219
- token: ${{ secrets.GITHUB_TOKEN }}
220
-
221
- - name: Set up Node.js
222
- uses: actions/setup-node@v4
223
- with:
224
- node-version: ${{ env.NODE_VERSION }}
225
- cache: 'npm'
226
- registry-url: 'https://registry.npmjs.org'
227
-
228
- - name: Install dependencies
229
- run: npm ci --prefer-offline --no-audit
230
-
231
- - name: Lint
232
- run: npm run lint
233
-
234
- - name: Build
235
- run: npm run build
236
-
237
- - name: Generate API documentation
238
- run: npm run docs
239
-
240
- - name: Run security checks on build
241
- run: |
242
- npx audit-ci --config audit-ci.json || echo "Security check completed with warnings"
243
- continue-on-error: true
244
-
245
- - name: Upload build artifacts
246
- uses: actions/upload-artifact@v4
247
- with:
248
- name: build-artifacts
249
- path: |
250
- dist/
251
- docs/
252
- retention-days: 30
253
-
254
- - name: Upload docs to GitHub Pages
255
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
256
- uses: peaceiris/actions-gh-pages@v4
257
- with:
258
- github_token: ${{ secrets.GITHUB_TOKEN }}
259
- publish_dir: ./docs
260
- publish_branch: gh-pages
261
- enable_jekyll: false
262
-
263
- - name: Publish package (Dry Run)
264
- if: github.event_name == 'pull_request'
265
- run: npm publish --dry-run
266
-
267
- - name: Create GitHub Release
268
- if: startsWith(github.ref, 'refs/tags/v')
269
- uses: softprops/action-gh-release@v2
270
- with:
271
- files: |
272
- dist/**
273
- docs/**
274
- generate_release_notes: true
275
- draft: false
276
- prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
277
-
278
- - name: Notify deployment status
279
- if: always() && github.ref == 'refs/heads/main'
280
- uses: 8398a7/action-slack@v3
281
- continue-on-error: true
282
- with:
283
- status: ${{ job.status }}
284
- channel: '#deployments'
285
- env:
286
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
@@ -1,30 +1,21 @@
1
- name: Pull Request Validation
1
+ name: Pull Request Policy
2
2
 
3
3
  on:
4
4
  pull_request:
5
+ branches: [main]
5
6
  types: [opened, synchronize, reopened, ready_for_review]
6
7
 
7
8
  permissions:
8
9
  contents: read
9
10
  pull-requests: write
10
- checks: write
11
11
 
12
12
  jobs:
13
13
  validate-pr:
14
- name: PR Validation
14
+ name: PR Metadata
15
15
  runs-on: ubuntu-latest
16
16
  timeout-minutes: 10
17
17
  if: github.event.pull_request.draft == false
18
18
  steps:
19
- - name: Harden Runner
20
- uses: step-security/harden-runner@v2
21
- with:
22
- egress-policy: audit
23
-
24
- - uses: actions/checkout@v4
25
- with:
26
- fetch-depth: 0
27
-
28
19
  - name: Validate PR title
29
20
  uses: amannn/action-semantic-pull-request@v5
30
21
  with:
@@ -43,7 +34,7 @@ jobs:
43
34
  requireScope: false
44
35
  disallowScopes: |
45
36
  release
46
- subjectPattern: ^(?![A-Z]).+$
37
+ subjectPattern: ^(?![A-Z]).+
47
38
  subjectPatternError: |
48
39
  The subject "{subject}" found in the pull request title "{title}"
49
40
  didn't match the configured pattern. Please ensure that the subject
@@ -51,7 +42,7 @@ jobs:
51
42
  env:
52
43
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53
44
 
54
- - name: Check PR size
45
+ - name: Apply PR size label
55
46
  uses: pascalgn/size-label-action@v0.5.0
56
47
  env:
57
48
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -59,135 +50,9 @@ jobs:
59
50
  sizes: >
60
51
  {
61
52
  "0": "XS",
62
- "20": "S",
53
+ "20": "S",
63
54
  "50": "M",
64
55
  "200": "L",
65
56
  "800": "XL",
66
57
  "2000": "XXL"
67
58
  }
68
-
69
- lint-and-test:
70
- name: Quality Checks
71
- runs-on: ubuntu-latest
72
- timeout-minutes: 15
73
- if: github.event.pull_request.draft == false
74
- steps:
75
- - name: Harden Runner
76
- uses: step-security/harden-runner@v2
77
- with:
78
- egress-policy: audit
79
-
80
- - uses: actions/checkout@v4
81
- with:
82
- fetch-depth: 0
83
-
84
- - name: Set up Node.js
85
- uses: actions/setup-node@v4
86
- with:
87
- node-version: '20.8.1'
88
- cache: 'npm'
89
-
90
- - name: Install dependencies
91
- run: npm ci --prefer-offline --no-audit
92
-
93
- - name: Run linter
94
- run: npm run lint
95
-
96
- - name: Type checking
97
- run: npm run type-check
98
-
99
- - name: Run tests
100
- run: npm run test:ci
101
- env:
102
- CI: true
103
-
104
- - name: Build project
105
- run: npm run build
106
-
107
- - name: Check for breaking changes
108
- run: |
109
- npm run build
110
- git diff --exit-code dist/ || (echo "Build artifacts changed, please commit the changes" && exit 1)
111
- continue-on-error: true
112
-
113
- security-check:
114
- name: Security Validation
115
- runs-on: ubuntu-latest
116
- timeout-minutes: 10
117
- if: github.event.pull_request.draft == false
118
- steps:
119
- - name: Harden Runner
120
- uses: step-security/harden-runner@v2
121
- with:
122
- egress-policy: audit
123
-
124
- - uses: actions/checkout@v4
125
- with:
126
- fetch-depth: 0
127
-
128
- - name: Set up Node.js
129
- uses: actions/setup-node@v4
130
- with:
131
- node-version: '20.8.1'
132
- cache: 'npm'
133
-
134
- - name: Install dependencies
135
- run: npm ci --prefer-offline --no-audit
136
-
137
- - name: Run security audit
138
- run: npm audit --audit-level=moderate
139
- continue-on-error: true
140
-
141
- - name: Scan for secrets
142
- uses: trufflesecurity/trufflehog@main
143
- with:
144
- path: ./
145
- base: ${{ github.event.repository.default_branch }}
146
- head: HEAD
147
- extra_args: --debug --only-verified
148
- continue-on-error: true
149
-
150
- documentation:
151
- name: Documentation Check
152
- runs-on: ubuntu-latest
153
- timeout-minutes: 10
154
- if: github.event.pull_request.draft == false
155
- steps:
156
- - name: Harden Runner
157
- uses: step-security/harden-runner@v2
158
- with:
159
- egress-policy: audit
160
-
161
- - uses: actions/checkout@v4
162
-
163
- - name: Set up Node.js
164
- uses: actions/setup-node@v4
165
- with:
166
- node-version: '20.8.1'
167
- cache: 'npm'
168
-
169
- - name: Install dependencies
170
- run: npm ci --prefer-offline --no-audit
171
-
172
- - name: Generate documentation
173
- run: npm run docs
174
-
175
- - name: Check for documentation changes
176
- run: |
177
- if git diff --quiet HEAD^ HEAD -- '*.md' 'docs/' ; then
178
- echo "No documentation changes detected"
179
- else
180
- echo "Documentation changes detected"
181
- fi
182
-
183
- auto-assign:
184
- name: Auto Assignment
185
- runs-on: ubuntu-latest
186
- timeout-minutes: 5
187
- if: github.event.action == 'opened'
188
- steps:
189
- - name: Auto assign PR
190
- uses: kentaro-m/auto-assign-action@v1.2.6
191
- with:
192
- repo-token: ${{ secrets.GITHUB_TOKEN }}
193
- configuration-path: .github/auto_assign.yml
@@ -2,6 +2,7 @@ name: Dependabot Auto Merge
2
2
 
3
3
  on:
4
4
  pull_request:
5
+ branches: [main]
5
6
  types:
6
7
  - opened
7
8
  - synchronize
@@ -2,6 +2,7 @@ name: Pull Request Labeler
2
2
 
3
3
  on:
4
4
  pull_request:
5
+ branches: [main]
5
6
  types: [opened, synchronize, reopened]
6
7
 
7
8
  jobs:
@@ -38,6 +38,7 @@ jobs:
38
38
  license-check:
39
39
  name: License Compliance
40
40
  runs-on: ubuntu-latest
41
+ if: github.event_name != 'pull_request'
41
42
  timeout-minutes: 10
42
43
  steps:
43
44
  - name: Harden Runner
@@ -64,6 +65,7 @@ jobs:
64
65
  supply-chain:
65
66
  name: Supply Chain Security
66
67
  runs-on: ubuntu-latest
68
+ if: github.event_name != 'pull_request'
67
69
  timeout-minutes: 15
68
70
  steps:
69
71
  - name: Harden Runner
@@ -101,6 +103,7 @@ jobs:
101
103
  sbom-generation:
102
104
  name: Generate SBOM
103
105
  runs-on: ubuntu-latest
106
+ if: github.event_name != 'pull_request'
104
107
  timeout-minutes: 10
105
108
  steps:
106
109
  - name: Harden Runner
package/CHANGELOG.md CHANGED
@@ -1,11 +1,16 @@
1
- # [1.4.0](https://github.com/rahul05ranjan/dhruv-cli/compare/v1.4.5...v1.4.0) (2026-09-18)
1
+ # [1.4.0](https://github.com/rahul05ranjan/dhruv-cli/compare/v1.4.6...v1.4.0) (2026-09-18)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * **ci:** isolate Scorecard publishing from other security scans ([087833b](https://github.com/rahul05ranjan/dhruv-cli/commit/087833b470c2df96da54eb1f07fc5ef488106f61))
7
- * **ci:** repair trusted publishing and security workflows ([7f6d202](https://github.com/rahul05ranjan/dhruv-cli/commit/7f6d2028ffde96a446d6f346d0936c56fb830e61))
8
- * **ci:** update Anchore scanner for the current vulnerability database ([7009198](https://github.com/rahul05ranjan/dhruv-cli/commit/70091989b636878f61c741eb2b5abf21fb5df922))
6
+ * change moduleResolution from Node to Bundler in tsconfig ([b8339bb](https://github.com/rahul05ranjan/dhruv-cli/commit/b8339bb89781490d5678f43052b606138f375d21))
7
+ * drop unused menu loop flag ([51eeec6](https://github.com/rahul05ranjan/dhruv-cli/commit/51eeec6a607299120ce3e1f15af9f9dc62396ce7))
8
+ * stabilize health and CLI contract tests on CI ([3b3e650](https://github.com/rahul05ranjan/dhruv-cli/commit/3b3e6503591c8c33d36f1887e94358dafe6163ce))
9
+
10
+
11
+ ### Features
12
+
13
+ * improve cli experience across commands ([ce41913](https://github.com/rahul05ranjan/dhruv-cli/commit/ce4191350ca3d1c5f49b371508e66de9421f6d20))
9
14
  # Changelog
10
15
 
11
16
  ## [1.1.1](https://github.com/rahul05ranjan/dhruv-cli/compare/v1.1.0...v1.1.1) (2025-06-29)