@hasna/microservices 0.0.10 → 0.0.11
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/bin/index.js +86 -1
- package/bin/mcp.js +86 -1
- package/dist/index.js +86 -1
- package/microservices/microservice-analytics/package.json +27 -0
- package/microservices/microservice-analytics/src/cli/index.ts +373 -0
- package/microservices/microservice-analytics/src/db/analytics.ts +564 -0
- package/microservices/microservice-analytics/src/db/database.ts +93 -0
- package/microservices/microservice-analytics/src/db/migrations.ts +50 -0
- package/microservices/microservice-analytics/src/index.ts +37 -0
- package/microservices/microservice-analytics/src/mcp/index.ts +334 -0
- package/microservices/microservice-assets/package.json +27 -0
- package/microservices/microservice-assets/src/cli/index.ts +375 -0
- package/microservices/microservice-assets/src/db/assets.ts +370 -0
- package/microservices/microservice-assets/src/db/database.ts +93 -0
- package/microservices/microservice-assets/src/db/migrations.ts +51 -0
- package/microservices/microservice-assets/src/index.ts +32 -0
- package/microservices/microservice-assets/src/mcp/index.ts +346 -0
- package/microservices/microservice-compliance/package.json +27 -0
- package/microservices/microservice-compliance/src/cli/index.ts +467 -0
- package/microservices/microservice-compliance/src/db/compliance.ts +633 -0
- package/microservices/microservice-compliance/src/db/database.ts +93 -0
- package/microservices/microservice-compliance/src/db/migrations.ts +63 -0
- package/microservices/microservice-compliance/src/index.ts +46 -0
- package/microservices/microservice-compliance/src/mcp/index.ts +438 -0
- package/microservices/microservice-habits/package.json +27 -0
- package/microservices/microservice-habits/src/cli/index.ts +315 -0
- package/microservices/microservice-habits/src/db/database.ts +93 -0
- package/microservices/microservice-habits/src/db/habits.ts +451 -0
- package/microservices/microservice-habits/src/db/migrations.ts +46 -0
- package/microservices/microservice-habits/src/index.ts +31 -0
- package/microservices/microservice-habits/src/mcp/index.ts +313 -0
- package/microservices/microservice-health/package.json +27 -0
- package/microservices/microservice-health/src/cli/index.ts +484 -0
- package/microservices/microservice-health/src/db/database.ts +93 -0
- package/microservices/microservice-health/src/db/health.ts +708 -0
- package/microservices/microservice-health/src/db/migrations.ts +70 -0
- package/microservices/microservice-health/src/index.ts +63 -0
- package/microservices/microservice-health/src/mcp/index.ts +437 -0
- package/microservices/microservice-notifications/package.json +27 -0
- package/microservices/microservice-notifications/src/cli/index.ts +349 -0
- package/microservices/microservice-notifications/src/db/database.ts +93 -0
- package/microservices/microservice-notifications/src/db/migrations.ts +62 -0
- package/microservices/microservice-notifications/src/db/notifications.ts +509 -0
- package/microservices/microservice-notifications/src/index.ts +41 -0
- package/microservices/microservice-notifications/src/mcp/index.ts +422 -0
- package/microservices/microservice-products/package.json +27 -0
- package/microservices/microservice-products/src/cli/index.ts +416 -0
- package/microservices/microservice-products/src/db/categories.ts +154 -0
- package/microservices/microservice-products/src/db/database.ts +93 -0
- package/microservices/microservice-products/src/db/migrations.ts +58 -0
- package/microservices/microservice-products/src/db/pricing-tiers.ts +66 -0
- package/microservices/microservice-products/src/db/products.ts +452 -0
- package/microservices/microservice-products/src/index.ts +53 -0
- package/microservices/microservice-products/src/mcp/index.ts +453 -0
- package/microservices/microservice-projects/package.json +27 -0
- package/microservices/microservice-projects/src/cli/index.ts +480 -0
- package/microservices/microservice-projects/src/db/database.ts +93 -0
- package/microservices/microservice-projects/src/db/migrations.ts +65 -0
- package/microservices/microservice-projects/src/db/projects.ts +715 -0
- package/microservices/microservice-projects/src/index.ts +57 -0
- package/microservices/microservice-projects/src/mcp/index.ts +501 -0
- package/microservices/microservice-proposals/package.json +27 -0
- package/microservices/microservice-proposals/src/cli/index.ts +400 -0
- package/microservices/microservice-proposals/src/db/database.ts +93 -0
- package/microservices/microservice-proposals/src/db/migrations.ts +52 -0
- package/microservices/microservice-proposals/src/db/proposals.ts +532 -0
- package/microservices/microservice-proposals/src/index.ts +37 -0
- package/microservices/microservice-proposals/src/mcp/index.ts +375 -0
- package/microservices/microservice-reading/package.json +27 -0
- package/microservices/microservice-reading/src/cli/index.ts +464 -0
- package/microservices/microservice-reading/src/db/database.ts +93 -0
- package/microservices/microservice-reading/src/db/migrations.ts +59 -0
- package/microservices/microservice-reading/src/db/reading.ts +524 -0
- package/microservices/microservice-reading/src/index.ts +51 -0
- package/microservices/microservice-reading/src/mcp/index.ts +368 -0
- package/microservices/microservice-travel/package.json +27 -0
- package/microservices/microservice-travel/src/cli/index.ts +505 -0
- package/microservices/microservice-travel/src/db/database.ts +93 -0
- package/microservices/microservice-travel/src/db/migrations.ts +77 -0
- package/microservices/microservice-travel/src/db/travel.ts +802 -0
- package/microservices/microservice-travel/src/index.ts +60 -0
- package/microservices/microservice-travel/src/mcp/index.ts +495 -0
- package/microservices/microservice-wiki/package.json +27 -0
- package/microservices/microservice-wiki/src/cli/index.ts +345 -0
- package/microservices/microservice-wiki/src/db/database.ts +93 -0
- package/microservices/microservice-wiki/src/db/migrations.ts +55 -0
- package/microservices/microservice-wiki/src/db/wiki.ts +395 -0
- package/microservices/microservice-wiki/src/index.ts +32 -0
- package/microservices/microservice-wiki/src/mcp/index.ts +344 -0
- package/package.json +1 -1
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import {
|
|
5
|
+
createRequirement,
|
|
6
|
+
getRequirement,
|
|
7
|
+
listRequirements,
|
|
8
|
+
updateRequirement,
|
|
9
|
+
deleteRequirement,
|
|
10
|
+
searchRequirements,
|
|
11
|
+
createLicense,
|
|
12
|
+
getLicense,
|
|
13
|
+
listLicenses,
|
|
14
|
+
renewLicense,
|
|
15
|
+
listExpiringLicenses,
|
|
16
|
+
deleteLicense,
|
|
17
|
+
getLicenseStats,
|
|
18
|
+
scheduleAudit,
|
|
19
|
+
listAudits,
|
|
20
|
+
completeAudit,
|
|
21
|
+
getAuditReport,
|
|
22
|
+
getComplianceScore,
|
|
23
|
+
getFrameworkStatus,
|
|
24
|
+
} from "../db/compliance.js";
|
|
25
|
+
|
|
26
|
+
const program = new Command();
|
|
27
|
+
|
|
28
|
+
program
|
|
29
|
+
.name("microservice-compliance")
|
|
30
|
+
.description("Compliance management microservice")
|
|
31
|
+
.version("0.0.1");
|
|
32
|
+
|
|
33
|
+
// --- Requirements ---
|
|
34
|
+
|
|
35
|
+
const reqCmd = program
|
|
36
|
+
.command("requirement")
|
|
37
|
+
.alias("req")
|
|
38
|
+
.description("Compliance requirement management");
|
|
39
|
+
|
|
40
|
+
reqCmd
|
|
41
|
+
.command("create")
|
|
42
|
+
.description("Create a compliance requirement")
|
|
43
|
+
.requiredOption("--name <name>", "Requirement name")
|
|
44
|
+
.option("--framework <framework>", "Framework (gdpr, soc2, hipaa, pci, tax, iso27001, custom)")
|
|
45
|
+
.option("--status <status>", "Status (compliant, non_compliant, in_progress, not_applicable)")
|
|
46
|
+
.option("--description <text>", "Description")
|
|
47
|
+
.option("--evidence <text>", "Evidence")
|
|
48
|
+
.option("--due-date <date>", "Due date (YYYY-MM-DD)")
|
|
49
|
+
.option("--reviewer <name>", "Reviewer name")
|
|
50
|
+
.option("--json", "Output as JSON", false)
|
|
51
|
+
.action((opts) => {
|
|
52
|
+
const req = createRequirement({
|
|
53
|
+
name: opts.name,
|
|
54
|
+
framework: opts.framework,
|
|
55
|
+
status: opts.status,
|
|
56
|
+
description: opts.description,
|
|
57
|
+
evidence: opts.evidence,
|
|
58
|
+
due_date: opts.dueDate,
|
|
59
|
+
reviewer: opts.reviewer,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (opts.json) {
|
|
63
|
+
console.log(JSON.stringify(req, null, 2));
|
|
64
|
+
} else {
|
|
65
|
+
console.log(`Created requirement: ${req.name} (${req.id})`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
reqCmd
|
|
70
|
+
.command("list")
|
|
71
|
+
.description("List requirements")
|
|
72
|
+
.option("--framework <framework>", "Filter by framework")
|
|
73
|
+
.option("--status <status>", "Filter by status")
|
|
74
|
+
.option("--search <query>", "Search by name or description")
|
|
75
|
+
.option("--limit <n>", "Limit results")
|
|
76
|
+
.option("--json", "Output as JSON", false)
|
|
77
|
+
.action((opts) => {
|
|
78
|
+
const reqs = listRequirements({
|
|
79
|
+
framework: opts.framework,
|
|
80
|
+
status: opts.status,
|
|
81
|
+
search: opts.search,
|
|
82
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (opts.json) {
|
|
86
|
+
console.log(JSON.stringify(reqs, null, 2));
|
|
87
|
+
} else {
|
|
88
|
+
if (reqs.length === 0) {
|
|
89
|
+
console.log("No requirements found.");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
for (const r of reqs) {
|
|
93
|
+
const fw = r.framework ? ` [${r.framework}]` : "";
|
|
94
|
+
console.log(` ${r.name}${fw} — ${r.status}`);
|
|
95
|
+
}
|
|
96
|
+
console.log(`\n${reqs.length} requirement(s)`);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
reqCmd
|
|
101
|
+
.command("get")
|
|
102
|
+
.description("Get a requirement by ID")
|
|
103
|
+
.argument("<id>", "Requirement ID")
|
|
104
|
+
.option("--json", "Output as JSON", false)
|
|
105
|
+
.action((id, opts) => {
|
|
106
|
+
const req = getRequirement(id);
|
|
107
|
+
if (!req) {
|
|
108
|
+
console.error(`Requirement '${id}' not found.`);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (opts.json) {
|
|
113
|
+
console.log(JSON.stringify(req, null, 2));
|
|
114
|
+
} else {
|
|
115
|
+
console.log(`${req.name}`);
|
|
116
|
+
console.log(` Status: ${req.status}`);
|
|
117
|
+
if (req.framework) console.log(` Framework: ${req.framework}`);
|
|
118
|
+
if (req.description) console.log(` Description: ${req.description}`);
|
|
119
|
+
if (req.evidence) console.log(` Evidence: ${req.evidence}`);
|
|
120
|
+
if (req.due_date) console.log(` Due: ${req.due_date}`);
|
|
121
|
+
if (req.reviewer) console.log(` Reviewer: ${req.reviewer}`);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
reqCmd
|
|
126
|
+
.command("update")
|
|
127
|
+
.description("Update a requirement")
|
|
128
|
+
.argument("<id>", "Requirement ID")
|
|
129
|
+
.option("--name <name>", "Name")
|
|
130
|
+
.option("--framework <framework>", "Framework")
|
|
131
|
+
.option("--status <status>", "Status")
|
|
132
|
+
.option("--description <text>", "Description")
|
|
133
|
+
.option("--evidence <text>", "Evidence")
|
|
134
|
+
.option("--due-date <date>", "Due date")
|
|
135
|
+
.option("--reviewer <name>", "Reviewer")
|
|
136
|
+
.option("--json", "Output as JSON", false)
|
|
137
|
+
.action((id, opts) => {
|
|
138
|
+
const input: Record<string, unknown> = {};
|
|
139
|
+
if (opts.name !== undefined) input.name = opts.name;
|
|
140
|
+
if (opts.framework !== undefined) input.framework = opts.framework;
|
|
141
|
+
if (opts.status !== undefined) input.status = opts.status;
|
|
142
|
+
if (opts.description !== undefined) input.description = opts.description;
|
|
143
|
+
if (opts.evidence !== undefined) input.evidence = opts.evidence;
|
|
144
|
+
if (opts.dueDate !== undefined) input.due_date = opts.dueDate;
|
|
145
|
+
if (opts.reviewer !== undefined) input.reviewer = opts.reviewer;
|
|
146
|
+
|
|
147
|
+
const req = updateRequirement(id, input);
|
|
148
|
+
if (!req) {
|
|
149
|
+
console.error(`Requirement '${id}' not found.`);
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (opts.json) {
|
|
154
|
+
console.log(JSON.stringify(req, null, 2));
|
|
155
|
+
} else {
|
|
156
|
+
console.log(`Updated: ${req.name} — ${req.status}`);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
reqCmd
|
|
161
|
+
.command("delete")
|
|
162
|
+
.description("Delete a requirement")
|
|
163
|
+
.argument("<id>", "Requirement ID")
|
|
164
|
+
.action((id) => {
|
|
165
|
+
const deleted = deleteRequirement(id);
|
|
166
|
+
if (deleted) {
|
|
167
|
+
console.log(`Deleted requirement ${id}`);
|
|
168
|
+
} else {
|
|
169
|
+
console.error(`Requirement '${id}' not found.`);
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// --- Licenses ---
|
|
175
|
+
|
|
176
|
+
const licCmd = program
|
|
177
|
+
.command("license")
|
|
178
|
+
.alias("lic")
|
|
179
|
+
.description("License management");
|
|
180
|
+
|
|
181
|
+
licCmd
|
|
182
|
+
.command("create")
|
|
183
|
+
.description("Create a license")
|
|
184
|
+
.requiredOption("--name <name>", "License name")
|
|
185
|
+
.option("--type <type>", "Type (software, business, professional, patent, trademark)")
|
|
186
|
+
.option("--issuer <issuer>", "Issuer")
|
|
187
|
+
.option("--license-number <number>", "License number")
|
|
188
|
+
.option("--status <status>", "Status (active, expired, pending_renewal)")
|
|
189
|
+
.option("--issued-at <date>", "Issued date")
|
|
190
|
+
.option("--expires-at <date>", "Expiry date")
|
|
191
|
+
.option("--auto-renew", "Auto-renew", false)
|
|
192
|
+
.option("--cost <amount>", "Cost")
|
|
193
|
+
.option("--json", "Output as JSON", false)
|
|
194
|
+
.action((opts) => {
|
|
195
|
+
const lic = createLicense({
|
|
196
|
+
name: opts.name,
|
|
197
|
+
type: opts.type,
|
|
198
|
+
issuer: opts.issuer,
|
|
199
|
+
license_number: opts.licenseNumber,
|
|
200
|
+
status: opts.status,
|
|
201
|
+
issued_at: opts.issuedAt,
|
|
202
|
+
expires_at: opts.expiresAt,
|
|
203
|
+
auto_renew: opts.autoRenew,
|
|
204
|
+
cost: opts.cost ? parseFloat(opts.cost) : undefined,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
if (opts.json) {
|
|
208
|
+
console.log(JSON.stringify(lic, null, 2));
|
|
209
|
+
} else {
|
|
210
|
+
console.log(`Created license: ${lic.name} (${lic.id})`);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
licCmd
|
|
215
|
+
.command("list")
|
|
216
|
+
.description("List licenses")
|
|
217
|
+
.option("--type <type>", "Filter by type")
|
|
218
|
+
.option("--status <status>", "Filter by status")
|
|
219
|
+
.option("--search <query>", "Search")
|
|
220
|
+
.option("--limit <n>", "Limit results")
|
|
221
|
+
.option("--json", "Output as JSON", false)
|
|
222
|
+
.action((opts) => {
|
|
223
|
+
const lics = listLicenses({
|
|
224
|
+
type: opts.type,
|
|
225
|
+
status: opts.status,
|
|
226
|
+
search: opts.search,
|
|
227
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
if (opts.json) {
|
|
231
|
+
console.log(JSON.stringify(lics, null, 2));
|
|
232
|
+
} else {
|
|
233
|
+
if (lics.length === 0) {
|
|
234
|
+
console.log("No licenses found.");
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
for (const l of lics) {
|
|
238
|
+
const type = l.type ? ` [${l.type}]` : "";
|
|
239
|
+
const expires = l.expires_at ? ` expires ${l.expires_at}` : "";
|
|
240
|
+
console.log(` ${l.name}${type} — ${l.status}${expires}`);
|
|
241
|
+
}
|
|
242
|
+
console.log(`\n${lics.length} license(s)`);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
licCmd
|
|
247
|
+
.command("get")
|
|
248
|
+
.description("Get a license by ID")
|
|
249
|
+
.argument("<id>", "License ID")
|
|
250
|
+
.option("--json", "Output as JSON", false)
|
|
251
|
+
.action((id, opts) => {
|
|
252
|
+
const lic = getLicense(id);
|
|
253
|
+
if (!lic) {
|
|
254
|
+
console.error(`License '${id}' not found.`);
|
|
255
|
+
process.exit(1);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (opts.json) {
|
|
259
|
+
console.log(JSON.stringify(lic, null, 2));
|
|
260
|
+
} else {
|
|
261
|
+
console.log(`${lic.name}`);
|
|
262
|
+
console.log(` Status: ${lic.status}`);
|
|
263
|
+
if (lic.type) console.log(` Type: ${lic.type}`);
|
|
264
|
+
if (lic.issuer) console.log(` Issuer: ${lic.issuer}`);
|
|
265
|
+
if (lic.license_number) console.log(` Number: ${lic.license_number}`);
|
|
266
|
+
if (lic.expires_at) console.log(` Expires: ${lic.expires_at}`);
|
|
267
|
+
if (lic.cost !== null) console.log(` Cost: ${lic.cost}`);
|
|
268
|
+
console.log(` Auto-renew: ${lic.auto_renew ? "yes" : "no"}`);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
licCmd
|
|
273
|
+
.command("renew")
|
|
274
|
+
.description("Renew a license with new expiry date")
|
|
275
|
+
.argument("<id>", "License ID")
|
|
276
|
+
.requiredOption("--expires-at <date>", "New expiry date")
|
|
277
|
+
.option("--json", "Output as JSON", false)
|
|
278
|
+
.action((id, opts) => {
|
|
279
|
+
const lic = renewLicense(id, opts.expiresAt);
|
|
280
|
+
if (!lic) {
|
|
281
|
+
console.error(`License '${id}' not found.`);
|
|
282
|
+
process.exit(1);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (opts.json) {
|
|
286
|
+
console.log(JSON.stringify(lic, null, 2));
|
|
287
|
+
} else {
|
|
288
|
+
console.log(`Renewed: ${lic.name} — expires ${lic.expires_at}`);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
licCmd
|
|
293
|
+
.command("expiring")
|
|
294
|
+
.description("List licenses expiring within N days")
|
|
295
|
+
.option("--days <n>", "Number of days", "30")
|
|
296
|
+
.option("--json", "Output as JSON", false)
|
|
297
|
+
.action((opts) => {
|
|
298
|
+
const days = parseInt(opts.days);
|
|
299
|
+
const lics = listExpiringLicenses(days);
|
|
300
|
+
|
|
301
|
+
if (opts.json) {
|
|
302
|
+
console.log(JSON.stringify(lics, null, 2));
|
|
303
|
+
} else {
|
|
304
|
+
if (lics.length === 0) {
|
|
305
|
+
console.log(`No licenses expiring within ${days} days.`);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
for (const l of lics) {
|
|
309
|
+
console.log(` ${l.name} — expires ${l.expires_at}`);
|
|
310
|
+
}
|
|
311
|
+
console.log(`\n${lics.length} license(s) expiring within ${days} days`);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// --- Audits ---
|
|
316
|
+
|
|
317
|
+
const auditCmd = program
|
|
318
|
+
.command("audit")
|
|
319
|
+
.description("Audit management");
|
|
320
|
+
|
|
321
|
+
auditCmd
|
|
322
|
+
.command("schedule")
|
|
323
|
+
.description("Schedule a new audit")
|
|
324
|
+
.requiredOption("--name <name>", "Audit name")
|
|
325
|
+
.option("--framework <framework>", "Framework")
|
|
326
|
+
.option("--auditor <name>", "Auditor name")
|
|
327
|
+
.option("--scheduled-at <date>", "Scheduled date")
|
|
328
|
+
.option("--json", "Output as JSON", false)
|
|
329
|
+
.action((opts) => {
|
|
330
|
+
const audit = scheduleAudit({
|
|
331
|
+
name: opts.name,
|
|
332
|
+
framework: opts.framework,
|
|
333
|
+
auditor: opts.auditor,
|
|
334
|
+
scheduled_at: opts.scheduledAt,
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
if (opts.json) {
|
|
338
|
+
console.log(JSON.stringify(audit, null, 2));
|
|
339
|
+
} else {
|
|
340
|
+
console.log(`Scheduled audit: ${audit.name} (${audit.id})`);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
auditCmd
|
|
345
|
+
.command("list")
|
|
346
|
+
.description("List audits")
|
|
347
|
+
.option("--framework <framework>", "Filter by framework")
|
|
348
|
+
.option("--status <status>", "Filter by status")
|
|
349
|
+
.option("--limit <n>", "Limit results")
|
|
350
|
+
.option("--json", "Output as JSON", false)
|
|
351
|
+
.action((opts) => {
|
|
352
|
+
const audits = listAudits({
|
|
353
|
+
framework: opts.framework,
|
|
354
|
+
status: opts.status,
|
|
355
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
if (opts.json) {
|
|
359
|
+
console.log(JSON.stringify(audits, null, 2));
|
|
360
|
+
} else {
|
|
361
|
+
if (audits.length === 0) {
|
|
362
|
+
console.log("No audits found.");
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
for (const a of audits) {
|
|
366
|
+
const fw = a.framework ? ` [${a.framework}]` : "";
|
|
367
|
+
console.log(` ${a.name}${fw} — ${a.status}`);
|
|
368
|
+
}
|
|
369
|
+
console.log(`\n${audits.length} audit(s)`);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
auditCmd
|
|
374
|
+
.command("complete")
|
|
375
|
+
.description("Complete an audit with findings")
|
|
376
|
+
.argument("<id>", "Audit ID")
|
|
377
|
+
.option("--findings <json>", "Findings as JSON array", "[]")
|
|
378
|
+
.option("--json", "Output as JSON", false)
|
|
379
|
+
.action((id, opts) => {
|
|
380
|
+
let findings: unknown[];
|
|
381
|
+
try {
|
|
382
|
+
findings = JSON.parse(opts.findings);
|
|
383
|
+
} catch {
|
|
384
|
+
console.error("Invalid JSON for findings.");
|
|
385
|
+
process.exit(1);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const audit = completeAudit(id, findings);
|
|
389
|
+
if (!audit) {
|
|
390
|
+
console.error(`Audit '${id}' not found.`);
|
|
391
|
+
process.exit(1);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (opts.json) {
|
|
395
|
+
console.log(JSON.stringify(audit, null, 2));
|
|
396
|
+
} else {
|
|
397
|
+
console.log(`Completed audit: ${audit.name} — ${audit.status} (${audit.findings.length} finding(s))`);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
// --- Analytics ---
|
|
402
|
+
|
|
403
|
+
program
|
|
404
|
+
.command("score")
|
|
405
|
+
.description("Get overall compliance score")
|
|
406
|
+
.option("--json", "Output as JSON", false)
|
|
407
|
+
.action((opts) => {
|
|
408
|
+
const score = getComplianceScore();
|
|
409
|
+
|
|
410
|
+
if (opts.json) {
|
|
411
|
+
console.log(JSON.stringify(score, null, 2));
|
|
412
|
+
} else {
|
|
413
|
+
console.log(`Compliance Score: ${score.score}%`);
|
|
414
|
+
console.log(` Total: ${score.total}`);
|
|
415
|
+
console.log(` Compliant: ${score.compliant}`);
|
|
416
|
+
console.log(` Non-compliant: ${score.non_compliant}`);
|
|
417
|
+
console.log(` In progress: ${score.in_progress}`);
|
|
418
|
+
console.log(` Not applicable: ${score.not_applicable}`);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
program
|
|
423
|
+
.command("framework-status")
|
|
424
|
+
.description("Get compliance status for a framework")
|
|
425
|
+
.argument("<framework>", "Framework name")
|
|
426
|
+
.option("--json", "Output as JSON", false)
|
|
427
|
+
.action((framework, opts) => {
|
|
428
|
+
const status = getFrameworkStatus(framework);
|
|
429
|
+
|
|
430
|
+
if (opts.json) {
|
|
431
|
+
console.log(JSON.stringify(status, null, 2));
|
|
432
|
+
} else {
|
|
433
|
+
console.log(`Framework: ${status.framework} — ${status.score}% compliant`);
|
|
434
|
+
console.log(` Total: ${status.total}`);
|
|
435
|
+
console.log(` Compliant: ${status.compliant}`);
|
|
436
|
+
console.log(` Non-compliant: ${status.non_compliant}`);
|
|
437
|
+
console.log(` In progress: ${status.in_progress}`);
|
|
438
|
+
console.log(` Not applicable: ${status.not_applicable}`);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
program
|
|
443
|
+
.command("stats")
|
|
444
|
+
.description("Get license statistics")
|
|
445
|
+
.option("--json", "Output as JSON", false)
|
|
446
|
+
.action((opts) => {
|
|
447
|
+
const stats = getLicenseStats();
|
|
448
|
+
|
|
449
|
+
if (opts.json) {
|
|
450
|
+
console.log(JSON.stringify(stats, null, 2));
|
|
451
|
+
} else {
|
|
452
|
+
console.log(`License Stats`);
|
|
453
|
+
console.log(` Total: ${stats.total}`);
|
|
454
|
+
console.log(` Active: ${stats.active}`);
|
|
455
|
+
console.log(` Expired: ${stats.expired}`);
|
|
456
|
+
console.log(` Pending renewal: ${stats.pending_renewal}`);
|
|
457
|
+
console.log(` Total cost: ${stats.total_cost}`);
|
|
458
|
+
if (Object.keys(stats.by_type).length > 0) {
|
|
459
|
+
console.log(` By type:`);
|
|
460
|
+
for (const [type, count] of Object.entries(stats.by_type)) {
|
|
461
|
+
console.log(` ${type}: ${count}`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
program.parse(process.argv);
|