@opscompass/opscompass-cli 1.0.8 → 1.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/colors.js +11 -0
- package/credentials.js +16 -38
- package/environment/current.js +7 -0
- package/environment/demo.js +6 -0
- package/environment/dev.js +6 -0
- package/environment/local.js +6 -0
- package/environment/production.js +7 -0
- package/index.js +5 -0
- package/lib/cliHelpers.js +229 -0
- package/lib/homeInteraction.js +211 -0
- package/license.txt +33 -0
- package/modules/compliance.js +184 -0
- package/modules/data-gathering-scripts.js +211 -0
- package/modules/license-manager.js +617 -0
- package/modules.js +7 -0
- package/package.json +7 -4
- package/updates.js +33 -0
package/updates.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const pkg = require("./package.json");
|
|
2
|
+
const semver = require("semver");
|
|
3
|
+
const { exec } = require("child_process");
|
|
4
|
+
const { greenText, yellowText } = require("./colors.js");
|
|
5
|
+
|
|
6
|
+
/* versionCheck sends a command to the terminal to check the latest package version and compares it to the current version specified in package.json, prompting the user to upgrade if it is out of date. */
|
|
7
|
+
/* This is turned off by default when using the local environment. To turn it on for dev purposes, comment out isLocal check in index.js */
|
|
8
|
+
|
|
9
|
+
function versionCheck() {
|
|
10
|
+
|
|
11
|
+
const environmentSpecificPackageVersion = `npm view ${pkg.name} version`
|
|
12
|
+
/* latestVersion is the standard output(stdout), which is read and compared to current package version */
|
|
13
|
+
exec(environmentSpecificPackageVersion, (error, latestVersion, stderr) => {
|
|
14
|
+
if (error) {
|
|
15
|
+
console.log(`error: ${error.message}`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (stderr) {
|
|
19
|
+
console.log(`stderr: ${stderr}`);
|
|
20
|
+
};
|
|
21
|
+
/* Semver used to semantically compare version numbers */
|
|
22
|
+
if (semver.gt(latestVersion, pkg.version)) {
|
|
23
|
+
console.error(yellowText, `Warning! You are using CLI version ${pkg.version}, but the latest version is ${latestVersion}To upgrade to the latest version, please run:`);
|
|
24
|
+
/* Prompt user to upgrade to the correct package based on their current environment */
|
|
25
|
+
console.error(greenText, `\nnpm install -g ${pkg.name}@${latestVersion}\n`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
versionCheck
|
|
33
|
+
};
|