@opscompass/opscompass-cli 1.3.6 → 1.3.7

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 CHANGED
@@ -158,17 +158,21 @@ async function downloadFile(downloadUrl, downloadFilePath, downloadName) {
158
158
  }
159
159
 
160
160
  /**
161
- * Unzips a file based on the passed parameters. Saves the unziped contents in the directory
162
- * containing the .zip.
163
- * @param {string} unzipFileLocation the path to the directory to store the unzipped contents
164
- * @param {string} unzipFileName the name of the unzipped file
161
+ * Unzips a file to the requested extraction directory.
162
+ * @param {string} unzipFileLocation directory containing the zip archive
163
+ * @param {string} unzipFileName archive file name
164
+ * @param {string} extractionDestination directory receiving extracted contents
165
165
  */
166
- async function unzipFile(unzipFileLocation, unzipFileName) {
166
+ async function unzipFile(
167
+ unzipFileLocation,
168
+ unzipFileName,
169
+ extractionDestination = unzipFileLocation,
170
+ ) {
167
171
  const zipFileLocation = path.join(unzipFileLocation, unzipFileName);
168
172
  try {
169
173
  const zip = new AdmZip(zipFileLocation);
170
174
  // Overwrite and keepOriginalPermissions
171
- zip.extractAllTo(unzipFileLocation, true, true);
175
+ zip.extractAllTo(extractionDestination, true, true);
172
176
  } catch (err) {
173
177
  deleteFile(zipFileLocation);
174
178
  throw "Something went wrong during unzipping.\nIf you specified a script version, confirm it is correct.\nIf the error continues, contact your OpsCompass rep.";
@@ -691,6 +691,21 @@ function isArchiveFile(filePath) {
691
691
  const lower = filePath.toLowerCase();
692
692
  return lower.endsWith(".tgz") || lower.endsWith(".tar.gz");
693
693
  }
694
+
695
+ function canonicalizeEncryptedArchiveForUpload(filePath) {
696
+ if (!filePath.toLowerCase().endsWith(".tar.gz.gpg")) {
697
+ return { filePath };
698
+ }
699
+
700
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "opscompass-send-dg-upload-"));
701
+ const uploadPath = path.join(
702
+ tempDir,
703
+ `${path.basename(filePath).slice(0, -".tar.gz.gpg".length)}.tgz.gpg`,
704
+ );
705
+ fs.copyFileSync(filePath, uploadPath);
706
+ return { filePath: uploadPath, tempDir };
707
+ }
708
+
694
709
  function logCheckpointKey(company, account, logDirectory) {
695
710
  return `${company}\u0000${account || ""}\u0000${path.resolve(logDirectory)}`;
696
711
  }
@@ -1013,6 +1028,9 @@ async function sendDgAction(args = [], logger = { emit: () => {} }) {
1013
1028
  if (!isEncryptedFile(filePath)) {
1014
1029
  encrypted = await encryptFile(filePath, params.account);
1015
1030
  }
1031
+ const uploadArchive = canonicalizeEncryptedArchiveForUpload(encrypted);
1032
+ encrypted = uploadArchive.filePath;
1033
+ if (uploadArchive.tempDir) stableOutputTempDirs.add(uploadArchive.tempDir);
1016
1034
 
1017
1035
  const response = await sendToOc(client, params.metadataType, params.fileType, encrypted, params.company);
1018
1036
  if (!transferSucceeded(response)) {
@@ -1,4 +1,5 @@
1
1
  import fs from "fs-extra";
2
+ import { randomUUID } from "node:crypto";
2
3
  import path from "path";
3
4
  import {
4
5
  Verify,
@@ -12,11 +13,9 @@ import {
12
13
  } from "../environment/current.js";
13
14
  import {
14
15
  findOrCreateFolder,
15
- deleteDirectory,
16
16
  downloadFile,
17
17
  unzipFile,
18
18
  deleteFile,
19
- moveFolder,
20
19
  writeFile,
21
20
  canReadFile,
22
21
  getAllFilesInFolder,
@@ -111,13 +110,148 @@ async function getScriptMetadata(scriptType) {
111
110
  }
112
111
  }
113
112
 
114
- /**
115
- * Removes the currently installed script for the specified script type
116
- * @param {string} scriptType the script type to remove
117
- */
118
- function removeCurrentlyInstalledScript(scriptType) {
119
- const scriptsPath = findOrCreateScriptsFolder();
120
- deleteDirectory(path.join(scriptsPath, scriptType, SRC_FOLDER_NAME));
113
+ function assertDirectChildSemver(version, description) {
114
+ if (
115
+ typeof version !== "string" ||
116
+ path.posix.basename(version) !== version ||
117
+ path.win32.basename(version) !== version ||
118
+ !semver.valid(version)
119
+ ) {
120
+ throw new Error(`${description} must be a direct-child semantic version.`);
121
+ }
122
+
123
+ return version;
124
+ }
125
+
126
+ function versionFromArchiveName(fileName) {
127
+ if (
128
+ typeof fileName !== "string" ||
129
+ path.posix.basename(fileName) !== fileName ||
130
+ path.win32.basename(fileName) !== fileName ||
131
+ !fileName.endsWith(".zip")
132
+ ) {
133
+ throw new Error("Script archive name must be a direct-child .zip file.");
134
+ }
135
+
136
+ return fileName.slice(0, -".zip".length);
137
+ }
138
+
139
+ async function validateInstalledMetadata(scriptType, scriptTypePath, srcPath) {
140
+ const metadataPath = path.join(scriptTypePath, METADATA_FILE_NAME);
141
+ if (!fs.existsSync(metadataPath)) {
142
+ if (fs.existsSync(srcPath)) {
143
+ throw new Error(
144
+ `Cannot replace ${scriptType} scripts because ${METADATA_FILE_NAME} does not contain the installed version.`,
145
+ );
146
+ }
147
+ return;
148
+ }
149
+
150
+ try {
151
+ const scriptMetadata = await getScriptMetadata(scriptType);
152
+ assertDirectChildSemver(
153
+ scriptMetadata?.version,
154
+ `Installed ${METADATA_FILE_NAME} version`,
155
+ );
156
+ } catch (err) {
157
+ throw new Error(
158
+ `Cannot replace ${scriptType} scripts because ${METADATA_FILE_NAME} is unreadable or lacks a valid direct-child semantic version.`,
159
+ { cause: err },
160
+ );
161
+ }
162
+ }
163
+
164
+ function normalizeScriptPermissions(destinationPath) {
165
+ const allFilePaths = getAllFilesInFolder(destinationPath);
166
+ allFilePaths.forEach(function (filePath) {
167
+ // Skip files we don't care about ({hidden}, bat, txt, ...)
168
+ if (path.basename(filePath).match(/^\./)) {
169
+ return;
170
+ }
171
+
172
+ const fileExtension = path.extname(filePath);
173
+ if (fileExtension.match(/bat|txt|pl/)) {
174
+ return;
175
+ }
176
+
177
+ const fileStat = fs.lstatSync(filePath);
178
+ if (fileStat.mode & 0o007) {
179
+ fs.chmodSync(filePath, fileStat.mode & 0o770);
180
+ }
181
+ });
182
+ }
183
+
184
+ async function removeInstallArtifact(artifactPath, output, description) {
185
+ try {
186
+ await fs.rm(artifactPath, { recursive: true, force: true });
187
+ } catch (err) {
188
+ output.warn?.(`Unable to remove ${description} ${artifactPath}: ${err}`);
189
+ }
190
+ }
191
+
192
+ async function cleanupOldBackups(backupRoot, keepBackupPath, output) {
193
+ if (!fs.existsSync(backupRoot)) {
194
+ return;
195
+ }
196
+
197
+ let entries;
198
+ try {
199
+ entries = await fs.readdir(backupRoot, { withFileTypes: true });
200
+ } catch (err) {
201
+ output.warn?.(`Unable to inspect script backups ${backupRoot}: ${err}`);
202
+ return;
203
+ }
204
+
205
+ const backupEntries = entries.filter((entry) =>
206
+ entry.name.startsWith("backup-"),
207
+ );
208
+ if (!keepBackupPath && backupEntries.length > 0) {
209
+ let newestModifiedTime = -Infinity;
210
+ try {
211
+ for (const entry of backupEntries) {
212
+ const backupPath = path.join(backupRoot, entry.name);
213
+ const modifiedTime = (await fs.stat(backupPath)).mtimeMs;
214
+ if (modifiedTime >= newestModifiedTime) {
215
+ newestModifiedTime = modifiedTime;
216
+ keepBackupPath = backupPath;
217
+ }
218
+ }
219
+ } catch (err) {
220
+ output.warn?.(`Unable to inspect script backups ${backupRoot}: ${err}`);
221
+ return;
222
+ }
223
+ }
224
+
225
+ for (const entry of backupEntries) {
226
+ const backupPath = path.join(backupRoot, entry.name);
227
+ if (backupPath === keepBackupPath) {
228
+ continue;
229
+ }
230
+ await removeInstallArtifact(backupPath, output, "old script backup");
231
+ }
232
+ }
233
+
234
+ async function restorePreviousSource({
235
+ srcPath,
236
+ stagedPayloadPath,
237
+ backupPath,
238
+ previousSourceBackedUp,
239
+ payloadPromoted,
240
+ installError,
241
+ }) {
242
+ try {
243
+ if (payloadPromoted) {
244
+ await fs.rename(srcPath, stagedPayloadPath);
245
+ }
246
+ if (previousSourceBackedUp) {
247
+ await fs.rename(backupPath, srcPath);
248
+ }
249
+ } catch (rollbackError) {
250
+ throw new Error(
251
+ `Script install failed (${installError}); rollback also failed (${rollbackError}). Live source: ${srcPath}. Previous source backup: ${backupPath || "none"}. Staged payload: ${stagedPayloadPath}.`,
252
+ { cause: installError },
253
+ );
254
+ }
121
255
  }
122
256
 
123
257
  /**
@@ -199,7 +333,7 @@ async function downloadScriptsToHome(
199
333
  );
200
334
  const scriptTypePath = findOrCreateScriptTypeFolder(scriptType);
201
335
  const fileName = scriptDownloadInfo.fileName;
202
- scriptVersion = fileName.replace(".zip", "");
336
+ scriptVersion = versionFromArchiveName(fileName);
203
337
 
204
338
  await downloadFile(
205
339
  scriptDownloadInfo.downloadUrl,
@@ -208,68 +342,132 @@ async function downloadScriptsToHome(
208
342
  );
209
343
 
210
344
  scriptDownloadInfo.filePath = path.join(scriptTypePath, fileName);
211
- const verification =
212
- (await Verify(scriptDownloadInfo, output)) || SCRIPT_VERIFICATION_FALLBACK;
345
+ let stagingDirectory;
346
+ let stagedPayloadPath;
347
+ let backupArtifactPath;
348
+ let backupPath;
349
+ let preserveDiagnosticPaths = false;
213
350
 
214
- // Signature present but invalid must fail closed and not install.
215
- if (verification.status === SCRIPT_BUNDLE_VERIFICATION_STATUS.invalid) {
216
- deleteFile(scriptDownloadInfo.filePath);
217
- throw new Error(
218
- `Script bundle verification failed for ${scriptType}: ${verification.reason || "invalid signature"}`,
219
- );
220
- }
351
+ try {
352
+ const verification =
353
+ (await Verify(scriptDownloadInfo, output)) || SCRIPT_VERIFICATION_FALLBACK;
221
354
 
222
- if (verification.status !== SCRIPT_BUNDLE_VERIFICATION_STATUS.verified) {
223
- output.warn?.(
224
- "Downloaded %s bundle is unverified (%s)",
225
- scriptType,
226
- verification.reason || "unknown",
227
- );
228
- }
355
+ // Signature present but invalid must fail closed and not install.
356
+ if (verification.status === SCRIPT_BUNDLE_VERIFICATION_STATUS.invalid) {
357
+ throw new Error(
358
+ `Script bundle verification failed for ${scriptType}: ${verification.reason || "invalid signature"}`,
359
+ );
360
+ }
229
361
 
230
- removeCurrentlyInstalledScript(scriptType);
362
+ if (verification.status !== SCRIPT_BUNDLE_VERIFICATION_STATUS.verified) {
363
+ output.warn?.(
364
+ "Downloaded %s bundle is unverified (%s)",
365
+ scriptType,
366
+ verification.reason || "unknown",
367
+ );
368
+ }
369
+ assertDirectChildSemver(scriptVersion, "Script archive version");
231
370
 
232
- await unzipFile(scriptTypePath, fileName);
371
+ const stagingRoot = path.join(scriptTypePath, ".src-staging");
372
+ await fs.ensureDir(stagingRoot);
373
+ stagingDirectory = await fs.mkdtemp(path.join(stagingRoot, "install-"));
374
+ await unzipFile(scriptTypePath, fileName, stagingDirectory);
233
375
 
234
- // Move contents from script version folder to src
235
- const destinationPath = path.join(scriptTypePath, SRC_FOLDER_NAME);
236
- await moveFolder(
237
- path.join(scriptTypePath, scriptVersion),
238
- destinationPath,
239
- );
376
+ stagedPayloadPath = path.join(stagingDirectory, scriptVersion);
377
+ let stagedPayloadStat;
378
+ try {
379
+ stagedPayloadStat = await fs.lstat(stagedPayloadPath);
380
+ } catch (err) {
381
+ throw new Error(
382
+ `Script archive does not contain the expected ${scriptVersion} directory.`,
383
+ { cause: err },
384
+ );
385
+ }
386
+ if (!stagedPayloadStat.isDirectory()) {
387
+ throw new Error(
388
+ `Script archive does not contain the expected ${scriptVersion} directory.`,
389
+ );
390
+ }
240
391
 
241
- // File permissions should be set by the pipeline that builds the distribution bundle
242
- // However, remove them if "other" has permissions - typically want just user and group
243
- const allFilePaths = getAllFilesInFolder(destinationPath);
244
- allFilePaths.forEach(function (filePath) {
245
- // Skip files we don't care about ({hidden}, bat, txt, ...)
246
- if (path.basename(filePath).match(/^\./)) {
247
- return;
248
- } else {
249
- var fileExtension = path.extname(filePath);
250
- if (fileExtension.match(/bat|txt|pl/)) {
251
- return;
392
+ normalizeScriptPermissions(stagedPayloadPath);
393
+
394
+ const srcPath = path.join(scriptTypePath, SRC_FOLDER_NAME);
395
+ await validateInstalledMetadata(scriptType, scriptTypePath, srcPath);
396
+
397
+ let previousSourceBackedUp = false;
398
+ let payloadPromoted = false;
399
+
400
+ // WHY: NFS clients can keep live script files open, so recursive replacement is not a safe cutover.
401
+ // DECISION: validate installed metadata before any live rename so an unsafe recovery state fails while src is untouched; use only native same-filesystem renames for the live transition.
402
+ // DECISION: Leave legacy direct-child semver folders untouched because an interrupted older installer may have left its only recoverable payload there.
403
+ // TRADEOFF: Keep the newest hidden backup with its validated metadata beside src after a successful cutover, accepting its disk-space cost for a self-describing recovery point.
404
+ try {
405
+ if (fs.existsSync(srcPath)) {
406
+ const backupRoot = path.join(scriptTypePath, ".src-backups");
407
+ await fs.ensureDir(backupRoot);
408
+ backupArtifactPath = await fs.mkdtemp(
409
+ path.join(backupRoot, "backup-"),
410
+ );
411
+ backupPath = path.join(backupArtifactPath, SRC_FOLDER_NAME);
412
+ await fs.copy(
413
+ path.join(scriptTypePath, METADATA_FILE_NAME),
414
+ path.join(backupArtifactPath, METADATA_FILE_NAME),
415
+ );
416
+ await fs.rename(srcPath, backupPath);
417
+ previousSourceBackedUp = true;
252
418
  }
253
- }
254
419
 
255
- var fileStat = fs.lstatSync(filePath);
256
- if (fileStat.mode & 0o007) {
257
- // console.error(
258
- // "Warning: loose permissions (0o%s) on %s",
259
- // (fileStat.mode & 0o777).toString(8),
260
- // filePath
261
- // );
262
- fs.chmodSync(filePath, fileStat.mode & 0o770);
420
+ await fs.rename(stagedPayloadPath, srcPath);
421
+ payloadPromoted = true;
422
+
423
+ await setScriptMetadata(scriptTypePath, scriptVersion, verification);
424
+ } catch (installError) {
425
+ try {
426
+ await restorePreviousSource({
427
+ srcPath,
428
+ stagedPayloadPath,
429
+ backupPath,
430
+ previousSourceBackedUp,
431
+ payloadPromoted,
432
+ installError,
433
+ });
434
+ } catch (rollbackError) {
435
+ preserveDiagnosticPaths = true;
436
+ throw rollbackError;
437
+ }
438
+ throw installError;
263
439
  }
264
- });
265
440
 
266
- // Set the script's metadata
267
- await setScriptMetadata(scriptTypePath, scriptVersion, verification);
268
-
269
- deleteFile(path.join(scriptTypePath, fileName));
441
+ await cleanupOldBackups(
442
+ path.join(scriptTypePath, ".src-backups"),
443
+ backupArtifactPath,
444
+ output,
445
+ );
270
446
 
271
- // Return the version downloaded
272
- return scriptVersion;
447
+ return scriptVersion;
448
+ } finally {
449
+ if (fs.existsSync(scriptDownloadInfo.filePath)) {
450
+ deleteFile(scriptDownloadInfo.filePath);
451
+ }
452
+ if (stagingDirectory && !preserveDiagnosticPaths) {
453
+ await removeInstallArtifact(
454
+ stagingDirectory,
455
+ output,
456
+ "script staging directory",
457
+ );
458
+ }
459
+ if (
460
+ backupArtifactPath &&
461
+ !preserveDiagnosticPaths &&
462
+ !fs.existsSync(backupPath)
463
+ ) {
464
+ await removeInstallArtifact(
465
+ backupArtifactPath,
466
+ output,
467
+ "empty script backup",
468
+ );
469
+ }
470
+ }
273
471
  }
274
472
 
275
473
  /**
@@ -287,7 +485,7 @@ function previousScriptsDownloaded(scriptType) {
287
485
  }
288
486
 
289
487
  /**
290
- * Creates/updates a file that contains a specific script's metadata.
488
+ * Atomically creates or updates a script's metadata.
291
489
  * @param {string} scriptFolderPath path to the script folder
292
490
  * @param {string} scriptVersion the version of the downloaded script
293
491
  */
@@ -296,6 +494,7 @@ async function setScriptMetadata(
296
494
  scriptVersion,
297
495
  verification = SCRIPT_VERIFICATION_FALLBACK,
298
496
  ) {
497
+ assertDirectChildSemver(scriptVersion, "Installed metadata version");
299
498
  const scriptMetadata = {
300
499
  version: scriptVersion,
301
500
  verification: {
@@ -309,13 +508,23 @@ async function setScriptMetadata(
309
508
  };
310
509
 
311
510
  const metadataFilePath = path.join(scriptFolderPath, METADATA_FILE_NAME);
511
+ const pendingMetadataPath = path.join(
512
+ scriptFolderPath,
513
+ `.metadata-${randomUUID()}.tmp`,
514
+ );
312
515
 
313
- // Clear out old metadata if present
314
- if (canReadFile(metadataFilePath)) {
315
- deleteFile(metadataFilePath);
516
+ try {
517
+ await writeFile(pendingMetadataPath, scriptMetadata);
518
+ await fs.rename(pendingMetadataPath, metadataFilePath);
519
+ } finally {
520
+ if (fs.existsSync(pendingMetadataPath)) {
521
+ try {
522
+ await fs.rm(pendingMetadataPath, { force: true });
523
+ } catch {
524
+ // The original write/rename failure is more useful than temp cleanup.
525
+ }
526
+ }
316
527
  }
317
-
318
- await writeFile(metadataFilePath, scriptMetadata);
319
528
  }
320
529
 
321
530
  async function getScriptVerificationState(scriptType) {
@@ -355,7 +564,6 @@ export {
355
564
  getInstalledScriptVersion,
356
565
  getScriptVerificationState,
357
566
  assertScriptBundleVerified,
358
- removeCurrentlyInstalledScript,
359
567
  downloadScriptsToHome,
360
568
  previousScriptsDownloaded,
361
569
  };
package/lib/utils.js CHANGED
@@ -72,8 +72,29 @@ function cleanupOldConfigBackups(dirPath, prefix, extension, maxAgeSeconds) {
72
72
  /**
73
73
  * Process standard arguments (eg company) and remove them
74
74
  * @param {string[]} args
75
+ * @returns {boolean}
75
76
  */
76
77
  function processStandardArgs(args) {
78
+ for (let i = 0; i < args.length; i++) {
79
+ if (
80
+ typeof args[i] === "string" &&
81
+ args[i].toLowerCase() === "--account"
82
+ ) {
83
+ const account = args[i + 1];
84
+ if (
85
+ account === undefined ||
86
+ account === null ||
87
+ (typeof account === "string" &&
88
+ (account.startsWith("--") || account.trim() === ""))
89
+ ) {
90
+ console.error(
91
+ "ERROR: --account is required (or set a default account).",
92
+ );
93
+ return false;
94
+ }
95
+ }
96
+ }
97
+
77
98
  // There should be global values from opscompassHome/defaults.json for these
78
99
  // - They are picked up by index.js
79
100
  // - Override them here from the command line
@@ -94,6 +115,7 @@ function processStandardArgs(args) {
94
115
  break;
95
116
  }
96
117
  }
118
+ return true;
97
119
  }
98
120
 
99
121
  /**
@@ -24,43 +24,61 @@ async function listLocalScripts(args) {
24
24
  }
25
25
 
26
26
  const scriptTypes = Object.values(ScriptType);
27
- let scriptsLocal;
27
+ const scriptsLocal = { path: undefined, versions: [] };
28
+ const failedScriptTypes = [];
28
29
 
29
30
  try {
30
31
  const baseScriptFolderPath = findOrCreateScriptsFolder();
31
- scriptsLocal = { path: baseScriptFolderPath, versions: [] };
32
+ scriptsLocal.path = baseScriptFolderPath;
32
33
  const items = fs.readdirSync(baseScriptFolderPath, { withFileTypes: true });
33
34
 
34
35
  for (const item of items) {
35
- if (scriptTypes.includes(item.name) && item.isDirectory()) {
36
- let metaFile = path.join(
37
- baseScriptFolderPath,
38
- item.name,
39
- "metadata.json",
40
- );
41
- if (fs.existsSync(metaFile)) {
42
- const data = fs.readFileSync(metaFile);
43
- const metaVersion = JSON.parse(data.toString());
44
-
45
- scriptsLocal.versions.push({
46
- scriptType: item.name,
47
- scriptVersion: metaVersion.version,
48
- });
36
+ if (!scriptTypes.includes(item.name) || !item.isDirectory()) {
37
+ continue;
38
+ }
39
+
40
+ const metaFile = path.join(
41
+ baseScriptFolderPath,
42
+ item.name,
43
+ "metadata.json",
44
+ );
45
+ if (!fs.existsSync(metaFile)) {
46
+ failedScriptTypes.push(item.name);
47
+ continue;
48
+ }
49
+
50
+ try {
51
+ const data = fs.readFileSync(metaFile);
52
+ const metaVersion = JSON.parse(data.toString());
53
+ if (!metaVersion?.version) {
54
+ failedScriptTypes.push(item.name);
55
+ continue;
49
56
  }
57
+
58
+ scriptsLocal.versions.push({
59
+ scriptType: item.name,
60
+ scriptVersion: metaVersion.version,
61
+ });
62
+ } catch (err) {
63
+ console.log(err);
64
+ failedScriptTypes.push(item.name);
50
65
  }
51
66
  }
52
67
 
53
- if (items.length <= 0) {
54
- throw "Cannot list scripts. Make sure the scripts are downloaded.\nIf the issue persists, contact your OpsCompass rep.";
55
- } else {
56
- if (!quiet) {
57
- // Go with compact output for this display
58
- // console.log(JSON.stringify(scriptsLocal, null, 2));
59
- console.log(scriptsLocal);
60
- }
68
+
69
+ if (!quiet) {
70
+ // Go with compact output for this display
71
+ // console.log(JSON.stringify(scriptsLocal, null, 2));
72
+ console.log(scriptsLocal);
61
73
  }
62
74
  } catch (err) {
63
75
  console.log(err);
76
+ scriptsLocal.success = false;
77
+ scriptsLocal.error = err;
78
+ }
79
+ if (failedScriptTypes.length > 0) {
80
+ scriptsLocal.success = false;
81
+ scriptsLocal.failedScriptTypes = failedScriptTypes;
64
82
  }
65
83
 
66
84
  return scriptsLocal;
@@ -92,7 +110,8 @@ async function downloadScripts(args) {
92
110
  const scriptTypes = Object.values(ScriptType);
93
111
  if (!scriptTypes.includes(scriptType)) {
94
112
  console.log("Unsupported script type...");
95
- return;
113
+ process.exitCode = 1;
114
+ return { success: false, scriptType };
96
115
  }
97
116
 
98
117
  try {
@@ -106,9 +125,16 @@ async function downloadScripts(args) {
106
125
  );
107
126
 
108
127
  console.log("Downloaded %s (v%s)", scriptType, rcvdVersion);
128
+ return {
129
+ success: true,
130
+ scriptType,
131
+ downloadedVersion: rcvdVersion,
132
+ };
109
133
  } catch (err) {
110
134
  console.log("Download script type %s failed...", scriptType);
111
135
  console.log(err);
136
+ process.exitCode = 1;
137
+ return { success: false, scriptType, error: err };
112
138
  }
113
139
  }
114
140
 
@@ -142,6 +168,7 @@ async function listAvailableScripts(args) {
142
168
  } catch (err) {
143
169
  console.log("List available script versions failed...");
144
170
  console.log(err);
171
+ return { success: false, error: err };
145
172
  }
146
173
  }
147
174
 
@@ -152,6 +179,21 @@ async function listAvailableScripts(args) {
152
179
  async function checkScriptUpdates(args) {
153
180
  let scriptType = undefined;
154
181
  let autoUpdate = false;
182
+ const updateResult = { success: true, failedScriptTypes: [] };
183
+ const recordUpdateFailure = (failedScriptType) => {
184
+ updateResult.success = false;
185
+ if (
186
+ failedScriptType &&
187
+ !updateResult.failedScriptTypes.includes(failedScriptType)
188
+ ) {
189
+ updateResult.failedScriptTypes.push(failedScriptType);
190
+ }
191
+ process.exitCode = 1;
192
+ return updateResult;
193
+ };
194
+ const isValidVersion = (version) =>
195
+ typeof version === "string" && semver.valid(version) !== null;
196
+
155
197
  for (let i = 0; i < args.length; i++) {
156
198
  switch (args[i].toLowerCase()) {
157
199
  case "--auto-update":
@@ -168,30 +210,58 @@ async function checkScriptUpdates(args) {
168
210
  }
169
211
  }
170
212
 
171
- const client = await getOpsCompassClient();
213
+ const scriptTypes = Object.values(ScriptType);
172
214
 
173
215
  // If script type was specified, just check that one
174
216
  if (scriptType) {
175
217
  // If script type is not supported, we do not want to continue.
176
- const scriptTypes = Object.values(ScriptType);
177
218
  if (!scriptTypes.includes(scriptType)) {
178
219
  console.log("Unsupported script type...");
179
- return;
220
+ return recordUpdateFailure(scriptType);
180
221
  }
181
222
 
182
- const currentScriptVersion = await getInstalledScriptVersion(scriptType);
223
+ let currentScriptVersion;
224
+ try {
225
+ currentScriptVersion = await getInstalledScriptVersion(scriptType);
226
+ } catch (err) {
227
+ console.log("Check local script version for type %s failed...", scriptType);
228
+ console.log(err);
229
+ return recordUpdateFailure(scriptType);
230
+ }
183
231
 
184
232
  if (!currentScriptVersion) {
185
233
  console.log(
186
234
  `Local scripts for type ${scriptType} not found. Please make sure they are downloaded.`,
187
235
  );
188
236
  console.log("If the issue persists, please contact your OpsCompass rep.");
189
- return;
237
+ return recordUpdateFailure(scriptType);
190
238
  }
191
239
 
192
- console.log("Checking for latest version of module %s...", scriptType);
193
- const latestScriptVersion =
194
- await client.dataGatheringScripts.checkScriptUpdates(company, scriptType);
240
+ if (!isValidVersion(currentScriptVersion)) {
241
+ console.log("Local script version for type %s is malformed.", scriptType);
242
+ return recordUpdateFailure(scriptType);
243
+ }
244
+
245
+ let client;
246
+ let latestScriptVersion;
247
+ try {
248
+ client = await getOpsCompassClient();
249
+ console.log("Checking for latest version of module %s...", scriptType);
250
+ latestScriptVersion =
251
+ await client.dataGatheringScripts.checkScriptUpdates(
252
+ company,
253
+ scriptType,
254
+ );
255
+ } catch (err) {
256
+ console.log("Check latest script version for type %s failed...", scriptType);
257
+ console.log(err);
258
+ return recordUpdateFailure(scriptType);
259
+ }
260
+
261
+ if (!isValidVersion(latestScriptVersion?.scriptVersion)) {
262
+ console.log("Remote script version for type %s is malformed.", scriptType);
263
+ return recordUpdateFailure(scriptType);
264
+ }
195
265
 
196
266
  //Semver returns true if the latest version is higher than the currentScriptVersion.
197
267
  if (semver.gt(latestScriptVersion.scriptVersion, currentScriptVersion)) {
@@ -218,6 +288,7 @@ async function checkScriptUpdates(args) {
218
288
  } catch (err) {
219
289
  console.log("Update script type %s failed...", scriptType);
220
290
  console.log(err);
291
+ recordUpdateFailure(scriptType);
221
292
  }
222
293
  }
223
294
  console.log();
@@ -229,37 +300,98 @@ async function checkScriptUpdates(args) {
229
300
  console.log();
230
301
  }
231
302
  } else {
303
+ let client;
304
+ try {
305
+ client = await getOpsCompassClient();
306
+ } catch (err) {
307
+ console.log("Check script updates failed...");
308
+ console.log(err);
309
+ return recordUpdateFailure();
310
+ }
311
+
232
312
  const scriptsLocal = await listLocalScripts([...args, "--quiet"]);
233
313
 
234
- if (
235
- scriptsLocal &&
236
- Array.isArray(scriptsLocal?.versions) &&
237
- scriptsLocal.versions?.length > 0
238
- ) {
239
- // We have at least one scriptType downloaded
240
- } else {
314
+ if (scriptsLocal?.success === false) {
315
+ if (
316
+ Array.isArray(scriptsLocal.failedScriptTypes) &&
317
+ scriptsLocal.failedScriptTypes.length > 0
318
+ ) {
319
+ for (const failedScriptType of scriptsLocal.failedScriptTypes) {
320
+ recordUpdateFailure(failedScriptType);
321
+ }
322
+ } else {
323
+ recordUpdateFailure();
324
+ }
325
+ }
326
+
327
+ if (!scriptsLocal || !Array.isArray(scriptsLocal.versions)) {
328
+ return recordUpdateFailure();
329
+ }
330
+
331
+ // DECISION: Treat a successfully read empty recognized inventory as a normal first-run informational state, but require a successful remote listing before reporting it.
332
+ const noLocalScripts = scriptsLocal.versions.length === 0;
333
+ if (noLocalScripts) {
241
334
  console.error("\nScripts available for download:");
242
- listAvailableScripts(args);
243
- return;
335
+ } else {
336
+ // Sort by script-type
337
+ scriptsLocal.versions.sort(function (a, b) {
338
+ return a.scriptType < b.scriptType
339
+ ? -1
340
+ : a.scriptType > b.scriptType
341
+ ? 1
342
+ : 0;
343
+ });
344
+
345
+ console.log("\nCheck-Updates fetching remote versions...");
244
346
  }
245
347
 
246
- // Sort by script-type
247
- scriptsLocal.versions.sort(function (a, b) {
248
- return a.scriptType < b.scriptType
249
- ? -1
250
- : a.scriptType > b.scriptType
251
- ? 1
252
- : 0;
253
- });
348
+ const scriptsRemote = await listAvailableScripts(
349
+ noLocalScripts ? args : [...args, "--quiet"],
350
+ );
351
+
352
+ if (
353
+ scriptsRemote?.success === false ||
354
+ !Array.isArray(scriptsRemote?.versions)
355
+ ) {
356
+ if (scriptsRemote?.success !== false) {
357
+ console.log("Remote script version response was malformed.");
358
+ }
359
+ return recordUpdateFailure();
360
+ }
254
361
 
255
- console.log("\nCheck-Updates fetching remote versions...");
256
- const scriptsRemote = await listAvailableScripts([...args, "--quiet"]);
362
+ if (noLocalScripts) {
363
+ if (updateResult.success) {
364
+ updateResult.status = "no_local_scripts";
365
+ }
366
+ return updateResult;
367
+ }
257
368
 
258
369
  for (const scriptVer of scriptsLocal.versions) {
370
+ if (
371
+ !scriptVer?.scriptType ||
372
+ !isValidVersion(scriptVer.scriptVersion)
373
+ ) {
374
+ console.log(
375
+ "Local script version for type %s is malformed.",
376
+ scriptVer?.scriptType,
377
+ );
378
+ recordUpdateFailure(scriptVer?.scriptType);
379
+ continue;
380
+ }
381
+
259
382
  const remoteVer = scriptsRemote.versions.find(
260
- (version) => version.scriptType === scriptVer.scriptType,
383
+ (version) => version?.scriptType === scriptVer.scriptType,
261
384
  );
262
385
 
386
+ if (!remoteVer || !isValidVersion(remoteVer.scriptVersion)) {
387
+ console.log(
388
+ "Remote script version for type %s is missing or malformed.",
389
+ scriptVer.scriptType,
390
+ );
391
+ recordUpdateFailure(scriptVer.scriptType);
392
+ continue;
393
+ }
394
+
263
395
  const needsUpdate = semver.gt(
264
396
  remoteVer.scriptVersion,
265
397
  scriptVer.scriptVersion,
@@ -294,8 +426,12 @@ async function checkScriptUpdates(args) {
294
426
  rcvdVersion,
295
427
  );
296
428
  } catch (err) {
297
- console.log("Auto update script type %s failed...", scriptType);
429
+ console.log(
430
+ "Auto update script type %s failed...",
431
+ scriptVer.scriptType,
432
+ );
298
433
  console.log(err);
434
+ recordUpdateFailure(scriptVer.scriptType);
299
435
  }
300
436
  }
301
437
  console.log();
@@ -309,6 +445,7 @@ async function checkScriptUpdates(args) {
309
445
  }
310
446
  //console.log(scriptsRemote);
311
447
  }
448
+ return updateResult;
312
449
  }
313
450
 
314
451
  async function autoCheckScriptUpdates(args) {
@@ -599,6 +599,19 @@ async function printDataGatheringHelp(ui = createDataGatheringUi()) {
599
599
  ui.item("--parallel <n>", "Surface reserved for future parallel execution.");
600
600
  ui.item("--allow-unverified", "Break-glass: allow execution of unverified bundles.");
601
601
 
602
+ ui.blank();
603
+ ui.section("Send DG Parameters");
604
+ ui.item("<file> [...file]", "One or more DG artifacts. Plain files are archived, encrypted, and uploaded.");
605
+ ui.item("--metadata-type", "sql-server-database | oracle-database | vmware-vsphere | network-discovery | nutanix-prism");
606
+ ui.item("--file-type", "Required for oracle/sql-server: oracle supports ebusiness, licensing, compliance; sql-server supports licensing, compliance.");
607
+ ui.item("--destinations", "Only oc is supported; default oc.");
608
+ ui.item("--company", "Company slug; omitted only when a default company is configured.");
609
+ ui.item("--account", "Account token used for encryption; omitted only when a default account is configured.");
610
+ ui.item("--directory", "Base directory for relative file paths; default current directory.");
611
+ ui.item("--log-directory", "Directory of DG logs to include when eligible; default OpsCompass log directory.");
612
+ ui.item("Accepted archive names", ".tgz, .tar.gz, .tgz.gpg, and .tar.gz.gpg. Encrypted .tar.gz.gpg files upload with a .tgz.gpg-compatible name.");
613
+
614
+
602
615
  ui.blank();
603
616
  ui.section("Examples");
604
617
  ui.command(
@@ -613,9 +626,16 @@ async function printDataGatheringHelp(ui = createDataGatheringUi()) {
613
626
  `${cliCommand} data-gathering run --dry-run --config /path/to/dgConfig.json --module msql-license`,
614
627
  "Preview the execution plan without running collectors.",
615
628
  );
629
+ ui.command(
630
+ `${cliCommand} data-gathering send-dg /path/to/oracle-metadata.tgz.gpg --metadata-type oracle-database --file-type licensing --company <slug>`,
631
+ "Upload a pre-encrypted Oracle licensing artifact.",
632
+ );
616
633
  ui.blank();
634
+ return { exitCode: DATA_GATHERING_EXIT_CODES.success };
617
635
  }
618
636
 
637
+
638
+
619
639
  function getCompletionEventType(action) {
620
640
  return action?.toLowerCase() === "setup" ? "setup.completed" : "run.completed";
621
641
  }
@@ -656,6 +676,8 @@ async function runDataGatheringAction(action, args) {
656
676
  },
657
677
  );
658
678
  case "help":
679
+ case "--help":
680
+ case "-h":
659
681
  case "":
660
682
  return printDataGatheringHelp(ui);
661
683
  default:
@@ -250,23 +250,46 @@ async function getMssqlAssessmentResources(args) {
250
250
  }
251
251
 
252
252
  async function checkMssqlConfigMetadata(args) {
253
- let callParams = {};
254
- for (let i = 0; i < args.length - 1; i++) {
253
+ const callParams = {};
254
+ let hasExplicitAccount = false;
255
+ for (let i = 0; i < args.length; i++) {
255
256
  switch (args[i].toLowerCase()) {
256
257
  case "--account-id":
257
258
  case "--accountid":
258
- callParams.accountId = args[++i];
259
+ hasExplicitAccount = true;
260
+ if (
261
+ args[i + 1] !== undefined &&
262
+ !args[i + 1].startsWith("--")
263
+ ) {
264
+ callParams.accountId = args[++i];
265
+ }
259
266
  break;
260
267
  case "--last-collected-before":
261
268
  case "--lastcollectedbefore":
262
- callParams.lastCollectedBefore = args[++i];
269
+ if (args[i + 1] !== undefined) {
270
+ callParams.lastCollectedBefore = args[++i];
271
+ }
263
272
  break;
264
273
  }
265
274
  }
266
275
 
276
+ const selectedAccount = hasExplicitAccount
277
+ ? callParams.accountId
278
+ : global.account;
279
+ if (selectedAccount === undefined || selectedAccount === null) {
280
+ console.error("ERROR: --account is required (or set a default account).");
281
+ return;
282
+ }
283
+
284
+ const normalizedAccount = String(selectedAccount).trim();
285
+ if (normalizedAccount === "") {
286
+ console.error("ERROR: --account is required (or set a default account).");
287
+ return;
288
+ }
289
+
267
290
  const client = await getOpsCompassClient();
268
291
  const response = await client.licenseManager.mssql.checkMssqlConfigMetadata(
269
- callParams.accountId,
292
+ normalizedAccount,
270
293
  global.company,
271
294
  callParams.lastCollectedBefore,
272
295
  );
@@ -836,7 +859,8 @@ async function printMssqlHelp() {
836
859
  "Checks the mssql configuration metadata for a company.",
837
860
  );
838
861
  console.log("Parameters:");
839
- console.log("--accountId [string] The account id for the company.");
862
+ console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId for the company.");
863
+ console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
840
864
  console.log(`--company [company_slug] (default: ${global.company})\n`);
841
865
  console.log(
842
866
  "--lastCollectedBefore [string] (optional) Only returns records that have not been collected since the given date. Format: UTC, example: '2022-08-23T17:00:00Z'",
@@ -93,12 +93,18 @@ async function getOracleCurrentEntitlements(args) {
93
93
  }
94
94
 
95
95
  if (accountId === undefined || accountId === null) {
96
- console.error("ERROR: --account-id is required.");
96
+ accountId = global.account;
97
+ }
98
+ if (accountId === undefined || accountId === null) {
99
+ console.error("ERROR: --account is required (or set a default account).");
97
100
  return;
98
101
  }
99
102
 
100
- const parsedAccountId = validatePositiveIntFlag(accountId, "account-id");
101
- if (parsedAccountId === undefined) return;
103
+ const parsedAccountId = String(accountId).trim();
104
+ if (parsedAccountId === "") {
105
+ console.error("ERROR: --account is required (or set a default account).");
106
+ return;
107
+ }
102
108
 
103
109
  const options = {};
104
110
  if (limit !== undefined) {
@@ -289,7 +295,13 @@ async function listOracleOrders(args) {
289
295
  break;
290
296
  case "--account-id":
291
297
  case "--accountid":
292
- if (!requireArgValue(args, i, "account-id")) return;
298
+ if (
299
+ args[i + 1] === undefined ||
300
+ args[i + 1].startsWith("--")
301
+ ) {
302
+ console.error("ERROR: --account is required (or set a default account).");
303
+ return;
304
+ }
293
305
  accountId = args[++i];
294
306
  break;
295
307
  case "--limit":
@@ -303,13 +315,27 @@ async function listOracleOrders(args) {
303
315
  }
304
316
  }
305
317
 
318
+ const trailingArg = args.at(-1)?.toLowerCase();
319
+ if (
320
+ accountId === undefined &&
321
+ (trailingArg === "--account-id" || trailingArg === "--accountid")
322
+ ) {
323
+ console.error("ERROR: --account is required (or set a default account).");
324
+ return;
325
+ }
306
326
  if (accountId === undefined || accountId === null) {
307
- console.error("ERROR: --account-id is required.");
327
+ accountId = global.account;
328
+ }
329
+ if (accountId === undefined || accountId === null) {
330
+ console.error("ERROR: --account is required (or set a default account).");
308
331
  return;
309
332
  }
310
333
 
311
- const parsedAccountId = validatePositiveIntFlag(accountId, "account-id");
312
- if (parsedAccountId === undefined) return;
334
+ const normalizedAccountId = String(accountId).trim();
335
+ if (normalizedAccountId === "") {
336
+ console.error("ERROR: --account is required (or set a default account).");
337
+ return;
338
+ }
313
339
 
314
340
  const options = {};
315
341
  if (limit !== undefined) {
@@ -334,7 +360,7 @@ async function listOracleOrders(args) {
334
360
  const client = await getOpsCompassClient();
335
361
  const result = await client.licenseManager.listOracleOrders(
336
362
  companySlug,
337
- parsedAccountId,
363
+ normalizedAccountId,
338
364
  Object.keys(options).length > 0 ? options : undefined,
339
365
  );
340
366
  console.log(JSON.stringify(result, null, 2));
@@ -352,7 +378,13 @@ async function getOracleOrderItems(args) {
352
378
  break;
353
379
  case "--account-id":
354
380
  case "--accountid":
355
- if (!requireArgValue(args, i, "account-id")) return;
381
+ if (
382
+ args[i + 1] === undefined ||
383
+ args[i + 1].startsWith("--")
384
+ ) {
385
+ console.error("ERROR: --account is required (or set a default account).");
386
+ return;
387
+ }
356
388
  accountId = args[++i];
357
389
  break;
358
390
  case "--id":
@@ -362,8 +394,25 @@ async function getOracleOrderItems(args) {
362
394
  }
363
395
  }
364
396
 
397
+ const trailingArg = args.at(-1)?.toLowerCase();
398
+ if (
399
+ accountId === undefined &&
400
+ (trailingArg === "--account-id" || trailingArg === "--accountid")
401
+ ) {
402
+ console.error("ERROR: --account is required (or set a default account).");
403
+ return;
404
+ }
365
405
  if (accountId === undefined || accountId === null) {
366
- console.error("ERROR: --account-id is required.");
406
+ accountId = global.account;
407
+ }
408
+ if (accountId === undefined || accountId === null) {
409
+ console.error("ERROR: --account is required (or set a default account).");
410
+ return;
411
+ }
412
+
413
+ const normalizedAccountId = String(accountId).trim();
414
+ if (normalizedAccountId === "") {
415
+ console.error("ERROR: --account is required (or set a default account).");
367
416
  return;
368
417
  }
369
418
 
@@ -381,7 +430,7 @@ async function getOracleOrderItems(args) {
381
430
  try {
382
431
  const result = await client.licenseManager.getOracleOrderItems(
383
432
  companySlug,
384
- Number(accountId),
433
+ normalizedAccountId,
385
434
  orderItemIds.map(Number),
386
435
  );
387
436
  console.log(JSON.stringify(result, null, 2));
@@ -398,7 +447,7 @@ async function printOracleHelp() {
398
447
  );
399
448
  console.log("Parameters:");
400
449
  console.log("--company [company_slug] (optional, defaults to current company)");
401
- console.log("--account-id [number] The account ID to retrieve entitlements for.");
450
+ console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId to retrieve entitlements for.");
402
451
  console.log(`--limit [number] (optional) Maximum number of results to return (max ${MAX_PAGINATION_LIMIT}), e.g. --limit 50.`);
403
452
  console.log(`--offset [number] (optional) Number of results to skip for pagination (max ${MAX_PAGINATION_OFFSET}), e.g. --offset 100.`);
404
453
  console.log();
@@ -435,7 +484,8 @@ async function printOracleHelp() {
435
484
  );
436
485
  console.log("Parameters:");
437
486
  console.log("--company [company_slug] (optional, defaults to current company)");
438
- console.log("--account-id [number] The account ID to retrieve orders for.");
487
+ console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId to retrieve orders for.");
488
+ console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
439
489
  console.log(`--limit [number] (optional) Maximum number of results to return (max ${MAX_PAGINATION_LIMIT}), e.g. --limit 50.`);
440
490
  console.log(`--offset [number] (optional) Number of results to skip for pagination (max ${MAX_PAGINATION_OFFSET}), e.g. --offset 100.`);
441
491
  console.log();
@@ -445,7 +495,8 @@ async function printOracleHelp() {
445
495
  );
446
496
  console.log("Parameters:");
447
497
  console.log("--company [company_slug] (optional, defaults to current company)");
448
- console.log("--account-id [number] The account ID to scope the request.");
498
+ console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId used to scope the request.");
499
+ console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
449
500
  console.log('--id [number] Use parameter multiple times to retrieve multiple items, e.g. --id 10 --id 11');
450
501
  console.log("Note: A maximum of 100 order-item IDs can be requested at once.");
451
502
  console.log();
@@ -824,22 +824,46 @@ async function createNetworkDiscoveryConfiguration(args) {
824
824
  }
825
825
 
826
826
  async function checkOracleConfigMetadata(args) {
827
- for (let i = 0; i < args.length - 1; i++) {
827
+ const callParams = {};
828
+ let hasExplicitAccount = false;
829
+ for (let i = 0; i < args.length; i++) {
828
830
  switch (args[i].toLowerCase()) {
829
831
  case "--account-id":
830
832
  case "--accountid":
831
- callParams.accountId = args[++i];
833
+ hasExplicitAccount = true;
834
+ if (
835
+ args[i + 1] !== undefined &&
836
+ !args[i + 1].startsWith("--")
837
+ ) {
838
+ callParams.accountId = args[++i];
839
+ }
832
840
  break;
833
841
  case "--last-collected-before":
834
842
  case "--lastcollectedbefore":
835
- callParams.lastCollectedBefore = args[++i];
843
+ if (args[i + 1] !== undefined) {
844
+ callParams.lastCollectedBefore = args[++i];
845
+ }
836
846
  break;
837
847
  }
838
848
  }
839
849
 
850
+ const selectedAccount = hasExplicitAccount
851
+ ? callParams.accountId
852
+ : global.account;
853
+ if (selectedAccount === undefined || selectedAccount === null) {
854
+ console.error("ERROR: --account is required (or set a default account).");
855
+ return;
856
+ }
857
+
858
+ const normalizedAccount = String(selectedAccount).trim();
859
+ if (normalizedAccount === "") {
860
+ console.error("ERROR: --account is required (or set a default account).");
861
+ return;
862
+ }
863
+
840
864
  const client = await getOpsCompassClient();
841
865
  const response = await client.licenseManager.checkOracleConfigMetadata(
842
- callParams.accountId,
866
+ normalizedAccount,
843
867
  global.company,
844
868
  callParams.lastCollectedBefore,
845
869
  );
@@ -1118,7 +1142,8 @@ async function printHelp() {
1118
1142
  "Checks the oracle configuration metadata for a company.",
1119
1143
  );
1120
1144
  console.log("Parameters:");
1121
- console.log("--accountId [string] The account id for the company.");
1145
+ console.log("--account [account-id-or-cloudSubscriptionId] (optional, defaults to current account) The account ID or cloudSubscriptionId for the company.");
1146
+ console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (optional legacy aliases; override the current account)");
1122
1147
  console.log(`--company [company_slug] (default: ${global.company})\n`);
1123
1148
  console.log(
1124
1149
  "--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 +1164,7 @@ async function printHelp() {
1139
1164
  }
1140
1165
 
1141
1166
  const licenseManagerModule = (action, ...args) => {
1142
- utils.processStandardArgs(args);
1167
+ if (utils.processStandardArgs(args) === false) return;
1143
1168
  switch (action?.toLowerCase() ?? "") {
1144
1169
  case "create-oracle-shared-credential":
1145
1170
  return createOracleSharedCredential(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opscompass/opscompass-cli",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
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,10 +25,10 @@
24
25
  "author": "opscompass",
25
26
  "license": "SEE LICENSE IN license.txt",
26
27
  "engines": {
27
- "node": "22 || 24 || 26"
28
+ "node": "^22.19.0 || ^24.0.0"
28
29
  },
29
30
  "dependencies": {
30
- "@opscompass/opscompass-api": "^1.3.6",
31
+ "@opscompass/opscompass-api": "^1.3.7",
31
32
  "adm-zip": "^0.6.0",
32
33
  "axios": "^1.18.1",
33
34
  "better-sqlite3": "12.11.1",