Skip to content

Commit

Permalink
fix: improve T&C text RD-5839 (#123)
Browse files Browse the repository at this point in the history
* fix: improve T&C text
  • Loading branch information
efimk-lu authored Aug 10, 2021
1 parent aa2cb8c commit f1dca97
Showing 1 changed file with 60 additions and 12 deletions.
72 changes: 60 additions & 12 deletions src/commands/scanner.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const _ = require("lodash");
var fs = require("fs");
const { Command, flags } = require("@oclif/command");
const { checkVersion } = require("../lib/version-check");
const { track } = require("../lib/analytics");
Expand All @@ -14,6 +15,39 @@ const { getAWSSDK } = require("../lib/aws");
const AWS = getAWSSDK();
const STS = new AWS.STS();

const getConfigurationFileName = () => {
const configurationFileName = ".lumigo-cli.json";
try {
const homedir = require("os").homedir();
return `${homedir}/${configurationFileName}`;
} catch (err) {
return configurationFileName;
}
};
const loadConf = () => {
let approved = false;
try {
if (fs.existsSync(getConfigurationFileName())) {
const data = fs.readFileSync(getConfigurationFileName());
const lumigoConf = JSON.parse(data);
approved = Boolean(lumigoConf.approved);
}
} catch (err) {
// Ignore gracefully
}
return {
approved
};
};

const saveConf = approved => {
try {
fs.writeFileSync(getConfigurationFileName(), JSON.stringify({ approved }));
} catch (error) {
// Ignore gracefully
}
};

class ScannerCommand extends Command {
async run() {
const { flags } = this.parse(ScannerCommand);
Expand All @@ -35,21 +69,35 @@ and recommends areas that can be improved.
A customized report will be sent to your email.
`);

this.log("We will send metadata about AWS resources to Lumigo.".yellow);
let { approved } = loadConf();

const { toProceed } = await inquirer.prompt([
{
type: "confirm",
name: "toProceed",
message:
"Do you give Lumigo permission to receive metadata about AWS resources?"
}
]);
if (!approved) {
let { toProceed } = await inquirer.prompt([
{
type: "confirm",
name: "toProceed",
message:
"Do you agree to Lumigo Terms of Use and Privacy policy ?'\n\tTerm of Use: https://lumigo.io/terms/\n\tPrivacy Policy: https://lumigo.io/privacy-policy/\n"
}
]);

if (!toProceed) {
return;
if (!toProceed) {
return;
}
toProceed = await inquirer.prompt([
{
type: "confirm",
name: "toProceed",
message:
"Do you give Lumigo permission to receive metadata about AWS resources?"
}
]);

if (!toProceed) {
return;
}
}

saveConf(true);
const email = await this.signIn().catch(err => {
throw err;
});
Expand Down

0 comments on commit f1dca97

Please sign in to comment.