@opscompass/opscompass-cli 1.3.6 → 1.3.8
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 +39 -0
- package/lib/cliHelpers.js +10 -6
- package/lib/dataGathering/sendDg.js +18 -0
- package/lib/homeInteraction.js +276 -68
- package/lib/utils.js +22 -0
- package/modules/data-gathering-scripts.js +191 -54
- package/modules/data-gathering.js +22 -0
- package/modules/license-manager/assessment.js +87 -0
- package/modules/license-manager/microsoft.js +49 -29
- package/modules/license-manager/oracle.js +87 -14
- package/modules/license-manager.js +58 -8
- package/package.json +6 -5
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { getOpsCompassClient } from "../../opscompass.js";
|
|
2
|
+
import { readAssessmentSection, printAssessmentHelp } from "./assessment.js";
|
|
3
|
+
|
|
4
|
+
async function getOracleAssessmentSummary(args) {
|
|
5
|
+
return readAssessmentSection(args, "getOracleAssessmentSummary", true);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async function getOracleAssessmentEntitlements(args) {
|
|
9
|
+
return readAssessmentSection(args, "getOracleAssessmentEntitlements", true);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function getOracleAssessmentLicenseUsageSummary(args) {
|
|
13
|
+
return readAssessmentSection(args, "getOracleAssessmentLicenseUsageSummary", true);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function getOracleAssessmentDeploymentDetails(args) {
|
|
17
|
+
return readAssessmentSection(args, "getOracleAssessmentDeploymentDetails", true);
|
|
18
|
+
}
|
|
2
19
|
|
|
3
20
|
/**
|
|
4
21
|
* Guard that the next argument in args at i+1 is present and not another flag.
|
|
@@ -93,12 +110,18 @@ async function getOracleCurrentEntitlements(args) {
|
|
|
93
110
|
}
|
|
94
111
|
|
|
95
112
|
if (accountId === undefined || accountId === null) {
|
|
96
|
-
|
|
113
|
+
accountId = global.account;
|
|
114
|
+
}
|
|
115
|
+
if (accountId === undefined || accountId === null) {
|
|
116
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
97
117
|
return;
|
|
98
118
|
}
|
|
99
119
|
|
|
100
|
-
const parsedAccountId =
|
|
101
|
-
if (parsedAccountId ===
|
|
120
|
+
const parsedAccountId = String(accountId).trim();
|
|
121
|
+
if (parsedAccountId === "") {
|
|
122
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
102
125
|
|
|
103
126
|
const options = {};
|
|
104
127
|
if (limit !== undefined) {
|
|
@@ -289,7 +312,13 @@ async function listOracleOrders(args) {
|
|
|
289
312
|
break;
|
|
290
313
|
case "--account-id":
|
|
291
314
|
case "--accountid":
|
|
292
|
-
if (
|
|
315
|
+
if (
|
|
316
|
+
args[i + 1] === undefined ||
|
|
317
|
+
args[i + 1].startsWith("--")
|
|
318
|
+
) {
|
|
319
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
293
322
|
accountId = args[++i];
|
|
294
323
|
break;
|
|
295
324
|
case "--limit":
|
|
@@ -303,13 +332,27 @@ async function listOracleOrders(args) {
|
|
|
303
332
|
}
|
|
304
333
|
}
|
|
305
334
|
|
|
335
|
+
const trailingArg = args.at(-1)?.toLowerCase();
|
|
336
|
+
if (
|
|
337
|
+
accountId === undefined &&
|
|
338
|
+
(trailingArg === "--account-id" || trailingArg === "--accountid")
|
|
339
|
+
) {
|
|
340
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (accountId === undefined || accountId === null) {
|
|
344
|
+
accountId = global.account;
|
|
345
|
+
}
|
|
306
346
|
if (accountId === undefined || accountId === null) {
|
|
307
|
-
console.error("ERROR: --account
|
|
347
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
308
348
|
return;
|
|
309
349
|
}
|
|
310
350
|
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
351
|
+
const normalizedAccountId = String(accountId).trim();
|
|
352
|
+
if (normalizedAccountId === "") {
|
|
353
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
313
356
|
|
|
314
357
|
const options = {};
|
|
315
358
|
if (limit !== undefined) {
|
|
@@ -334,7 +377,7 @@ async function listOracleOrders(args) {
|
|
|
334
377
|
const client = await getOpsCompassClient();
|
|
335
378
|
const result = await client.licenseManager.listOracleOrders(
|
|
336
379
|
companySlug,
|
|
337
|
-
|
|
380
|
+
normalizedAccountId,
|
|
338
381
|
Object.keys(options).length > 0 ? options : undefined,
|
|
339
382
|
);
|
|
340
383
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -352,7 +395,13 @@ async function getOracleOrderItems(args) {
|
|
|
352
395
|
break;
|
|
353
396
|
case "--account-id":
|
|
354
397
|
case "--accountid":
|
|
355
|
-
if (
|
|
398
|
+
if (
|
|
399
|
+
args[i + 1] === undefined ||
|
|
400
|
+
args[i + 1].startsWith("--")
|
|
401
|
+
) {
|
|
402
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
356
405
|
accountId = args[++i];
|
|
357
406
|
break;
|
|
358
407
|
case "--id":
|
|
@@ -362,8 +411,25 @@ async function getOracleOrderItems(args) {
|
|
|
362
411
|
}
|
|
363
412
|
}
|
|
364
413
|
|
|
414
|
+
const trailingArg = args.at(-1)?.toLowerCase();
|
|
415
|
+
if (
|
|
416
|
+
accountId === undefined &&
|
|
417
|
+
(trailingArg === "--account-id" || trailingArg === "--accountid")
|
|
418
|
+
) {
|
|
419
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (accountId === undefined || accountId === null) {
|
|
423
|
+
accountId = global.account;
|
|
424
|
+
}
|
|
365
425
|
if (accountId === undefined || accountId === null) {
|
|
366
|
-
console.error("ERROR: --account
|
|
426
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const normalizedAccountId = String(accountId).trim();
|
|
431
|
+
if (normalizedAccountId === "") {
|
|
432
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
367
433
|
return;
|
|
368
434
|
}
|
|
369
435
|
|
|
@@ -381,7 +447,7 @@ async function getOracleOrderItems(args) {
|
|
|
381
447
|
try {
|
|
382
448
|
const result = await client.licenseManager.getOracleOrderItems(
|
|
383
449
|
companySlug,
|
|
384
|
-
|
|
450
|
+
normalizedAccountId,
|
|
385
451
|
orderItemIds.map(Number),
|
|
386
452
|
);
|
|
387
453
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -391,6 +457,7 @@ async function getOracleOrderItems(args) {
|
|
|
391
457
|
}
|
|
392
458
|
|
|
393
459
|
async function printOracleHelp() {
|
|
460
|
+
printAssessmentHelp("oracle");
|
|
394
461
|
console.log();
|
|
395
462
|
console.log(
|
|
396
463
|
"get-oracle-current-entitlements",
|
|
@@ -398,7 +465,7 @@ async function printOracleHelp() {
|
|
|
398
465
|
);
|
|
399
466
|
console.log("Parameters:");
|
|
400
467
|
console.log("--company [company_slug] (optional, defaults to current company)");
|
|
401
|
-
console.log("--account-id
|
|
468
|
+
console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId to retrieve entitlements for.");
|
|
402
469
|
console.log(`--limit [number] (optional) Maximum number of results to return (max ${MAX_PAGINATION_LIMIT}), e.g. --limit 50.`);
|
|
403
470
|
console.log(`--offset [number] (optional) Number of results to skip for pagination (max ${MAX_PAGINATION_OFFSET}), e.g. --offset 100.`);
|
|
404
471
|
console.log();
|
|
@@ -435,7 +502,8 @@ async function printOracleHelp() {
|
|
|
435
502
|
);
|
|
436
503
|
console.log("Parameters:");
|
|
437
504
|
console.log("--company [company_slug] (optional, defaults to current company)");
|
|
438
|
-
console.log("--account-id
|
|
505
|
+
console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId to retrieve orders for.");
|
|
506
|
+
console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
|
|
439
507
|
console.log(`--limit [number] (optional) Maximum number of results to return (max ${MAX_PAGINATION_LIMIT}), e.g. --limit 50.`);
|
|
440
508
|
console.log(`--offset [number] (optional) Number of results to skip for pagination (max ${MAX_PAGINATION_OFFSET}), e.g. --offset 100.`);
|
|
441
509
|
console.log();
|
|
@@ -445,13 +513,18 @@ async function printOracleHelp() {
|
|
|
445
513
|
);
|
|
446
514
|
console.log("Parameters:");
|
|
447
515
|
console.log("--company [company_slug] (optional, defaults to current company)");
|
|
448
|
-
console.log("--account-id
|
|
516
|
+
console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId used to scope the request.");
|
|
517
|
+
console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
|
|
449
518
|
console.log('--id [number] Use parameter multiple times to retrieve multiple items, e.g. --id 10 --id 11');
|
|
450
519
|
console.log("Note: A maximum of 100 order-item IDs can be requested at once.");
|
|
451
520
|
console.log();
|
|
452
521
|
}
|
|
453
522
|
|
|
454
523
|
export {
|
|
524
|
+
getOracleAssessmentSummary,
|
|
525
|
+
getOracleAssessmentEntitlements,
|
|
526
|
+
getOracleAssessmentLicenseUsageSummary,
|
|
527
|
+
getOracleAssessmentDeploymentDetails,
|
|
455
528
|
getOracleCurrentEntitlements,
|
|
456
529
|
listOracleMetrics,
|
|
457
530
|
listOracleLimitations,
|
|
@@ -22,6 +22,9 @@ import {
|
|
|
22
22
|
listMssqlAssessments,
|
|
23
23
|
getMssqlAssessment,
|
|
24
24
|
getMssqlAssessmentEntitlements,
|
|
25
|
+
getMssqlAssessmentSummary,
|
|
26
|
+
getMssqlAssessmentLicenseUsageSummary,
|
|
27
|
+
getMssqlAssessmentDeploymentDetails,
|
|
25
28
|
getMssqlAssessmentLicenseUsageMaps,
|
|
26
29
|
getMssqlAssessmentResources,
|
|
27
30
|
checkMssqlConfigMetadata,
|
|
@@ -40,6 +43,10 @@ import {
|
|
|
40
43
|
// Oracle entitlement read-only functions
|
|
41
44
|
import {
|
|
42
45
|
printOracleHelp,
|
|
46
|
+
getOracleAssessmentSummary,
|
|
47
|
+
getOracleAssessmentEntitlements,
|
|
48
|
+
getOracleAssessmentLicenseUsageSummary,
|
|
49
|
+
getOracleAssessmentDeploymentDetails,
|
|
43
50
|
getOracleCurrentEntitlements,
|
|
44
51
|
listOracleMetrics,
|
|
45
52
|
listOracleLimitations,
|
|
@@ -824,22 +831,46 @@ async function createNetworkDiscoveryConfiguration(args) {
|
|
|
824
831
|
}
|
|
825
832
|
|
|
826
833
|
async function checkOracleConfigMetadata(args) {
|
|
827
|
-
|
|
834
|
+
const callParams = {};
|
|
835
|
+
let hasExplicitAccount = false;
|
|
836
|
+
for (let i = 0; i < args.length; i++) {
|
|
828
837
|
switch (args[i].toLowerCase()) {
|
|
829
838
|
case "--account-id":
|
|
830
839
|
case "--accountid":
|
|
831
|
-
|
|
840
|
+
hasExplicitAccount = true;
|
|
841
|
+
if (
|
|
842
|
+
args[i + 1] !== undefined &&
|
|
843
|
+
!args[i + 1].startsWith("--")
|
|
844
|
+
) {
|
|
845
|
+
callParams.accountId = args[++i];
|
|
846
|
+
}
|
|
832
847
|
break;
|
|
833
848
|
case "--last-collected-before":
|
|
834
849
|
case "--lastcollectedbefore":
|
|
835
|
-
|
|
850
|
+
if (args[i + 1] !== undefined) {
|
|
851
|
+
callParams.lastCollectedBefore = args[++i];
|
|
852
|
+
}
|
|
836
853
|
break;
|
|
837
854
|
}
|
|
838
855
|
}
|
|
839
856
|
|
|
857
|
+
const selectedAccount = hasExplicitAccount
|
|
858
|
+
? callParams.accountId
|
|
859
|
+
: global.account;
|
|
860
|
+
if (selectedAccount === undefined || selectedAccount === null) {
|
|
861
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
const normalizedAccount = String(selectedAccount).trim();
|
|
866
|
+
if (normalizedAccount === "") {
|
|
867
|
+
console.error("ERROR: --account is required (or set a default account).");
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
|
|
840
871
|
const client = await getOpsCompassClient();
|
|
841
872
|
const response = await client.licenseManager.checkOracleConfigMetadata(
|
|
842
|
-
|
|
873
|
+
normalizedAccount,
|
|
843
874
|
global.company,
|
|
844
875
|
callParams.lastCollectedBefore,
|
|
845
876
|
);
|
|
@@ -1118,7 +1149,8 @@ async function printHelp() {
|
|
|
1118
1149
|
"Checks the oracle configuration metadata for a company.",
|
|
1119
1150
|
);
|
|
1120
1151
|
console.log("Parameters:");
|
|
1121
|
-
console.log("--
|
|
1152
|
+
console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId for the company.");
|
|
1153
|
+
console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
|
|
1122
1154
|
console.log(`--company [company_slug] (default: ${global.company})\n`);
|
|
1123
1155
|
console.log(
|
|
1124
1156
|
"--lastCollectedBefore [string] (optional) Only returns records that have not been collected since the given date. Format: UTC, example: '2022-08-23T17:00:00Z'",
|
|
@@ -1139,7 +1171,27 @@ async function printHelp() {
|
|
|
1139
1171
|
}
|
|
1140
1172
|
|
|
1141
1173
|
const licenseManagerModule = (action, ...args) => {
|
|
1142
|
-
|
|
1174
|
+
// WHY: Legacy standard-argument parsing consumes scope flags before validation.
|
|
1175
|
+
// Assessment reads must reject malformed explicit scope rather than use defaults.
|
|
1176
|
+
switch (action?.toLowerCase()) {
|
|
1177
|
+
case "get-oracle-assessment-summary":
|
|
1178
|
+
return getOracleAssessmentSummary(args);
|
|
1179
|
+
case "get-oracle-assessment-entitlements":
|
|
1180
|
+
return getOracleAssessmentEntitlements(args);
|
|
1181
|
+
case "get-oracle-assessment-license-usage-summary":
|
|
1182
|
+
return getOracleAssessmentLicenseUsageSummary(args);
|
|
1183
|
+
case "get-oracle-assessment-deployment-details":
|
|
1184
|
+
return getOracleAssessmentDeploymentDetails(args);
|
|
1185
|
+
case "get-mssql-assessment-summary":
|
|
1186
|
+
return getMssqlAssessmentSummary(args);
|
|
1187
|
+
case "get-mssql-assessment-entitlements":
|
|
1188
|
+
return getMssqlAssessmentEntitlements(args);
|
|
1189
|
+
case "get-mssql-assessment-license-usage-summary":
|
|
1190
|
+
return getMssqlAssessmentLicenseUsageSummary(args);
|
|
1191
|
+
case "get-mssql-assessment-deployment-details":
|
|
1192
|
+
return getMssqlAssessmentDeploymentDetails(args);
|
|
1193
|
+
}
|
|
1194
|
+
if (utils.processStandardArgs(args) === false) return;
|
|
1143
1195
|
switch (action?.toLowerCase() ?? "") {
|
|
1144
1196
|
case "create-oracle-shared-credential":
|
|
1145
1197
|
return createOracleSharedCredential(args);
|
|
@@ -1169,8 +1221,6 @@ const licenseManagerModule = (action, ...args) => {
|
|
|
1169
1221
|
return listMssqlAssessments(args);
|
|
1170
1222
|
case "get-mssql-assessment":
|
|
1171
1223
|
return getMssqlAssessment(args);
|
|
1172
|
-
case "get-mssql-assessment-entitlements":
|
|
1173
|
-
return getMssqlAssessmentEntitlements(args);
|
|
1174
1224
|
case "get-mssql-assessment-license-usage-maps":
|
|
1175
1225
|
return getMssqlAssessmentLicenseUsageMaps(args);
|
|
1176
1226
|
case "get-mssql-assessment-resources":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opscompass/opscompass-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "Calls OpsCompass's APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
"check:publish-environment": "node ./scripts/check-publish-environment.mjs",
|
|
10
10
|
"check:pack-contents": "node ./scripts/check-pack-contents.mjs",
|
|
11
11
|
"check:restricted-apis": "node ./scripts/check-restricted-apis.mjs",
|
|
12
|
+
"check:prod-engines": "node ./scripts/check-prod-engines.mjs",
|
|
12
13
|
"check:prod-deprecations": "node ./scripts/check-prod-deprecations.mjs",
|
|
13
14
|
"check:prod-vulnerabilities": "node ./scripts/check-prod-vulnerabilities.mjs",
|
|
14
|
-
"test": "npm run ensure-current-environment && npm run check:restricted-apis && npm run check:prod-deprecations && npm run check:prod-vulnerabilities && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.js --runInBand",
|
|
15
|
+
"test": "npm run ensure-current-environment && npm run check:restricted-apis && npm run check:prod-engines && npm run check:prod-deprecations && npm run check:prod-vulnerabilities && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.js --runInBand",
|
|
15
16
|
"pack:check": "npm run ensure-current-environment && npm run check:pack-contents",
|
|
16
17
|
"build": "cd ../api;npx tsc; cd -"
|
|
17
18
|
},
|
|
@@ -24,11 +25,11 @@
|
|
|
24
25
|
"author": "opscompass",
|
|
25
26
|
"license": "SEE LICENSE IN license.txt",
|
|
26
27
|
"engines": {
|
|
27
|
-
"node": "22 || 24
|
|
28
|
+
"node": "^22.19.0 || ^24.0.0"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@opscompass/opscompass-api": "^1.3.
|
|
31
|
-
"adm-zip": "^0.6.
|
|
31
|
+
"@opscompass/opscompass-api": "^1.3.7",
|
|
32
|
+
"adm-zip": "^0.6.1",
|
|
32
33
|
"axios": "^1.18.1",
|
|
33
34
|
"better-sqlite3": "12.11.1",
|
|
34
35
|
"fs-extra": "^10.1.0",
|