@principal-ai/quality-lens-cli 0.1.0 → 0.1.1

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 (2) hide show
  1. package/README.md +79 -11
  2. package/package.json +8 -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
- - uses: actions/checkout@v4
67
+ - name: Checkout code
68
+ uses: actions/checkout@v4
67
69
 
68
- - uses: actions/setup-node@v4
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
- - run: npm ci
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: Install quality-lens-cli
75
- run: npm install -g @principal-ai/quality-lens-cli
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,jest,typescript
83
-
84
- - name: Upload results
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.0",
3
+ "version": "0.1.1",
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,9 @@
15
15
  "lint": "eslint . --ext .ts",
16
16
  "lint:fix": "eslint . --ext .ts --fix",
17
17
  "typecheck": "tsc --noEmit",
18
- "test": "echo \"Error: no test specified\" && exit 1"
18
+ "test": "jest",
19
+ "test:integration": "jest test/integration",
20
+ "test:watch": "jest --watch"
19
21
  },
20
22
  "keywords": [
21
23
  "quality",
@@ -32,18 +34,21 @@
32
34
  "license": "MIT",
33
35
  "dependencies": {
34
36
  "@principal-ai/codebase-composition": "^0.2.8",
35
- "@principal-ai/codebase-quality-lenses": "^0.1.7",
37
+ "@principal-ai/codebase-quality-lenses": "^0.1.8",
36
38
  "@principal-ai/repository-abstraction": "^0.2.0",
37
39
  "chalk": "^5.3.0",
38
40
  "tslib": "^2.8.1",
39
41
  "yargs": "^17.7.2"
40
42
  },
41
43
  "devDependencies": {
44
+ "@types/jest": "^30.0.0",
42
45
  "@types/node": "^20.0.0",
43
46
  "@types/yargs": "^17.0.32",
44
47
  "@typescript-eslint/eslint-plugin": "^6.0.0",
45
48
  "@typescript-eslint/parser": "^6.0.0",
46
49
  "eslint": "^8.0.0",
50
+ "jest": "^29.7.0",
51
+ "ts-jest": "^29.4.5",
47
52
  "typescript": "^5.0.0"
48
53
  },
49
54
  "optionalDependencies": {