@principal-ai/quality-lens-cli 0.1.0 → 0.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.
- package/README.md +79 -11
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -60,34 +60,102 @@ on:
|
|
|
60
60
|
|
|
61
61
|
jobs:
|
|
62
62
|
analyze:
|
|
63
|
+
environment: production # Required for NPM_TOKEN secret
|
|
63
64
|
runs-on: ubuntu-latest
|
|
64
65
|
|
|
65
66
|
steps:
|
|
66
|
-
-
|
|
67
|
+
- name: Checkout code
|
|
68
|
+
uses: actions/checkout@v4
|
|
67
69
|
|
|
68
|
-
-
|
|
70
|
+
- name: Setup Node.js
|
|
71
|
+
uses: actions/setup-node@v4
|
|
69
72
|
with:
|
|
70
73
|
node-version: '20'
|
|
74
|
+
cache: 'npm'
|
|
71
75
|
|
|
72
|
-
-
|
|
76
|
+
- name: Configure npm authentication
|
|
77
|
+
run: |
|
|
78
|
+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
|
|
79
|
+
echo "@principal-ai:registry=https://registry.npmjs.org/" >> ~/.npmrc
|
|
80
|
+
|
|
81
|
+
- name: Install dependencies
|
|
82
|
+
run: npm ci
|
|
73
83
|
|
|
74
|
-
- name:
|
|
75
|
-
run: npm
|
|
84
|
+
- name: Build CLI
|
|
85
|
+
run: npm run build
|
|
76
86
|
|
|
77
87
|
- name: Run quality lenses
|
|
78
88
|
run: |
|
|
79
|
-
quality-lens run .
|
|
80
|
-
--output results.json
|
|
81
|
-
--format json
|
|
82
|
-
--lenses eslint,
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
node bin/quality-lens.js run . \
|
|
90
|
+
--output results.json \
|
|
91
|
+
--format json \
|
|
92
|
+
--lenses eslint,typescript
|
|
93
|
+
continue-on-error: true
|
|
94
|
+
|
|
95
|
+
- name: Upload results artifact
|
|
96
|
+
if: always()
|
|
85
97
|
uses: actions/upload-artifact@v4
|
|
86
98
|
with:
|
|
87
99
|
name: quality-lens-results
|
|
88
100
|
path: results.json
|
|
101
|
+
if-no-files-found: warn
|
|
102
|
+
|
|
103
|
+
- name: Comment PR with results
|
|
104
|
+
if: github.event_name == 'pull_request' && always()
|
|
105
|
+
uses: actions/github-script@v7
|
|
106
|
+
with:
|
|
107
|
+
script: |
|
|
108
|
+
const fs = require('fs');
|
|
109
|
+
if (!fs.existsSync('results.json')) return;
|
|
110
|
+
|
|
111
|
+
const results = JSON.parse(fs.readFileSync('results.json', 'utf8'));
|
|
112
|
+
const analysisResults = results.results || [];
|
|
113
|
+
|
|
114
|
+
let passed = 0, failed = 0, details = [];
|
|
115
|
+
analysisResults.forEach(result => {
|
|
116
|
+
if (result.execution?.success) passed++;
|
|
117
|
+
else failed++;
|
|
118
|
+
|
|
119
|
+
const icon = result.execution?.success ? '✅' : '❌';
|
|
120
|
+
const pkg = result.package?.name || 'unknown';
|
|
121
|
+
const lens = result.lens?.id || 'unknown';
|
|
122
|
+
const duration = result.execution?.duration || 0;
|
|
123
|
+
|
|
124
|
+
details.push(`${icon} **${pkg}** - ${lens} (${duration}ms)`);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const body = `## 🔍 Quality Lens Analysis Results
|
|
128
|
+
|
|
129
|
+
**Summary:**
|
|
130
|
+
- Total Checks: ${passed + failed}
|
|
131
|
+
- Passed: ✅ ${passed}
|
|
132
|
+
- Failed: ❌ ${failed}
|
|
133
|
+
|
|
134
|
+
**Details:**
|
|
135
|
+
${details.join('\n')}`;
|
|
136
|
+
|
|
137
|
+
github.rest.issues.createComment({
|
|
138
|
+
issue_number: context.issue.number,
|
|
139
|
+
owner: context.repo.owner,
|
|
140
|
+
repo: context.repo.repo,
|
|
141
|
+
body: body
|
|
142
|
+
});
|
|
89
143
|
```
|
|
90
144
|
|
|
145
|
+
### Setup Requirements
|
|
146
|
+
|
|
147
|
+
1. **NPM Token**: Add `NPM_TOKEN` to your repository's production environment secrets at:
|
|
148
|
+
`https://github.com/your-org/your-repo/settings/secrets/actions`
|
|
149
|
+
|
|
150
|
+
2. **Production Environment**: Create a production environment in your repository settings if it doesn't exist:
|
|
151
|
+
`https://github.com/your-org/your-repo/settings/environments`
|
|
152
|
+
|
|
153
|
+
The workflow will:
|
|
154
|
+
- Run quality lenses on push and pull requests
|
|
155
|
+
- Upload results as artifacts
|
|
156
|
+
- Automatically comment on PRs with analysis summary
|
|
157
|
+
- Continue workflow execution even if quality checks fail
|
|
158
|
+
|
|
91
159
|
## Output Format
|
|
92
160
|
|
|
93
161
|
### JSON Output
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principal-ai/quality-lens-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "CLI tool for running quality lenses on codebases in CI/CD pipelines",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"lint": "eslint . --ext .ts",
|
|
16
16
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
17
17
|
"typecheck": "tsc --noEmit",
|
|
18
|
-
"test": "
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test:integration": "jest --config jest.config.integration.js",
|
|
20
|
+
"test:watch": "jest --watch",
|
|
21
|
+
"test:all": "npm run test && npm run test:integration"
|
|
19
22
|
},
|
|
20
23
|
"keywords": [
|
|
21
24
|
"quality",
|
|
@@ -32,18 +35,21 @@
|
|
|
32
35
|
"license": "MIT",
|
|
33
36
|
"dependencies": {
|
|
34
37
|
"@principal-ai/codebase-composition": "^0.2.8",
|
|
35
|
-
"@principal-ai/codebase-quality-lenses": "^0.1.
|
|
38
|
+
"@principal-ai/codebase-quality-lenses": "^0.1.10",
|
|
36
39
|
"@principal-ai/repository-abstraction": "^0.2.0",
|
|
37
40
|
"chalk": "^5.3.0",
|
|
38
41
|
"tslib": "^2.8.1",
|
|
39
42
|
"yargs": "^17.7.2"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
45
|
+
"@types/jest": "^30.0.0",
|
|
42
46
|
"@types/node": "^20.0.0",
|
|
43
47
|
"@types/yargs": "^17.0.32",
|
|
44
48
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
45
49
|
"@typescript-eslint/parser": "^6.0.0",
|
|
46
50
|
"eslint": "^8.0.0",
|
|
51
|
+
"jest": "^29.7.0",
|
|
52
|
+
"ts-jest": "^29.4.5",
|
|
47
53
|
"typescript": "^5.0.0"
|
|
48
54
|
},
|
|
49
55
|
"optionalDependencies": {
|