@opscompass/opscompass-cli 1.3.4 → 1.3.5
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/lib/cliHelpers.js +2 -2
- package/lib/dataGathering/sendDg.js +1 -1
- package/lib/utils.js +32 -9
- package/modules/license-manager/microsoft.js +18 -14
- package/modules/license-manager/nutanix.js +2 -2
- package/modules/license-manager/vcenter.js +2 -2
- package/modules/license-manager.js +2 -2
- package/package.json +14 -8
package/lib/cliHelpers.js
CHANGED
|
@@ -17,8 +17,8 @@ function getHttpsProxyAgent() {
|
|
|
17
17
|
(process.env.https_proxy || process.env.HTTPS_PROXY)
|
|
18
18
|
) {
|
|
19
19
|
proxyAgentPromise = import("https-proxy-agent").then(
|
|
20
|
-
({
|
|
21
|
-
httpsProxyAgent =
|
|
20
|
+
({ default: HttpsProxyAgent }) => {
|
|
21
|
+
httpsProxyAgent = new HttpsProxyAgent(
|
|
22
22
|
process.env.https_proxy || process.env.HTTPS_PROXY,
|
|
23
23
|
);
|
|
24
24
|
return httpsProxyAgent;
|
package/lib/utils.js
CHANGED
|
@@ -13,7 +13,6 @@ import path from "path";
|
|
|
13
13
|
|
|
14
14
|
import { opscompassHome, decoder, cliCommand } from "../environment/current.js";
|
|
15
15
|
import { resourceTypes, encryptAttrs } from "./consts.js";
|
|
16
|
-
import findRemoveSync from "find-remove";
|
|
17
16
|
|
|
18
17
|
const defaultsPath = path.join(opscompassHome, "defaults.json");
|
|
19
18
|
|
|
@@ -44,6 +43,32 @@ function getTimestamp(dNow = new Date()) {
|
|
|
44
43
|
return `${tsYr}${tsMo}${tsDy}-${tsHr}${tsMi}${tsSe}`;
|
|
45
44
|
}
|
|
46
45
|
|
|
46
|
+
function cleanupOldConfigBackups(dirPath, prefix, extension, maxAgeSeconds) {
|
|
47
|
+
if (!fs.existsSync(dirPath)) return;
|
|
48
|
+
|
|
49
|
+
const cutoffTime = Date.now() - maxAgeSeconds * 1000;
|
|
50
|
+
const extensionSuffix = extension ? `.${extension}` : "";
|
|
51
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
52
|
+
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
if (!entry.isFile()) continue;
|
|
55
|
+
|
|
56
|
+
const fileName = entry.name;
|
|
57
|
+
if (!fileName.startsWith(prefix)) continue;
|
|
58
|
+
if (extensionSuffix && !fileName.endsWith(extensionSuffix)) continue;
|
|
59
|
+
|
|
60
|
+
const filePath = path.join(dirPath, fileName);
|
|
61
|
+
try {
|
|
62
|
+
const stats = fs.statSync(filePath);
|
|
63
|
+
if (stats.mtimeMs <= cutoffTime) {
|
|
64
|
+
fs.rmSync(filePath, { force: true });
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
// Best-effort cleanup; ignore files that vanish or cannot be read.
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
47
72
|
/**
|
|
48
73
|
* Process standard arguments (eg company) and remove them
|
|
49
74
|
* @param {string[]} args
|
|
@@ -433,14 +458,12 @@ async function writeConfigFile(args, cfgData = undefined, overwrite = false) {
|
|
|
433
458
|
// Cleanup old files matching this name
|
|
434
459
|
// It processes in file order (which is apparently sorted), so with no restrictions
|
|
435
460
|
// it will get a list of all non-current config files
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
});
|
|
443
|
-
// console.log(JSON.stringify(result, null, 2));
|
|
461
|
+
cleanupOldConfigBackups(
|
|
462
|
+
cfgPath,
|
|
463
|
+
cfgBase + "_", // Add _ to target non-current backups
|
|
464
|
+
fExt,
|
|
465
|
+
2505600, // 29 days
|
|
466
|
+
);
|
|
444
467
|
|
|
445
468
|
return newConfig;
|
|
446
469
|
}
|
|
@@ -431,18 +431,20 @@ async function createMssqlConfiguration(args) {
|
|
|
431
431
|
optionalParams.password = args[++i];
|
|
432
432
|
break;
|
|
433
433
|
case "--directory-auth":
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
434
|
+
{
|
|
435
|
+
const authArg = args[++i];
|
|
436
|
+
if (authArg.toLowerCase() === "null") {
|
|
437
|
+
optionalParams.directory_auth = null;
|
|
438
|
+
} else {
|
|
439
|
+
optionalParams.directory_auth = "SESSION";
|
|
440
|
+
}
|
|
439
441
|
}
|
|
440
442
|
break;
|
|
441
443
|
}
|
|
442
444
|
}
|
|
443
445
|
|
|
444
446
|
const msqlConfiguration = await createMaskedConfig(
|
|
445
|
-
|
|
447
|
+
"createMssqlConfiguration",
|
|
446
448
|
configurationName,
|
|
447
449
|
optionalParams,
|
|
448
450
|
);
|
|
@@ -491,18 +493,20 @@ async function updateMssqlConfiguration(args) {
|
|
|
491
493
|
callParams.password = args[++i];
|
|
492
494
|
break;
|
|
493
495
|
case "--directory-auth":
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
496
|
+
{
|
|
497
|
+
const authArg = args[++i];
|
|
498
|
+
if (authArg.toLowerCase() === "null") {
|
|
499
|
+
callParams.directory_auth = null;
|
|
500
|
+
} else {
|
|
501
|
+
callParams.directory_auth = "SESSION";
|
|
502
|
+
}
|
|
499
503
|
}
|
|
500
504
|
break;
|
|
501
505
|
}
|
|
502
506
|
}
|
|
503
507
|
|
|
504
508
|
const msqlConfiguration = await updateMaskedConfig(
|
|
505
|
-
|
|
509
|
+
"updateMssqlConfiguration",
|
|
506
510
|
callParams.id,
|
|
507
511
|
callParams,
|
|
508
512
|
);
|
|
@@ -553,8 +557,8 @@ async function updateMssqlConfigurations(args) {
|
|
|
553
557
|
} else if (args[i].toLowerCase() === "--password") {
|
|
554
558
|
callParams.password = args[i + 1];
|
|
555
559
|
} else if (args[i].toLowerCase() === "--directory-auth") {
|
|
556
|
-
authArg = args[i + 1];
|
|
557
|
-
if (authArg.toLowerCase === "null") {
|
|
560
|
+
const authArg = args[i + 1];
|
|
561
|
+
if (authArg.toLowerCase() === "null") {
|
|
558
562
|
callParams.directory_auth = null;
|
|
559
563
|
} else {
|
|
560
564
|
callParams.directory_auth = "SESSION";
|
|
@@ -94,7 +94,7 @@ async function createNutanixConfiguration(args) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
const nutanixConfiguration = await createMaskedConfig(
|
|
97
|
-
|
|
97
|
+
"createNutanixConfiguration",
|
|
98
98
|
configurationName,
|
|
99
99
|
optionalParams,
|
|
100
100
|
);
|
|
@@ -129,7 +129,7 @@ async function updateNutanixConfiguration(args) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
const nutanixConfiguration = await updateMaskedConfig(
|
|
132
|
-
|
|
132
|
+
"updateNutanixConfiguration",
|
|
133
133
|
callParams.id,
|
|
134
134
|
callParams,
|
|
135
135
|
);
|
|
@@ -90,7 +90,7 @@ async function createVcenterConfiguration(args) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
const vCenterConfiguration = await createMaskedConfig(
|
|
93
|
-
|
|
93
|
+
"createVcenterConfiguration",
|
|
94
94
|
configurationName,
|
|
95
95
|
optionalParams,
|
|
96
96
|
);
|
|
@@ -125,7 +125,7 @@ async function updateVcenterConfiguration(args) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
const vCenterConfiguration = await updateMaskedConfig(
|
|
128
|
-
|
|
128
|
+
"updateVcenterConfiguration",
|
|
129
129
|
callParams.id,
|
|
130
130
|
callParams,
|
|
131
131
|
);
|
|
@@ -496,7 +496,7 @@ async function createOracleDatabaseConfiguration(args) {
|
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
const oracleDatabaseConfiguration = await createMaskedConfig(
|
|
499
|
-
|
|
499
|
+
"createOracleDatabaseConfiguration",
|
|
500
500
|
configurationName,
|
|
501
501
|
optionalParams,
|
|
502
502
|
);
|
|
@@ -594,7 +594,7 @@ async function updateOracleDatabaseConfiguration(args) {
|
|
|
594
594
|
}
|
|
595
595
|
|
|
596
596
|
const oracleDatabaseConfiguration = await updateMaskedConfig(
|
|
597
|
-
|
|
597
|
+
"updateOracleDatabaseConfiguration",
|
|
598
598
|
callParams.id,
|
|
599
599
|
callParams,
|
|
600
600
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opscompass/opscompass-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Calls OpsCompass's APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -9,7 +9,9 @@
|
|
|
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
|
-
"
|
|
12
|
+
"check:prod-deprecations": "node ./scripts/check-prod-deprecations.mjs",
|
|
13
|
+
"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",
|
|
13
15
|
"pack:check": "npm run ensure-current-environment && npm run check:pack-contents",
|
|
14
16
|
"build": "cd ../api;npx tsc; cd -"
|
|
15
17
|
},
|
|
@@ -25,20 +27,24 @@
|
|
|
25
27
|
"node": ">=22 <23 || >=24 <25"
|
|
26
28
|
},
|
|
27
29
|
"dependencies": {
|
|
28
|
-
"@opscompass/opscompass-api": "^1.3.
|
|
30
|
+
"@opscompass/opscompass-api": "^1.3.4",
|
|
29
31
|
"adm-zip": "^0.5.16",
|
|
30
|
-
"axios": "^
|
|
31
|
-
"better-sqlite3": "12.
|
|
32
|
-
"find-remove": "^5.0.0",
|
|
32
|
+
"axios": "^1.18.1",
|
|
33
|
+
"better-sqlite3": "12.11.1",
|
|
33
34
|
"fs-extra": "^10.1.0",
|
|
34
35
|
"https-proxy-agent": "^5.0.1",
|
|
35
36
|
"open": "^8.2.1",
|
|
36
37
|
"openpgp": "6.2.2",
|
|
37
38
|
"semver": "^7.3.7",
|
|
38
|
-
"tar": "^
|
|
39
|
+
"tar": "^7.5.16"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"jest": "^
|
|
42
|
+
"jest": "^30.4.2"
|
|
43
|
+
},
|
|
44
|
+
"overrides": {
|
|
45
|
+
"minimatch": "^10.2.3",
|
|
46
|
+
"brace-expansion": "^2.0.2",
|
|
47
|
+
"tar-fs": "^2.1.4"
|
|
42
48
|
},
|
|
43
49
|
"files": [
|
|
44
50
|
"index.js",
|